Skip to content

Commit ba859b9

Browse files
committed
rpcserver: set block timestamp on chain assets
When marshalling a chain asset, ensure the block timestamp is set. This is needed for assets fetched from the DB since the timestamp is not stored in the table with the asset.
1 parent ed4e537 commit ba859b9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rpcserver.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,13 @@ func (r *rpcServer) MarshalChainAsset(ctx context.Context, a asset.ChainAsset,
12121212
return nil, err
12131213
}
12141214

1215+
// Ensure the block timestamp is set if a block height is set.
1216+
if a.AnchorBlockTimestamp == 0 && a.AnchorBlockHeight > 0 {
1217+
a.AnchorBlockTimestamp = r.cfg.ChainBridge.GetBlockTimestamp(
1218+
ctx, a.AnchorBlockHeight,
1219+
)
1220+
}
1221+
12151222
return taprpc.MarshalChainAsset(
12161223
ctx, a, decDisplay, withWitness, keyRing,
12171224
)

0 commit comments

Comments
 (0)