elements icon indicating copy to clipboard operation
elements copied to clipboard

signrawtransactionwithkey overrides signatures for segwit multisignature p2wsh address

Open NCrashed opened this issue 4 years ago • 0 comments

Expected behavior I have a segwit blinded p2wsh address with:

unblinded_address=ex1qf000vr35slcvgrus2qpkqn8ccn7z3hn72uygy4qspghrnc80cflqa2ynaw
redeem_script=52210209e67ac042dfd0b6de4f5829633abe1fd454cc4d28e1cd02d579f5aa9bf0b49521035e39052a6f3245d5f1eea824ddb393b07b181bc728c956c4728dc6ed088628402103c7f33f55a5ca147a58b5a0d3cd1e2cda845fc76015548e9d0d847ce1fc1fb1ec53ae
descriptor=wsh(multi(2,0209e67ac042dfd0b6de4f5829633abe1fd454cc4d28e1cd02d579f5aa9bf0b495,035e39052a6f3245d5f1eea824ddb393b07b181bc728c956c4728dc6ed08862840,03c7f33f55a5ca147a58b5a0d3cd1e2cda845fc76015548e9d0d847ce1fc1fb1ec))#ru8mha3q
blinded_address=lq1qqd45tcekmy6asgfyvklkjms4eet0u47mzw7ugc5avmdd2rmj73y6hze39m2f53wp2mlg0dmruup0ca2fgr3uu43rffdj8yuda

And I want to spend the following unspent output from the address:

[
  {
    "txid": "c6b2114d43f9bc2a9397a9126bd1f5a68ebf67ed1962d78b1346e510ed0f8850",
    "vout": 0,
    "address": "ex1qf000vr35slcvgrus2qpkqn8ccn7z3hn72uygy4qspghrnc80cflqa2ynaw",
    "label": "",
    "witnessScript": "52210209e67ac042dfd0b6de4f5829633abe1fd454cc4d28e1cd02d579f5aa9bf0b49521035e39052a6f3245d5f1eea824ddb393b07b181bc728c956c4728dc6ed088628402103c7f33f55a5ca147a58b5a0d3cd1e2cda845fc76015548e9d0d847ce1fc1fb1ec53ae",
    "scriptPubKey": "00204bdef60e3487f0c40f905003604cf8c4fc28de7e57088254100a2e39e0efc27e",
    "amount": 0.00012000,
    "assetcommitment": "0a30643bc922512bb45846680eaf492cca0d7775d2e33427d38d76b3942a18dd1d",
    "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d",
    "amountcommitment": "0881efd8d12c1ee89137b3473a751f8a6f3bf9f882268510eaa573b8b492517b04",
    "amountblinder": "2082c51b4e3525b15901cc9aa748e91a0cd6d660e71a455dd1f9e03fa686e426",
    "assetblinder": "d895c624e5a1252cf8e8f0c66bb6b00d67b271686936f5344ec6421f0cf3706c",
    "confirmations": 442,
    "spendable": false,
    "solvable": true,
    "desc": "wsh(multi(2,[7f4a97af/0'/0'/0']0209e67ac042dfd0b6de4f5829633abe1fd454cc4d28e1cd02d579f5aa9bf0b495,[1b6f657b]035e39052a6f3245d5f1eea824ddb393b07b181bc728c956c4728dc6ed08862840,[b3920fe5]03c7f33f55a5ca147a58b5a0d3cd1e2cda845fc76015548e9d0d847ce1fc1fb1ec))#ppm8xad2",
    "safe": true
  }
]

I made the following transaction with createrawtransaction and fundrawtransaction:

02000000000150880fed10e546138bd76219ed67bf8ea6f5d16b12a997932abcf9434d11b2c60000000000fdffffff02016d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f010000000000002e3b0273171f280c6110c28c83e56bfa773bb39801183b9ef5c2a3f1175e44d34dcc9017a914402e39ed060ed5046ae700684977490092ccd79887016d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f0100000000000000a5000000000000

And signing script:

blindedtx=$(elements-cli blindrawtransaction $txhex)
privkey=$(elements-cli dumpprivkey $priv_address)
elements-cli signrawtransactionwithkey $notsigned "[\"$privkey\"]" "[ { \"txid\": \"$txid\", \"vout\": $vout, \"scriptPubKey\": \"$script_pubkey\", \"witnessScript\": \"$witness_script\", \"amount\": $amount, \"amountcommitment\": \"$amountcommitment\" } ]"

The result seems right, but when I try to sign the transaction with the second private key, the signature from the previous key is overwritten with the new one.

Actual behavior

If you consider P2SH "legacy" multisig address, the same process will result in expected multiple signatures in the output.

System information

Elements Core RPC client version v0.21.0.0-g134ba2c972a5403fe73bbc9c1877178b3f4d74f9

NCrashed avatar Dec 29 '21 17:12 NCrashed