I have an address with three compressed public keys:

SCRIPT="5221"$(cat compressed_public_key_1.txt)"21"$(cat compressed_public_key_2.txt)"21"$(cat compressed_public_key_3.txt)"53AE"

and I generated a P2SH address from here.

Now, I would like to use a descriptor to sign the multisignature transaction.

Previously, I used:

TX_SIGNED=$(bitcoin-cli signrawtransactionwithkey $TX_DATA '["'$PK1'"]' '[{"txid":"'$TXID'","vout":'$VOUT',"scriptPubKey":"'$SCRIPTPUBKEY'","redeemScript":"'$REDEEM'"}]'  | jq -r '.hex')
TX_SIGNED=$(bitcoin-cli signrawtransactionwithkey $TX_SIGNED '["'$PK2'"]' '[{"txid":"'$TXID'","vout":'$VOUT',"scriptPubKey":"'$SCRIPTPUBKEY'","redeemScript":"'$REDEEM'"}]'  | jq -r '.hex')

and it is still working. However, I want to know if I need to use signrawtransactionwithwallet.

To check this, I attempted:

PK1=`cat compressed_private_key_WIF_1.txt`
PK2=`cat compressed_private_key_WIF_2.txt`
PK3=`cat compressed_private_key_WIF_3.txt`

CHECKSUM=$(bitcoin-cli getdescriptorinfo "sh(multi(2,$PK1,$PK2,$PK3))" | jq -r .checksum)
bitcoin-cli importdescriptors '[{ "desc": "sh(multi(2,'$PK1','$PK2','$PK3'))#'$CHECKSUM'", "timestamp": "now", "internal": true }]'

I could import without any error. But when I try to use:

TX_SIGNED=$(bitcoin-cli signrawtransactionwithwallet $TX_DATA '[{"txid":"'$TXID'","vout":'$VOUT',"scriptPubKey":"'$SCRIPTPUBKEY'","redeemScript":"'$REDEEM'"}]'  | jq -r '.hex')

I get this error:

"error": "Unable to sign input, invalid stack size (possibly missing key)"

I'm using this kind of script for my study notes

  • Are the PK1 etc private keys or public keys? It won't work without private keys. Commented Dec 8, 2023 at 17:58
  • private keys, updated the question.
    – monkeyUser
    Commented Dec 8, 2023 at 18:03
  • Does the address match exactly? You can use deriveaddresses on the descriptor. Commented Dec 8, 2023 at 18:11
  • thanks for the reply, no the address is different after using deriveaddresses but the Order of PB during creating the Redeem script is the same
    – monkeyUser
    Commented Dec 8, 2023 at 18:24
  • 1
    Well if the address doesn't match, it's not a descriptor for the exact output you have, so it won't work. BTW: your SCRIPT uses the same public key twice. Commented Dec 8, 2023 at 18:26


Your Answer

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