diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h index f4cc399..00dcf78 100644 --- a/src/interfaces/mining.h +++ b/src/interfaces/mining.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -38,8 +39,29 @@ class BlockTemplate // Sigop cost per transaction, not including coinbase transaction. virtual std::vector getTxSigops() = 0; - virtual CTransactionRef getCoinbaseTx() = 0; + /** Return fields needed to construct a coinbase transaction */ + virtual node::CoinbaseTxTemplate getCoinbaseTx() = 0; + + /** + * Return serialized dummy coinbase transaction. + * + * @note deprecated: use getCoinbaseTx() + */ + virtual CTransactionRef getCoinbaseRawTx() = 0; + + /** + * Return scriptPubKey with SegWit OP_RETURN. + * + * @note deprecated: use getCoinbaseRawTx() + */ virtual std::vector getCoinbaseCommitment() = 0; + + /** + * Return which output in the dummy coinbase contains the SegWit OP_RETURN. + * + * @note deprecated. Scan outputs from getCoinbaseRawTx() outputs field for the + * SegWit marker. + */ virtual int getWitnessCommitmentIndex() = 0; /** diff --git a/src/ipc/capnp/mining-types.h b/src/ipc/capnp/mining-types.h index 7d00625..eea4678 100644 --- a/src/ipc/capnp/mining-types.h +++ b/src/ipc/capnp/mining-types.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace mp { // Custom serializations diff --git a/src/ipc/capnp/mining.capnp b/src/ipc/capnp/mining.capnp index ed01e44..28da7d9 100644 --- a/src/ipc/capnp/mining.capnp +++ b/src/ipc/capnp/mining.capnp @@ -27,7 +27,8 @@ interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") { getBlock @2 (context: Proxy.Context) -> (result: Data); getTxFees @3 (context: Proxy.Context) -> (result: List(Int64)); getTxSigops @4 (context: Proxy.Context) -> (result: List(Int64)); - getCoinbaseTx @5 (context: Proxy.Context) -> (result: Data); + getCoinbaseTx @12 (context: Proxy.Context) -> (result: CoinbaseTxTemplate); + getCoinbaseRawTx @5 (context: Proxy.Context) -> (result: Data); 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 CoinbaseTxTemplate $Proxy.wrap("node::CoinbaseTxTemplate") { + 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"); +} diff --git a/src/sv2/coinbase_template.h b/src/sv2/coinbase_template.h new file mode 100644 index 0000000..d6b48b4 --- /dev/null +++ b/src/sv2/coinbase_template.h @@ -0,0 +1,63 @@ +// Copyright (c) 2025 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_SV2_COINBASE_TEMPLATE_H +#define BITCOIN_SV2_COINBASE_TEMPLATE_H + +#include +#include +#include +#include +#include