multi: make input.OutPoint return wire.OutPoint

This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:32 +08:00
1 parent fce86f9b22
commit e771993785
21 files changed
+136 -134

No files matched your search

+5 -5
View File
@@ -1102,8 +1102,8 @@ func (bo *breachedOutput) Amount() btcutil.Amount {
// OutPoint returns the breached output's identifier that is to be included as a
// transaction input.
func (bo *breachedOutput) OutPoint() *wire.OutPoint {
return &bo.outpoint
func (bo *breachedOutput) OutPoint() wire.OutPoint {
return bo.outpoint
}
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
@@ -1547,7 +1547,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight int64,
// transaction.
for _, inp := range inputs {
txn.AddTxIn(&wire.TxIn{
PreviousOutPoint: *inp.OutPoint(),
PreviousOutPoint: inp.OutPoint(),
Sequence: inp.BlocksToMaturity(),
})
}
@@ -1641,7 +1641,7 @@ func taprootBriefcaseFromRetInfo(retInfo *retributionInfo) *taprootBriefcase {
case input.TaprootHtlcAcceptedRevoke:
fallthrough
case input.TaprootHtlcOfferedRevoke:
resID := newResolverID(*bo.OutPoint())
resID := newResolverID(bo.OutPoint())
var firstLevelTweak [32]byte
copy(firstLevelTweak[:], bo.signDesc.TapTweak)
@@ -1684,7 +1684,7 @@ func applyTaprootRetInfo(tapCase *taprootBriefcase,
case input.TaprootHtlcAcceptedRevoke:
fallthrough
case input.TaprootHtlcOfferedRevoke:
resID := newResolverID(*bo.OutPoint())
resID := newResolverID(bo.OutPoint())
tap1, ok := tapCase.TapTweaks.BreachedHtlcTweaks[resID]
if !ok {
+6 -1
View File
@@ -1202,8 +1202,13 @@ func TestBreachCreateJusticeTx(t *testing.T) {
for i, wt := range outputTypes {
// Create a fake breached output for each type, ensuring they
// 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.Index = uint32(i)
op.Index = uint32(1000 + i)
breachedOutputs[i] = makeBreachedOutput(
&op,
wt,
+2 -2
View File
@@ -394,7 +394,7 @@ func TestHtlcSuccessSecondStageResolutionSweeper(t *testing.T) {
resolver := ctx.resolver.(*htlcSuccessResolver)
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
op := inp.OutPoint()
if *op != commitOutpoint {
if op != commitOutpoint {
return fmt.Errorf("outpoint %v swept, "+
"expected %v", op,
commitOutpoint)
@@ -443,7 +443,7 @@ func TestHtlcSuccessSecondStageResolutionSweeper(t *testing.T) {
Hash: reSignedHash,
Index: 1,
}
if *op != exp {
if op != exp {
return fmt.Errorf("swept outpoint %v, expected %v",
op, exp)
}
+3 -3
View File
@@ -1030,7 +1030,7 @@ func TestHtlcTimeoutSecondStageSweeper(t *testing.T) {
resolver := ctx.resolver.(*htlcTimeoutResolver)
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
op := inp.OutPoint()
if *op != commitOutpoint {
if op != commitOutpoint {
return fmt.Errorf("outpoint %v swept, "+
"expected %v", op,
commitOutpoint)
@@ -1095,7 +1095,7 @@ func TestHtlcTimeoutSecondStageSweeper(t *testing.T) {
Hash: reSignedHash,
Index: 1,
}
if *op != exp {
if op != exp {
return fmt.Errorf("wrong outpoint swept")
}
@@ -1205,7 +1205,7 @@ func TestHtlcTimeoutSecondStageSweeperRemoteSpend(t *testing.T) {
resolver := ctx.resolver.(*htlcTimeoutResolver)
inp := <-resolver.Sweeper.(*mockSweeper).sweptInputs
op := inp.OutPoint()
if *op != commitOutpoint {
if op != commitOutpoint {
return fmt.Errorf("outpoint %v swept, "+
"expected %v", op,
commitOutpoint)
+2 -2
View File
@@ -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
// form <prefix><outpoint>.
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,
// followed by the outpoint.
@@ -221,7 +221,7 @@ func prefixOutputKey(statePrefix []byte,
return nil, err
}
err := writeOutpoint(&pfxOutputBuffer, outpoint)
err := writeOutpoint(&pfxOutputBuffer, &outpoint)
if err != nil {
return nil, err
}
+7 -6
View File
@@ -1134,7 +1134,7 @@ func (c *ContractMaturityReport) AddLimboStage1TimeoutHtlc(baby *babyOutput) {
// TODO(roasbeef): bool to indicate stage 1 vs stage 2?
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
Outpoint: *baby.OutPoint(),
Outpoint: baby.OutPoint(),
Amount: baby.Amount(),
MaturityHeight: baby.expiry,
Stage: 1,
@@ -1148,7 +1148,7 @@ func (c *ContractMaturityReport) AddLimboDirectHtlc(kid *kidOutput) {
c.LimboBalance += kid.Amount()
htlcReport := HtlcMaturityReport{
Outpoint: *kid.OutPoint(),
Outpoint: kid.OutPoint(),
Amount: kid.Amount(),
MaturityHeight: kid.absoluteMaturity,
Stage: 2,
@@ -1164,7 +1164,7 @@ func (c *ContractMaturityReport) AddLimboStage1SuccessHtlc(kid *kidOutput) {
c.LimboBalance += kid.Amount()
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
Outpoint: *kid.OutPoint(),
Outpoint: kid.OutPoint(),
Amount: kid.Amount(),
Stage: 1,
})
@@ -1176,7 +1176,7 @@ func (c *ContractMaturityReport) AddLimboStage2Htlc(kid *kidOutput) {
c.LimboBalance += kid.Amount()
htlcReport := HtlcMaturityReport{
Outpoint: *kid.OutPoint(),
Outpoint: kid.OutPoint(),
Amount: kid.Amount(),
Stage: 2,
}
@@ -1197,7 +1197,7 @@ func (c *ContractMaturityReport) AddRecoveredHtlc(kid *kidOutput) {
c.RecoveredBalance += kid.Amount()
c.Htlcs = append(c.Htlcs, HtlcMaturityReport{
Outpoint: *kid.OutPoint(),
Outpoint: kid.OutPoint(),
Amount: kid.Amount(),
MaturityHeight: kid.ConfHeight() + kid.BlocksToMaturity(),
})
@@ -1421,7 +1421,8 @@ func (k *kidOutput) Encode(w io.Writer) error {
return err
}
if err := writeOutpoint(w, k.OutPoint()); err != nil {
op := k.OutPoint()
if err := writeOutpoint(w, &op); err != nil {
return err
}
if err := writeOutpoint(w, k.OriginChanPoint()); err != nil {
+2 -2
View File
@@ -1065,7 +1065,7 @@ func newMockSweeperFull(t *testing.T) *mockSweeperFull {
func (s *mockSweeperFull) sweepInput(input input.Input,
_ 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 {
case s.sweepChan <- input:
@@ -1077,7 +1077,7 @@ func (s *mockSweeperFull) sweepInput(input input.Input,
defer s.lock.Unlock()
c := make(chan sweep.Result, 1)
s.resultChans[*input.OutPoint()] = c
s.resultChans[input.OutPoint()] = c
return c, nil
}