Add getCoinbaseMerklePath() to Mining interface

This commit is contained in:
Sjors Provoost 2024-07-12 16:08:38 +02:00
parent 63d6ad7c89
commit 47b4875ef0
No known key found for this signature in database
GPG key ID: 57FF9BDBCC301009
3 changed files with 14 additions and 0 deletions

View file

@ -42,6 +42,13 @@ public:
virtual CTransactionRef getCoinbaseTx() = 0;
virtual std::vector<unsigned char> getCoinbaseCommitment() = 0;
virtual int getWitnessCommitmentIndex() = 0;
/**
* Compute merkle path to the coinbase transaction
*
* @return merkle path ordered from the deepest
*/
virtual std::vector<uint256> getCoinbaseMerklePath() = 0;
};
//! Interface giving clients (RPC, Stratum v2 Template Provider in the future)

View file

@ -31,6 +31,7 @@ interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {
getCoinbaseTx @4 (context: Proxy.Context) -> (result: Data);
getCoinbaseCommitment @5 (context: Proxy.Context) -> (result: Data);
getWitnessCommitmentIndex @6 (context: Proxy.Context) -> (result: Int32);
getCoinbaseMerklePath @7 (context: Proxy.Context) -> (result: List(Data));
}
struct BlockCreateOptions $Proxy.wrap("node::BlockCreateOptions") {

View file

@ -8,6 +8,7 @@
#include <chain.h>
#include <chainparams.h>
#include <common/args.h>
#include <consensus/merkle.h>
#include <consensus/validation.h>
#include <deploymentstatus.h>
#include <external_signer.h>
@ -910,6 +911,11 @@ public:
return GetWitnessCommitmentIndex(m_block_template->block);
}
std::vector<uint256> getCoinbaseMerklePath() override
{
return BlockMerkleBranch(m_block_template->block);
}
const std::unique_ptr<CBlockTemplate> m_block_template;
};