lnwallet: replace hard-coded fees and adjust tests accordingly

This commit replaces the hard-coded 5000 satoshi fees with calls to the
FeeEstimator interface. This should provide a way to cleanly plug in
additional fee calculation algorithms in the future. This change
affected quite a few tests. When possible, the tests were changed to
assert amounts sent rather than balances so that fees wouldn't need to
be taken into account. There were several tests for which this wasn't
possible, so calls to the static fee calculator were made.
This commit is contained in:
bryanvu authored and Olaoluwa Osuntokun committed 2017-05-15 20:26:11 -07:00
1 parent abe2e502d5
commit 4ac7cc719f
8 files changed
+222 -242

No files matched your search

+5 -6
View File
@@ -37,7 +37,8 @@ const (
// rotations, etc.
identityKeyIndex = hdkeychain.HardenedKeyStart + 2
commitFee = 5000
commitWeight = btcutil.Amount(724)
htlcWeight = 172
)
var (
@@ -526,8 +527,7 @@ func (l *LightningWallet) handleFundingReserveRequest(req *initFundingReserveMsg
}
id := atomic.AddUint64(&l.nextFundingID, 1)
totalCapacity := req.capacity + commitFee
reservation := NewChannelReservation(totalCapacity, req.fundingAmount,
reservation := NewChannelReservation(req.capacity, req.fundingAmount,
req.minFeeRate, l, id, req.numConfs, req.pushSat)
// Grab the mutex on the ChannelReservation to ensure thread-safety
@@ -551,9 +551,8 @@ func (l *LightningWallet) handleFundingReserveRequest(req *initFundingReserveMsg
if req.fundingAmount != 0 {
// TODO(roasbeef): consult model for proper fee rate on funding
// tx
feeRate := uint64(10)
amt := req.fundingAmount + commitFee
err := l.selectCoinsAndChange(feeRate, amt, ourContribution)
err := l.selectCoinsAndChange(uint64(req.minFeeRate),
req.fundingAmount, ourContribution)
if err != nil {
req.err <- err
req.resp <- nil