Skip to content

Commit

Permalink
multi: allow specifying max csv for locally initiated channels
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaKC committed Nov 4, 2020
1 parent f4136de commit 91bf59d
Show file tree
Hide file tree
Showing 6 changed files with 800 additions and 760 deletions.
14 changes: 13 additions & 1 deletion fundingmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ type reservationWithCtx struct {
remoteMaxValue lnwire.MilliSatoshi
remoteMaxHtlcs uint16

// maxLocalCsv is the maximum csv we will accept from the remote.
maxLocalCsv uint16

updateMtx sync.RWMutex
lastUpdated time.Time

Expand Down Expand Up @@ -1404,6 +1407,7 @@ func (f *fundingManager) handleFundingOpen(peer lnpeer.Peer,
remoteMinHtlc: minHtlc,
remoteMaxValue: remoteMaxValue,
remoteMaxHtlcs: maxHtlcs,
maxLocalCsv: f.cfg.MaxLocalCSVDelay,
err: make(chan error, 1),
peer: peer,
}
Expand Down Expand Up @@ -1532,7 +1536,7 @@ func (f *fundingManager) handleFundingAccept(peer lnpeer.Peer,
CsvDelay: msg.CsvDelay,
}
err = resCtx.reservation.CommitConstraints(
channelConstraints, f.cfg.MaxLocalCSVDelay,
channelConstraints, resCtx.maxLocalCsv,
)
if err != nil {
fndgLog.Warnf("Unacceptable channel constraints: %v", err)
Expand Down Expand Up @@ -3064,8 +3068,15 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
remoteCsvDelay = msg.remoteCsvDelay
maxValue = msg.maxValueInFlight
maxHtlcs = msg.maxHtlcs
maxCSV = msg.maxLocalCsv
)

// If no maximum CSV delay was set for this channel, we use our default
// value.
if maxCSV == 0 {
maxCSV = f.cfg.MaxLocalCSVDelay
}

// We'll determine our dust limit depending on which chain is active.
var ourDustLimit btcutil.Amount
switch f.cfg.RegisteredChains.PrimaryChain() {
Expand Down Expand Up @@ -3221,6 +3232,7 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
remoteMinHtlc: minHtlcIn,
remoteMaxValue: maxValue,
remoteMaxHtlcs: maxHtlcs,
maxLocalCsv: maxCSV,
reservation: reservation,
peer: msg.peer,
updates: msg.updates,
Expand Down
Loading

0 comments on commit 91bf59d

Please sign in to comment.