Skip to content

Commit c69f5fe

Browse files
committed
universerpc: extend FetchSupplyCommitResponse with block header map
Extend the FetchSupplyCommitResponse RPC message with a new field: a map from block height to SupplyLeafBlockHeader. The SupplyLeafBlockHeader message includes the block header timestamp (in seconds since the Unix epoch) and the 32-byte block header hash. This map includes all block heights referenced in the supply leaves.
1 parent 787fed1 commit c69f5fe

File tree

4 files changed

+437
-388
lines changed

4 files changed

+437
-388
lines changed

rpcserver.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,6 +4282,17 @@ func (r *rpcServer) FetchSupplyCommit(ctx context.Context,
42824282
"outstanding supply: %w", err)
42834283
}
42844284

4285+
// Extract block headers for all block heights that have supply leaves.
4286+
// And then marshal them into the RPC format.
4287+
heightHeaderMap, err := supplycommit.ExtractSupplyLeavesBlockHeaders(
4288+
ctx, r.cfg.ChainBridge, commit.Leaves,
4289+
)
4290+
if err != nil {
4291+
return nil, fmt.Errorf("failed to extract block headers for "+
4292+
"supply leaves: %w", err)
4293+
}
4294+
rpcHeightHeaderMap := marshalSupplyLeafBlockHeaders(heightHeaderMap)
4295+
42854296
return &unirpc.FetchSupplyCommitResponse{
42864297
ChainData: chainData,
42874298
TxChainFeesSats: commitBlock.ChainFees,
@@ -4296,6 +4307,8 @@ func (r *rpcServer) FetchSupplyCommit(ctx context.Context,
42964307

42974308
TotalOutstandingSupply: totalOutstandingSupply,
42984309
SpentCommitmentOutpoint: spentCommitmentOutpoint,
4310+
4311+
BlockHeaders: rpcHeightHeaderMap,
42994312
}, nil
43004313
}
43014314

0 commit comments

Comments
 (0)