@@ -16,7 +16,6 @@ import (
1616 "github.com/lightninglabs/taproot-assets/proof"
1717 "github.com/lightninglabs/taproot-assets/tapgarden"
1818 "github.com/lightninglabs/taproot-assets/universe/supplycommit"
19- "github.com/lightningnetwork/lnd/keychain"
2019)
2120
2221// VerifierCfg is the configuration for the verifier.
@@ -539,7 +538,9 @@ func (v *Verifier) verifyIssuanceLeaf(ctx context.Context,
539538
540539 // Attempt to extract the pre-commitment output from the issuance proof
541540 // anchor transaction.
542- _ , err = ExtractPreCommitOutput (issuanceProof , delegationKey )
541+ _ , err = supplycommit .NewPreCommitFromProof (
542+ issuanceProof , delegationKey ,
543+ )
543544 if err != nil {
544545 return fmt .Errorf ("unable to extract pre-commit output from " +
545546 "issuance proof anchor tx: %w" , err )
@@ -822,53 +823,3 @@ func (v *Verifier) VerifyCommit(ctx context.Context,
822823 unspentPreCommits ,
823824 )
824825}
825-
826- // ExtractPreCommitOutput extracts and returns the supply pre-commitment output
827- // from the given issuance proof and asset metadata reveal.
828- func ExtractPreCommitOutput (issuanceProof proof.Proof ,
829- delegationKey btcec.PublicKey ) (supplycommit.PreCommitment , error ) {
830-
831- var zero supplycommit.PreCommitment
832-
833- // Identify txOut in mint anchor transaction which corresponds to the
834- // supply pre-commitment output.
835- //
836- // Construct the expected pre-commit tx out.
837- expectedTxOut , err := tapgarden .PreCommitTxOut (delegationKey )
838- if err != nil {
839- return zero , fmt .Errorf ("unable to derive expected pre-commit " +
840- "txout: %w" , err )
841- }
842-
843- var preCommitTxOutIndex int32 = - 1
844- for idx := range issuanceProof .AnchorTx .TxOut {
845- txOut := * issuanceProof .AnchorTx .TxOut [idx ]
846-
847- // Compare txOut to the expected pre-commit tx out.
848- isValueEqual := txOut .Value == expectedTxOut .Value
849- isPkScriptEqual := bytes .Equal (
850- txOut .PkScript , expectedTxOut .PkScript ,
851- )
852-
853- if isValueEqual && isPkScriptEqual {
854- preCommitTxOutIndex = int32 (idx )
855- }
856- }
857-
858- // If we didn't find the pre-commit tx out, then return an error.
859- if preCommitTxOutIndex == - 1 {
860- return zero , fmt .Errorf ("unable to find pre-commit tx out in " +
861- "issuance anchor tx" )
862- }
863-
864- // Calculate the outpoint of the supply pre-commitment.
865- return supplycommit.PreCommitment {
866- BlockHeight : issuanceProof .BlockHeight ,
867- MintingTxn : & issuanceProof .AnchorTx ,
868- OutIdx : uint32 (preCommitTxOutIndex ),
869- InternalKey : keychain.KeyDescriptor {
870- PubKey : & delegationKey ,
871- },
872- GroupPubKey : issuanceProof .Asset .GroupKey .GroupPubKey ,
873- }, nil
874- }
0 commit comments