@@ -564,7 +564,7 @@ func ConfirmBatch(t *testing.T, minerClient *rpcclient.Client,
564564
565565func ManualMintSimpleAsset (t * harnessTest , lndNode * node.HarnessNode ,
566566 tapClient * tapdHarness , commitVersion commitment.TapCommitmentVersion ,
567- req * mintrpc.MintAsset ) (* taprpc.Asset , * tapdevrpc. ImportProofRequest ) {
567+ req * mintrpc.MintAsset ) (* taprpc.Asset , proof. Blob , string ) {
568568
569569 ctxb := context .Background ()
570570 ctxt , cancel := context .WithTimeout (ctxb , defaultWaitTimeout )
@@ -725,12 +725,9 @@ func ManualMintSimpleAsset(t *harnessTest, lndNode *node.HarnessNode,
725725 require .NoError (t .t , err )
726726 require .True (t .t , proof .IsProofFile (proofBlob ))
727727
728- importReq := tapdevrpc.ImportProofRequest {
729- ProofFile : proofBlob ,
730- GenesisPoint : genesisOutpoint .String (),
731- }
732- _ , err = tapClient .ImportProof (ctxb , & importReq )
733- require .NoError (t .t , err )
728+ ImportProofFileDeprecated (
729+ t , tapClient , proofBlob , genesisOutpoint .String (),
730+ )
734731
735732 // After proof import, the minted assets should appear in the output of
736733 // ListAssets.
@@ -743,7 +740,7 @@ func ManualMintSimpleAsset(t *harnessTest, lndNode *node.HarnessNode,
743740 confEvent .Block .BlockHash (),
744741 )
745742
746- return mintedAsset [0 ], & importReq
743+ return mintedAsset [0 ], proofBlob , genesisOutpoint . String ()
747744}
748745
749746// ExternalSigRes is a helper struct that holds the signed PSBT and the
@@ -1009,9 +1006,73 @@ func ExportProofFile(t *testing.T, src *tapdHarness, assetID, scriptKey []byte,
10091006 return proofResp
10101007}
10111008
1012- // ImportProofFile manually imports a proof file using the development only
1013- // ImportProof RPC.
1009+ // ImportProofFile manually imports a proof file into the given node's universe,
1010+ // then registers the inbound transfer to make the wallet aware of the new asset
1011+ // it received.
10141012func ImportProofFile (t * harnessTest , dst commands.RpcClientsBundle ,
1013+ rawFile proof.Blob ) {
1014+
1015+ t .Logf ("Importing proof %x" , rawFile )
1016+
1017+ ctxb := context .Background ()
1018+ ctxt , cancel := context .WithTimeout (ctxb , defaultWaitTimeout )
1019+ defer cancel ()
1020+
1021+ resp , err := dst .UnpackProofFile (ctxt , & taprpc.UnpackProofFileRequest {
1022+ RawProofFile : rawFile ,
1023+ })
1024+ require .NoError (t .t , err )
1025+
1026+ // Import the proof into the universe.
1027+ var lastProof * unirpc.AssetProofResponse
1028+ for _ , rawProof := range resp .RawProofs {
1029+ lastProof = InsertProofIntoUniverse (t .t , dst , rawProof )
1030+ }
1031+ require .NotNil (t .t , lastProof )
1032+ require .NotNil (t .t , lastProof .AssetLeaf )
1033+ require .NotNil (t .t , lastProof .AssetLeaf .Proof )
1034+
1035+ // The proof leaf only contains the actual asset and none of the
1036+ // taprpc.ChainAsset fields. So for anything related to the actual chain
1037+ // output, we need to decode the proof in the leaf.
1038+ decodeResp , err := dst .DecodeProof (ctxt , & taprpc.DecodeProofRequest {
1039+ RawProof : lastProof .AssetLeaf .Proof ,
1040+ })
1041+ require .NoError (t .t , err )
1042+
1043+ proofAsset := lastProof .AssetLeaf .Asset
1044+ chainAnchor := decodeResp .DecodedProof .Asset .ChainAnchor
1045+ op , err := wire .NewOutPointFromString (chainAnchor .AnchorOutpoint )
1046+ require .NoError (t .t , err )
1047+
1048+ var groupKey []byte
1049+ if proofAsset .AssetGroup != nil {
1050+ groupKey = proofAsset .AssetGroup .TweakedGroupKey
1051+ }
1052+
1053+ // In order for Bob to expect this incoming transfer, we need to
1054+ // register it with the internal wallet of Bob.
1055+ registerResp , err := dst .RegisterTransfer (
1056+ ctxb , & taprpc.RegisterTransferRequest {
1057+ AssetId : proofAsset .AssetGenesis .AssetId ,
1058+ GroupKey : groupKey ,
1059+ ScriptKey : proofAsset .ScriptKey ,
1060+ Outpoint : & taprpc.OutPoint {
1061+ Txid : op .Hash [:],
1062+ OutputIndex : op .Index ,
1063+ },
1064+ },
1065+ )
1066+ require .NoError (t .t , err )
1067+ require .Equal (
1068+ t .t , proofAsset .ScriptKey ,
1069+ registerResp .RegisteredAsset .ScriptKey ,
1070+ )
1071+ }
1072+
1073+ // ImportProofFileDeprecated manually imports a proof file using the development
1074+ // only ImportProof RPC.
1075+ func ImportProofFileDeprecated (t * harnessTest , dst commands.RpcClientsBundle ,
10151076 rawFile proof.Blob ,
10161077 genesisPoint string ) * tapdevrpc.ImportProofResponse {
10171078
@@ -1114,54 +1175,55 @@ func ExportProofFileFromUniverse(t *testing.T, src commands.RpcClientsBundle,
11141175// InsertProofIntoUniverse manually inserts a proof into the given node using
11151176// the universe related InsertProof RPC.
11161177func InsertProofIntoUniverse (t * testing.T , dst commands.RpcClientsBundle ,
1117- proof * proof.Proof ) * unirpc.AssetProofResponse {
1178+ proofBytes proof.Blob ) * unirpc.AssetProofResponse {
11181179
11191180 ctxb := context .Background ()
11201181 ctxt , cancel := context .WithTimeout (ctxb , defaultWaitTimeout )
11211182 defer cancel ()
11221183
1123- var lastProofBytes bytes.Buffer
1124- err := proof .Encode (& lastProofBytes )
1184+ resp , err := dst .DecodeProof (ctxt , & taprpc.DecodeProofRequest {
1185+ RawProof : proofBytes ,
1186+ WithMetaReveal : true ,
1187+ WithPrevWitnesses : true ,
1188+ })
11251189 require .NoError (t , err )
11261190
1127- proofAsset := proof .Asset
1128-
1129- proofType := universe .ProofTypeTransfer
1130- if proofAsset .IsGenesisAsset () {
1131- proofType = universe .ProofTypeIssuance
1132- }
1191+ rpcProof := resp .DecodedProof
1192+ rpcAsset := rpcProof .Asset
1193+ rpcAnchor := rpcAsset .ChainAnchor
11331194
11341195 uniID := universe.Identifier {
1135- AssetID : proofAsset .ID (),
1136- ProofType : proofType ,
1196+ ProofType : universe .ProofTypeTransfer ,
1197+ }
1198+ if rpcProof .GenesisReveal != nil {
1199+ uniID .ProofType = universe .ProofTypeIssuance
11371200 }
1138- if proofAsset .GroupKey != nil {
1139- uniID .GroupKey = & proofAsset .GroupKey .GroupPubKey
1201+
1202+ copy (uniID .AssetID [:], rpcAsset .AssetGenesis .AssetId )
1203+ if rpcAsset .AssetGroup != nil {
1204+ uniID .GroupKey , err = btcec .ParsePubKey (
1205+ rpcAsset .AssetGroup .TweakedGroupKey ,
1206+ )
1207+ require .NoError (t , err )
11401208 }
11411209
11421210 rpcUniID , err := taprootassets .MarshalUniID (uniID )
11431211 require .NoError (t , err )
11441212
1145- rpcOutPoint := & unirpc.Outpoint {
1146- HashStr : proof .AnchorTx .TxHash ().String (),
1147- Index : int32 (proof .InclusionProof .OutputIndex ),
1148- }
1149-
1150- scriptKeyBytes := proofAsset .ScriptKey .PubKey .SerializeCompressed ()
11511213 importResp , err := dst .InsertProof (ctxt , & unirpc.AssetProof {
11521214 Key : & unirpc.UniverseKey {
11531215 Id : rpcUniID ,
11541216 LeafKey : & unirpc.AssetKey {
1155- Outpoint : & unirpc.AssetKey_Op {
1156- Op : rpcOutPoint ,
1217+ Outpoint : & unirpc.AssetKey_OpStr {
1218+ OpStr : rpcAnchor . AnchorOutpoint ,
11571219 },
11581220 ScriptKey : & unirpc.AssetKey_ScriptKeyBytes {
1159- ScriptKeyBytes : scriptKeyBytes ,
1221+ ScriptKeyBytes : rpcAsset . ScriptKey ,
11601222 },
11611223 },
11621224 },
11631225 AssetLeaf : & unirpc.AssetLeaf {
1164- Proof : lastProofBytes . Bytes () ,
1226+ Proof : proofBytes ,
11651227 },
11661228 })
11671229 require .NoError (t , err )
0 commit comments