feat: add genesis + mempool chain actions (106 total)
Some checks failed
Security Scan / security (push) Successful in 23s
Test / Test (push) Failing after 39s

- blockchain.chain.genesis — returns genesis block hash, timestamp,
  network detection (mainnet/testnet/unknown)
- blockchain.chain.mempool — returns tx pool size (empty for Go node)

Total Core Actions: 106.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 07:13:00 +01:00
parent e9ad1b1fc6
commit 5c38716303
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -37,6 +37,8 @@ func RegisterActions(c *core.Core, ch *chain.Chain) {
c.Action("blockchain.chain.difficulty", makeChainDifficulty(ch))
c.Action("blockchain.chain.transaction", makeChainTransaction(ch))
c.Action("blockchain.chain.peers", makeChainPeers(ch))
c.Action("blockchain.chain.genesis", makeChainGenesis(ch))
c.Action("blockchain.chain.mempool", makeChainMempool(ch))
// Aliases
c.Action("blockchain.alias.list", makeAliasList(ch))
@ -202,6 +204,33 @@ func makeChainPeers(ch *chain.Chain) core.ActionHandler {
}
}
func makeChainGenesis(ch *chain.Chain) core.ActionHandler {
return func(ctx context.Context, opts core.Options) core.Result {
blk, meta, err := ch.GetBlockByHeight(0)
if err != nil {
return core.Result{Value: map[string]interface{}{
"hash": chain.GenesisHash, "height": uint64(0),
}, OK: true}
}
return core.Result{Value: map[string]interface{}{
"hash": meta.Hash.String(),
"height": uint64(0),
"timestamp": blk.Timestamp,
"network": chain.DetectNetwork(meta.Hash.String()),
}, OK: true}
}
}
func makeChainMempool(ch *chain.Chain) core.ActionHandler {
return func(ctx context.Context, opts core.Options) core.Result {
return core.Result{Value: map[string]interface{}{
"size": 0,
"transactions": []interface{}{},
"note": "Go node does not maintain a local mempool",
}, OK: true}
}
}
func makeAliasList(ch *chain.Chain) core.ActionHandler {
return func(ctx context.Context, opts core.Options) core.Result {
return core.Result{Value: ch.GetAllAliases(), OK: true}