mining: add new getCoinbaseTx() returning a struct

Introduce a new method intended to replace getCoinbaseRawTx(), which
provides a struct with everything clients need to construct a coinbase.
This is safer than providing a raw dummy coinbase that clients then have
to manipulate.

The CoinbaseTx data is populated during the dummy transaction generation
and stored in struct CBlockTemplate.

Expand the interface_ipc.py functional test to document its usage
and ensure equivalence.
This commit is contained in:
Sjors Provoost
2026-01-05 09:51:57 +07:00
parent d59b4cdb57
commit 48f57bb35b
9 changed files with 219 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {
getTxFees @3 (context: Proxy.Context) -> (result: List(Int64));
getTxSigops @4 (context: Proxy.Context) -> (result: List(Int64));
getCoinbaseRawTx @5 (context: Proxy.Context) -> (result: Data);
getCoinbaseTx @12 (context: Proxy.Context) -> (result: CoinbaseTx);
getCoinbaseCommitment @6 (context: Proxy.Context) -> (result: Data);
getWitnessCommitmentIndex @7 (context: Proxy.Context) -> (result: Int32);
getCoinbaseMerklePath @8 (context: Proxy.Context) -> (result: List(Data));
@@ -51,3 +52,13 @@ struct BlockCheckOptions $Proxy.wrap("node::BlockCheckOptions") {
checkMerkleRoot @0 :Bool $Proxy.name("check_merkle_root");
checkPow @1 :Bool $Proxy.name("check_pow");
}
struct CoinbaseTx $Proxy.wrap("node::CoinbaseTx") {
version @0 :UInt32 $Proxy.name("version");
sequence @1 :UInt32 $Proxy.name("sequence");
scriptSigPrefix @2 :Data $Proxy.name("script_sig_prefix");
witness @3 :Data $Proxy.name("witness");
blockRewardRemaining @4 :Int64 $Proxy.name("block_reward_remaining");
requiredOutputs @5 :List(Data) $Proxy.name("required_outputs");
lockTime @6 :UInt32 $Proxy.name("lock_time");
}