multi: make input.OutPoint return wire.OutPoint
This commit is contained in:
21 files changed
+136
-134
No files matched your search
+2
-2
@@ -521,7 +521,7 @@ func (b *BudgetAggregator) ClusterInputs(inputs InputsMap) []InputSet {
|
||||
// Put exclusive inputs in their own set.
|
||||
if input.params.ExclusiveGroup != nil {
|
||||
log.Tracef("Input %v is exclusive", input.OutPoint())
|
||||
exclusiveInputs[*input.OutPoint()] = input
|
||||
exclusiveInputs[input.OutPoint()] = input
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ func (b *BudgetAggregator) filterInputs(inputs InputsMap) InputsMap {
|
||||
}
|
||||
}
|
||||
|
||||
filteredInputs[*op] = pi
|
||||
filteredInputs[op] = pi
|
||||
}
|
||||
|
||||
return filteredInputs
|
||||
|
||||
+18
-18
@@ -460,7 +460,7 @@ func TestBudgetAggregatorFilterInputs(t *testing.T) {
|
||||
|
||||
// Mock the `OutPoint` method to return a unique outpoint.
|
||||
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.
|
||||
const minFeeRate = chainfee.SatPerKWeight(1000)
|
||||
@@ -502,10 +502,10 @@ func TestBudgetAggregatorFilterInputs(t *testing.T) {
|
||||
inpDust.On("WitnessType").Return(wt)
|
||||
|
||||
// Mock the `OutPoint` method to return the unique outpoint.
|
||||
inpLow.On("OutPoint").Return(&opLow)
|
||||
inpEqual.On("OutPoint").Return(&opEqual)
|
||||
inpHigh.On("OutPoint").Return(&opHigh)
|
||||
inpDust.On("OutPoint").Return(&opDust)
|
||||
inpLow.On("OutPoint").Return(opLow)
|
||||
inpEqual.On("OutPoint").Return(opEqual)
|
||||
inpHigh.On("OutPoint").Return(opHigh)
|
||||
inpDust.On("OutPoint").Return(opDust)
|
||||
|
||||
// Mock the `RequiredTxOut` to return nil.
|
||||
inpEqual.On("RequiredTxOut").Return(nil)
|
||||
@@ -700,7 +700,7 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
||||
mockInput1.On("WitnessType").Return(
|
||||
input.CommitmentAnchor)
|
||||
mockInput1.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
},
|
||||
expectedNumSets: 1,
|
||||
},
|
||||
@@ -717,9 +717,9 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
||||
input.CommitmentAnchor)
|
||||
|
||||
mockInput1.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
mockInput2.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||
},
|
||||
expectedNumSets: 1,
|
||||
},
|
||||
@@ -738,11 +738,11 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
||||
input.CommitmentAnchor)
|
||||
|
||||
mockInput1.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
mockInput2.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||
mockInput3.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{3}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{3}})
|
||||
},
|
||||
expectedNumSets: 2,
|
||||
},
|
||||
@@ -760,11 +760,11 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
|
||||
input.CommitmentAnchor)
|
||||
|
||||
mockInput1.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{1}})
|
||||
mockInput3.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{3}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{3}})
|
||||
mockInput4.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||
wire.OutPoint{Hash: chainhash.Hash{2}})
|
||||
},
|
||||
expectedNumSets: 1,
|
||||
},
|
||||
@@ -837,7 +837,7 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
|
||||
// 3. when assigning the input to the exclusiveInputs.
|
||||
// 4. when iterating the exclusiveInputs.
|
||||
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.
|
||||
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
|
||||
// `filterInputs`.
|
||||
inpLow.On("OutPoint").Return(&opLow).Once()
|
||||
inpLow.On("OutPoint").Return(opLow).Once()
|
||||
|
||||
// We expect the high budget input to call this method three
|
||||
// times, one in `filterInputs` and one in `createInputSet`,
|
||||
// and one in `NewBudgetInputSet`.
|
||||
inpHigh1.On("OutPoint").Return(&opHigh1).Times(3)
|
||||
inpHigh2.On("OutPoint").Return(&opHigh2).Times(3)
|
||||
inpHigh1.On("OutPoint").Return(opHigh1).Times(3)
|
||||
inpHigh2.On("OutPoint").Return(opHigh2).Times(3)
|
||||
|
||||
// Mock the `WitnessType` method to return the witness type.
|
||||
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
|
||||
}
|
||||
|
||||
+2
-2
@@ -996,7 +996,7 @@ func (t *TxPublisher) createSweepTx(inputs []input.Input, changePkScript []byte,
|
||||
|
||||
idxs = append(idxs, o)
|
||||
sweepTx.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: *o.OutPoint(),
|
||||
PreviousOutPoint: o.OutPoint(),
|
||||
Sequence: o.BlocksToMaturity(),
|
||||
})
|
||||
sweepTx.AddTxOut(o.RequiredTxOut())
|
||||
@@ -1011,7 +1011,7 @@ func (t *TxPublisher) createSweepTx(inputs []input.Input, changePkScript []byte,
|
||||
|
||||
idxs = append(idxs, o)
|
||||
sweepTx.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: *o.OutPoint(),
|
||||
PreviousOutPoint: o.OutPoint(),
|
||||
Sequence: o.BlocksToMaturity(),
|
||||
})
|
||||
}
|
||||
|
||||
+15
-13
@@ -502,10 +502,12 @@ func (s *UtxoSweeper) Stop() error {
|
||||
// cannot make a local copy in sweeper.
|
||||
//
|
||||
// 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) {
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -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, "+
|
||||
"relative_time_lock=%v, absolute_time_lock=%v, amount=%v, "+
|
||||
"parent=(%v), params=(%v), currentHeight=%v", input.OutPoint(),
|
||||
input.WitnessType(), input.BlocksToMaturity(), absoluteTimeLock,
|
||||
btcutil.Amount(input.SignDesc().Output.Value),
|
||||
input.UnconfParent(), params, s.currentHeight)
|
||||
"parent=(%v), params=(%v)", inp.OutPoint(), inp.WitnessType(),
|
||||
inp.BlocksToMaturity(), absoluteTimeLock,
|
||||
btcutil.Amount(inp.SignDesc().Output.Value),
|
||||
inp.UnconfParent(), params)
|
||||
|
||||
sweeperInput := &sweepInputMessage{
|
||||
input: input,
|
||||
input: inp,
|
||||
params: params,
|
||||
resultChan: make(chan Result, 1),
|
||||
}
|
||||
@@ -837,7 +839,7 @@ func (s *UtxoSweeper) sweep(set InputSet) error {
|
||||
if err != nil {
|
||||
outpoints := make([]wire.OutPoint, len(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.
|
||||
@@ -860,7 +862,7 @@ func (s *UtxoSweeper) sweep(set InputSet) error {
|
||||
func (s *UtxoSweeper) markInputsPendingPublish(set InputSet) {
|
||||
// Reschedule sweep.
|
||||
for _, input := range set.Inputs() {
|
||||
pi, ok := s.inputs[*input.OutPoint()]
|
||||
pi, ok := s.inputs[input.OutPoint()]
|
||||
if !ok {
|
||||
// It could be that this input is an additional wallet
|
||||
// input that was attached. In that case there also
|
||||
@@ -1045,7 +1047,7 @@ func (s *UtxoSweeper) handlePendingSweepsReq(
|
||||
for _, inp := range s.inputs {
|
||||
// Only the exported fields are set, as we expect the response
|
||||
// to only be consumed externally.
|
||||
op := *inp.OutPoint()
|
||||
op := inp.OutPoint()
|
||||
resps[op] = &PendingInputResponse{
|
||||
OutPoint: op,
|
||||
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
|
||||
// scheduling sweeping for it.
|
||||
func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
||||
outpoint := *input.input.OutPoint()
|
||||
outpoint := input.input.OutPoint()
|
||||
pi, pending := s.inputs[outpoint]
|
||||
if pending {
|
||||
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
|
||||
// input has already been spent. If so, we'll start the input with
|
||||
// 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
|
||||
// the passed in result channel. If this input is offered for sweep
|
||||
|
||||
+50
-53
@@ -264,7 +264,7 @@ func (ctx *sweeperTestContext) assertPendingInputs(inputs ...input.Input) {
|
||||
|
||||
inputSet := make(map[wire.OutPoint]struct{}, len(inputs))
|
||||
for _, input := range inputs {
|
||||
inputSet[*input.OutPoint()] = struct{}{}
|
||||
inputSet[input.OutPoint()] = struct{}{}
|
||||
}
|
||||
|
||||
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))
|
||||
for _, input := range inputs {
|
||||
m[*input.OutPoint()] = struct{}{}
|
||||
m[input.OutPoint()] = struct{}{}
|
||||
}
|
||||
for _, txIn := range sweepTx.TxIn {
|
||||
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))
|
||||
for _, input := range inputs {
|
||||
m[*input.OutPoint()] = input
|
||||
m[input.OutPoint()] = input
|
||||
}
|
||||
|
||||
var inputAmt int64
|
||||
@@ -387,7 +387,7 @@ func TestSuccess(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: *inp.OutPoint(),
|
||||
PreviousOutPoint: inp.OutPoint(),
|
||||
}},
|
||||
}
|
||||
|
||||
@@ -473,8 +473,8 @@ func TestDust(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *largeInput.OutPoint()},
|
||||
{PreviousOutPoint: *dustInput.OutPoint()},
|
||||
{PreviousOutPoint: largeInput.OutPoint()},
|
||||
{PreviousOutPoint: dustInput.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ func TestWalletUtxo(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *dustInput.OutPoint()},
|
||||
{PreviousOutPoint: dustInput.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -615,8 +615,8 @@ func TestNegativeInput(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *largeInput.OutPoint()},
|
||||
{PreviousOutPoint: *positiveInput.OutPoint()},
|
||||
{PreviousOutPoint: largeInput.OutPoint()},
|
||||
{PreviousOutPoint: positiveInput.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -675,9 +675,8 @@ func TestNegativeInput(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *negInput.OutPoint()},
|
||||
{PreviousOutPoint: *secondLargeInput.
|
||||
OutPoint()},
|
||||
{PreviousOutPoint: negInput.OutPoint()},
|
||||
{PreviousOutPoint: secondLargeInput.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -735,9 +734,9 @@ func TestChunks(t *testing.T) {
|
||||
//nolint:lll
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *spendableInputs[0].OutPoint()},
|
||||
{PreviousOutPoint: *spendableInputs[1].OutPoint()},
|
||||
{PreviousOutPoint: *spendableInputs[2].OutPoint()},
|
||||
{PreviousOutPoint: spendableInputs[0].OutPoint()},
|
||||
{PreviousOutPoint: spendableInputs[1].OutPoint()},
|
||||
{PreviousOutPoint: spendableInputs[2].OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -764,8 +763,8 @@ func TestChunks(t *testing.T) {
|
||||
//nolint:lll
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *spendableInputs[3].OutPoint()},
|
||||
{PreviousOutPoint: *spendableInputs[4].OutPoint()},
|
||||
{PreviousOutPoint: spendableInputs[3].OutPoint()},
|
||||
{PreviousOutPoint: spendableInputs[4].OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -838,7 +837,7 @@ func testRemoteSpend(t *testing.T, postSweep bool) {
|
||||
// will be spent by the remote.
|
||||
tx := &wire.MsgTx{
|
||||
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.
|
||||
remoteTx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *(spendableInputs[0].OutPoint())},
|
||||
{PreviousOutPoint: spendableInputs[0].OutPoint()},
|
||||
},
|
||||
}
|
||||
err = ctx.backend.publishTransaction(remoteTx)
|
||||
@@ -954,7 +953,7 @@ func TestIdempotency(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input.OutPoint()},
|
||||
{PreviousOutPoint: input.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1039,7 +1038,7 @@ func TestRestart(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input1.OutPoint()},
|
||||
{PreviousOutPoint: input1.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1082,7 +1081,7 @@ func TestRestart(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input2.OutPoint()},
|
||||
{PreviousOutPoint: input2.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1170,7 +1169,7 @@ func TestRestartRemoteSpend(t *testing.T) {
|
||||
// will be spent by the remote.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input2.OutPoint()},
|
||||
{PreviousOutPoint: input2.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1213,7 +1212,7 @@ func TestRestartRemoteSpend(t *testing.T) {
|
||||
|
||||
remoteTx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input1.OutPoint()},
|
||||
{PreviousOutPoint: input1.OutPoint()},
|
||||
},
|
||||
}
|
||||
err = ctx.backend.publishTransaction(remoteTx)
|
||||
@@ -1280,7 +1279,7 @@ func TestRestartConfirmed(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input.OutPoint()},
|
||||
{PreviousOutPoint: input.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1349,7 +1348,7 @@ func TestRetry(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *inp0.OutPoint()},
|
||||
{PreviousOutPoint: inp0.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1384,7 +1383,7 @@ func TestRetry(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *inp1.OutPoint()},
|
||||
{PreviousOutPoint: inp1.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1464,8 +1463,8 @@ func TestDifferentFeePreferences(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input1.OutPoint()},
|
||||
{PreviousOutPoint: *input2.OutPoint()},
|
||||
{PreviousOutPoint: input1.OutPoint()},
|
||||
{PreviousOutPoint: input2.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1491,7 +1490,7 @@ func TestDifferentFeePreferences(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input3.OutPoint()},
|
||||
{PreviousOutPoint: input3.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1596,8 +1595,8 @@ func TestPendingInputs(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input1.OutPoint()},
|
||||
{PreviousOutPoint: *input2.OutPoint()},
|
||||
{PreviousOutPoint: input1.OutPoint()},
|
||||
{PreviousOutPoint: input2.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1623,7 +1622,7 @@ func TestPendingInputs(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input3.OutPoint()},
|
||||
{PreviousOutPoint: input3.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1707,7 +1706,7 @@ func TestExclusiveGroup(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input1.OutPoint()},
|
||||
{PreviousOutPoint: input1.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1733,7 +1732,7 @@ func TestExclusiveGroup(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input2.OutPoint()},
|
||||
{PreviousOutPoint: input2.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1759,7 +1758,7 @@ func TestExclusiveGroup(t *testing.T) {
|
||||
// Create a fake sweep tx.
|
||||
tx := &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
{PreviousOutPoint: *input3.OutPoint()},
|
||||
{PreviousOutPoint: input3.OutPoint()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1954,7 +1953,7 @@ func TestLockTimes(t *testing.T) {
|
||||
}
|
||||
|
||||
op := inp.OutPoint()
|
||||
inputs[*op] = inp
|
||||
inputs[op] = inp
|
||||
|
||||
cluster, ok := clusters[lt]
|
||||
if !ok {
|
||||
@@ -1966,7 +1965,7 @@ func TestLockTimes(t *testing.T) {
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
inp := spendableInputs[i+numSweeps*2]
|
||||
inputs[*inp.OutPoint()] = inp
|
||||
inputs[inp.OutPoint()] = inp
|
||||
|
||||
lt := uint32(10 + (i % numSweeps))
|
||||
clusters[lt] = append(clusters[lt], inp)
|
||||
@@ -1982,7 +1981,7 @@ func TestLockTimes(t *testing.T) {
|
||||
// Append the inputs.
|
||||
for _, inp := range cluster {
|
||||
txIn := &wire.TxIn{
|
||||
PreviousOutPoint: *inp.OutPoint(),
|
||||
PreviousOutPoint: inp.OutPoint(),
|
||||
}
|
||||
tx.TxIn = append(tx.TxIn, txIn)
|
||||
}
|
||||
@@ -2137,15 +2136,15 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
||||
inputNotExist := &input.MockInput{}
|
||||
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 := &input.MockInput{}
|
||||
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,
|
||||
}
|
||||
|
||||
@@ -2153,9 +2152,9 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
||||
inputPendingPublish := &input.MockInput{}
|
||||
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,
|
||||
}
|
||||
|
||||
@@ -2163,9 +2162,9 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
||||
inputTerminated := &input.MockInput{}
|
||||
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,
|
||||
}
|
||||
|
||||
@@ -2181,16 +2180,14 @@ func TestMarkInputsPendingPublish(t *testing.T) {
|
||||
require.Len(s.inputs, 3)
|
||||
|
||||
// We expect the init input's state to become pending publish.
|
||||
require.Equal(PendingPublish,
|
||||
s.inputs[*inputInit.OutPoint()].state)
|
||||
require.Equal(PendingPublish, s.inputs[inputInit.OutPoint()].state)
|
||||
|
||||
// We expect the pending-publish to stay unchanged.
|
||||
require.Equal(PendingPublish,
|
||||
s.inputs[*inputPendingPublish.OutPoint()].state)
|
||||
s.inputs[inputPendingPublish.OutPoint()].state)
|
||||
|
||||
// We expect the terminated to stay unchanged.
|
||||
require.Equal(Excluded,
|
||||
s.inputs[*inputTerminated.OutPoint()].state)
|
||||
require.Equal(Excluded, s.inputs[inputTerminated.OutPoint()].state)
|
||||
}
|
||||
|
||||
// TestMarkInputsPublished checks that given a list of inputs with different
|
||||
@@ -2355,7 +2352,7 @@ func TestMarkInputsSwept(t *testing.T) {
|
||||
defer mockInput.AssertExpectations(t)
|
||||
|
||||
// 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.
|
||||
s := New(&UtxoSweeperConfig{})
|
||||
@@ -2639,7 +2636,7 @@ func TestMarkInputFailed(t *testing.T) {
|
||||
defer mockInput.AssertExpectations(t)
|
||||
|
||||
// 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.
|
||||
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 := make(map[*wire.OutPoint]struct{})
|
||||
dedupInputs := make(map[wire.OutPoint]struct{})
|
||||
|
||||
// deadlineSet stores unique deadline heights.
|
||||
deadlineSet := make(map[fn.Option[int32]]struct{})
|
||||
|
||||
@@ -411,7 +411,7 @@ func TestNeedWalletInput(t *testing.T) {
|
||||
// These two methods are only invoked when the
|
||||
// unit test is running with a logger.
|
||||
mockInput.On("OutPoint").Return(
|
||||
&wire.OutPoint{Hash: chainhash.Hash{1}},
|
||||
wire.OutPoint{Hash: chainhash.Hash{1}},
|
||||
).Maybe()
|
||||
mockInput.On("WitnessType").Return(
|
||||
input.CommitmentAnchor,
|
||||
@@ -632,7 +632,7 @@ func TestAddWalletInputSuccess(t *testing.T) {
|
||||
//
|
||||
// NOTE: these methods are not functional as they are only used for
|
||||
// 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)
|
||||
|
||||
// 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)
|
||||
sweepTx.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: *o.OutPoint(),
|
||||
PreviousOutPoint: o.OutPoint(),
|
||||
Sequence: o.BlocksToMaturity(),
|
||||
})
|
||||
sweepTx.AddTxOut(o.RequiredTxOut())
|
||||
@@ -102,7 +102,7 @@ func createSweepTx(inputs []input.Input, outputs []*wire.TxOut,
|
||||
|
||||
idxs = append(idxs, o)
|
||||
sweepTx.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: *o.OutPoint(),
|
||||
PreviousOutPoint: o.OutPoint(),
|
||||
Sequence: o.BlocksToMaturity(),
|
||||
})
|
||||
|
||||
@@ -309,9 +309,7 @@ func inputTypeSummary(inputs []input.Input) string {
|
||||
|
||||
var parts []string
|
||||
for _, i := range sortedInputs {
|
||||
part := fmt.Sprintf("%v (%v)",
|
||||
*i.OutPoint(), i.WitnessType())
|
||||
|
||||
part := fmt.Sprintf("%v (%v)", i.OutPoint(), i.WitnessType())
|
||||
parts = append(parts, part)
|
||||
}
|
||||
return strings.Join(parts, ", ")
|
||||
|
||||
Reference in new issue
Block a user