1

What are the steps that we can follow to create an unsigned tx for watch-only cold storage address using bitcoin core? How can we sign the transaction and broadcast it later?

1 Answer 1

2

create wallet

cold-storage-example

Run the below commands in electrum console:



>> getaddresshistory('tb1qu2l4n8st9w3hhsxstd8muaxgnu63fql9rkylmd')
[
    {
        "height": 1807710,
        "tx_hash": "727707cced87f9bc2a1ca3ed28df39588e9881fd50c272e78bc76a5bb1ffde9c"
    }
]
>> deserialize(gettransaction('727707cced87f9bc2a1ca3ed28df39588e9881fd50c272e78bc76a5bb1ffde9c'))
{
    "inputs": [
        {
            "coinbase": false,
            "nsequence": 4294967295,
            "prevout_hash": "99ebe2d047c545a50cf86f0ff5f4c0648437cb8724137f1a33c2f06eb06ef35a",
            "prevout_n": 1,
            "scriptSig": "",
            "witness": "0247304402206379d344d75fbee07f54213378f95e44dc757872d59a35efbc14ec7e1ca7dfd102207a47f9c1be39cafa8f9ac8a879e2b968e2359bead23a1f6598478ed7d141c73d012103ee169045615c663c0204472f86e3c2b2ae43e574146d30607c42fe6d670ac7be"
        }
    ],
    "locktime": 0,
    "outputs": [
        {
            "address": "tb1qu2l4n8st9w3hhsxstd8muaxgnu63fql9rkylmd",
            "scriptpubkey": "0014e2bf599e0b2ba37bc0d05b4fbe74c89f351483e5",
            "value_sats": 3000000
        },
        {
            "address": "tb1q7sx47sra5w7kw8we5xeusl4089ryverhjcft6q",
            "scriptpubkey": "0014f40d5f407da3bd671dd9a1b3c87eaf3946466477",
            "value_sats": 61797954
        }
    ],
    "version": 2
}

You get the scriptPubKey in above output which can be used in importmulti command in bitcoin core:

"address": "tb1qu2l4n8st9w3hhsxstd8muaxgnu63fql9rkylmd",
"scriptpubkey": "0014e2bf599e0b2ba37bc0d05b4fbe74c89f351483e5"

Get the public key of the address from details:

address-details-electrum

If you are using bitcoin core wallet instead of electrum in this example, you can run the getaddressinfo command in console to get scriptPubKey and pubkey of the address.

Run the below command in bitcoin core console to import the address with the details copied from electrum:

importmulti '[{"scriptPubKey" : "0014e2bf599e0b2ba37bc0d05b4fbe74c89f351483e5","pubkeys" : ["0304c5184085eea27a072628de03fbb953f5fdd99fb526f097fdd4c6968d165f1a"],"timestamp" : "now","label" : "watch-address-test", "watchonly": true}

You can ignore the steps mentioned above for scriptPubKey and only use the "Public Key" of an address by using descriptor:

We need checksum in importmulti which is returned in descriptorinfo for the public key mentioned

descriptorinfo

Next, we can run importmulti command (I have used public key for a different address in this command):


importmulti '[{"desc" : "wpkh(026641b79d7ffa40ddf994f0277c2649f3ddcbd871194ba6ef87687daea22ca503)#zl4yt8hu","timestamp" : "now","label" : "watch-address-test", "watchonly": true}]'

receiving-address

rescanblockchain 1800000 1835099

I can see available inputs in GUI:

inputs

We still get an error if trying to create an unsigned tx which involves sending some amount to change address because we aren't trying to spend the whole balance.

change-error

Add a change address for creating unsigned tx:

add-change-address

Option to copy PSBT:

PSBT

Load transaction using the copied text in electrum:

load-tx

sign-tx

Copy the hex of signed tx and run the below command in bitcoin core:



sendrawtransaction 020000000001019cdeffb15b6ac78be772c250fd81988e5839df28eda31c2abcf987edcc0777720000000000fdffffff02b3410f0000000000160014112c8ecb9e0876a645e7b8e89eed83bd61096e2c80841e00000000001600145f24e8fbfe65840c27dad3b053855de4cee843820247304402200d7cc29a8588c180e6a460e0eb88ea830db76dbb040a875d45fe8c64c9509a80022060879365af1c6d19e7c47bdbfa402a053ed42809c52db6816cd249dff46529b001210304c5184085eea27a072628de03fbb953f5fdd99fb526f097fdd4c6968d165f1a5f001c00

It returns the transaction id: 4890c14e7635a3e72320046645686052339e443eba56e5a62849a48b3f67f419

You can check the details in a block explorer: https://blockstream.info/testnet/tx/4890c14e7635a3e72320046645686052339e443eba56e5a62849a48b3f67f419

Related questions:

How to create unsigned tx in a watch-only wallet?

How to move/sweep your Bitcoin Core bitcoins safely and air-gapped to your new fancy cold storage?

Related issues: https://github.com/bitcoin-core/gui/issues/94

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.