I am using python's bitcoinlib to try and set up payments where a client sends funds to a server and then sends requests signed with their key as proof that the request came from them. The server keeps track of how much funds are remaining. Additionally, a client will be expected to connect to many nodes. I would like to have only one key-address pair to keep track of in the client.
Unless I am mistaken, the easiest way to do this would be to send the change back to the original address in the payment transaction.
However, bitcoinlib's wallet.send and wallet.create_transaction functions don't let you set the change address(es).
Additionally, I tried creating a transaction using transaction_create, taking the change output and creating a new address with that change value being sent to the original address
t = w1.transaction_create([(k2.address, 100)], account_id=0)
change = list(filter(lambda x: x.address != k2.address, t.outputs))[0]
new_t = w1.transaction_create([(k2.address, 100), (k1.address, change.value)], account_id=0)
But I get a
bitcoinlib.wallets.WalletError: Not enough unspent transaction outputs found
at the second transaction_create.
How can I set the change address of the transaction?
Also if this is the wrong approach what would be the right one?
send
norcreate_transaction
related to the wallet.account_id
: github.com/1200wd/bitcoinlib/blob/…