Closed dangeross closed 8 months ago
Here are the logs, the process starts at 2024-01-10T07:39:33.750Z and ends at 2024-01-10T07:39:36.591Z com.satimoto-latest.txt
Here is a decode of the tx w/ the Witness program hash mismatch
:
bitcoin-cli decoderawtransaction 020000000001013db0eb77d3275977ab5e33adbb35361c40eb8971db957491a73c53727ab2b5e3030000000001000000023e3704000000000016001487e09361881dcb6897e3161ee602f62290ba8d812202000000000000225120c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b02483045022100eba3c7db03e7be73a932d39816f10be376a79fb3ac2b960617a3331c5212ef0802201aaee301beac012ccd413a3ea6dbcd8edbf1ae3c26ccfc2ab979e70c352fc19b0121020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f33313970c00
{
"txid": "c61a315065ffb927e5464515e632c24c617f126a556afccae3cf890aaa338e53",
"hash": "e36191ca8f6f2313f50325e1e3a554fd6432f2a2e0dbcb941fe9b4ad283d3100",
"version": 2,
"size": 235,
"vsize": 153,
"weight": 610,
"locktime": 825107,
"vin": [
{
"txid": "e3b5b27a72533ca7917495db7189eb401c3635bbad335eab775927d377ebb03d",
"vout": 3,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"3045022100eba3c7db03e7be73a932d39816f10be376a79fb3ac2b960617a3331c5212ef0802201aaee301beac012ccd413a3ea6dbcd8edbf1ae3c26ccfc2ab979e70c352fc19b01",
"020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f333"
],
"sequence": 1
}
],
"vout": [
{
"value": 0.00276286,
"n": 0,
"scriptPubKey": {
"asm": "0 87e09361881dcb6897e3161ee602f62290ba8d81",
"desc": "addr(bc1qslsfxcvgrh9k39lrzc0wvqhky2gt4rvpwxmeap)#5kjmxkdg",
"hex": "001487e09361881dcb6897e3161ee602f62290ba8d81",
"address": "bc1qslsfxcvgrh9k39lrzc0wvqhky2gt4rvpwxmeap",
"type": "witness_v0_keyhash"
}
},
{
"value": 0.00000546,
"n": 1,
"scriptPubKey": {
"asm": "1 c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b",
"desc": "rawtr(c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b)#nj32wcvg",
"hex": "5120c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b",
"address": "bc1pc7fu67whtzcy5068rvvztdw5rh3wkcfgn6tv65kx7xs7wumwy6ds35es75",
"type": "witness_v1_taproot"
}
}
]
}
@ksedgwic I'm not quite up to speed on the error that is being reported here. Could this somehow be related to our use of VLS, or is this related to the data we feed into VLS?
The sendrawtx error:
2024-01-10T07:39:36.591Z [DEBUG] BreezSDK: [DEBUG] node-logs: DEBUG plugin-bcli: sendrawtx exit 26 (bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=8332 -rpcuser=... -stdinrpcpass sendrawtransaction 020000000001013db0eb77d3275977ab5e33adbb35361c40eb8971db957491a73c53727ab2b5e3030000000001000000023e3704000000000016001487e09361881dcb6897e3161ee602f62290ba8d812202000000000000225120c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b02483045022100eba3c7db03e7be73a932d39816f10be376a79fb3ac2b960617a3331c5212ef0802201aaee301beac012ccd413a3ea6dbcd8edbf1ae3c26ccfc2ab979e70c352fc19b0121020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f33313970c00) error code: -26\nerror message:\nnon-mandatory-script-verify-flag (Witness program hash mismatch)
Parent tx in block explorer: https://mempool.space/tx/e3b5b27a72533ca7917495db7189eb401c3635bbad335eab775927d377ebb03d
The transaction decoded:
bitcoin@home5:~$ bitcoin-cli decoderawtransaction 020000000001013db0eb77d3275977ab5e33adbb35361c40eb8971db957491a73c53727ab2b5e3030000000001000000023e3704000000000016001487e09361881dcb6897e3161ee602f62290ba8d812202000000000000225120c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b02483045022100eba3c7db03e7be73a932d39816f10be376a79fb3ac2b960617a3331c5212ef0802201aaee301beac012ccd413a3ea6dbcd8edbf1ae3c26ccfc2ab979e70c352fc19b0121020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f33313970c00
{
"txid": "c61a315065ffb927e5464515e632c24c617f126a556afccae3cf890aaa338e53",
"hash": "e36191ca8f6f2313f50325e1e3a554fd6432f2a2e0dbcb941fe9b4ad283d3100",
"version": 2,
"size": 235,
"vsize": 153,
"weight": 610,
"locktime": 825107,
"vin": [
{
"txid": "e3b5b27a72533ca7917495db7189eb401c3635bbad335eab775927d377ebb03d",
"vout": 3,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"3045022100eba3c7db03e7be73a932d39816f10be376a79fb3ac2b960617a3331c5212ef0802201aaee301beac012ccd413a3ea6dbcd8edbf1ae3c26ccfc2ab979e70c352fc19b01",
"020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f333"
],
"sequence": 1
}
],
"vout": [
{
"value": 0.00276286,
"n": 0,
"scriptPubKey": {
"asm": "0 87e09361881dcb6897e3161ee602f62290ba8d81",
"desc": "addr(bc1qslsfxcvgrh9k39lrzc0wvqhky2gt4rvpwxmeap)#5kjmxkdg",
"hex": "001487e09361881dcb6897e3161ee602f62290ba8d81",
"address": "bc1qslsfxcvgrh9k39lrzc0wvqhky2gt4rvpwxmeap",
"type": "witness_v0_keyhash"
}
},
{
"value": 0.00000546,
"n": 1,
"scriptPubKey": {
"asm": "1 c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b",
"desc": "rawtr(c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b)#nj32wcvg",
"hex": "5120c793cd79d758b04a3f471b1825b5d41de2eb61289e96cd52c6f1a1e7736e269b",
"address": "bc1pc7fu67whtzcy5068rvvztdw5rh3wkcfgn6tv65kx7xs7wumwy6ds35es75",
"type": "witness_v1_taproot"
}
}
]
}
The witness script decoded:
bitcoin@home5:~$ bitcoin-cli decodescript 020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f333
{
"asm": "3853 OP_NOP [error]",
"desc": "raw(020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f333)#j7hk5lw4",
"type": "nonstandard"
}
Analysis:
to_remote
output from the commitment:
to_local
based on the redeem script used on itBased on https://github.com/lightning/bolts/blob/master/03-transactions.md#to_remote-output
the witness should be <remote_sig>
(followed by the redeemscript)
Comparing failed operation above (F
) to similar successful instance (A
):
Observations:
A
was a "Channel close: ..."
while F
was only "Multisig 2 of 2"? maybe difference in
announcements?The good channel's outputs are spent by:
<remotepubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY
https://mempool.space/tx/b357bc5f8f087211786be62c9b1d7bdf9e9b2cf33b74181c40a0bad7f08f5452#vin=5OP_IF <revocationpubkey> OP_ELSE
to_self_delayOP_CHECKSEQUENCEVERIFY OP_DROP <local_delayedpubkey> OP_ENDIF OP_CHECKSIG
https://mempool.space/tx/8492511e2c73337acede42c1480d25fcc0c0269a3a7d07cda6e84615abe14fdb#vin=0The troubled commitment's main outputs are:
OP_IF <revocationpubkey> OP_ELSE
to_self_delayOP_CHECKSEQUENCEVERIFY OP_DROP <local_delayedpubkey> OP_ENDIF OP_CHECKSIG
https://mempool.space/tx/315b9223ccbf8090331d0c2eac5eaf43d0cf73ab137707812efd5bffbeebf823#vin=0
The witness for A
's to_remote is:
3045022100f5bad7155179820b4c74107a5c878a94dfdd61bd5561710546b5b4f5663ace8202203493a886ead7c11d2c04f31434e02338f68a31e6c9dcb18f15fbe50f99e0b13e01
2103e20728952d387266bbec58a0b608952124baa9dd58e6c339e52ec7115bb54501ad51b2
The script decodes as:
bitcoin@home5:~$ bitcoin-cli decodescript 2103e20728952d387266bbec58a0b608952124baa9dd58e6c339e52ec7115bb54501ad51b2
{
"asm": "03e20728952d387266bbec58a0b608952124baa9dd58e6c339e52ec7115bb54501 OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY",
"desc": "raw(2103e20728952d387266bbec58a0b608952124baa9dd58e6c339e52ec7115bb54501ad51b2)#7kdpwq3z",
"type": "nonstandard",
"p2sh": "3MmR7DiFemknUa1vQoE3ycri2ahU7hTR9b",
"segwit": {
"asm": "0 b61d3aec9892251b2aaeb5ce5600d4477090a9ef7e59ea11156edd1b4dcde2d9",
"desc": "wsh(and_v(v:pk(03e20728952d387266bbec58a0b608952124baa9dd58e6c339e52ec7115bb54501),older(1)))#9pt2xcnl",
"hex": "0020b61d3aec9892251b2aaeb5ce5600d4477090a9ef7e59ea11156edd1b4dcde2d9",
"address": "bc1qkcwn4mycjgj3k24wkh89vqx5gacfp2000ev75yg4dmw3knwdutvsa5fh5j",
"type": "witness_v0_scripthash",
"p2sh-segwit": "32gXVyAjbrDhKb8iyAKh7xiYiZKeuekto3"
}
}
The witness for F
's to_remote is:
3045022100eba3c7db03e7be73a932d39816f10be376a79fb3ac2b960617a3331c5212ef0802201aaee301beac012ccd413a3ea6dbcd8edbf1ae3c26ccfc2ab979e70c352fc19b01
020d0f6142c6ad7c190875838f7a57bcfdcceb6e7bcc253849d038a8e6d847f333
The script is wrong
I think the issue is related to the uniclosekeys
argument to SignWithdrawal
. The output in question is being spent and it is being identified as the output of a prior unilateral close. I suspect we need to deal with the anchors case explicitly ...
I analyzed the problem in the issue linked above. The issue is that we are missing the redeemscript in the witness stack for the anchors case.
I'm surprised that this case is not covered by the CLN system tests.
The script is wrong
That witness element would have been correct if this was non-anchors (p2wpkh
), but it's indeed wrong for the anchors case (p2wsh
).
I improved the VLS debugging of Unilateral Close Info and slightly modified a CLN integration test to expose this issue in integration testing: https://gitlab.com/lightning-signer/vls-hsmd/-/merge_requests/136
A user is reporting several failed attempts to withdraw funds after a force close. The failure always results in the error:
Error calling method Withdraw: RpcError{ code: Some(-1), message: \"Error broadcasting transaction: error-code: -26\\\\nerror message: \\\\nnon-mandatory-script-verify-flag (Witness program hash mismatch). Unsent tx discarded ...
after which the utxo's are marked reserved for a day or so. Once the utxo's are available again, the user repeats resulting in the same error. Node id for reference is: 02810d14934b1b41b52af4b6c118878a00e857cc4922442ea59e18b31906b09c67
A similar issue is also raised in https://github.com/Blockstream/green_android/issues/185 relating to the same circumstances and error.
I have requested the user provides a trace log the next time they attempt a withdraw and will attach them to this issue.