mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
itest+lntest: fix itest re the new sweeping behavior
This commit is contained in:
@@ -2042,57 +2042,6 @@ func (h *HarnessTest) CalculateTxesFeeRate(txns []*wire.MsgTx) int64 {
|
||||
return feeRate
|
||||
}
|
||||
|
||||
type SweptOutput struct {
|
||||
OutPoint wire.OutPoint
|
||||
SweepTx *wire.MsgTx
|
||||
}
|
||||
|
||||
// FindCommitAndAnchor looks for a commitment sweep and anchor sweep in the
|
||||
// mempool. Our anchor output is identified by having multiple inputs in its
|
||||
// sweep transition, because we have to bring another input to add fees to the
|
||||
// anchor. Note that the anchor swept output may be nil if the channel did not
|
||||
// have anchors.
|
||||
func (h *HarnessTest) FindCommitAndAnchor(sweepTxns []*wire.MsgTx,
|
||||
closeTx string) (*SweptOutput, *SweptOutput) {
|
||||
|
||||
var commitSweep, anchorSweep *SweptOutput
|
||||
|
||||
for _, tx := range sweepTxns {
|
||||
txHash := tx.TxHash()
|
||||
sweepTx := h.Miner.GetRawTransaction(&txHash)
|
||||
|
||||
// We expect our commitment sweep to have a single input, and,
|
||||
// our anchor sweep to have more inputs (because the wallet
|
||||
// needs to add balance to the anchor amount). We find their
|
||||
// sweep txids here to setup appropriate resolutions. We also
|
||||
// need to find the outpoint for our resolution, which we do by
|
||||
// matching the inputs to the sweep to the close transaction.
|
||||
inputs := sweepTx.MsgTx().TxIn
|
||||
if len(inputs) == 1 {
|
||||
commitSweep = &SweptOutput{
|
||||
OutPoint: inputs[0].PreviousOutPoint,
|
||||
SweepTx: tx,
|
||||
}
|
||||
} else {
|
||||
// Since we have more than one input, we run through
|
||||
// them to find the one whose previous outpoint matches
|
||||
// the closing txid, which means this input is spending
|
||||
// the close tx. This will be our anchor output.
|
||||
for _, txin := range inputs {
|
||||
op := txin.PreviousOutPoint.Hash.String()
|
||||
if op == closeTx {
|
||||
anchorSweep = &SweptOutput{
|
||||
OutPoint: txin.PreviousOutPoint,
|
||||
SweepTx: tx,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commitSweep, anchorSweep
|
||||
}
|
||||
|
||||
// AssertSweepFound looks up a sweep in a nodes list of broadcast sweeps and
|
||||
// asserts it's found.
|
||||
//
|
||||
|
Reference in New Issue
Block a user