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
|
// TODO(roasbeef): subtract reserve
|
||||||
channelBandwidth := l.channel.AvailableBalance()
|
channelBandwidth := l.channel.AvailableBalance()
|
||||||
overflowBandwidth := l.overflowQueue.TotalHtlcAmount()
|
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
|
// 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)
|
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(), bobPrivKey)
|
||||||
|
|
||||||
channelCapacity := aliceAmount + bobAmount
|
channelCapacity := aliceAmount + bobAmount
|
||||||
aliceDustLimit := btcutil.Amount(200)
|
|
||||||
bobDustLimit := btcutil.Amount(800)
|
|
||||||
csvTimeoutAlice := uint32(5)
|
csvTimeoutAlice := uint32(5)
|
||||||
csvTimeoutBob := uint32(4)
|
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
|
var hash [sha256.Size]byte
|
||||||
randomSeed, err := generateRandomBytes(sha256.Size)
|
randomSeed, err := generateRandomBytes(sha256.Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -116,9 +132,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
|||||||
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
||||||
|
|
||||||
aliceCfg := channeldb.ChannelConfig{
|
aliceCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelConstraints: *aliceConstraints,
|
||||||
DustLimit: aliceDustLimit,
|
|
||||||
},
|
|
||||||
CsvDelay: uint16(csvTimeoutAlice),
|
CsvDelay: uint16(csvTimeoutAlice),
|
||||||
MultiSigKey: aliceKeyPub,
|
MultiSigKey: aliceKeyPub,
|
||||||
RevocationBasePoint: aliceKeyPub,
|
RevocationBasePoint: aliceKeyPub,
|
||||||
@ -127,9 +141,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
|||||||
HtlcBasePoint: aliceKeyPub,
|
HtlcBasePoint: aliceKeyPub,
|
||||||
}
|
}
|
||||||
bobCfg := channeldb.ChannelConfig{
|
bobCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelConstraints: *bobConstraints,
|
||||||
DustLimit: bobDustLimit,
|
|
||||||
},
|
|
||||||
CsvDelay: uint16(csvTimeoutBob),
|
CsvDelay: uint16(csvTimeoutBob),
|
||||||
MultiSigKey: bobKeyPub,
|
MultiSigKey: bobKeyPub,
|
||||||
RevocationBasePoint: bobKeyPub,
|
RevocationBasePoint: bobKeyPub,
|
||||||
|
Loading…
Reference in New Issue
Block a user