Skip to content

Commit fac0840

Browse files
ffranrdarioAnongba
authored andcommitted
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 bebf17f commit fac0840

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
@@ -4293,6 +4293,17 @@ func (r *rpcServer) FetchSupplyCommit(ctx context.Context,
42934293
"outstanding supply: %w", err)
42944294
}
42954295

4296+
// Extract block headers for all block heights that have supply leaves.
4297+
// And then marshal them into the RPC format.
4298+
heightHeaderMap, err := supplycommit.ExtractSupplyLeavesBlockHeaders(
4299+
ctx, r.cfg.ChainBridge, commit.Leaves,
4300+
)
4301+
if err != nil {
4302+
return nil, fmt.Errorf("failed to extract block headers for "+
4303+
"supply leaves: %w", err)
4304+
}
4305+
rpcHeightHeaderMap := marshalSupplyLeafBlockHeaders(heightHeaderMap)
4306+
42964307
return &unirpc.FetchSupplyCommitResponse{
42974308
ChainData: chainData,
42984309
TxChainFeesSats: commitBlock.ChainFees,
@@ -4307,6 +4318,8 @@ func (r *rpcServer) FetchSupplyCommit(ctx context.Context,
43074318

43084319
TotalOutstandingSupply: totalOutstandingSupply,
43094320
SpentCommitmentOutpoint: spentCommitmentOutpoint,
4321+
4322+
BlockHeaders: rpcHeightHeaderMap,
43104323
}, nil
43114324
}
43124325

0 commit comments

Comments
 (0)