I’m utilizing python’s bitcoinlib to attempt 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 observe of how a lot funds are remaining. Moreover, a consumer can be anticipated to connect with many nodes. I wish to have just one key-address pair to maintain observe of within the consumer.
Until I’m mistaken, the simplest means to do that could be to ship the change again to the unique handle within the cost transaction.
Nevertheless, bitcoinlib’s pockets.ship and pockets.create_transaction features do not allow you to set the change handle(es).
Moreover, I attempted making a transaction utilizing transaction_create, taking the change output and creating a brand new handle with that change worth being despatched to the unique handle
t = w1.transaction_create([(k2.address, 100)], account_id=0)
change = record(filter(lambda x: x.handle != k2.handle, 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 handle of the transaction?
Additionally if that is the incorrect method what could be the precise one?