Quickly creating lots of UTXO's with Electron Cash

3 91
Avatar for cashdev
4 years ago

If you tend to run into the transaction chain limit, or run out of shuffled coins, it's time to split up your coins. Electron Cash has a largely undocumented, but powerful Python console. The source code is the best documentation, so look at the source code.

The console tab is not visible by default, so if you haven't, you can add it by going to View -> Show console.

Disclamer: The console is powerful and lets you shoot yourself in the foot, don't blame me if you do that!

Here's an example of how to create 5 new utxos using the console:

Create 5 new addresses

>> addresses = [createnewaddress() for _ in range(5)]
>> print(addresses)
['qqzq5xmrwzp6u8pwddsnddzphrrqjk336vskk2g0de', 'qps0ax66rzde56qvg39qymn7wnelp2ftdus9yaj5ew', 'qq4352kp6wedd7fnhcpvjcayha5hfsawq5kjc5c4ud', 'qravjyev5cl6xvqldxqfurwsyqgptey0qvpp3543l0', 'qzatvg72ve63q6c38u64xtl8paktyux03v0vlm4dc3']

Create the outputs for sending 0.0001BCH to each address

>> outputs = [[addr, 0.0001] for addr in addresses]
>> print(outputs)
[['qqzq5xmrwzp6u8pwddsnddzphrrqjk336vskk2g0de', 0.0001], ['qps0ax66rzde56qvg39qymn7wnelp2ftdus9yaj5ew', 0.0001], ['qq4352kp6wedd7fnhcpvjcayha5hfsawq5kjc5c4ud', 0.0001], ['qravjyev5cl6xvqldxqfurwsyqgptey0qvpp3543l0', 0.0001], ['qzatvg72ve63q6c38u64xtl8paktyux03v0vlm4dc3', 0.0001]]

Create the transaction

>> tx = paytomany(outputs)
>> print(tx)
{'hex': '01000000017851d81132a94a0f5e0495169e1021cdbcecc7100312f888898597db89346eb70100000064412aaab95d84dc3a57385bde9a70f60cc0613e68b5b216604f7f3cb96e639e6a95130b51933fecbdfdb18426560986131e728add05de3e3f5afbbcf72b9cf9516841210203401e4cb7260fc1f594e2719cf2b49e39abd1edb0870ae5586057583884f384feffffff0610270000000000001976a914040a1b637083ae1c2e6b6136b441b8c6095a31d388ac10270000000000001976a9142b1a2ac1d3b2d6f933be02c963a4bf6974c3ae0588ac10270000000000001976a91460fe9b5a189b9a680c444a026e7e74f3f0a92b6f88ac10270000000000001976a914bab623ca6675106b113f35532fe70f6cb270cf8b88ac10270000000000001976a914fac9132ca63fa3301f69809e0dd0201015e48f0388ac486b0100000000001976a9142f181a2ff7c44b1e678e53fe2e689c6b56c8bb1d88acb8710900', 'complete': True, 'final': True}
>> 

Broadcast the transaction

>> broadcast(tx)
[
    true,
    "8f298905d530b41ae5588588c48a76aaf7f5abea86ed3b0d500682c76df08138"
]

The result

If you go back to the History tab, you should see a new transaction. Right click for details. It will look something like this:

Sponsors of cashdev
empty
empty
empty

1
$ 1.01
$ 0.50 from @Read.Cash
$ 0.50 from @sploit
$ 0.01 from @effkee
Avatar for cashdev
4 years ago

Comments

One liner:

broadcast(paytomany([[createnewaddress(), 0.0002] for _ in range(10)]))
$ 0.10
4 years ago

Very cool! I didn't even know Electron Cash had a Python console.

$ 0.00
4 years ago

Cool! This is a handy one.

$ 0.50
4 years ago