<p>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.</p>
<p>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.</p>
<p>If a transaction doesn't get confirmed in a reasonable time (days, weeks?) you could unmark the appropriate UTXOs in your local list.</p>

CC BY-SA 4.0
2023-02-14T18:34:26.627Z
2023-02-14T18:34:26.627Z
RedGrittyBrick
<p>You could maybe maintain a list/map of &quot;reserved&quot; UTXO's -- meaning UTXO's you're already using in a unconfirmed transaction.</p>
<p>Once transaction is confirmed you can update your list/map of reserved UTXO's.</p>

CC BY-SA 4.0
2023-04-20T19:27:54.853Z
2023-04-20T19:27:54.853Z
pyropy
<p>How to prevent selection of unspent transaction from UTXO's which is already used in another unconfirmed transaction ?</p>
<p>I am fetching list of UTXO's from here -
<a href="https://mempool.space/testnet/docs/api/rest#get-address-utxo" rel="nofollow noreferrer">https://mempool.space/testnet/docs/api/rest#get-address-utxo</a></p>
<p>Trying to send bitcoins from native segwit address to all other types of addresses using bitcoinjs-lib in node js.</p>
<p>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 ?</p>

<transactions><utxo><transaction-input><utxo-set>
Selection of inputs from UTXO's who are not used by other unconfirmed transaction
coder123
# Selection of inputs from UTXO's who are not used by other unconfirmed transaction

(Asked by: username_0 on 2023-02-14)

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 ?

**Tags:** transactions, utxo, transaction-input, utxo-set


---

## 2 answers

### Answer by username_1 on 2023-02-14. Score: 2 | Accepted answer

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.


---

### Answer by username_2 on 2023-04-20. Score: 1

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.


---

