Skip to content

Empty Witness Data, although transaction has witness populated in other full-nodes #28730

Closed
@ziggie1984

Description

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:

# To remote node with revocation key
OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
OP_IF
    OP_CHECKSIG
OP_ELSE
    <remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
    OP_NOTIF
        # To local node via HTLC-timeout transaction (timelocked).
        OP_DROP 2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
    OP_ELSE
        # To remote node with preimage.
        OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
        OP_CHECKSIG
    OP_ENDIF
OP_ENDIF

This Script can only be unlocked by the following 3 types of witness data:

//  SENDR: <0> <sendr sig>  <recvr sig> <0> (2nd level timeout)
//  RECVR: <recvr sig>  <preimage>
//  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.lightningnetwork/lnd#8028 (comment)
2.lightningnetwork/lnd#7803
3.lightningnetwork/lnd#5977
4.lightningnetwork/lnd#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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions