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

PostRestartHtlcCleaner handle channel closing #1338

Merged
merged 9 commits into from Apr 1, 2020

Commits on Mar 31, 2020

  1. Add missing cases to PostRestart

    When a channel is closed we want to remove its HTLCs from our
    list of pending broken HTLCs (they are being resolved on-chain).
    
    We should also ignore outgoing HTLCs that have already been
    settled upstream (which can happen when downstream is closing).
    t-bast committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    0a9d2bb View commit details
    Browse the repository at this point in the history
  2. Watch for downstream HTLC resolved on-chain

    When a downstream channel is closing, we can safely fail upstream the
    HTLCs that were either timed out on-chain or not included in the
    broadcast commit transaction.
    
    Channels will not always raise events about those after a reboot, so we
    need to inspect the channel state and detect such HTLCs.
    t-bast committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    0547cde View commit details
    Browse the repository at this point in the history
  3. Add helper function to HTLC scripts

    To extract the payment_hash or preimage from an HTLC script seen on-chain.
    t-bast committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    6d8d2be View commit details
    Browse the repository at this point in the history
  4. Cleanup on-chain HTLC timeout handling for MPP

    With MPP, it's possible that a channel contains multiple HTLCs for the
    same payment hash, and potentially even for the same expiry and amount.
    
    We add more fine-grained handling of HTLC timeouts that share the same
    payment hash. This allows a cleaner handling after a restart, and makes
    sure we correctly detect failure that should be propagated upstream.
    Otherwise we wouldn't be losing any money, but some channels may be closed
    that we can avoid.
    t-bast committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    6edcf34 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6267a8d View commit details
    Browse the repository at this point in the history
  6. Refactor isClosingAlreadyKnown

    t-bast committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    0791853 View commit details
    Browse the repository at this point in the history

Commits on Apr 1, 2020

  1. Address PR comments

    A couple refactorings to avoid duplication and some clean-up.
    t-bast committed Apr 1, 2020
    Configuration menu
    Copy the full SHA
    b9590b1 View commit details
    Browse the repository at this point in the history
  2. Handle out-of-order htlc-timeout txs

    It may happen that a commit tx and some htlc-timeout txs end up in the
    same block. In that case, there is no guarantee on the order we'll receive
    the confirmation events.
    
    If any tx in a local/remoteCommitPublished is confirmed, that implicitly
    means that the commit tx is confirmed (because it spends from it).
    So we can consider the closing type known and forward the failure upstream.
    t-bast committed Apr 1, 2020
    Configuration menu
    Copy the full SHA
    79f8d37 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    30e4f97 View commit details
    Browse the repository at this point in the history