C-Otto / BitBook

BitBook helps you organize your bitcoin addresses and transactions.
https://bitbook.c-otto.de
MIT License
43 stars 6 forks source link

Bug: lnd, force closed channel: claimed OUTGOING_HTLC should not be marked as owned #119

Closed C-Otto closed 3 years ago

C-Otto commented 3 years ago

Describe the bug In the case of a force close the lncli closedchannels output may contain a resolution for an outgoing HTLC (resolution_type: OUTGOING_HTLC). If the outcome is CLAIMED, this means that the peer received the funds. Only if the outcome is TIMEOUT, the own node has access to the funds. The bug is that the target address is marked as owned, although it belongs to the remote peer.

To Reproduce

Have `lncli closedchannels` with output containing something like this:
{
            "channel_point": "x:0",
            "chan_id": "1",
            "chain_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
            "closing_tx_hash": "y",
            "remote_pubkey": "z",
            "capacity": "2",
            "close_height": 3,
            "settled_balance": "4",
            "time_locked_balance": "0",
            "close_type": "REMOTE_FORCE_CLOSE",
            "open_initiator": "INITIATOR_LOCAL",
            "close_initiator": "INITIATOR_REMOTE",
            "resolutions": [
                {
                    "resolution_type": "OUTGOING_HTLC",
                    "outcome": "CLAIMED",
                    "outpoint": {
                        "txid_bytes": "aaa",
                        "txid_str": "bbb",
                        "output_index": 1
                    },
                    "amount_sat": "1",
                    "sweep_txid": "ccc"
                },
                {
                    "resolution_type": "COMMIT",
                    "outcome": "CLAIMED",
                    "outpoint": {
                        "txid_bytes": "ddd",
                        "txid_str": "eee",
                        "output_index": 2
                    },
                    "amount_sat": "1",
                    "sweep_txid": "fff"
                }
            ]
        },

Import the file using lnd-add-from-closed-channels.

Expected behavior The OUTGOING_HTLC destination address should not be marked as owned.