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:
1 parent
abe2e502d5
commit
4ac7cc719f
8 files changed
+222
-242
No files matched your search
@@ -155,6 +155,8 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount, minFeeRate btcut
|
||||
initiator bool
|
||||
)
|
||||
|
||||
commitFee := minFeeRate * commitWeight / 1000
|
||||
|
||||
// If we're the responder to a single-funder reservation, then we have
|
||||
// no initial balance in the channel unless the remote party is pushing
|
||||
// some funds to us within the first commitment state.
|
||||
@@ -166,20 +168,22 @@ func NewChannelReservation(capacity, fundingAmt btcutil.Amount, minFeeRate btcut
|
||||
// TODO(roasbeef): need to rework fee structure in general and
|
||||
// also when we "unlock" dual funder within the daemon
|
||||
|
||||
if capacity == fundingAmt+commitFee {
|
||||
if capacity == fundingAmt {
|
||||
// If we're initiating a single funder workflow, then
|
||||
// we pay all the initial fees within the commitment
|
||||
// transaction. We also deduct our balance by the
|
||||
// amount pushed as part of the initial state.
|
||||
ourBalance = capacity - commitFee - pushSat
|
||||
theirBalance = capacity - fundingAmt + pushSat
|
||||
} else {
|
||||
// Otherwise, this is a dual funder workflow where both
|
||||
// slides split the amount funded and the commitment
|
||||
// fee.
|
||||
ourBalance = fundingAmt - commitFee
|
||||
ourBalance = fundingAmt - (commitFee / 2)
|
||||
theirBalance = capacity - fundingAmt -
|
||||
(commitFee / 2) + pushSat
|
||||
}
|
||||
|
||||
theirBalance = capacity - fundingAmt - commitFee + pushSat
|
||||
initiator = true
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user