utxo – Chain 2 transactions in similar block with bitcoinlib in Python


I requested yesterday if it is potential to have a tx from A to B then B to C in the identical block, with the second tx spending the UTXO of the primary one (with preliminary stability of B is 0)

Apparently it’s : Can two associated “spends” be in the identical block?

But now i am attempting to check this with bitcoinlib in Python.
My code is :

pockets = Pockets.create('MyWallet',
                        keys = seed_phrase,
                        witness_type = "segwit")

deal with = pockets.get_key(0).deal with
address2 = pockets.get_key(1).deal with
address3 = pockets.get_key(2).deal with

pockets.transactions_update()

payment = 1_000
send_value = pockets.stability() - payment

tx = pockets.ship( [(address2, send_value)],
                    payment = payment,
                    offline = True)

pockets.transaction_import(tx)

send_value2 = send_value - payment

tx2 = pockets.ship( [(address3, send_value2)], 
                     account_id = 1,
                     payment = payment,
                     offline = True)

The primary tx work accurately as a result of the primary deal with have a stability, but then the second fail with :

WalletError: Create transaction: No unspent transaction outputs discovered or no key accessible for UTXO's

I feel the issue is with the importation of the primary tx within the pockets

Any concept on the way to repair this ?
Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top