1

I created a multisignature address in regtest:

ADDR_1=`bitcoin-cli getnewaddress "" "bech32"`
ADDR_2=`bitcoin-cli getnewaddress "" "bech32"`
PB1=$(bitcoin-cli -named getaddressinfo address=$ADDR_1 | jq -r '.pubkey')
PB2=$(bitcoin-cli -named getaddressinfo address=$ADDR_2 | jq -r '.pubkey')
ADDR_P2SH_P2WPKH_NATIVE_2=`bitcoin-cli -named createmultisig nrequired=1 keys='''["'$PB1'","'$PB2'"]''' address_type="bech32" | jq -r '.address'`

After that, I generated 101 blocks:

bitcoin-cli generatetoaddress 101 $ADDR_P2SH_P2WPKH_NATIVE_2

Then, I wanted to retrieve the listunspent:

bitcoin-cli listunspent 1 101 '["'$ADDR_P2SH_P2WPKH_NATIVE_2'"]'

However, it returned an empty result. So, I attempted to import the new address using addr():

CHECKSUM=$(bitcoin-cli getdescriptorinfo "addr($ADDR_P2SH_P2WPKH_NATIVE_2)" | jq -r .checksum)
bitcoin-cli importdescriptors '[{ "desc": "addr('$ADDR_P2SH_P2WPKH_NATIVE_2')#'"$CHECKSUM"'", "timestamp": "now", "internal": true }]'

This resulted in an error:

[
  {
    "success": false,
    "error": {
      "code": -4,
      "message": "Cannot import descriptor without private keys to a wallet with private keys enabled"
    }
  }
]

I also tried:

CHECKSUM=$(bitcoin-cli getdescriptorinfo "wsh(multi(1,$PB1,$PB2))" | jq -r .checksum)
bitcoin-cli importdescriptors '[{ "desc": "wsh(multi(1,'$PB1','$PB2'))#'"$CHECKSUM"'", "timestamp": "now", "internal": true }]'

But encountered the same result.

Another attempt is

bitcoin-cli -named createwallet wallet_name="bia" disable_private_keys=true
CHECKSUM=$(bitcoin-cli getdescriptorinfo "wsh(multi(1,$PB1,$PB2))" | jq -r .checksum)
bitcoin-cli -rpcwallet=bia importdescriptors '[{ "desc": "wsh(multi(1,'$PB1','$PB2'))#'"$CHECKSUM"'", "timestamp": "now", "internal": true }]'
bitcoin-cli -rpcwallet=bia listunspent 1 101 '["'$ADDR_P2SH_P2WPKH_NATIVE_2'"]'

it's still empty

12
  • You're passing "timestamp": "now", implying that the address was only created now, so no rescanning of history will take place. You need to either explicitly rescan, or set the timestamp to a value before the first transaction to that address took place. Dec 10, 2023 at 14:43
  • thanks for the reply, I need to create a new wallet and use -rpcwallet ? Because with other method I get the error about private keys
    – monkeyUser
    Dec 10, 2023 at 15:20
  • With descriptor wallets there doesn't exist a distinction between watch-only addresses and full addresses in the wallet anymore. Instead, the whole wallet is either watch-only or full. Dec 10, 2023 at 15:30
  • you are right I can scan before mine the blocks and I can find UTXO available, but I need to create a new wallet with disable_private_keys=true? Only my last attempt work. in that way I will have a problem during the signrawtransactionwithwallet
    – monkeyUser
    Dec 10, 2023 at 18:50
  • 1
    There is even documentation on that topic: github.com/bitcoin/bitcoin/blob/master/doc/multisig-tutorial.md Dec 11, 2023 at 16:40

0

Your Answer

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