Methods to set change tackle with python bitcoinlib

0
61


I’m utilizing python’s bitcoinlib to try to arrange funds the place a consumer sends funds to a server after which sends requests signed with their key as proof that the request got here from them. The server retains monitor of how a lot funds are remaining. Moreover, a consumer will likely be anticipated to connect with many nodes. I want to have just one key-address pair to maintain monitor of within the consumer.

Except I’m mistaken, the simplest means to do that could be to ship the change again to the unique tackle within the cost transaction.

Nevertheless, bitcoinlib’s pockets.ship and pockets.create_transaction features do not allow you to set the change tackle(es).

Moreover, I attempted making a transaction utilizing transaction_create, taking the change output and creating a brand new tackle with that change worth being despatched to the unique tackle

t = w1.transaction_create([(k2.address, 100)], account_id=0)
change = record(filter(lambda x: x.tackle != k2.tackle, t.outputs))[0]
new_t = w1.transaction_create([(k2.address, 100), (k1.address, change.value)], account_id=0)

However I get a

bitcoinlib.wallets.WalletError: Not sufficient unspent transaction outputs discovered

on the second transaction_create.

How can I set the change tackle of the transaction?

Additionally if that is the flawed method what could be the correct one?

LEAVE A REPLY

Please enter your comment!
Please enter your name here