MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / make_txout

Function make_txout

bitcoin/tests/fakebitcoinproxy.py:70–92  ·  view source on GitHub ↗

Make a CTxOut object based on the parameters. Otherwise randomly generate a CTxOut to represent a transaction output. :param amount: amount in satoshis

(amount=None, address=None, counter=None)

Source from the content-addressed store, hash-verified

68 return address
69
70def make_txout(amount=None, address=None, counter=None):
71 """
72 Make a CTxOut object based on the parameters. Otherwise randomly generate a
73 CTxOut to represent a transaction output.
74
75 :param amount: amount in satoshis
76 """
77 passphrase_template = "correct horse battery staple txout {counter}"
78
79 if not counter:
80 counter = random.randrange(0, 2**50)
81
82 if not address:
83 passphrase = passphrase_template.format(counter=counter)
84 address = make_address_from_passphrase(bytes(passphrase, "utf-8"))
85
86 if not amount:
87 maxsatoshis = (21 * 1000 * 1000) * (100 * 1000 * 1000) # 21 million BTC * 100 million satoshi per BTC
88 amount = random.randrange(0, maxsatoshis) # between 0 satoshi and 21 million BTC
89
90 txout = CMutableTxOut(amount, CBitcoinAddress(address).to_scriptPubKey())
91
92 return txout
93
94def make_blocks_from_blockhashes(blockhashes):
95 """

Calls 4

CMutableTxOutClass · 0.90
CBitcoinAddressClass · 0.90
to_scriptPubKeyMethod · 0.45