Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support anchor outputs on ln channels #1597

Closed
wants to merge 1 commit into from

Conversation

holzeis
Copy link
Contributor

@holzeis holzeis commented Nov 17, 2023

fixes #1596

Adds anchor outputs to the commitment transaction see below an example of a commitment transaction with anchor outputs.

{
    "addresses": [
        "bc1q2zfkaerpl0xe2n0wnkkcxqnj9xx6dac8qnft7kndyxlu8hjpu62qusa7ga",
        "bc1q0jf0ncmpa70frgdkjnkx9khap24yrwgdtjnwx6m4096w7mh2wyns2azzc7",
        "bc1qwgkl04thfchyqctndvvr7w9wc4tdw80078dzdy2cnsnvjdmmrmusapmcl7",
        "bc1q64hyx7qexkzvwa6spwlwek33hwsxy42sty2yeq9vtr5jhkyg68tsyzm68d"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 0,
    "hash": "3b94c7ff64af9bbe0821df7e397565a903ae7824e8817ae4b47ef2c878074724",
    "inputs": [
        {
            "age": 0,
            "output_index": 0,
            "prev_hash": "84151c91fd82eee06a0b0b0bf0fb0f0bfdae9915ec5c87b28f86f504f7b49c79",
            "script_type": "empty",
            "sequence": 2160200047
        }
    ],
    "lock_time": 548510010,
    "opt_in_rbf": true,
    "outputs": [
        {
            "addresses": [
                "bc1q2zfkaerpl0xe2n0wnkkcxqnj9xx6dac8qnft7kndyxlu8hjpu62qusa7ga"
            ],
            "script": "002050936ee461fbcd954dee9dad830272298da6f70704d2bf5a6d21bfc3de41e694",
            "script_type": "pay-to-witness-script-hash",
            "value": 330
        },
        {
            "addresses": [
                "bc1q0jf0ncmpa70frgdkjnkx9khap24yrwgdtjnwx6m4096w7mh2wyns2azzc7"
            ],
            "script": "00207c92f9e361ef9e91a1b694ec62dafd0aaa41b90d5ca6e36b757974ef6eea7127",
            "script_type": "pay-to-witness-script-hash",
            "value": 330
        },
        {
            "addresses": [
                "bc1qwgkl04thfchyqctndvvr7w9wc4tdw80078dzdy2cnsnvjdmmrmusapmcl7"
            ],
            "script": "0020722df7d5774e2e4061736b183f38aec556d71deff1da2691589c26c9377b1ef9",
            "script_type": "pay-to-witness-script-hash",
            "value": 90000
        },
        {
            "addresses": [
                "bc1q64hyx7qexkzvwa6spwlwek33hwsxy42sty2yeq9vtr5jhkyg68tsyzm68d"
            ],
            "script": "0020d56e4378193584c777500bbeecda31bba062555059144c80ac58e92bd888d1d7",
            "script_type": "pay-to-witness-script-hash",
            "value": 109056
        }
    ],
    "preference": "low",
    "received": "2023-11-17T07:54:21.743033463Z",
    "relayed_by": "44.197.112.107",
    "size": 443,
    "total": 199716,
    "ver": 2,
    "vin_sz": 1,
    "vout_sz": 4,
    "vsize": 278
}

Judging from the rust-lightning release notes regarding anchor nodes (copied below). It looks like though it would make sense to upgrade as soon as possible at least to v0.0.117.

v0.0.118

  • Anchor outputs are now properly considered when calculating the amount
    available to send in HTLCs. This can prevent force-closes in anchor channels
    when sending payments which overflow the available balance (#2674).

v0.0.117

  • Anchor channels which were closed by a counterparty broadcasting its
    commitment transaction (i.e. force-closing) would previously not generate a
    SpendableOutputs event for our to_remote (i.e. non-HTLC-encumbered)
    balance. Those with such balances available should fetch the missing
    SpendableOutputDescriptors using the new
    ChannelMonitor::get_spendable_outputs method (#2605).

  • Anchor channels may result in spurious or missing Balance entries for HTLC
    balances (fix: Show the number of seed words correctly (don't split across lines) #2610).

Security

0.0.117 fixes several loss-of-funds vulnerabilities in anchor output channels,
support for which was added in 0.0.116, in reorg handling, and when accepting
channel(s) from counterparties which are miners.

@holzeis holzeis requested review from bonomat and luckysori November 17, 2023 08:05
@holzeis holzeis self-assigned this Nov 17, 2023
@holzeis holzeis force-pushed the feat/use-anchor-outputs-on-channels branch from f787a2d to 238393f Compare November 17, 2023 09:01
Copy link
Contributor

@luckysori luckysori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you look at how ldk-node, ldk-sample and mutiny handle these events when anchor outputs are enabled? Looking at those projects is helpful for me when I upgrade or change the config.

@holzeis holzeis force-pushed the feat/use-anchor-outputs-on-channels branch from 238393f to 9709bea Compare November 17, 2023 09:34
@holzeis
Copy link
Contributor Author

holzeis commented Nov 17, 2023

Did you look at how ldk-node, ldk-sample and mutiny handle these events when anchor outputs are enabled? Looking at those projects is helpful for me when I upgrade or change the config.

I just had a look

  • ldk-node and mutiny do not use anchor channels
  • ldk-sample uses it, but does not check anything on Event::OpenChannelRequest

@holzeis
Copy link
Contributor Author

holzeis commented Nov 17, 2023

Given the bugs in 116 in regards to anchor channels, I don't think we should go with that change before we've upgraded to 117.

@holzeis holzeis force-pushed the feat/use-anchor-outputs-on-channels branch from 9709bea to a7f68a0 Compare November 17, 2023 11:00
@holzeis
Copy link
Contributor Author

holzeis commented Nov 29, 2023

Closing this PR for now as it is depending on the 117 upgrade.

@holzeis holzeis closed this Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support anchor outputs on lightning channels
2 participants