mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 10:35:32 +02:00
multi: make input.OutPoint
return wire.OutPoint
This commit is contained in:
@ -1102,8 +1102,8 @@ func (bo *breachedOutput) Amount() btcutil.Amount {
|
|||||||
|
|
||||||
// OutPoint returns the breached output's identifier that is to be included as a
|
// OutPoint returns the breached output's identifier that is to be included as a
|
||||||
// transaction input.
|
// transaction input.
|
||||||
func (bo *breachedOutput) OutPoint() *wire.OutPoint {
|
func (bo *breachedOutput) OutPoint() wire.OutPoint {
|
||||||
return &bo.outpoint
|
return bo.outpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
|
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
|
||||||
@ -1547,7 +1547,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight int64,
|
|||||||
// transaction.
|
// transaction.
|
||||||
for _, inp := range inputs {
|
for _, inp := range inputs {
|
||||||
txn.AddTxIn(&wire.TxIn{
|
txn.AddTxIn(&wire.TxIn{
|
||||||
PreviousOutPoint: *inp.OutPoint(),
|
PreviousOutPoint: inp.OutPoint(),
|
||||||
Sequence: inp.BlocksToMaturity(),
|
Sequence: inp.BlocksToMaturity(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1641,7 +1641,7 @@ func taprootBriefcaseFromRetInfo(retInfo *retributionInfo) *taprootBriefcase {
|
|||||||
case input.TaprootHtlcAcceptedRevoke:
|
case input.TaprootHtlcAcceptedRevoke:
|
||||||
fallthrough
|
fallthrough
|
||||||
case input.TaprootHtlcOfferedRevoke:
|
case input.TaprootHtlcOfferedRevoke:
|
||||||
resID := newResolverID(*bo.OutPoint())
|
resID := newResolverID(bo.OutPoint())
|
||||||
|
|
||||||
var firstLevelTweak [32]byte
|
var firstLevelTweak [32]byte
|
||||||
copy(firstLevelTweak[:], bo.signDesc.TapTweak)
|
copy(firstLevelTweak[:], bo.signDesc.TapTweak)
|
||||||
@ -1684,7 +1684,7 @@ func applyTaprootRetInfo(tapCase *taprootBriefcase,
|
|||||||
case input.TaprootHtlcAcceptedRevoke:
|
case input.TaprootHtlcAcceptedRevoke:
|
||||||
fallthrough
|
fallthrough
|
||||||
case input.TaprootHtlcOfferedRevoke:
|
case input.TaprootHtlcOfferedRevoke:
|
||||||
resID := newResolverID(*bo.OutPoint())
|
resID := newResolverID(bo.OutPoint())
|
||||||
|
|
||||||
tap1, ok := tapCase.TapTweaks.BreachedHtlcTweaks[resID]
|
tap1, ok := tapCase.TapTweaks.BreachedHtlcTweaks[resID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -1202,8 +1202,13 @@ func TestBreachCreateJusticeTx(t *testing.T) {
|
|||||||
for i, wt := range outputTypes {
|
for i, wt := range outputTypes {
|
||||||
// Create a fake breached output for each type, ensuring they
|
// Create a fake breached output for each type, ensuring they
|
||||||
// have different outpoints for our logic to accept them.
|
// have different outpoints for our logic to accept them.
|
||||||
|
//
|
||||||
|
// NOTE: although they are fake, we need to make sure the
|
||||||
|
// outputs are not empty values, otherwise they will be equal
|
||||||
|
// to `EmptyOutPoint` and `MultiPrevOutFetcher` will return an
|
||||||
|
// error.
|
||||||
op := breachedOutputs[0].outpoint
|
op := breachedOutputs[0].outpoint
|
||||||
op.Index = uint32(i)
|
op.Index = uint32(1000 + i)
|
||||||
breachedOutputs[i] = makeBreachedOutput(
|
breachedOutputs[i] = makeBreachedOutput(
|
||||||
&op,
|
&op,
|
||||||
wt,
|
wt,
|
||||||
|
@ -394,7 +394,7 @@ func TestHtlcSuccessSecondStageResolutionSweeper(t *testing.T) {
|
|||||||
resolver := ctx.resolver.(*htlcSuccessResolver)
|
resolver := ctx.resolver.(*htlcSuccessResolver)
|
||||||
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
|
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
|
||||||
op := inp.OutPoint()
|
op := inp.OutPoint()
|
||||||
if *op != commitOutpoint {
|
if op != commitOutpoint {
|
||||||
return fmt.Errorf("outpoint %v swept, "+
|
return fmt.Errorf("outpoint %v swept, "+
|
||||||
"expected %v", op,
|
"expected %v", op,
|
||||||
commitOutpoint)
|
commitOutpoint)
|
||||||
@ -443,7 +443,7 @@ func TestHtlcSuccessSecondStageResolutionSweeper(t *testing.T) {
|
|||||||
Hash: reSignedHash,
|
Hash: reSignedHash,
|
||||||
Index: 1,
|
Index: 1,
|
||||||
}
|
}
|
||||||
if *op != exp {
|
if op != exp {
|
||||||
return fmt.Errorf("swept outpoint %v, expected %v",
|
return fmt.Errorf("swept outpoint %v, expected %v",
|
||||||
op, exp)
|
op, exp)
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1030,7 @@ func TestHtlcTimeoutSecondStageSweeper(t *testing.T) {
|
|||||||
resolver := ctx.resolver.(*htlcTimeoutResolver)
|
resolver := ctx.resolver.(*htlcTimeoutResolver)
|
||||||
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
|
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
|
||||||
op := inp.OutPoint()
|
op := inp.OutPoint()
|
||||||
if *op != commitOutpoint {
|
if op != commitOutpoint {
|
||||||
return fmt.Errorf("outpoint %v swept, "+
|
return fmt.Errorf("outpoint %v swept, "+
|
||||||
"expected %v", op,
|
"expected %v", op,
|
||||||
commitOutpoint)
|
commitOutpoint)
|
||||||
@ -1095,7 +1095,7 @@ func TestHtlcTimeoutSecondStageSweeper(t *testing.T) {
|
|||||||
Hash: reSignedHash,
|
Hash: reSignedHash,
|
||||||
Index: 1,
|
Index: 1,
|
||||||
}
|
}
|
||||||
if *op != exp {
|
if op != exp {
|
||||||
return fmt.Errorf("wrong outpoint swept")
|
return fmt.Errorf("wrong outpoint swept")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1205,7 +1205,7 @@ func TestHtlcTimeoutSecondStageSweeperRemoteSpend(t *testing.T) {
|
|||||||
resolver := ctx.resolver.(*htlcTimeoutResolver)
|
resolver := ctx.resolver.(*htlcTimeoutResolver)
|
||||||
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
|
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
|
||||||
op := inp.OutPoint()
|
op := inp.OutPoint()
|
||||||
if *op != commitOutpoint {
|
if op != commitOutpoint {
|
||||||
return fmt.Errorf("outpoint %v swept, "+
|
return fmt.Errorf("outpoint %v swept, "+
|
||||||
"expected %v", op,
|
"expected %v", op,
|
||||||
commitOutpoint)
|
commitOutpoint)
|
||||||
|
@ -212,7 +212,7 @@ func prefixChainKey(sysPrefix []byte, hash *chainhash.Hash) ([]byte, error) {
|
|||||||
// outpoint with the provided state prefix. The returned bytes will be of the
|
// outpoint with the provided state prefix. The returned bytes will be of the
|
||||||
// form <prefix><outpoint>.
|
// form <prefix><outpoint>.
|
||||||
func prefixOutputKey(statePrefix []byte,
|
func prefixOutputKey(statePrefix []byte,
|
||||||
outpoint *wire.OutPoint) ([]byte, error) {
|
outpoint wire.OutPoint) ([]byte, error) {
|
||||||
|
|
||||||
// Create a buffer to which we will first write the state prefix,
|
// Create a buffer to which we will first write the state prefix,
|
||||||
// followed by the outpoint.
|
// followed by the outpoint.
|
||||||
@ -221,7 +221,7 @@ func prefixOutputKey(statePrefix []byte,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err := writeOutpoint(&pfxOutputBuffer, outpoint)
|
err := writeOutpoint(&pfxOutputBuffer, &outpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1134,7 @@ func (c *ContractMaturityReport) AddLimboStage1TimeoutHtlc(baby *babyOutput) {
|
|||||||
|
|
||||||
// TODO(roasbeef): bool to indicate stage 1 vs stage 2?
|
// TODO(roasbeef): bool to indicate stage 1 vs stage 2?
|
||||||
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
|
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
|
||||||
Outpoint: *baby.OutPoint(),
|
Outpoint: baby.OutPoint(),
|
||||||
Amount: baby.Amount(),
|
Amount: baby.Amount(),
|
||||||
MaturityHeight: baby.expiry,
|
MaturityHeight: baby.expiry,
|
||||||
Stage: 1,
|
Stage: 1,
|
||||||
@ -1148,7 +1148,7 @@ func (c *ContractMaturityReport) AddLimboDirectHtlc(kid *kidOutput) {
|
|||||||
c.LimboBalance += kid.Amount()
|
c.LimboBalance += kid.Amount()
|
||||||
|
|
||||||
htlcReport := HtlcMaturityReport{
|
htlcReport := HtlcMaturityReport{
|
||||||
Outpoint: *kid.OutPoint(),
|
Outpoint: kid.OutPoint(),
|
||||||
Amount: kid.Amount(),
|
Amount: kid.Amount(),
|
||||||
MaturityHeight: kid.absoluteMaturity,
|
MaturityHeight: kid.absoluteMaturity,
|
||||||
Stage: 2,
|
Stage: 2,
|
||||||
@ -1164,7 +1164,7 @@ func (c *ContractMaturityReport) AddLimboStage1SuccessHtlc(kid *kidOutput) {
|
|||||||
c.LimboBalance += kid.Amount()
|
c.LimboBalance += kid.Amount()
|
||||||
|
|
||||||
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
|
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
|
||||||
Outpoint: *kid.OutPoint(),
|
Outpoint: kid.OutPoint(),
|
||||||
Amount: kid.Amount(),
|
Amount: kid.Amount(),
|
||||||
Stage: 1,
|
Stage: 1,
|
||||||
})
|
})
|
||||||
@ -1176,7 +1176,7 @@ func (c *ContractMaturityReport) AddLimboStage2Htlc(kid *kidOutput) {
|
|||||||
c.LimboBalance += kid.Amount()
|
c.LimboBalance += kid.Amount()
|
||||||
|
|
||||||
htlcReport := HtlcMaturityReport{
|
htlcReport := HtlcMaturityReport{
|
||||||
Outpoint: *kid.OutPoint(),
|
Outpoint: kid.OutPoint(),
|
||||||
Amount: kid.Amount(),
|
Amount: kid.Amount(),
|
||||||
Stage: 2,
|
Stage: 2,
|
||||||
}
|
}
|
||||||
@ -1197,7 +1197,7 @@ func (c *ContractMaturityReport) AddRecoveredHtlc(kid *kidOutput) {
|
|||||||
c.RecoveredBalance += kid.Amount()
|
c.RecoveredBalance += kid.Amount()
|
||||||
|
|
||||||
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
|
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
|
||||||
Outpoint: *kid.OutPoint(),
|
Outpoint: kid.OutPoint(),
|
||||||
Amount: kid.Amount(),
|
Amount: kid.Amount(),
|
||||||
MaturityHeight: kid.ConfHeight() + kid.BlocksToMaturity(),
|
MaturityHeight: kid.ConfHeight() + kid.BlocksToMaturity(),
|
||||||
})
|
})
|
||||||
@ -1421,7 +1421,8 @@ func (k *kidOutput) Encode(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := writeOutpoint(w, k.OutPoint()); err != nil {
|
op := k.OutPoint()
|
||||||
|
if err := writeOutpoint(w, &op); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := writeOutpoint(w, k.OriginChanPoint()); err != nil {
|
if err := writeOutpoint(w, k.OriginChanPoint()); err != nil {
|
||||||
|
@ -1065,7 +1065,7 @@ func newMockSweeperFull(t *testing.T) *mockSweeperFull {
|
|||||||
func (s *mockSweeperFull) sweepInput(input input.Input,
|
func (s *mockSweeperFull) sweepInput(input input.Input,
|
||||||
_ sweep.Params) (chan sweep.Result, error) {
|
_ sweep.Params) (chan sweep.Result, error) {
|
||||||
|
|
||||||
log.Debugf("mockSweeper sweepInput called for %v", *input.OutPoint())
|
log.Debugf("mockSweeper sweepInput called for %v", input.OutPoint())
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case s.sweepChan <- input:
|
case s.sweepChan <- input:
|
||||||
@ -1077,7 +1077,7 @@ func (s *mockSweeperFull) sweepInput(input input.Input,
|
|||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
||||||
c := make(chan sweep.Result, 1)
|
c := make(chan sweep.Result, 1)
|
||||||
s.resultChans[*input.OutPoint()] = c
|
s.resultChans[input.OutPoint()] = c
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// EmptyOutPoint is a zeroed outpoint.
|
||||||
|
var EmptyOutPoint wire.OutPoint
|
||||||
|
|
||||||
// Input represents an abstract UTXO which is to be spent using a sweeping
|
// Input represents an abstract UTXO which is to be spent using a sweeping
|
||||||
// transaction. The method provided give the caller all information needed to
|
// transaction. The method provided give the caller all information needed to
|
||||||
// construct a valid input within a sweeping transaction to sweep this
|
// construct a valid input within a sweeping transaction to sweep this
|
||||||
@ -16,7 +19,7 @@ import (
|
|||||||
type Input interface {
|
type Input interface {
|
||||||
// Outpoint returns the reference to the output being spent, used to
|
// Outpoint returns the reference to the output being spent, used to
|
||||||
// construct the corresponding transaction input.
|
// construct the corresponding transaction input.
|
||||||
OutPoint() *wire.OutPoint
|
OutPoint() wire.OutPoint
|
||||||
|
|
||||||
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
|
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
|
||||||
// transaction output. This is used in the SINGLE|ANYONECANPAY case to
|
// transaction output. This is used in the SINGLE|ANYONECANPAY case to
|
||||||
@ -107,8 +110,8 @@ type inputKit struct {
|
|||||||
|
|
||||||
// OutPoint returns the breached output's identifier that is to be included as
|
// OutPoint returns the breached output's identifier that is to be included as
|
||||||
// a transaction input.
|
// a transaction input.
|
||||||
func (i *inputKit) OutPoint() *wire.OutPoint {
|
func (i *inputKit) OutPoint() wire.OutPoint {
|
||||||
return &i.outpoint
|
return i.outpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiredTxOut returns a nil for the base input type.
|
// RequiredTxOut returns a nil for the base input type.
|
||||||
|
@ -23,15 +23,11 @@ var _ Input = (*MockInput)(nil)
|
|||||||
|
|
||||||
// Outpoint returns the reference to the output being spent, used to construct
|
// Outpoint returns the reference to the output being spent, used to construct
|
||||||
// the corresponding transaction input.
|
// the corresponding transaction input.
|
||||||
func (m *MockInput) OutPoint() *wire.OutPoint {
|
func (m *MockInput) OutPoint() wire.OutPoint {
|
||||||
args := m.Called()
|
args := m.Called()
|
||||||
op := args.Get(0)
|
op := args.Get(0)
|
||||||
|
|
||||||
if op == nil {
|
return op.(wire.OutPoint)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return op.(*wire.OutPoint)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
|
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
|
||||||
|
@ -43,7 +43,7 @@ func MultiPrevOutFetcher(inputs []Input) (*txscript.MultiPrevOutFetcher, error)
|
|||||||
op := inp.OutPoint()
|
op := inp.OutPoint()
|
||||||
desc := inp.SignDesc()
|
desc := inp.SignDesc()
|
||||||
|
|
||||||
if op == nil {
|
if op == EmptyOutPoint {
|
||||||
return nil, fmt.Errorf("missing input outpoint")
|
return nil, fmt.Errorf("missing input outpoint")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ func MultiPrevOutFetcher(inputs []Input) (*txscript.MultiPrevOutFetcher, error)
|
|||||||
return nil, fmt.Errorf("missing input utxo information")
|
return nil, fmt.Errorf("missing input utxo information")
|
||||||
}
|
}
|
||||||
|
|
||||||
fetcher.AddPrevOut(*op, desc.Output)
|
fetcher.AddPrevOut(op, desc.Output)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetcher, nil
|
return fetcher, nil
|
||||||
|
@ -521,7 +521,7 @@ func (b *BudgetAggregator) ClusterInputs(inputs InputsMap) []InputSet {
|
|||||||
// Put exclusive inputs in their own set.
|
// Put exclusive inputs in their own set.
|
||||||
if input.params.ExclusiveGroup != nil {
|
if input.params.ExclusiveGroup != nil {
|
||||||
log.Tracef("Input %v is exclusive", input.OutPoint())
|
log.Tracef("Input %v is exclusive", input.OutPoint())
|
||||||
exclusiveInputs[*input.OutPoint()] = input
|
exclusiveInputs[input.OutPoint()] = input
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ func (b *BudgetAggregator) filterInputs(inputs InputsMap) InputsMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredInputs[*op] = pi
|
filteredInputs[op] = pi
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredInputs
|
return filteredInputs
|
||||||
|
@ -460,7 +460,7 @@ func TestBudgetAggregatorFilterInputs(t *testing.T) {
|
|||||||
|
|
||||||
// Mock the `OutPoint` method to return a unique outpoint.
|
// Mock the `OutPoint` method to return a unique outpoint.
|
||||||
opErr := wire.OutPoint{Hash: chainhash.Hash{1}}
|
opErr := wire.OutPoint{Hash: chainhash.Hash{1}}
|
||||||
inpErr.On("OutPoint").Return(&opErr).Once()
|
inpErr.On("OutPoint").Return(opErr).Once()
|
||||||
|
|
||||||
// Mock the estimator to return a constant fee rate.
|
// Mock the estimator to return a constant fee rate.
|
||||||
const minFeeRate = chainfee.SatPerKWeight(1000)
|
const minFeeRate = chainfee.SatPerKWeight(1000)
|
||||||
@ -502,10 +502,10 @@ func TestBudgetAggregatorFilterInputs(t *testing.T) {
|
|||||||
inpDust.On("WitnessType").Return(wt)
|
inpDust.On("WitnessType").Return(wt)
|
||||||
|
|
||||||
// Mock the `OutPoint` method to return the unique outpoint.
|
// Mock the `OutPoint` method to return the unique outpoint.
|
||||||
inpLow.On("OutPoint").Return(&opLow)
|
inpLow.On("OutPoint").Return(opLow)
|
||||||
inpEqual.On("OutPoint").Return(&opEqual)
|
inpEqual.On("OutPoint").Return(opEqual)
|
||||||
inpHigh.On("OutPoint").Return(&opHigh)
|
inpHigh.On("OutPoint").Return(opHigh)
|
||||||
inpDust.On("OutPoint").Return(&opDust)
|
inpDust.On("OutPoint").Return(opDust)
|
||||||
|
|
||||||
// Mock the `RequiredTxOut` to return nil.
|
// Mock the `RequiredTxOut` to return nil.
|
||||||
inpEqual.On("RequiredTxOut").Return(nil)
|
inpEqual.On("RequiredTxOut").Return(nil)
|
||||||
@ -700,7 +700,7 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
|||||||
mockInput1.On("WitnessType").Return(
|
mockInput1.On("WitnessType").Return(
|
||||||
input.CommitmentAnchor)
|
input.CommitmentAnchor)
|
||||||
mockInput1.On("OutPoint").Return(
|
mockInput1.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
},
|
},
|
||||||
expectedNumSets: 1,
|
expectedNumSets: 1,
|
||||||
},
|
},
|
||||||
@ -717,9 +717,9 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
|||||||
input.CommitmentAnchor)
|
input.CommitmentAnchor)
|
||||||
|
|
||||||
mockInput1.On("OutPoint").Return(
|
mockInput1.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
mockInput2.On("OutPoint").Return(
|
mockInput2.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{2}})
|
wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||||
},
|
},
|
||||||
expectedNumSets: 1,
|
expectedNumSets: 1,
|
||||||
},
|
},
|
||||||
@ -738,11 +738,11 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
|||||||
input.CommitmentAnchor)
|
input.CommitmentAnchor)
|
||||||
|
|
||||||
mockInput1.On("OutPoint").Return(
|
mockInput1.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
mockInput2.On("OutPoint").Return(
|
mockInput2.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{2}})
|
wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||||
mockInput3.On("OutPoint").Return(
|
mockInput3.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{3}})
|
wire.OutPoint{Hash: chainhash.Hash{3}})
|
||||||
},
|
},
|
||||||
expectedNumSets: 2,
|
expectedNumSets: 2,
|
||||||
},
|
},
|
||||||
@ -760,11 +760,11 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
|||||||
input.CommitmentAnchor)
|
input.CommitmentAnchor)
|
||||||
|
|
||||||
mockInput1.On("OutPoint").Return(
|
mockInput1.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
mockInput3.On("OutPoint").Return(
|
mockInput3.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{3}})
|
wire.OutPoint{Hash: chainhash.Hash{3}})
|
||||||
mockInput4.On("OutPoint").Return(
|
mockInput4.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{2}})
|
wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||||
},
|
},
|
||||||
expectedNumSets: 1,
|
expectedNumSets: 1,
|
||||||
},
|
},
|
||||||
@ -837,7 +837,7 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
|
|||||||
// 3. when assigning the input to the exclusiveInputs.
|
// 3. when assigning the input to the exclusiveInputs.
|
||||||
// 4. when iterating the exclusiveInputs.
|
// 4. when iterating the exclusiveInputs.
|
||||||
opExclusive := wire.OutPoint{Hash: chainhash.Hash{1, 2, 3, 4, 5}}
|
opExclusive := wire.OutPoint{Hash: chainhash.Hash{1, 2, 3, 4, 5}}
|
||||||
inpExclusive.On("OutPoint").Return(&opExclusive).Times(4)
|
inpExclusive.On("OutPoint").Return(opExclusive).Times(4)
|
||||||
|
|
||||||
// Mock the `WitnessType` method to return the witness type.
|
// Mock the `WitnessType` method to return the witness type.
|
||||||
inpExclusive.On("WitnessType").Return(wt)
|
inpExclusive.On("WitnessType").Return(wt)
|
||||||
@ -891,13 +891,13 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
|
|||||||
//
|
//
|
||||||
// We expect the low budget input to call this method once in
|
// We expect the low budget input to call this method once in
|
||||||
// `filterInputs`.
|
// `filterInputs`.
|
||||||
inpLow.On("OutPoint").Return(&opLow).Once()
|
inpLow.On("OutPoint").Return(opLow).Once()
|
||||||
|
|
||||||
// We expect the high budget input to call this method three
|
// We expect the high budget input to call this method three
|
||||||
// times, one in `filterInputs` and one in `createInputSet`,
|
// times, one in `filterInputs` and one in `createInputSet`,
|
||||||
// and one in `NewBudgetInputSet`.
|
// and one in `NewBudgetInputSet`.
|
||||||
inpHigh1.On("OutPoint").Return(&opHigh1).Times(3)
|
inpHigh1.On("OutPoint").Return(opHigh1).Times(3)
|
||||||
inpHigh2.On("OutPoint").Return(&opHigh2).Times(3)
|
inpHigh2.On("OutPoint").Return(opHigh2).Times(3)
|
||||||
|
|
||||||
// Mock the `WitnessType` method to return the witness type.
|
// Mock the `WitnessType` method to return the witness type.
|
||||||
inpLow.On("WitnessType").Return(wt)
|
inpLow.On("WitnessType").Return(wt)
|
||||||
|
@ -28,7 +28,7 @@ func (b bucket) tryAdd(input *SweeperInput) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b[*input.OutPoint()] = input
|
b[input.OutPoint()] = input
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -996,7 +996,7 @@ func (t *TxPublisher) createSweepTx(inputs []input.Input, changePkScript []byte,
|
|||||||
|
|
||||||
idxs = append(idxs, o)
|
idxs = append(idxs, o)
|
||||||
sweepTx.AddTxIn(&wire.TxIn{
|
sweepTx.AddTxIn(&wire.TxIn{
|
||||||
PreviousOutPoint: *o.OutPoint(),
|
PreviousOutPoint: o.OutPoint(),
|
||||||
Sequence: o.BlocksToMaturity(),
|
Sequence: o.BlocksToMaturity(),
|
||||||
})
|
})
|
||||||
sweepTx.AddTxOut(o.RequiredTxOut())
|
sweepTx.AddTxOut(o.RequiredTxOut())
|
||||||
@ -1011,7 +1011,7 @@ func (t *TxPublisher) createSweepTx(inputs []input.Input, changePkScript []byte,
|
|||||||
|
|
||||||
idxs = append(idxs, o)
|
idxs = append(idxs, o)
|
||||||
sweepTx.AddTxIn(&wire.TxIn{
|
sweepTx.AddTxIn(&wire.TxIn{
|
||||||
PreviousOutPoint: *o.OutPoint(),
|
PreviousOutPoint: o.OutPoint(),
|
||||||
Sequence: o.BlocksToMaturity(),
|
Sequence: o.BlocksToMaturity(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -502,10 +502,12 @@ func (s *UtxoSweeper) Stop() error {
|
|||||||
// cannot make a local copy in sweeper.
|
// cannot make a local copy in sweeper.
|
||||||
//
|
//
|
||||||
// TODO(yy): make sure the caller is using the Result chan.
|
// TODO(yy): make sure the caller is using the Result chan.
|
||||||
func (s *UtxoSweeper) SweepInput(input input.Input,
|
func (s *UtxoSweeper) SweepInput(inp input.Input,
|
||||||
params Params) (chan Result, error) {
|
params Params) (chan Result, error) {
|
||||||
|
|
||||||
if input == nil || input.OutPoint() == nil || input.SignDesc() == nil {
|
if inp == nil || inp.OutPoint() == input.EmptyOutPoint ||
|
||||||
|
inp.SignDesc() == nil {
|
||||||
|
|
||||||
return nil, errors.New("nil input received")
|
return nil, errors.New("nil input received")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,16 +523,16 @@ func (s *UtxoSweeper) SweepInput(input input.Input,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
absoluteTimeLock, _ := input.RequiredLockTime()
|
absoluteTimeLock, _ := inp.RequiredLockTime()
|
||||||
log.Infof("Sweep request received: out_point=%v, witness_type=%v, "+
|
log.Infof("Sweep request received: out_point=%v, witness_type=%v, "+
|
||||||
"relative_time_lock=%v, absolute_time_lock=%v, amount=%v, "+
|
"relative_time_lock=%v, absolute_time_lock=%v, amount=%v, "+
|
||||||
"parent=(%v), params=(%v), currentHeight=%v", input.OutPoint(),
|
"parent=(%v), params=(%v)", inp.OutPoint(), inp.WitnessType(),
|
||||||
input.WitnessType(), input.BlocksToMaturity(), absoluteTimeLock,
|
inp.BlocksToMaturity(), absoluteTimeLock,
|
||||||
btcutil.Amount(input.SignDesc().Output.Value),
|
btcutil.Amount(inp.SignDesc().Output.Value),
|
||||||
input.UnconfParent(), params, s.currentHeight)
|
inp.UnconfParent(), params)
|
||||||
|
|
||||||
sweeperInput := &sweepInputMessage{
|
sweeperInput := &sweepInputMessage{
|
||||||
input: input,
|
input: inp,
|
||||||
params: params,
|
params: params,
|
||||||
resultChan: make(chan Result, 1),
|
resultChan: make(chan Result, 1),
|
||||||
}
|
}
|
||||||
@ -837,7 +839,7 @@ func (s *UtxoSweeper) sweep(set InputSet) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
outpoints := make([]wire.OutPoint, len(set.Inputs()))
|
outpoints := make([]wire.OutPoint, len(set.Inputs()))
|
||||||
for i, inp := range set.Inputs() {
|
for i, inp := range set.Inputs() {
|
||||||
outpoints[i] = *inp.OutPoint()
|
outpoints[i] = inp.OutPoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(yy): find out which input is causing the failure.
|
// TODO(yy): find out which input is causing the failure.
|
||||||
@ -860,7 +862,7 @@ func (s *UtxoSweeper) sweep(set InputSet) error {
|
|||||||
func (s *UtxoSweeper) markInputsPendingPublish(set InputSet) {
|
func (s *UtxoSweeper) markInputsPendingPublish(set InputSet) {
|
||||||
// Reschedule sweep.
|
// Reschedule sweep.
|
||||||
for _, input := range set.Inputs() {
|
for _, input := range set.Inputs() {
|
||||||
pi, ok := s.inputs[*input.OutPoint()]
|
pi, ok := s.inputs[input.OutPoint()]
|
||||||
if !ok {
|
if !ok {
|
||||||
// It could be that this input is an additional wallet
|
// It could be that this input is an additional wallet
|
||||||
// input that was attached. In that case there also
|
// input that was attached. In that case there also
|
||||||
@ -1045,7 +1047,7 @@ func (s *UtxoSweeper) handlePendingSweepsReq(
|
|||||||
for _, inp := range s.inputs {
|
for _, inp := range s.inputs {
|
||||||
// Only the exported fields are set, as we expect the response
|
// Only the exported fields are set, as we expect the response
|
||||||
// to only be consumed externally.
|
// to only be consumed externally.
|
||||||
op := *inp.OutPoint()
|
op := inp.OutPoint()
|
||||||
resps[op] = &PendingInputResponse{
|
resps[op] = &PendingInputResponse{
|
||||||
OutPoint: op,
|
OutPoint: op,
|
||||||
WitnessType: inp.WitnessType(),
|
WitnessType: inp.WitnessType(),
|
||||||
@ -1220,7 +1222,7 @@ func (s *UtxoSweeper) mempoolLookup(op wire.OutPoint) fn.Option[wire.MsgTx] {
|
|||||||
// handleNewInput processes a new input by registering spend notification and
|
// handleNewInput processes a new input by registering spend notification and
|
||||||
// scheduling sweeping for it.
|
// scheduling sweeping for it.
|
||||||
func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
||||||
outpoint := *input.input.OutPoint()
|
outpoint := input.input.OutPoint()
|
||||||
pi, pending := s.inputs[outpoint]
|
pi, pending := s.inputs[outpoint]
|
||||||
if pending {
|
if pending {
|
||||||
log.Debugf("Already has pending input %v received", outpoint)
|
log.Debugf("Already has pending input %v received", outpoint)
|
||||||
@ -1233,7 +1235,7 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
|||||||
// This is a new input, and we want to query the mempool to see if this
|
// This is a new input, and we want to query the mempool to see if this
|
||||||
// input has already been spent. If so, we'll start the input with
|
// input has already been spent. If so, we'll start the input with
|
||||||
// state Published and attach the RBFInfo.
|
// state Published and attach the RBFInfo.
|
||||||
state, rbfInfo := s.decideStateAndRBFInfo(*input.input.OutPoint())
|
state, rbfInfo := s.decideStateAndRBFInfo(input.input.OutPoint())
|
||||||
|
|
||||||
// Create a new pendingInput and initialize the listeners slice with
|
// Create a new pendingInput and initialize the listeners slice with
|
||||||
// the passed in result channel. If this input is offered for sweep
|
// the passed in result channel. If this input is offered for sweep
|
||||||
|
@ -264,7 +264,7 @@ func (ctx *sweeperTestContext) assertPendingInputs(inputs ...input.Input) {
|
|||||||
|
|
||||||
inputSet := make(map[wire.OutPoint]struct{}, len(inputs))
|
inputSet := make(map[wire.OutPoint]struct{}, len(inputs))
|
||||||
for _, input := range inputs {
|
for _, input := range inputs {
|
||||||
inputSet[*input.OutPoint()] = struct{}{}
|
inputSet[input.OutPoint()] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputsMap, err := ctx.sweeper.PendingInputs()
|
inputsMap, err := ctx.sweeper.PendingInputs()
|
||||||
@ -295,7 +295,7 @@ func assertTxSweepsInputs(t *testing.T, sweepTx *wire.MsgTx,
|
|||||||
}
|
}
|
||||||
m := make(map[wire.OutPoint]struct{}, len(inputs))
|
m := make(map[wire.OutPoint]struct{}, len(inputs))
|
||||||
for _, input := range inputs {
|
for _, input := range inputs {
|
||||||
m[*input.OutPoint()] = struct{}{}
|
m[input.OutPoint()] = struct{}{}
|
||||||
}
|
}
|
||||||
for _, txIn := range sweepTx.TxIn {
|
for _, txIn := range sweepTx.TxIn {
|
||||||
if _, ok := m[txIn.PreviousOutPoint]; !ok {
|
if _, ok := m[txIn.PreviousOutPoint]; !ok {
|
||||||
@ -322,7 +322,7 @@ func assertTxFeeRate(t *testing.T, tx *wire.MsgTx,
|
|||||||
|
|
||||||
m := make(map[wire.OutPoint]input.Input, len(inputs))
|
m := make(map[wire.OutPoint]input.Input, len(inputs))
|
||||||
for _, input := range inputs {
|
for _, input := range inputs {
|
||||||
m[*input.OutPoint()] = input
|
m[input.OutPoint()] = input
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputAmt int64
|
var inputAmt int64
|
||||||
@ -387,7 +387,7 @@ func TestSuccess(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{{
|
TxIn: []*wire.TxIn{{
|
||||||
PreviousOutPoint: *inp.OutPoint(),
|
PreviousOutPoint: inp.OutPoint(),
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,8 +473,8 @@ func TestDust(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *largeInput.OutPoint()},
|
{PreviousOutPoint: largeInput.OutPoint()},
|
||||||
{PreviousOutPoint: *dustInput.OutPoint()},
|
{PreviousOutPoint: dustInput.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +541,7 @@ func TestWalletUtxo(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *dustInput.OutPoint()},
|
{PreviousOutPoint: dustInput.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,8 +615,8 @@ func TestNegativeInput(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *largeInput.OutPoint()},
|
{PreviousOutPoint: largeInput.OutPoint()},
|
||||||
{PreviousOutPoint: *positiveInput.OutPoint()},
|
{PreviousOutPoint: positiveInput.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,9 +675,8 @@ func TestNegativeInput(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *negInput.OutPoint()},
|
{PreviousOutPoint: negInput.OutPoint()},
|
||||||
{PreviousOutPoint: *secondLargeInput.
|
{PreviousOutPoint: secondLargeInput.OutPoint()},
|
||||||
OutPoint()},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,9 +734,9 @@ func TestChunks(t *testing.T) {
|
|||||||
//nolint:lll
|
//nolint:lll
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *spendableInputs[0].OutPoint()},
|
{PreviousOutPoint: spendableInputs[0].OutPoint()},
|
||||||
{PreviousOutPoint: *spendableInputs[1].OutPoint()},
|
{PreviousOutPoint: spendableInputs[1].OutPoint()},
|
||||||
{PreviousOutPoint: *spendableInputs[2].OutPoint()},
|
{PreviousOutPoint: spendableInputs[2].OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,8 +763,8 @@ func TestChunks(t *testing.T) {
|
|||||||
//nolint:lll
|
//nolint:lll
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *spendableInputs[3].OutPoint()},
|
{PreviousOutPoint: spendableInputs[3].OutPoint()},
|
||||||
{PreviousOutPoint: *spendableInputs[4].OutPoint()},
|
{PreviousOutPoint: spendableInputs[4].OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,7 +837,7 @@ func testRemoteSpend(t *testing.T, postSweep bool) {
|
|||||||
// will be spent by the remote.
|
// will be spent by the remote.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *spendableInputs[1].OutPoint()},
|
{PreviousOutPoint: spendableInputs[1].OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,7 +873,7 @@ func testRemoteSpend(t *testing.T, postSweep bool) {
|
|||||||
// Spend the input with an unknown tx.
|
// Spend the input with an unknown tx.
|
||||||
remoteTx := &wire.MsgTx{
|
remoteTx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *(spendableInputs[0].OutPoint())},
|
{PreviousOutPoint: spendableInputs[0].OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err = ctx.backend.publishTransaction(remoteTx)
|
err = ctx.backend.publishTransaction(remoteTx)
|
||||||
@ -954,7 +953,7 @@ func TestIdempotency(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input.OutPoint()},
|
{PreviousOutPoint: input.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1039,7 +1038,7 @@ func TestRestart(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input1.OutPoint()},
|
{PreviousOutPoint: input1.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,7 +1081,7 @@ func TestRestart(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input2.OutPoint()},
|
{PreviousOutPoint: input2.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1170,7 +1169,7 @@ func TestRestartRemoteSpend(t *testing.T) {
|
|||||||
// will be spent by the remote.
|
// will be spent by the remote.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input2.OutPoint()},
|
{PreviousOutPoint: input2.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,7 +1212,7 @@ func TestRestartRemoteSpend(t *testing.T) {
|
|||||||
|
|
||||||
remoteTx := &wire.MsgTx{
|
remoteTx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input1.OutPoint()},
|
{PreviousOutPoint: input1.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err = ctx.backend.publishTransaction(remoteTx)
|
err = ctx.backend.publishTransaction(remoteTx)
|
||||||
@ -1280,7 +1279,7 @@ func TestRestartConfirmed(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input.OutPoint()},
|
{PreviousOutPoint: input.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1349,7 +1348,7 @@ func TestRetry(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *inp0.OutPoint()},
|
{PreviousOutPoint: inp0.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1384,7 +1383,7 @@ func TestRetry(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *inp1.OutPoint()},
|
{PreviousOutPoint: inp1.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1464,8 +1463,8 @@ func TestDifferentFeePreferences(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input1.OutPoint()},
|
{PreviousOutPoint: input1.OutPoint()},
|
||||||
{PreviousOutPoint: *input2.OutPoint()},
|
{PreviousOutPoint: input2.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1491,7 +1490,7 @@ func TestDifferentFeePreferences(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input3.OutPoint()},
|
{PreviousOutPoint: input3.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1596,8 +1595,8 @@ func TestPendingInputs(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input1.OutPoint()},
|
{PreviousOutPoint: input1.OutPoint()},
|
||||||
{PreviousOutPoint: *input2.OutPoint()},
|
{PreviousOutPoint: input2.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1623,7 +1622,7 @@ func TestPendingInputs(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input3.OutPoint()},
|
{PreviousOutPoint: input3.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1707,7 +1706,7 @@ func TestExclusiveGroup(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input1.OutPoint()},
|
{PreviousOutPoint: input1.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1733,7 +1732,7 @@ func TestExclusiveGroup(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input2.OutPoint()},
|
{PreviousOutPoint: input2.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1759,7 +1758,7 @@ func TestExclusiveGroup(t *testing.T) {
|
|||||||
// Create a fake sweep tx.
|
// Create a fake sweep tx.
|
||||||
tx := &wire.MsgTx{
|
tx := &wire.MsgTx{
|
||||||
TxIn: []*wire.TxIn{
|
TxIn: []*wire.TxIn{
|
||||||
{PreviousOutPoint: *input3.OutPoint()},
|
{PreviousOutPoint: input3.OutPoint()},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1954,7 +1953,7 @@ func TestLockTimes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
op := inp.OutPoint()
|
op := inp.OutPoint()
|
||||||
inputs[*op] = inp
|
inputs[op] = inp
|
||||||
|
|
||||||
cluster, ok := clusters[lt]
|
cluster, ok := clusters[lt]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -1966,7 +1965,7 @@ func TestLockTimes(t *testing.T) {
|
|||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
inp := spendableInputs[i+numSweeps*2]
|
inp := spendableInputs[i+numSweeps*2]
|
||||||
inputs[*inp.OutPoint()] = inp
|
inputs[inp.OutPoint()] = inp
|
||||||
|
|
||||||
lt := uint32(10 + (i % numSweeps))
|
lt := uint32(10 + (i % numSweeps))
|
||||||
clusters[lt] = append(clusters[lt], inp)
|
clusters[lt] = append(clusters[lt], inp)
|
||||||
@ -1982,7 +1981,7 @@ func TestLockTimes(t *testing.T) {
|
|||||||
// Append the inputs.
|
// Append the inputs.
|
||||||
for _, inp := range cluster {
|
for _, inp := range cluster {
|
||||||
txIn := &wire.TxIn{
|
txIn := &wire.TxIn{
|
||||||
PreviousOutPoint: *inp.OutPoint(),
|
PreviousOutPoint: inp.OutPoint(),
|
||||||
}
|
}
|
||||||
tx.TxIn = append(tx.TxIn, txIn)
|
tx.TxIn = append(tx.TxIn, txIn)
|
||||||
}
|
}
|
||||||
@ -2137,15 +2136,15 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
|||||||
inputNotExist := &input.MockInput{}
|
inputNotExist := &input.MockInput{}
|
||||||
defer inputNotExist.AssertExpectations(t)
|
defer inputNotExist.AssertExpectations(t)
|
||||||
|
|
||||||
inputNotExist.On("OutPoint").Return(&wire.OutPoint{Index: 0})
|
inputNotExist.On("OutPoint").Return(wire.OutPoint{Index: 0})
|
||||||
|
|
||||||
// inputInit specifies a newly created input.
|
// inputInit specifies a newly created input.
|
||||||
inputInit := &input.MockInput{}
|
inputInit := &input.MockInput{}
|
||||||
defer inputInit.AssertExpectations(t)
|
defer inputInit.AssertExpectations(t)
|
||||||
|
|
||||||
inputInit.On("OutPoint").Return(&wire.OutPoint{Index: 1})
|
inputInit.On("OutPoint").Return(wire.OutPoint{Index: 1})
|
||||||
|
|
||||||
s.inputs[*inputInit.OutPoint()] = &SweeperInput{
|
s.inputs[inputInit.OutPoint()] = &SweeperInput{
|
||||||
state: Init,
|
state: Init,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2153,9 +2152,9 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
|||||||
inputPendingPublish := &input.MockInput{}
|
inputPendingPublish := &input.MockInput{}
|
||||||
defer inputPendingPublish.AssertExpectations(t)
|
defer inputPendingPublish.AssertExpectations(t)
|
||||||
|
|
||||||
inputPendingPublish.On("OutPoint").Return(&wire.OutPoint{Index: 2})
|
inputPendingPublish.On("OutPoint").Return(wire.OutPoint{Index: 2})
|
||||||
|
|
||||||
s.inputs[*inputPendingPublish.OutPoint()] = &SweeperInput{
|
s.inputs[inputPendingPublish.OutPoint()] = &SweeperInput{
|
||||||
state: PendingPublish,
|
state: PendingPublish,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2163,9 +2162,9 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
|||||||
inputTerminated := &input.MockInput{}
|
inputTerminated := &input.MockInput{}
|
||||||
defer inputTerminated.AssertExpectations(t)
|
defer inputTerminated.AssertExpectations(t)
|
||||||
|
|
||||||
inputTerminated.On("OutPoint").Return(&wire.OutPoint{Index: 3})
|
inputTerminated.On("OutPoint").Return(wire.OutPoint{Index: 3})
|
||||||
|
|
||||||
s.inputs[*inputTerminated.OutPoint()] = &SweeperInput{
|
s.inputs[inputTerminated.OutPoint()] = &SweeperInput{
|
||||||
state: Excluded,
|
state: Excluded,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2181,16 +2180,14 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
|||||||
require.Len(s.inputs, 3)
|
require.Len(s.inputs, 3)
|
||||||
|
|
||||||
// We expect the init input's state to become pending publish.
|
// We expect the init input's state to become pending publish.
|
||||||
require.Equal(PendingPublish,
|
require.Equal(PendingPublish, s.inputs[inputInit.OutPoint()].state)
|
||||||
s.inputs[*inputInit.OutPoint()].state)
|
|
||||||
|
|
||||||
// We expect the pending-publish to stay unchanged.
|
// We expect the pending-publish to stay unchanged.
|
||||||
require.Equal(PendingPublish,
|
require.Equal(PendingPublish,
|
||||||
s.inputs[*inputPendingPublish.OutPoint()].state)
|
s.inputs[inputPendingPublish.OutPoint()].state)
|
||||||
|
|
||||||
// We expect the terminated to stay unchanged.
|
// We expect the terminated to stay unchanged.
|
||||||
require.Equal(Excluded,
|
require.Equal(Excluded, s.inputs[inputTerminated.OutPoint()].state)
|
||||||
s.inputs[*inputTerminated.OutPoint()].state)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestMarkInputsPublished checks that given a list of inputs with different
|
// TestMarkInputsPublished checks that given a list of inputs with different
|
||||||
@ -2355,7 +2352,7 @@ func TestMarkInputsSwept(t *testing.T) {
|
|||||||
defer mockInput.AssertExpectations(t)
|
defer mockInput.AssertExpectations(t)
|
||||||
|
|
||||||
// Mock the `OutPoint` to return a dummy outpoint.
|
// Mock the `OutPoint` to return a dummy outpoint.
|
||||||
mockInput.On("OutPoint").Return(&wire.OutPoint{Hash: chainhash.Hash{1}})
|
mockInput.On("OutPoint").Return(wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
|
|
||||||
// Create a test sweeper.
|
// Create a test sweeper.
|
||||||
s := New(&UtxoSweeperConfig{})
|
s := New(&UtxoSweeperConfig{})
|
||||||
@ -2639,7 +2636,7 @@ func TestMarkInputFailed(t *testing.T) {
|
|||||||
defer mockInput.AssertExpectations(t)
|
defer mockInput.AssertExpectations(t)
|
||||||
|
|
||||||
// Mock the `OutPoint` to return a dummy outpoint.
|
// Mock the `OutPoint` to return a dummy outpoint.
|
||||||
mockInput.On("OutPoint").Return(&wire.OutPoint{Hash: chainhash.Hash{1}})
|
mockInput.On("OutPoint").Return(wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
|
|
||||||
// Create a test sweeper.
|
// Create a test sweeper.
|
||||||
s := New(&UtxoSweeperConfig{})
|
s := New(&UtxoSweeperConfig{})
|
||||||
|
@ -568,7 +568,7 @@ func validateInputs(inputs []SweeperInput) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dedupInputs is a map used to track unique outpoints of the inputs.
|
// dedupInputs is a map used to track unique outpoints of the inputs.
|
||||||
dedupInputs := make(map[*wire.OutPoint]struct{})
|
dedupInputs := make(map[wire.OutPoint]struct{})
|
||||||
|
|
||||||
// deadlineSet stores unique deadline heights.
|
// deadlineSet stores unique deadline heights.
|
||||||
deadlineSet := make(map[fn.Option[int32]]struct{})
|
deadlineSet := make(map[fn.Option[int32]]struct{})
|
||||||
|
@ -411,7 +411,7 @@ func TestNeedWalletInput(t *testing.T) {
|
|||||||
// These two methods are only invoked when the
|
// These two methods are only invoked when the
|
||||||
// unit test is running with a logger.
|
// unit test is running with a logger.
|
||||||
mockInput.On("OutPoint").Return(
|
mockInput.On("OutPoint").Return(
|
||||||
&wire.OutPoint{Hash: chainhash.Hash{1}},
|
wire.OutPoint{Hash: chainhash.Hash{1}},
|
||||||
).Maybe()
|
).Maybe()
|
||||||
mockInput.On("WitnessType").Return(
|
mockInput.On("WitnessType").Return(
|
||||||
input.CommitmentAnchor,
|
input.CommitmentAnchor,
|
||||||
@ -632,7 +632,7 @@ func TestAddWalletInputSuccess(t *testing.T) {
|
|||||||
//
|
//
|
||||||
// NOTE: these methods are not functional as they are only used for
|
// NOTE: these methods are not functional as they are only used for
|
||||||
// loggings in debug or trace mode so we use arbitrary values.
|
// loggings in debug or trace mode so we use arbitrary values.
|
||||||
mockInput.On("OutPoint").Return(&wire.OutPoint{Hash: chainhash.Hash{1}})
|
mockInput.On("OutPoint").Return(wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||||
mockInput.On("WitnessType").Return(input.CommitmentAnchor)
|
mockInput.On("WitnessType").Return(input.CommitmentAnchor)
|
||||||
|
|
||||||
// Create a wallet utxo that cannot cover the budget.
|
// Create a wallet utxo that cannot cover the budget.
|
||||||
|
@ -74,7 +74,7 @@ func createSweepTx(inputs []input.Input, outputs []*wire.TxOut,
|
|||||||
|
|
||||||
idxs = append(idxs, o)
|
idxs = append(idxs, o)
|
||||||
sweepTx.AddTxIn(&wire.TxIn{
|
sweepTx.AddTxIn(&wire.TxIn{
|
||||||
PreviousOutPoint: *o.OutPoint(),
|
PreviousOutPoint: o.OutPoint(),
|
||||||
Sequence: o.BlocksToMaturity(),
|
Sequence: o.BlocksToMaturity(),
|
||||||
})
|
})
|
||||||
sweepTx.AddTxOut(o.RequiredTxOut())
|
sweepTx.AddTxOut(o.RequiredTxOut())
|
||||||
@ -102,7 +102,7 @@ func createSweepTx(inputs []input.Input, outputs []*wire.TxOut,
|
|||||||
|
|
||||||
idxs = append(idxs, o)
|
idxs = append(idxs, o)
|
||||||
sweepTx.AddTxIn(&wire.TxIn{
|
sweepTx.AddTxIn(&wire.TxIn{
|
||||||
PreviousOutPoint: *o.OutPoint(),
|
PreviousOutPoint: o.OutPoint(),
|
||||||
Sequence: o.BlocksToMaturity(),
|
Sequence: o.BlocksToMaturity(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -309,9 +309,7 @@ func inputTypeSummary(inputs []input.Input) string {
|
|||||||
|
|
||||||
var parts []string
|
var parts []string
|
||||||
for _, i := range sortedInputs {
|
for _, i := range sortedInputs {
|
||||||
part := fmt.Sprintf("%v (%v)",
|
part := fmt.Sprintf("%v (%v)", i.OutPoint(), i.WitnessType())
|
||||||
*i.OutPoint(), i.WitnessType())
|
|
||||||
|
|
||||||
parts = append(parts, part)
|
parts = append(parts, part)
|
||||||
}
|
}
|
||||||
return strings.Join(parts, ", ")
|
return strings.Join(parts, ", ")
|
||||||
|
@ -67,10 +67,10 @@ func newBackupTask(id wtdb.BackupID, sweepPkScript []byte) *backupTask {
|
|||||||
func (t *backupTask) inputs() map[wire.OutPoint]input.Input {
|
func (t *backupTask) inputs() map[wire.OutPoint]input.Input {
|
||||||
inputs := make(map[wire.OutPoint]input.Input)
|
inputs := make(map[wire.OutPoint]input.Input)
|
||||||
if t.toLocalInput != nil {
|
if t.toLocalInput != nil {
|
||||||
inputs[*t.toLocalInput.OutPoint()] = t.toLocalInput
|
inputs[t.toLocalInput.OutPoint()] = t.toLocalInput
|
||||||
}
|
}
|
||||||
if t.toRemoteInput != nil {
|
if t.toRemoteInput != nil {
|
||||||
inputs[*t.toRemoteInput.OutPoint()] = t.toRemoteInput
|
inputs[t.toRemoteInput.OutPoint()] = t.toRemoteInput
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
@ -297,7 +297,7 @@ func (t *backupTask) craftSessionPayload(
|
|||||||
commitType := t.commitmentType
|
commitType := t.commitmentType
|
||||||
for _, inp := range inputs {
|
for _, inp := range inputs {
|
||||||
// Lookup the input's new post-sort position.
|
// Lookup the input's new post-sort position.
|
||||||
i := inputIndex[*inp.OutPoint()]
|
i := inputIndex[inp.OutPoint()]
|
||||||
|
|
||||||
// Construct the full witness required to spend this input.
|
// Construct the full witness required to spend this input.
|
||||||
inputScript, err := inp.CraftInputScript(
|
inputScript, err := inp.CraftInputScript(
|
||||||
|
@ -580,10 +580,10 @@ func testBackupTask(t *testing.T, test backupTaskTest) {
|
|||||||
// task's inputs() method.
|
// task's inputs() method.
|
||||||
expInputs := make(map[wire.OutPoint]input.Input)
|
expInputs := make(map[wire.OutPoint]input.Input)
|
||||||
if task.toLocalInput != nil {
|
if task.toLocalInput != nil {
|
||||||
expInputs[*task.toLocalInput.OutPoint()] = task.toLocalInput
|
expInputs[task.toLocalInput.OutPoint()] = task.toLocalInput
|
||||||
}
|
}
|
||||||
if task.toRemoteInput != nil {
|
if task.toRemoteInput != nil {
|
||||||
expInputs[*task.toRemoteInput.OutPoint()] = task.toRemoteInput
|
expInputs[task.toRemoteInput.OutPoint()] = task.toRemoteInput
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that the inputs method returns the correct slice of
|
// Assert that the inputs method returns the correct slice of
|
||||||
|
Reference in New Issue
Block a user