`walletcreatefundedpsbt` with unconfirmed inputs

2

I would like to create a psbt using walletcreatefundedpsbt spending unconfirmed ouptputs. Is this possible?

When I call that RPC command with 0 confirmed balance but with sufficient unconfirmed outputs, I get an Insufficient funds error.

Thanks in advance!

justinmoon

Posted 2019-07-14T04:02:01.993

Reputation: 311

Are the unconfirmed inputs from incoming outputs or change outputs? If they are incoming, Bitcoin Core will not select them for transactions.Andrew Chow 2019-07-14T04:38:23.897

Incoming. Is it true that Bitcoin Core's coin selection algorithm won't select unconfirmed incoming outputs in general?justinmoon 2019-07-14T05:24:16.637

Answers

2

Bitcoin Core will never select unconfirmed incoming outputs. These are always considered to be untrusted and not safe for coin selection. This applies to any transactions that Bitcoin Core creates, including those created by using walletcreatefundedpsbt or fundrawtransaction.

For a code reference, the AvailableCoins function is used to fetch and filter the coins available for coin selection which calls the IsTrusted function for every available output (well really transaction stored in the wallet which include incoming and outgoing transactions). If the transaction was not created by that wallet, it is considered not trusted, so IsTrusted returns false which results in AvailableCoins excluding all of that transaction's outputs from the set of outputs used for coin selection.

Andrew Chow

Posted 2019-07-14T04:02:01.993

Reputation: 40 910

Perfect. Thanks!justinmoon 2019-07-14T06:20:19.173