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

Method parse

code-ch13/tx.py:482–491  ·  view source on GitHub ↗

Takes a byte stream and parses the tx_output at the start return a TxOut object

(cls, s)

Source from the content-addressed store, hash-verified

480
481 @classmethod
482 def parse(cls, s):
483 '''Takes a byte stream and parses the tx_output at the start
484 return a TxOut object
485 '''
486 # amount is an integer in 8 bytes, little endian
487 amount = little_endian_to_int(s.read(8))
488 # use Script.parse to get the ScriptPubKey
489 script_pubkey = Script.parse(s)
490 # return an instance of the class (see __init__ for args)
491 return cls(amount, script_pubkey)
492
493 def serialize(self):
494 '''Returns the byte serialization of the transaction output'''

Callers

nothing calls this directly

Calls 3

little_endian_to_intFunction · 0.90
readMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected