@@ -120,27 +120,23 @@ func testBurnAssets(t *harnessTest) {
120120	)
121121
122122	burnResp , err  :=  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
123- 		Asset : & taprpc.BurnAssetRequest_AssetId {
124- 			AssetId : simpleAssetID [:],
123+ 		AssetSpecifier : & taprpc.AssetSpecifier {
124+ 			Id : simpleAssetID [:],
125125		},
126126		AmountToBurn :     burnAmt ,
127127		Note :             burnNote ,
128128		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
129129	})
130130	require .NoError (t .t , err )
131131
132- 	burnRespJSON , err  :=  formatProtoJSON (burnResp )
133- 	require .NoError (t .t , err )
134- 	t .Logf ("Got response from burning %d units: %v" , burnAmt , burnRespJSON )
135- 
136132	AssertAssetOutboundTransferWithOutputs (
137133		t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
138134		[][]byte {simpleAssetGen .AssetId },
139135		[]uint64 {outputAmounts [3 ] -  burnAmt , burnAmt }, 1 , 2 , 2 , true ,
140136	)
141137
142138	// We'll now assert that the burned asset has the correct state. 
143- 	burnedAsset  :=  burnResp .BurnProof .Asset 
139+ 	burnedAsset  :=  burnResp .BurnProofs [ 0 ] .Asset 
144140	allAssets , err  :=  t .tapd .ListAssets (ctxt , & taprpc.ListAssetRequest {
145141		IncludeSpent :  true ,
146142		ScriptKeyType : allScriptKeysQuery ,
@@ -196,18 +192,14 @@ func testBurnAssets(t *harnessTest) {
196192	// collectible from the original mint TX), while there are other, 
197193	// passive assets in the anchor output. 
198194	burnResp , err  =  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
199- 		Asset : & taprpc.BurnAssetRequest_AssetId {
200- 			AssetId : simpleCollectibleGen .AssetId ,
195+ 		AssetSpecifier : & taprpc.AssetSpecifier {
196+ 			Id : simpleCollectibleGen .AssetId ,
201197		},
202198		AmountToBurn :     simpleCollectible .Amount ,
203199		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
204200	})
205201	require .NoError (t .t , err )
206202
207- 	burnRespJSON , err  =  formatProtoJSON (burnResp )
208- 	require .NoError (t .t , err )
209- 	t .Logf ("Got response from burning all units: %v" , burnRespJSON )
210- 
211203	AssertAssetOutboundTransferWithOutputs (
212204		t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
213205		[][]byte {simpleCollectibleGen .AssetId }, []uint64 {1 }, 3 , 4 , 1 ,
@@ -227,19 +219,14 @@ func testBurnAssets(t *harnessTest) {
227219	const  changeAmt  =  300 
228220	multiBurnAmt  :=  outputAmounts [2 ] +  secondSendAmt  -  changeAmt 
229221	burnResp , err  =  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
230- 		Asset : & taprpc.BurnAssetRequest_AssetId {
231- 			AssetId : simpleAssetGen .AssetId ,
222+ 		AssetSpecifier : & taprpc.AssetSpecifier {
223+ 			Id : simpleAssetGen .AssetId ,
232224		},
233225		AmountToBurn :     multiBurnAmt ,
234226		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
235227	})
236228	require .NoError (t .t , err )
237229
238- 	burnRespJSON , err  =  formatProtoJSON (burnResp )
239- 	require .NoError (t .t , err )
240- 	t .Logf ("Got response from burning units from multiple inputs: %v" ,
241- 		burnRespJSON )
242- 
243230	AssertAssetOutboundTransferWithOutputs (
244231		t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
245232		[][]byte {simpleAssetGen .AssetId },
@@ -259,33 +246,25 @@ func testBurnAssets(t *harnessTest) {
259246		WithScriptKeyType (asset .ScriptKeyBurn ),
260247	)
261248
262- 	resp , err  : =t .tapd .ListAssets (ctxt , & taprpc.ListAssetRequest {
249+ 	_ , err  =  t .tapd .ListAssets (ctxt , & taprpc.ListAssetRequest {
263250		IncludeSpent : true ,
264251	})
265252	require .NoError (t .t , err )
266- 	assets , err  :=  formatProtoJSON (resp )
267- 	require .NoError (t .t , err )
268- 	t .Logf ("All assets before last burn: %v" , assets )
269253
270254	// Test case 4: Burn some units of a grouped asset. We start by making 
271255	// sure we still have the full balance before burning. 
272256	AssertBalanceByID (
273257		t .t , t .tapd , simpleGroupGen .AssetId , simpleGroup .Amount ,
274258	)
275259	burnResp , err  =  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
276- 		Asset : & taprpc.BurnAssetRequest_AssetId {
277- 			AssetId : simpleGroupGen .AssetId ,
260+ 		AssetSpecifier : & taprpc.AssetSpecifier {
261+ 			Id : simpleGroupGen .AssetId ,
278262		},
279263		AmountToBurn :     burnAmt ,
280264		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
281265	})
282266	require .NoError (t .t , err )
283267
284- 	burnRespJSON , err  =  formatProtoJSON (burnResp )
285- 	require .NoError (t .t , err )
286- 	t .Logf ("Got response from burning units from grouped asset: %v" ,
287- 		burnRespJSON )
288- 
289268	AssertAssetOutboundTransferWithOutputs (
290269		t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
291270		[][]byte {simpleGroupGen .AssetId },
@@ -295,10 +274,12 @@ func testBurnAssets(t *harnessTest) {
295274		t .t , t .tapd , simpleGroupGen .AssetId , simpleGroup .Amount - burnAmt ,
296275	)
297276
277+ 	// Depending on passive re-anchoring behavior, earlier burn outputs 
278+ 	// might become spent when inputs are consolidated. We assert only 
279+ 	// currently unspent burn outputs here. 
298280	AssertBalances (
299281		t .t , t .tapd ,
300- 		burnAmt + simpleCollectible .Amount + multiBurnAmt + burnAmt ,
301- 		WithNumUtxos (4 ), WithNumAnchorUtxos (4 ),
282+ 		burnAmt + multiBurnAmt + burnAmt ,
302283		WithScriptKeyType (asset .ScriptKeyBurn ),
303284	)
304285
@@ -335,19 +316,14 @@ func testBurnAssets(t *harnessTest) {
335316		simpleGroupCollect .Amount ,
336317	)
337318	burnResp , err  =  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
338- 		Asset : & taprpc.BurnAssetRequest_AssetId {
339- 			AssetId : simpleGroupCollectGen .AssetId ,
319+ 		AssetSpecifier : & taprpc.AssetSpecifier {
320+ 			Id : simpleGroupCollectGen .AssetId ,
340321		},
341322		AmountToBurn :     1 ,
342323		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
343324	})
344325	require .NoError (t .t , err )
345326
346- 	burnRespJSON , err  =  formatProtoJSON (burnResp )
347- 	require .NoError (t .t , err )
348- 	t .Logf ("Got response from burning units from grouped asset: %v" ,
349- 		burnRespJSON )
350- 
351327	AssertAssetOutboundTransferWithOutputs (
352328		t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
353329		[][]byte {simpleGroupCollectGen .AssetId }, []uint64 {1 }, 6 , 7 , 1 ,
@@ -357,8 +333,7 @@ func testBurnAssets(t *harnessTest) {
357333
358334	AssertBalances (
359335		t .t , t .tapd ,
360- 		burnAmt + simpleCollectible .Amount + multiBurnAmt + burnAmt + 1 ,
361- 		WithNumUtxos (5 ), WithNumAnchorUtxos (5 ),
336+ 		burnAmt + multiBurnAmt + burnAmt + 1 ,
362337		WithScriptKeyType (asset .ScriptKeyBurn ),
363338	)
364339
@@ -406,6 +381,7 @@ func testBurnGroupedAssets(t *harnessTest) {
406381
407382	var  (
408383		firstMintResp  =  firstMintResponses [0 ]
384+ 		burnAssetID1   =  firstMintResp .AssetGenesis .AssetId 
409385		assetGroupKey  =  firstMintResp .AssetGroup .TweakedGroupKey 
410386	)
411387
@@ -440,38 +416,37 @@ func testBurnGroupedAssets(t *harnessTest) {
440416	assetGroup  :=  assetGroups .Groups [encodedGroupKey ]
441417	require .Len (t .t , assetGroup .Assets , 2 )
442418
443- 	// Burn some amount of the second asset. 
419+ 	totalAmt  :=  firstMintResp .Amount  +  secondMintResp .Amount 
420+ 	AssertBalanceByGroup (t .t , t .tapd , encodedGroupKey , totalAmt )
421+ 
422+ 	// Test case 1: Burn by asset id. 
444423	var  (
445- 		burnAssetID  =  secondMintResp .AssetGenesis .AssetId 
424+ 		burnAssetID2  =  secondMintResp .AssetGenesis .AssetId 
446425
447426		preBurnAmt   =  secondMintResp .Amount 
448427		burnAmt      =  uint64 (10 )
449428		postBurnAmt  =  preBurnAmt  -  burnAmt 
450429	)
451430
452431	burnResp , err  :=  t .tapd .BurnAsset (ctxb , & taprpc.BurnAssetRequest {
453- 		Asset : & taprpc.BurnAssetRequest_AssetId {
454- 			AssetId :  burnAssetID ,
432+ 		AssetSpecifier : & taprpc.AssetSpecifier {
433+ 			Id :  burnAssetID2 ,
455434		},
456435		AmountToBurn :     burnAmt ,
457436		Note :             burnNote ,
458437		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
459438	})
460439	require .NoError (t .t , err )
461440
462- 	burnRespJSON , err  :=  formatProtoJSON (burnResp )
463- 	require .NoError (t .t , err )
464- 	t .Logf ("Got response from burning %d units: %v" , burnAmt , burnRespJSON )
465- 
466441	// Assert that the asset burn transfer occurred correctly. 
467442	AssertAssetOutboundTransferWithOutputs (
468443		t .t , miner , t .tapd , burnResp .BurnTransfer ,
469- 		[][]byte {burnAssetID }, []uint64 {postBurnAmt , burnAmt }, 0 , 1 , 2 ,
444+ 		[][]byte {burnAssetID2 }, []uint64 {postBurnAmt , burnAmt }, 0 , 1 , 2 ,
470445		true ,
471446	)
472447
473448	// Ensure that the burnt asset has the correct state. 
474- 	burnedAsset  :=  burnResp .BurnProof .Asset 
449+ 	burnedAsset  :=  burnResp .BurnProofs [ 0 ] .Asset 
475450	allAssets , err  :=  t .tapd .ListAssets (ctxb , & taprpc.ListAssetRequest {
476451		IncludeSpent :  true ,
477452		ScriptKeyType : allScriptKeysQuery ,
@@ -486,7 +461,7 @@ func testBurnGroupedAssets(t *harnessTest) {
486461	)
487462
488463	// Our asset balance should have been decreased by the burned amount. 
489- 	AssertBalanceByID (t .t , t .tapd , burnAssetID , postBurnAmt )
464+ 	AssertBalanceByID (t .t , t .tapd , burnAssetID2 , postBurnAmt )
490465
491466	// Confirm that the minted asset group still contains two assets. 
492467	assetGroups , err  =  t .tapd .ListGroups (ctxb , & taprpc.ListGroupsRequest {})
@@ -507,6 +482,40 @@ func testBurnGroupedAssets(t *harnessTest) {
507482	require .Equal (t .t , burnAmt , burn .Amount )
508483	require .Equal (t .t , burnNote , burn .Note )
509484	require .Equal (t .t , assetGroupKey , burn .TweakedGroupKey )
485+ 
486+ 	// Test case 2: Burn by group key to we select multiple inputs. 
487+ 	// We burn the full amount. 
488+ 	burnResp , err  =  t .tapd .BurnAsset (ctxb , & taprpc.BurnAssetRequest {
489+ 		AssetSpecifier : & taprpc.AssetSpecifier {
490+ 			GroupKey : assetGroupKey ,
491+ 		},
492+ 		AmountToBurn :     totalAmt  -  burnAmt ,
493+ 		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
494+ 	})
495+ 	require .NoError (t .t , err )
496+ 
497+ 	// When burning by group key with multiple inputs, 
498+ 	// the coin selection can vary. We verify that: 
499+ 	// - There are 2 outputs total 
500+ 	// - We burn all remaining balance. 
501+ 	amounts  :=  make ([]uint64 , len (burnResp .BurnTransfer .Outputs ))
502+ 	for  i , out  :=  range  burnResp .BurnTransfer .Outputs  {
503+ 		amounts [i ] =  out .Amount 
504+ 	}
505+ 	require .Len (t .t , amounts , 2 )
506+ 
507+ 	actualSum  :=  uint64 (0 )
508+ 	for  _ , amt  :=  range  amounts  {
509+ 		actualSum  +=  amt 
510+ 	}
511+ 	require .Equal (t .t , totalAmt - burnAmt , actualSum )
512+ 
513+ 	AssertAssetOutboundTransferWithOutputs (
514+ 		t .t , miner , t .tapd , burnResp .BurnTransfer ,
515+ 		[][]byte {burnAssetID1 , burnAssetID2 },
516+ 		amounts , 1 , 2 , 2 , true ,
517+ 	)
518+ 	AssertBalanceByGroup (t .t , t .tapd , encodedGroupKey , 0 )
510519}
511520
512521// testFullBurnUTXO tests that we can burn the full amount of an asset UTXO. 
@@ -534,8 +543,8 @@ func testFullBurnUTXO(t *harnessTest) {
534543	// Perform a full burn of the asset. 
535544	fullBurnAmt  :=  simpleAsset .Amount 
536545	burnResp , err  :=  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
537- 		Asset : & taprpc.BurnAssetRequest_AssetId {
538- 			AssetId : simpleAssetID [:],
546+ 		AssetSpecifier : & taprpc.AssetSpecifier {
547+ 			Id : simpleAssetID [:],
539548		},
540549		AmountToBurn :     fullBurnAmt ,
541550		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
@@ -558,8 +567,8 @@ func testFullBurnUTXO(t *harnessTest) {
558567
559568	proofResp  :=  ExportProofFile (
560569		t .t , t .tapd ,
561- 		burnResp .BurnProof .Asset .AssetGenesis .AssetId ,
562- 		burnResp .BurnProof .Asset .ScriptKey ,
570+ 		burnResp .BurnProofs [ 0 ] .Asset .AssetGenesis .AssetId ,
571+ 		burnResp .BurnProofs [ 0 ] .Asset .ScriptKey ,
563572		outpoint ,
564573	)
565574	verifyResp , err  :=  t .tapd .VerifyProof (ctxt , & taprpc.ProofFile {
@@ -586,8 +595,8 @@ func testFullBurnUTXO(t *harnessTest) {
586595
587596	fullBurnAmt  =  collectibleAsset .Amount 
588597	burnResp , err  =  t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
589- 		Asset : & taprpc.BurnAssetRequest_AssetId {
590- 			AssetId : collectibleAssetID [:],
598+ 		AssetSpecifier : & taprpc.AssetSpecifier {
599+ 			Id : collectibleAssetID [:],
591600		},
592601		AmountToBurn :     fullBurnAmt ,
593602		ConfirmationText : taprootassets .AssetBurnConfirmationText ,
@@ -610,8 +619,8 @@ func testFullBurnUTXO(t *harnessTest) {
610619
611620	proofResp  =  ExportProofFile (
612621		t .t , t .tapd ,
613- 		burnResp .BurnProof .Asset .AssetGenesis .AssetId ,
614- 		burnResp .BurnProof .Asset .ScriptKey ,
622+ 		burnResp .BurnProofs [ 0 ] .Asset .AssetGenesis .AssetId ,
623+ 		burnResp .BurnProofs [ 0 ] .Asset .ScriptKey ,
615624		outpoint ,
616625	)
617626	verifyResp , err  =  t .tapd .VerifyProof (ctxt , & taprpc.ProofFile {
0 commit comments