I use Bitcoin Core for offline signing. I created a legacy watch-only wallet, imported a public key using importpubkey, then called rescanblockchain, then generated a psbt transaction text(psbt_tx_txt), and finally successfully signed offline with my Bitcoin Core signing client.
However, if I restart the Bitcoin Core watch-only client, and regenerate psbt_tx_txt, it will missing the public key: analyzing psbt_tx_txt with analyzepsbt, it prompts missing pubkey:
{
"inputs": [
{
"has_utxo": true,
"is_final": false,
"next": "updater",
"missing": {
"pubkeys": [
"a_public_key_id"
]
}
}
],
"fee": 0.00001100,
"next": "updater"
}
But when I query the address information with getaddressinfo, the public key is exactly included in it:
{
"address": "bc1......",
"scriptPubKey": "......",
"ismine": false,
"solvable": true,
"desc": "wpkh(......)#l8qyd3u4",
"iswatchonly": true,
"isscript": false,
"iswitness": true,
"witness_version": 0,
"witness_program": "......",
"pubkey": "a_PUBLIC_KEY",
"ischange": false,
"timestamp": 1,
"labels": [
"......"
]
}
If I use the psbt_tx_txt to sign on the signing client, the bitcoin core client prompts: transaction is missing some information about inputs.
After restarting Bitcoin Core, it doesn't seem to be able to find the previously imported public key.
This means that every time I create an offline signed transaction, I need to create a new wallet, importpubkey,and rescanblockchain.
I think the public key should be able to be inserted into the psbt_tx_txt, next time I can JUST create the psbt, am I missing something?
[update]
The issue can be reproduced by this:
Starting the bitcoin-qt GUI client and synchronizing the blocks. Create a blank ledgcy watch-only wallet and enable the coin control feature in the bitcoin-qt preferences settings.
Import the public key of the address with the balance using importpubkey in the bitcoin-qt console. Select the Send main menu, select an input in the inputs option, go back to the Send main menu and leave the change address empty. Fill in a receiving address, select the maximum amount(Use available balance), enable Subtract fee from amount, customize the transaction fee to a fixed value, disable Replace-By-Fee feature, click Create Unsigned button to create psbt-string-A.
Restart bitcoin-qt, select the wallet you just created, and repeat the the same operation to create psbt-string-B.
Analyzing psbt-string-A and psbt-string-B with analyzepsbt in bitcoin-qt console, psbt-string-A is normal, psbt-string-B is missing public key.