Skip to content

Commit 07ab992

Browse files
committed
tapgarden: set verboseBatches length to zero to avoid nil element
Fix a bug where verboseBatches was initialized with a single nil element, leading to a panic during RPC marshalling. This occurred when a single unfunded batch was processed—the loop skipped to the next iteration, leaving verboseBatches with a nil entry. Also add a comment explaining why funding is required for a verbose batch.
1 parent 17b125f commit 07ab992

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tapgarden/planter.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ func listBatches(ctx context.Context, batchStore MintingStore,
15161516
}
15171517

15181518
// Formulate verbose batches from the sorted batches.
1519-
verboseBatches := make([]*VerboseBatch, len(sortedBatches))
1519+
verboseBatches := make([]*VerboseBatch, 0, len(sortedBatches))
15201520

15211521
for idx := range sortedBatches {
15221522
currentBatch := sortedBatches[idx]
@@ -1527,6 +1527,10 @@ func listBatches(ctx context.Context, batchStore MintingStore,
15271527
case currentBatch.State() != BatchStatePending:
15281528
continue
15291529
case !currentBatch.IsFunded():
1530+
// The batch isn't funded yet, so we can't display any
1531+
// pending asset group information. Funding is required
1532+
// because the anchor transaction outpoint is needed to
1533+
// formulate pending asset group key requests.
15301534
continue
15311535
case len(currentBatch.Seedlings) == 0:
15321536
continue
@@ -1538,7 +1542,7 @@ func listBatches(ctx context.Context, batchStore MintingStore,
15381542
return nil, err
15391543
}
15401544

1541-
verboseBatches[idx] = verboseBatch
1545+
verboseBatches = append(verboseBatches, verboseBatch)
15421546
}
15431547

15441548
return verboseBatches, nil

0 commit comments

Comments
 (0)