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)
| 68 | return address |
| 69 | |
| 70 | def 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 | |
| 94 | def make_blocks_from_blockhashes(blockhashes): |
| 95 | """ |