1

How to prevent selection of unspent transaction from UTXO's which is already used in another unconfirmed transaction ?

I am fetching list of UTXO's from here - https://mempool.space/testnet/docs/api/rest#get-address-utxo

Trying to send bitcoins from native segwit address to all other types of addresses using bitcoinjs-lib in node js.

From list of UTXO's I am selecting the inputs as required. If the first input is already selected for a transaction which is unconfirmed how can I prevent the selection of that first input in next transaction ?

0

2 Answers 2

2

When writing a wallet it is probably a bad idea to rely on a trusted third party to provide a list of UTXOs. I would expect any wallet application to keep a local list of UTXO's for which it has the corresponding private keys.

Then you mark UTXO's as provisionally committed when you transmit a transaction consuming them. When creating transactions you avoid selecting local UTXOs you have previously marked as provisionally committed.

If a transaction doesn't get confirmed in a reasonable time (days, weeks?) you could unmark the appropriate UTXOs in your local list.

0

You could maybe maintain a list/map of "reserved" UTXO's -- meaning UTXO's you're already using in a unconfirmed transaction.

Once transaction is confirmed you can update your list/map of reserved UTXO's.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.