Skip to content

Commit 0698b7f

Browse files
committed
rpc: populate minting batch txid, add test assertion
1 parent 6bcc9b4 commit 0698b7f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

itest/utils.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,5 +276,18 @@ func MintAssetsConfirmBatch(t *testing.T, minerClient *rpcclient.Client,
276276
mintrpc.BatchState_BATCH_STATE_FINALIZED,
277277
)
278278

279+
// We should be able to fetch the batch, and also find that the txid of
280+
// the batch tx is populated.
281+
batchResp, err := tapClient.ListBatches(ctxt, &mintrpc.ListBatchRequest{
282+
Filter: &mintrpc.ListBatchRequest_BatchKey{
283+
BatchKey: batchKey,
284+
},
285+
})
286+
require.NoError(t, err)
287+
require.Len(t, batchResp.Batches, 1)
288+
289+
batch := batchResp.Batches[0]
290+
require.NotEmpty(t, batch.BatchTxid)
291+
279292
return AssertAssetsMinted(t, tapClient, assetRequests, mintTXID, blockHash)
280293
}

rpcserver.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/btcsuite/btcd/btcec/v2"
1919
"github.com/btcsuite/btcd/btcec/v2/schnorr"
20+
"github.com/btcsuite/btcd/btcutil/psbt"
2021
"github.com/btcsuite/btcd/chaincfg/chainhash"
2122
"github.com/btcsuite/btcd/wire"
2223
"github.com/davecgh/go-spew/spew"
@@ -2321,6 +2322,18 @@ func marshalMintingBatch(batch *tapgarden.MintingBatch,
23212322
State: rpcBatchState,
23222323
}
23232324

2325+
// If we have the genesis packet available (funded+signed), then we'll
2326+
// display the txid as well.
2327+
if batch.GenesisPacket != nil {
2328+
batchTx, err := psbt.Extract(batch.GenesisPacket.Pkt)
2329+
if err == nil {
2330+
rpcBatch.BatchTxid = batchTx.TxHash().String()
2331+
} else {
2332+
rpcsLog.Errorf("unable to extract batch tx: %v", err)
2333+
}
2334+
2335+
}
2336+
23242337
// If we don't need to include the seedlings, we can return here.
23252338
if skipSeedlings {
23262339
return rpcBatch, nil

0 commit comments

Comments
 (0)