Skip to content

Commit dbb80f6

Browse files
committed
tapfreighter: fix wrong proof outpoint being used
This fixes a couple of instances where the porter used the wrong outpoint for proof locators when creating new proofs for a send package. This was previously not noticed because the outpoint in the locator was ignored by both the file based and database archive. With the outpoint now being mandatory, this lead to failures in the integration tests.
1 parent 387d99e commit dbb80f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tapfreighter/chain_porter.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func (p *ChainPorter) storeProofs(sendPkg *sendPackage) error {
458458
outputProofLocator := proof.Locator{
459459
AssetID: &firstInput.ID,
460460
ScriptKey: *out.ScriptKey.PubKey,
461-
OutPoint: &firstInput.OutPoint,
461+
OutPoint: fn.Ptr(proofSuffix.OutPoint()),
462462
}
463463
outputProof := &proof.AnnotatedProof{
464464
Locator: outputProofLocator,
@@ -536,19 +536,20 @@ func (p *ChainPorter) fetchInputProof(ctx context.Context,
536536
// updateAssetProofFile retrieves and updates the proof file for the given asset
537537
// ID and script key with the new proof.
538538
func (p *ChainPorter) updateAssetProofFile(ctx context.Context, assetID asset.ID,
539-
scriptKeyPub *btcec.PublicKey, outPoint *wire.OutPoint,
539+
scriptKeyPub *btcec.PublicKey, oldOutPoint *wire.OutPoint,
540540
confEvent *chainntnfs.TxConfirmation,
541541
newProof *proof.Proof) (*proof.AnnotatedProof, *proof.Proof, error) {
542542

543543
// Retrieve current proof file.
544544
locator := proof.Locator{
545545
AssetID: &assetID,
546546
ScriptKey: *scriptKeyPub,
547-
OutPoint: outPoint,
547+
OutPoint: oldOutPoint,
548548
}
549549
currentProofFileBlob, err := p.cfg.AssetProofs.FetchProof(ctx, locator)
550550
if err != nil {
551-
return nil, nil, fmt.Errorf("error fetching proof: %w", err)
551+
return nil, nil, fmt.Errorf("error fetching current proof: %w",
552+
err)
552553
}
553554
currentProofFile := proof.NewEmptyFile(proof.V0)
554555
err = currentProofFile.Decode(bytes.NewReader(currentProofFileBlob))
@@ -585,7 +586,7 @@ func (p *ChainPorter) updateAssetProofFile(ctx context.Context, assetID asset.ID
585586
Locator: proof.Locator{
586587
AssetID: &assetID,
587588
ScriptKey: *newProof.Asset.ScriptKey.PubKey,
588-
OutPoint: outPoint,
589+
OutPoint: fn.Ptr(newProof.OutPoint()),
589590
},
590591
Blob: newProofFileBuffer.Bytes(),
591592
}
@@ -734,7 +735,7 @@ func (p *ChainPorter) transferReceiverProof(pkg *sendPackage) error {
734735
proofLocator := proof.Locator{
735736
AssetID: &passiveAsset.GenesisID,
736737
ScriptKey: *passiveAsset.ScriptKey.PubKey,
737-
OutPoint: &passiveAsset.PrevAnchorPoint,
738+
OutPoint: fn.Ptr(passiveAsset.NewProof.OutPoint()),
738739
}
739740
proofFileBlob, err := p.cfg.AssetProofs.FetchProof(
740741
ctx, proofLocator,

0 commit comments

Comments
 (0)