I created a script for studying purposes, generating a private key, a public key, and a P2SH address with a redeem script and RIPEMD160. I stored the address string in address_P2SH.txt.

I updated Bitcoin Core to version 26, and since version 0.21, Bitcoin uses Descriptor wallets. Now, I can't use importaddress because, by default, createwallet uses descriptors.

ADDR_P2SH=`cat address_P2SH.txt`
bitcoin-cli importaddress $ADDR_P2SH

I know I can use descriptor=false during createwallet, but I'd like to know if I can migrate my "external" address to a descriptor and sign my transaction with signrawtransactionwithwallet. If I'm not mistaken, I can't use signrawtransactionwithkey anymore because the descriptor doesn't allow getting the private key, only the master private key, even if I have the private key from my external address.

Update The redeem script is a P2PKH SCRIPT="76a9"$PBLENGTH$PBH"88AC". I presume that the logic for other kinds of scripts is the same.

second Update

I followed the steps of @Pieter Wuille

bitcoin-cli getdescriptorinfo "sh(pkh($(cat compressed_private_key_WIF_1.txt)))"

and I got

  "descriptor": "sh(pkh(0233e11f2a33d480d4fa1bcb7a0e118ea56d6511a21735e01c00182e924c5a8efc))#cx4xdav6",
  "checksum": "e2yjqzgh",
  "isrange": false,
  "issolvable": true,
  "hasprivatekeys": true


 bitcoin-cli importdescriptors '[{ "desc": "sh(pkh(0233e11f2a33d480d4fa1bcb7a0e118ea56d6511a21735e01c00182e924c5a8efc))#cx4xdav6", "timestamp": "now", "internal": true }]'
    "success": false,
    "error": {
      "code": -4,
      "message": "Cannot import descriptor without private keys to a wallet with private keys enabled"

Third update Thanks to Peter I can import the address

CHECKSUM=$(bitcoin-cli getdescriptorinfo "sh(pkh($(cat compressed_private_key_WIF_1.txt)))" | jq -r .checksum)

bitcoin-cli importdescriptors '[{ "desc": "sh(pkh('$(cat compressed_private_key_WIF_1.txt)'))#'"$CHECKSUM"'", "timestamp": "now", "internal": true }]'
  • What kind of script is the P2SH redeemScript? With just an address all you can do is watch. If you want to participate in signing, you'll need a descriptor that describes how the address is constructed. I can't advise on that without knowing what the script is. Commented Dec 7, 2023 at 18:48
  • you are right, I Updated my question
    – monkeyUser
    Commented Dec 7, 2023 at 18:57

1 Answer 1


If all you have is an address that you want to watch, you can use an addr(ADDR) descriptor (with ADDR replaced with your actual address). Importing that will make a descriptor wallet treat the address as its own, list its transactions, and use it in balance calculations.

If you want to also participate in signing, you'll need to provide more detail about its construction.

In your case, we're talking about a P2PKH-in-P2SH script, for which the descriptor would be sh(pkh(KEY)) (sh is for P2SH, pkh is for P2PKH), where KEY can either be a hex pubkey, a WIF privkey, an xpub with derivation path, or an xprv with derivation path.

See the descriptors documentation for how to write ones for other types of scripts, but in very short, the single-key constructions I can come up with:

  • pk(KEY) for P2PK
  • pkh(KEY) for P2PKH
  • wpkh(KEY) for P2WPKH
  • tr(KEY) for P2TR (with KEY as internal key)
  • sh(pk(KEY)) for P2SH-P2PK
  • sh(pkh(KEY)) for P2SH-P2PKH
  • sh(wpkh(KEY)) for P2SH-P2WPKH
  • wsh(pk(KEY)) for P2WSH-P2PK
  • wsh(pkh(KEY)) for P2WSH-P2PKH
  • sh(wsh(pk(KEY))) for P2SH-P2WSH-P2PK
  • sh(wsh(pkh(KEY))) for P2SH-P2WSH-P2PKH

It's hopefully obvious that I don't recommend any but the first few in this list, but it can be fun to play around with the ability to compose.

Note that the importdescriptors call requires descriptors that include a checksum. The checksum can be calculated using the getdescriptorinfo RPC.

  • 1
    I'm using P2SH-P2PKH because I created some examples for my study notes, and now I want to adjust them if possible. I also have examples for P2SH-P2PK and P2WPKH.
    – monkeyUser
    Commented Dec 7, 2023 at 19:21
  • I updated again the answer with your steps
    – monkeyUser
    Commented Dec 7, 2023 at 19:40
  • @monkeyUser The descriptor field in the getdescriptorinfo output is the normalized descriptor (which excludes private key material) for your input (note that it replaced your WIF key with a hex pubkey). If you want to import private key material too, you need to use the original (the checksum field reports the checksum for your original descriptor). Commented Dec 7, 2023 at 19:42
  • Thanks for your time and for new edited answer
    – monkeyUser
    Commented Dec 7, 2023 at 21:05

Your Answer

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

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