htlcswitch: account for channel reserve in Bandwidth
This commit is contained in:
parent
7e7516137d
commit
7e84892c21
@ -1264,8 +1264,9 @@ func (l *channelLink) Bandwidth() lnwire.MilliSatoshi {
|
||||
// TODO(roasbeef): subtract reserve
|
||||
channelBandwidth := l.channel.AvailableBalance()
|
||||
overflowBandwidth := l.overflowQueue.TotalHtlcAmount()
|
||||
reserve := lnwire.NewMSatFromSatoshis(l.channel.GetReserve())
|
||||
|
||||
return channelBandwidth - overflowBandwidth
|
||||
return channelBandwidth - overflowBandwidth - reserve
|
||||
}
|
||||
|
||||
// policyUpdate is a message sent to a channel link when an outside sub-system
|
||||
|
@ -97,11 +97,27 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(), bobPrivKey)
|
||||
|
||||
channelCapacity := aliceAmount + bobAmount
|
||||
aliceDustLimit := btcutil.Amount(200)
|
||||
bobDustLimit := btcutil.Amount(800)
|
||||
csvTimeoutAlice := uint32(5)
|
||||
csvTimeoutBob := uint32(4)
|
||||
|
||||
aliceConstraints := &channeldb.ChannelConstraints{
|
||||
DustLimit: btcutil.Amount(200),
|
||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
||||
channelCapacity),
|
||||
ChanReserve: 0,
|
||||
MinHTLC: 0,
|
||||
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
|
||||
}
|
||||
|
||||
bobConstraints := &channeldb.ChannelConstraints{
|
||||
DustLimit: btcutil.Amount(800),
|
||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
||||
channelCapacity),
|
||||
ChanReserve: 0,
|
||||
MinHTLC: 0,
|
||||
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
|
||||
}
|
||||
|
||||
var hash [sha256.Size]byte
|
||||
randomSeed, err := generateRandomBytes(sha256.Size)
|
||||
if err != nil {
|
||||
@ -116,9 +132,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
||||
|
||||
aliceCfg := channeldb.ChannelConfig{
|
||||
ChannelConstraints: channeldb.ChannelConstraints{
|
||||
DustLimit: aliceDustLimit,
|
||||
},
|
||||
ChannelConstraints: *aliceConstraints,
|
||||
CsvDelay: uint16(csvTimeoutAlice),
|
||||
MultiSigKey: aliceKeyPub,
|
||||
RevocationBasePoint: aliceKeyPub,
|
||||
@ -127,9 +141,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
HtlcBasePoint: aliceKeyPub,
|
||||
}
|
||||
bobCfg := channeldb.ChannelConfig{
|
||||
ChannelConstraints: channeldb.ChannelConstraints{
|
||||
DustLimit: bobDustLimit,
|
||||
},
|
||||
ChannelConstraints: *bobConstraints,
|
||||
CsvDelay: uint16(csvTimeoutBob),
|
||||
MultiSigKey: bobKeyPub,
|
||||
RevocationBasePoint: bobKeyPub,
|
||||
|
Loading…
Reference in New Issue
Block a user