mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-14 18:30:52 +02:00
watchtower/multi: use ComputeJusticeTxOuts, test altruist+reward
This commit is contained in:
@@ -3,7 +3,6 @@ package wtdb
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtpolicy"
|
||||
)
|
||||
|
||||
@@ -35,11 +34,6 @@ var (
|
||||
// number larger than the session's max number of updates.
|
||||
ErrSessionConsumed = errors.New("all session updates have been " +
|
||||
"consumed")
|
||||
|
||||
// ErrFeeExceedsInputs signals that the total input value of breaching
|
||||
// commitment txn is insufficient to cover the fees required to sweep
|
||||
// it.
|
||||
ErrFeeExceedsInputs = errors.New("sweep fee exceeds input values")
|
||||
)
|
||||
|
||||
// SessionInfo holds the negotiated session parameters for single session id,
|
||||
@@ -98,31 +92,6 @@ func (s *SessionInfo) AcceptUpdateSequence(seqNum, lastApplied uint16) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ComputeSweepOutputs splits the total funds in a breaching commitment
|
||||
// transaction between the victim and the tower, according to the sweep fee rate
|
||||
// and reward rate. The fees are first subtracted from the overall total, before
|
||||
// splitting the remaining balance amongst the victim and tower.
|
||||
func (s *SessionInfo) ComputeSweepOutputs(totalAmt btcutil.Amount,
|
||||
txVSize int64) (btcutil.Amount, btcutil.Amount, error) {
|
||||
|
||||
txFee := s.Policy.SweepFeeRate.FeeForWeight(txVSize)
|
||||
if txFee > totalAmt {
|
||||
return 0, 0, ErrFeeExceedsInputs
|
||||
}
|
||||
|
||||
totalAmt -= txFee
|
||||
|
||||
// Apply the reward rate to the remaining total, specified in millionths
|
||||
// of the available balance.
|
||||
rewardRate := btcutil.Amount(s.Policy.RewardRate)
|
||||
rewardAmt := (totalAmt*rewardRate + 999999) / 1000000
|
||||
sweepAmt := totalAmt - rewardAmt
|
||||
|
||||
// TODO(conner): check dustiness
|
||||
|
||||
return sweepAmt, rewardAmt, nil
|
||||
}
|
||||
|
||||
// Match is returned in response to a database query for a breach hints
|
||||
// contained in a particular block. The match encapsulates all data required to
|
||||
// properly decrypt a client's encrypted blob, and pursue action on behalf of
|
||||
|
Reference in New Issue
Block a user