server: use new FundingConfsForAmounts helper func
This commit is contained in:
1 parent
9e74916118
commit
45aa94c760
1 file changed
+11
-33
@@ -1482,16 +1482,6 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
|
|||||||
DefaultMinHtlcIn: cc.MinHtlcIn,
|
DefaultMinHtlcIn: cc.MinHtlcIn,
|
||||||
NumRequiredConfs: func(chanAmt btcutil.Amount,
|
NumRequiredConfs: func(chanAmt btcutil.Amount,
|
||||||
pushAmt lnwire.MilliSatoshi) uint16 {
|
pushAmt lnwire.MilliSatoshi) uint16 {
|
||||||
// For large channels we increase the number
|
|
||||||
// of confirmations we require for the
|
|
||||||
// channel to be considered open. As it is
|
|
||||||
// always the responder that gets to choose
|
|
||||||
// value, the pushAmt is value being pushed
|
|
||||||
// to us. This means we have more to lose
|
|
||||||
// in the case this gets re-orged out, and
|
|
||||||
// we will require more confirmations before
|
|
||||||
// we consider it open.
|
|
||||||
|
|
||||||
// In case the user has explicitly specified
|
// In case the user has explicitly specified
|
||||||
// a default value for the number of
|
// a default value for the number of
|
||||||
// confirmations, we use it.
|
// confirmations, we use it.
|
||||||
@@ -1500,29 +1490,17 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
|
|||||||
return defaultConf
|
return defaultConf
|
||||||
}
|
}
|
||||||
|
|
||||||
minConf := uint64(3)
|
// Otherwise, scale the number of confirmations based on
|
||||||
maxConf := uint64(6)
|
// the channel amount and push amount. For large
|
||||||
|
// channels we increase the number of
|
||||||
// If this is a wumbo channel, then we'll require the
|
// confirmations we require for the channel to be
|
||||||
// max amount of confirmations.
|
// considered open. As it is always the
|
||||||
if chanAmt > MaxFundingAmount {
|
// responder that gets to choose value, the
|
||||||
return uint16(maxConf)
|
// pushAmt is value being pushed to us. This
|
||||||
}
|
// means we have more to lose in the case this
|
||||||
|
// gets re-orged out, and we will require more
|
||||||
// If not we return a value scaled linearly
|
// confirmations before we consider it open.
|
||||||
// between 3 and 6, depending on channel size.
|
return lnwallet.FundingConfsForAmounts(chanAmt, pushAmt)
|
||||||
// TODO(halseth): Use 1 as minimum?
|
|
||||||
maxChannelSize := uint64(
|
|
||||||
lnwire.NewMSatFromSatoshis(MaxFundingAmount))
|
|
||||||
stake := lnwire.NewMSatFromSatoshis(chanAmt) + pushAmt
|
|
||||||
conf := maxConf * uint64(stake) / maxChannelSize
|
|
||||||
if conf < minConf {
|
|
||||||
conf = minConf
|
|
||||||
}
|
|
||||||
if conf > maxConf {
|
|
||||||
conf = maxConf
|
|
||||||
}
|
|
||||||
return uint16(conf)
|
|
||||||
},
|
},
|
||||||
RequiredRemoteDelay: func(chanAmt btcutil.Amount) uint16 {
|
RequiredRemoteDelay: func(chanAmt btcutil.Amount) uint16 {
|
||||||
// We scale the remote CSV delay (the time the
|
// We scale the remote CSV delay (the time the
|
||||||
|
|||||||
Reference in new issue
Block a user