Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
Writing this issue on behalf of several reported cases (see below), so the exact bitcoind specifications are different in each case.
All lightning implementation scan for the preimage in case an HTLC as to be resolved onchain. Doing this we analyse the witness data of related outputs because we know what to expect. Example for this is an offered HTLC we have to resolve onchain. Let’s imagine that we locally force-closed a channel, this would lead to the following Witnessscript for the offered HTLC:
0# To remote node with revocation key
1OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
2OP_IF
3 OP_CHECKSIG
4OP_ELSE
5 <remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
6 OP_NOTIF
7 # To local node via HTLC-timeout transaction (timelocked).
8 OP_DROP 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
9 OP_ELSE
10 # To remote node with preimage.
11 OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
12 OP_CHECKSIG
13 OP_ENDIF
14OP_ENDIF
This Script can only be unlocked by the following 3 types of witness data:
0// SENDR: <0> <sendr sig> <recvr sig> <0> (2nd level timeout)
1// RECVR: <recvr sig> <preimage>
2// REVOK: <revoke sig> <revoke key>
So we can conclude that the witness data will be at least of size 2. In lnd we therefore do a check for the second witness element to be a 32 byte preimage.
Now comes the problem. People reported now several times, that their lightning-node was crashing because of this behaviour. And when queried their backend with bitcoin-cli getrawtransaction
their output did also not have the witness data populated. A reindexing of the blockchain helped I think in all cases which reported this behaviour. I am reporting this issue here because I have the feeling that somehow bitcoind might have an edge case for this behaviour (in case the hardware is not the problem).
Reported cases: 1.https://github.com/lightningnetwork/lnd/issues/8028#issuecomment-1778777711 2.https://github.com/lightningnetwork/lnd/issues/7803 3.https://github.com/lightningnetwork/lnd/issues/5977 4.https://github.com/lightningnetwork/lnd/issues/6381
Wondering whether some of you have an idea where to look at. Can I assume that a bitcoin node could only report this transaction (hence accepting it via a block) if the witness data was not provided? Otherwise we would have failed the block verification I guess?
Happy to get your thoughts on this.
Thank you in advance!
Expected behaviour
Not sure whether this is just a hardware failure which manifests itself via the above described behaviour. So no expected behaviour yet.
Steps to reproduce
TBD.
Relevant log output
No response
How did you obtain Bitcoin Core
Pre-built binaries
What version of Bitcoin Core are you using?
-
Operating system and version
-
Machine specifications
No response