mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
sweep: use p2tr output as change weight
This commit is contained in:
parent
ac9ca024a4
commit
b47c1da07d
2 changed files with 7 additions and 7 deletions
|
@ -79,7 +79,7 @@ func (t *txInputSetState) weightEstimate(change bool) *weightEstimator {
|
|||
|
||||
// Add a change output to the weight estimate if requested.
|
||||
if change {
|
||||
weightEstimate.addP2WKHOutput()
|
||||
weightEstimate.addP2TROutput()
|
||||
}
|
||||
|
||||
return weightEstimate
|
||||
|
|
|
@ -32,23 +32,23 @@ func TestTxInputSet(t *testing.T) {
|
|||
}
|
||||
|
||||
fee := set.weightEstimate(true).fee()
|
||||
require.Equal(t, btcutil.Amount(439), fee)
|
||||
require.Equal(t, btcutil.Amount(487), fee)
|
||||
|
||||
// The tx output should now be 700-439 = 261 sats. The dust limit isn't
|
||||
// The tx output should now be 700-487 = 213 sats. The dust limit isn't
|
||||
// reached yet.
|
||||
if set.totalOutput() != 261 {
|
||||
if set.totalOutput() != 213 {
|
||||
t.Fatal("unexpected output value")
|
||||
}
|
||||
if set.enoughInput() {
|
||||
t.Fatal("expected dust limit not yet to be reached")
|
||||
}
|
||||
|
||||
// Add a 1000 sat input. This increases the tx fee to 712 sats. The tx
|
||||
// output should now be 1000+700 - 712 = 988 sats.
|
||||
// Add a 1000 sat input. This increases the tx fee to 760 sats. The tx
|
||||
// output should now be 1000+700 - 760 = 940 sats.
|
||||
if !set.add(createP2WKHInput(1000), constraintsRegular) {
|
||||
t.Fatal("expected add of positively yielding input to succeed")
|
||||
}
|
||||
if set.totalOutput() != 988 {
|
||||
if set.totalOutput() != 940 {
|
||||
t.Fatal("unexpected output value")
|
||||
}
|
||||
if !set.enoughInput() {
|
||||
|
|
Loading…
Add table
Reference in a new issue