multi: apply the new type lntypes.WeightUnit

This commit is contained in:
yyforyongyu
2024-05-24 21:56:30 +08:00
parent dc9a0b31c0
commit 8da68bb7db
36 changed files with 178 additions and 133 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
@@ -180,8 +181,9 @@ func (p *Policy) Validate() error {
// that pays no reward to the tower. The value is computed using the weight of
// of the justice transaction and subtracting an amount that satisfies the
// policy's fee rate.
func (p *Policy) ComputeAltruistOutput(totalAmt btcutil.Amount,
txWeight int64, sweepScript []byte) (btcutil.Amount, error) {
func (p *Policy) ComputeAltruistOutput(
totalAmt btcutil.Amount, txWeight lntypes.WeightUnit,
sweepScript []byte) (btcutil.Amount, error) {
txFee := p.SweepFeeRate.FeeForWeight(txWeight)
if txFee > totalAmt {
@@ -204,7 +206,7 @@ func (p *Policy) ComputeAltruistOutput(totalAmt btcutil.Amount,
// and reward rate. The reward to he tower is subtracted first, before
// splitting the remaining balance amongst the victim and fees.
func (p *Policy) ComputeRewardOutputs(totalAmt btcutil.Amount,
txWeight int64,
txWeight lntypes.WeightUnit,
rewardScript []byte) (btcutil.Amount, btcutil.Amount, error) {
txFee := p.SweepFeeRate.FeeForWeight(txWeight)
@@ -266,7 +268,8 @@ func ComputeRewardAmount(total btcutil.Amount, base, rate uint32) btcutil.Amount
// rewardPkScript is the pkScript of the tower where its reward will be
// deposited, and will be
// ignored if the blob type does not specify a reward.
func (p *Policy) ComputeJusticeTxOuts(totalAmt btcutil.Amount, txWeight int64,
func (p *Policy) ComputeJusticeTxOuts(
totalAmt btcutil.Amount, txWeight lntypes.WeightUnit,
sweepPkScript, rewardPkScript []byte) ([]*wire.TxOut, error) {
var outputs []*wire.TxOut