0

I'm attempting to use walletcreatefundedpsbt with a watch-only wallet.

With 2.0 BTC in the watch-only wallet, I attempt to create a psbt sending 0.2 BTC without specifying inputs and receive an "Insufficient funds" error:

$ bitcoin-cli -regtest -rpcwallet=watchonly getbalance "*" 0 true
2.00000000

$ bitcoin-cli -regtest -rpcwallet=watchonly walletcreatefundedpsbt '[]' '[{"bcrt1qnv3tl3z9cll9faqf79ppfn3rrp7pn9wwmq04p5gqgqtxg55xfxuslkyk94": "0.20000000"}]' 0 '{"includeWatching": true, "changeAddress": "bcrt1qa4h6amsgyc878k094grqh6ktmgvp97dt6et9cy5hjmyxlgd9q63q3p6hch"}' true
error code: -4
error message:
Insufficient funds

When I specify inputs to the same RPC call, I get a (confusing) "Signing transaction failed" error:

$ bitcoin-cli -regtest -rpcwallet=watchonly walletcreatefundedpsbt '[{"txid": "1d76879500aecafde541770b5d44ccec5955b4c1a455fae446bf1df7b5ea43e9", "vout": 0}, {"txid": "e5a8dfa9459ac154fe62652e1d43049dae13f11815da36cc32881e27917a0dff", "vout": 1}]' '[{"bcrt1qnv3tl3z9cll9faqf79ppfn3rrp7pn9wwmq04p5gqgqtxg55xfxuslkyk94": "0.20000000"}]' 0 '{"includeWatching": true, "changeAddress": "bcrt1qa4h6amsgyc878k094grqh6ktmgvp97dt6et9cy5hjmyxlgd9q63q3p6hch"}' true
error code: -4
error message:
Signing transaction failed

These inputs are visible in listunspent, but they are not "solvable".

$ bitcoin-cli -regtest -rpcwallet=watchonly listunspent
[
  {
    "txid": "1d76879500aecafde541770b5d44ccec5955b4c1a455fae446bf1df7b5ea43e9",
    "vout": 0,
    "address": "bcrt1qupu3f9ekx2jpu9adgnrckkuh60d0x5zunmrxla34cwc5z79lajrs52gcpu",
    "label": "",
    "scriptPubKey": "0020e07914973632a41e17ad44c78b5b97d3daf3505c9ec66ff635c3b14178bfec87",
    "amount": 1.00000000,
    "confirmations": 205,
    "spendable": false,
    "solvable": false,
    "safe": true
  },
  {
    "txid": "e5a8dfa9459ac154fe62652e1d43049dae13f11815da36cc32881e27917a0dff",
    "vout": 1,
    "address": "bcrt1qz9xlsapracexvk7gwjd8ytf9c5ckyeg6v64lmuun8j9x6l2770cs42f7kl",
    "label": "",
    "scriptPubKey": "0020114df87423ee32665bc8749a722d25c53162651a66abfdf3933c8a6d7d5ef3f1",
    "amount": 1.00000000,
    "confirmations": 103,
    "spendable": false,
    "solvable": false,
    "safe": true
  }
]

These UTXOs correspond to exotic scripts that cannot be expressed in the descriptor language, and were imported with the importmulti RPC. During the import, the following warning was displayed:

$ bitcoin-cli -regtest -rpcwallet=watchonly importmulti '[{"scriptPubKey": "0020e07914973632a41e17ad44c78b5b97d3daf3505c9ec66ff635c3b14178bfec87", "witnessscript": "63522102a7451395735369f2ecdfc829c0f774e88ef1303dfe5b2f04dbaab30a535dfdd62102303cc8dc4e50bb574899b4715c0ddcd63268137b2d95011ff0e71db0968d819d2103d9dcfae4253ef1dd7b2401f82f79b1e739e76ad22ad30cd6a58a04076a033e5a53ae6702f401b1755221033defb46605b0bf90e99821150926daabc0a909ae4d7e09ddd9cc691735896709210245449f5d5cb7cd0d299fcbfd7a3bf2e46a5ae43bdc75289f5ab1e0c7654cc057210299f94c03fc71ae8ced4d3a4f739cc2f227687885b8d1a5184ad1de14faa6c71c53ae68", "internal": false, "keypool": false, "timestamp": "now", "watchonly": true}]'
[
  {
    "success": true,
    "warnings": [
      "All private keys are provided, outputs will be considered spendable. If this is intentional, do not specify the watchonly flag.",
      "Importing as non-solvable: unrecognized script. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript."
    ]
  }
]

Are both of these errors caused by the same problem -- the absence of "solvable" utxos?

| improve this question | | | | |
1

Yes. Bitcoin Core will not be able to select for coins that are not solvable. This is because, for fee estimation, it must know how large the final transaction will be, but it cannot do this without knowing everything needed to construct the final transaction.

The outputs don't need to be spendable (i.e. you don't need to have the private keys for them) because Core knows how large a signature will be so it creates a dummy signature. But it needs to have everything else such as scripts and public keys. Without those, the output is not solvable and cannot be used in coin selection.

| improve this answer | | | | |
  • I encountered the problem described here and resolved it by replacing the call to walletcreatefundedpsbt() with a call to createpsbt(), which works as I expect. However now I have a new problem in that I need to know the size of the TX in order to calculate the fee. The best solution that I can think of is to execute a dummy call to createpsbt() using a dummy fee value, then measure the size of the TX, then do a real call to createpsbt() after correctly calculating the fee amount. Is there a better way? – eric Jan 8 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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