lnwallet+rpcserver: fix weight calculation for taproot channels
This commit is contained in:
2 files changed
+24
-4
No files matched your search
+8
-2
@@ -3027,11 +3027,17 @@ func (lc *LightningChannel) fetchCommitmentView(remoteChain bool,
|
|||||||
}
|
}
|
||||||
fee := lc.channelState.Capacity - totalOut
|
fee := lc.channelState.Capacity - totalOut
|
||||||
|
|
||||||
|
var witnessWeight int64
|
||||||
|
if lc.channelState.ChanType.IsTaproot() {
|
||||||
|
witnessWeight = input.TaprootKeyPathWitnessSize
|
||||||
|
} else {
|
||||||
|
witnessWeight = input.WitnessCommitmentTxWeight
|
||||||
|
}
|
||||||
|
|
||||||
// Since the transaction is not signed yet, we use the witness weight
|
// Since the transaction is not signed yet, we use the witness weight
|
||||||
// used for weight calculation.
|
// used for weight calculation.
|
||||||
uTx := btcutil.NewTx(commitTx.txn)
|
uTx := btcutil.NewTx(commitTx.txn)
|
||||||
weight := blockchain.GetTransactionWeight(uTx) +
|
weight := blockchain.GetTransactionWeight(uTx) + witnessWeight
|
||||||
input.WitnessCommitmentTxWeight
|
|
||||||
|
|
||||||
effFeeRate := chainfee.SatPerKWeight(fee) * 1000 /
|
effFeeRate := chainfee.SatPerKWeight(fee) * 1000 /
|
||||||
chainfee.SatPerKWeight(weight)
|
chainfee.SatPerKWeight(weight)
|
||||||
|
|||||||
+16
-2
@@ -3476,10 +3476,17 @@ func (r *rpcServer) fetchPendingOpenChannels() (pendingOpenChannels, error) {
|
|||||||
// broadcast.
|
// broadcast.
|
||||||
// TODO(roasbeef): query for funding tx from wallet, display
|
// TODO(roasbeef): query for funding tx from wallet, display
|
||||||
// that also?
|
// that also?
|
||||||
|
var witnessWeight int64
|
||||||
|
if pendingChan.ChanType.IsTaproot() {
|
||||||
|
witnessWeight = input.TaprootKeyPathWitnessSize
|
||||||
|
} else {
|
||||||
|
witnessWeight = input.WitnessCommitmentTxWeight
|
||||||
|
}
|
||||||
|
|
||||||
localCommitment := pendingChan.LocalCommitment
|
localCommitment := pendingChan.LocalCommitment
|
||||||
utx := btcutil.NewTx(localCommitment.CommitTx)
|
utx := btcutil.NewTx(localCommitment.CommitTx)
|
||||||
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
||||||
commitWeight := commitBaseWeight + input.WitnessCommitmentTxWeight
|
commitWeight := commitBaseWeight + witnessWeight
|
||||||
|
|
||||||
// FundingExpiryBlocks is the distance from the current block
|
// FundingExpiryBlocks is the distance from the current block
|
||||||
// height to the broadcast height + MaxWaitNumBlocksFundingConf.
|
// height to the broadcast height + MaxWaitNumBlocksFundingConf.
|
||||||
@@ -4227,10 +4234,17 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
|||||||
// estimated weight of the witness to calculate the weight of
|
// estimated weight of the witness to calculate the weight of
|
||||||
// the transaction if it were to be immediately unilaterally
|
// the transaction if it were to be immediately unilaterally
|
||||||
// broadcast.
|
// broadcast.
|
||||||
|
var witnessWeight int64
|
||||||
|
if dbChannel.ChanType.IsTaproot() {
|
||||||
|
witnessWeight = input.TaprootKeyPathWitnessSize
|
||||||
|
} else {
|
||||||
|
witnessWeight = input.WitnessCommitmentTxWeight
|
||||||
|
}
|
||||||
|
|
||||||
localCommit := dbChannel.LocalCommitment
|
localCommit := dbChannel.LocalCommitment
|
||||||
utx := btcutil.NewTx(localCommit.CommitTx)
|
utx := btcutil.NewTx(localCommit.CommitTx)
|
||||||
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
||||||
commitWeight := commitBaseWeight + input.WitnessCommitmentTxWeight
|
commitWeight := commitBaseWeight + witnessWeight
|
||||||
|
|
||||||
localBalance := localCommit.LocalBalance
|
localBalance := localCommit.LocalBalance
|
||||||
remoteBalance := localCommit.RemoteBalance
|
remoteBalance := localCommit.RemoteBalance
|
||||||
|
|||||||
Reference in new issue
Block a user