MCPcopy Index your code
hub / github.com/jimmysong/programmingbitcoin / serialize

Method serialize

code-ch13/tx.py:436–446  ·  view source on GitHub ↗

Returns the byte serialization of the transaction input

(self)

Source from the content-addressed store, hash-verified

434 return cls(prev_tx, prev_index, script_sig, sequence)
435
436 def serialize(self):
437 '''Returns the byte serialization of the transaction input'''
438 # serialize prev_tx, little endian
439 result = self.prev_tx[::-1]
440 # serialize prev_index, 4 bytes, little endian
441 result += int_to_little_endian(self.prev_index, 4)
442 # serialize the script_sig
443 result += self.script_sig.serialize()
444 # serialize sequence, 4 bytes, little endian
445 result += int_to_little_endian(self.sequence, 4)
446 return result
447
448 def fetch_tx(self, testnet=False):
449 return TxFetcher.fetch(self.prev_tx.hex(), testnet=testnet)

Callers

nothing calls this directly

Calls 2

int_to_little_endianFunction · 0.90
serializeMethod · 0.45

Tested by

no test coverage detected