<p>No, coin selection does not have a public API nor any RPCs to operate on arbitrary UTXO pools. The only way to use Bitcoin Core's coin selection algorithms is to create a wallet that has the relevant scripts imported so that it detects the UTXOs and can do coin selection on them.</p>

CC BY-SA 4.0
2024-11-25T03:44:41.790Z
How would one typically accomplish this then? I notice that mempool.space's GET Address UTXO endpoint does something similar:

> Get the list of unspent transaction outputs associated with the address/scripthash. Available fields: txid, vout, value, and status (with the status of the funding tx).

However this would only work for a single address in the derivation sequence.
rdong8
CC BY-SA 4.0
2024-11-22T02:09:39.157Z
2024-11-22T02:09:39.157Z
Ava Chow
<p>I'm interested in creating a swap application using HTLCs. The user connects their wallet to the frontend, places an order, and the backend matches the order with a maker and creates the HTLC transaction. The user's UTXOs are used as inputs to fund the transaction, and the single non-change output is the one with the HTLC as the unlocking script. The flow would look similar to the one depicted <a href="https://viscarra.dev/post/pyo3-psbt/" rel="nofollow noreferrer">here</a>:</p>
<p><a href="https://i.sstatic.net/veVHdro7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/veVHdro7.png" alt="PSBT application flow" /></a></p>
<p>However, I don't want the backend to have to do the coin selection and figure out which UTXOs are optimal to fund the transaction. From my understanding, normally the <code>walletcreatefundedpsbt</code> RPC method would do that for you, but in this case the wallet in question is the user's wallet. Is there an equivalent way I can do coin selection for <em>someone else's</em> wallet?</p>

<transactions><json-rpc><signature><raw-transaction><bip174-psbt>
What is equivalent to walletcreatefundedpsbt but with an arbitrary funding wallet?
rdong8
# What is equivalent to walletcreatefundedpsbt but with an arbitrary funding wallet?

(Asked by: username_0 on 2024-11-21)

I'm interested in creating a swap application using HTLCs. The user connects their wallet to the frontend, places an order, and the backend matches the order with a maker and creates the HTLC transaction. The user's UTXOs are used as inputs to fund the transaction, and the single non-change output is the one with the HTLC as the unlocking script. The flow would look similar to the one depicted [here](https://viscarra.dev/post/pyo3-psbt/):

[![PSBT application flow](https://i.sstatic.net/veVHdro7.png)](https://i.sstatic.net/veVHdro7.png)

However, I don't want the backend to have to do the coin selection and figure out which UTXOs are optimal to fund the transaction. From my understanding, normally the `walletcreatefundedpsbt` RPC method would do that for you, but in this case the wallet in question is the user's wallet. Is there an equivalent way I can do coin selection for *someone else's* wallet?

**Tags:** transactions, json-rpc, signature, raw-transaction, bip174-psbt


---

## 1 answers

### Answer by username_1 on 2024-11-22. Score: 1

No, coin selection does not have a public API nor any RPCs to operate on arbitrary UTXO pools. The only way to use Bitcoin Core's coin selection algorithms is to create a wallet that has the relevant scripts imported so that it detects the UTXOs and can do coin selection on them.

> **Comments:**
> **username_0**: How would one typically accomplish this then? I notice that mempool.space's GET Address UTXO endpoint does something similar:  > Get the list of unspent transaction outputs associated with the address/scripthash. Available fields: txid, vout, value, and status (with the status of the funding tx).  However this would only work for a single address in the derivation sequence.  

---

