• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16293469910

15 Jul 2025 12:37PM UTC coverage: 67.331%. First build
16293469910

Pull #10076

github

web-flow
Merge d2cba13bd into df6c02e3a
Pull Request #10076: Design Doc for Dynamic Commitments

9 of 24 new or added lines in 3 files covered. (37.5%)

135418 of 201124 relevant lines covered (67.33%)

21712.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/htlcswitch/dyn/updater.go
1
package dyn
2

3
import (
4
        "github.com/btcsuite/btcd/btcutil"
5
        "github.com/lightningnetwork/lnd/fn/v2"
6
        "github.com/lightningnetwork/lnd/lnwire"
7
)
8

9
// UpdateLinkStatus is used in the `UpdateLinkResponse` to indicate the current
10
// status of a given update request.
11
type UpdateLinkStatus uint8
12

13
const (
14
        // UpdateLinkStatusInitialized is the status the update flow is in when
15
        // the request is received by the Updater.
16
        UpdateLinkStatusInitialized UpdateLinkStatus = iota
17

18
        // UpdateLinkStatusPending defines the status when the request is being
19
        // processed by the Updater.
20
        UpdateLinkStatusPending
21

22
        // UpdateLinkStatusSucceeded defines the status when the update finished
23
        // successfully.
24
        UpdateLinkStatusSucceeded
25

26
        // UpdateLinkStatusFailed defines the status when the update failed.
27
        UpdateLinkStatusFailed
28
)
29

30
// String returns a human readable string that represents the status.
NEW
31
func (u UpdateLinkStatus) String() string {
×
NEW
32
        switch u {
×
NEW
33
        case UpdateLinkStatusInitialized:
×
NEW
34
                return "Initialized"
×
35

NEW
36
        case UpdateLinkStatusPending:
×
NEW
37
                return "Pending"
×
38

NEW
39
        case UpdateLinkStatusSucceeded:
×
NEW
40
                return "Succeeded"
×
41

NEW
42
        case UpdateLinkStatusFailed:
×
NEW
43
                return "Failed"
×
44

NEW
45
        default:
×
NEW
46
                return "Unknown"
×
47
        }
48
}
49

50
// UpdateLinkRequest defines a request that contains the channel params to be
51
// changed.
52
type UpdateLinkRequest struct {
53
        // ChanID identifies the channel link to be updated.
54
        ChanID lnwire.ChannelID
55

56
        // DustLimit is the threshold (in satoshis) below which any outputs
57
        // should be trimmed. When an output is trimmed, it isn't materialized
58
        // as an actual output, but is instead burned to miner's fees.
59
        DustLimit fn.Option[btcutil.Amount]
60

61
        // MaxPendingAmount is the maximum pending HTLC value that the
62
        // owner of these constraints can offer the remote node at a
63
        // particular time.
64
        MaxPendingAmount fn.Option[lnwire.MilliSatoshi]
65

66
        // ChanReserve is an absolute reservation on the channel for the
67
        // owner of this set of constraints. This means that the current
68
        // settled balance for this node CANNOT dip below the reservation
69
        // amount. This acts as a defense against costless attacks when
70
        // either side no longer has any skin in the game.
71
        ChanReserve fn.Option[btcutil.Amount]
72

73
        // MinHTLC is the minimum HTLC value that the owner of these
74
        // constraints can offer the remote node. If any HTLCs below this
75
        // amount are offered, then the HTLC will be rejected. This, in
76
        // tandem with the dust limit allows a node to regulate the
77
        // smallest HTLC that it deems economically relevant.
78
        MinHTLC fn.Option[lnwire.MilliSatoshi]
79

80
        // CsvDelay is the relative time lock delay expressed in blocks. Any
81
        // settled outputs that pay to the owner of this channel configuration
82
        // MUST ensure that the delay branch uses this value as the relative
83
        // time lock. Similarly, any HTLC's offered by this node should use
84
        // this value as well.
85
        CsvDelay fn.Option[uint16]
86

87
        // MaxAcceptedHtlcs is the maximum number of HTLCs that the owner of
88
        // this set of constraints can offer the remote node. This allows each
89
        // node to limit their over all exposure to HTLCs that may need to be
90
        // acted upon in the case of a unilateral channel closure or a contract
91
        // breach.
92
        MaxAcceptedHtlcs fn.Option[uint16]
93
}
94

95
// UpdateLinkResponse defines a response to be returned to the caller.
96
type UpdateLinkResponse struct {
97
        // Status gives the current status of the update flow.
98
        Status UpdateLinkStatus
99

100
        // Err gives the details about a failed update request.
101
        Err error
102
}
103

104
// UpdateReq is a `fn.Req` type that wraps the request and response into a
105
// single struct.
106
type UpdateReq = fn.Req[UpdateLinkRequest, UpdateLinkResponse]
107

108
// Updater defines an interface that is used to update the channel link params.
109
// It provides the basic flow control methods like Start and Stop. In addition,
110
// `InitReq` is used for the user to initialize an upgrade request flow, and
111
// `ReceiveMsg` should be called in the link when a related msg is received,
112
// such as DynProposal, DynAck, DynCommit, DynReject, CommitSig, and
113
// RevokeAndAck.
114
type Updater interface {
115
        // Start starts the updater so it can accept update requests.
116
        Start()
117

118
        // Stop stops the updater.
119
        Stop()
120

121
        // InitReq initializes a channel update request, which is used by the
122
        // user to start the update flow via RPC.
123
        InitReq(r *UpdateReq) error
124

125
        // ReceiveMsg takes a msg sent from the peer and processes it.
126
        ReceiveMsg(msg lnwire.Message)
127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc