Skip to content

Commit 47b4875

Browse files
committed
Add getCoinbaseMerklePath() to Mining interface
1 parent 63d6ad7 commit 47b4875

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/interfaces/mining.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ class BlockTemplate
4242
virtual CTransactionRef getCoinbaseTx() = 0;
4343
virtual std::vector<unsigned char> getCoinbaseCommitment() = 0;
4444
virtual int getWitnessCommitmentIndex() = 0;
45+
46+
/**
47+
* Compute merkle path to the coinbase transaction
48+
*
49+
* @return merkle path ordered from the deepest
50+
*/
51+
virtual std::vector<uint256> getCoinbaseMerklePath() = 0;
4552
};
4653

4754
//! Interface giving clients (RPC, Stratum v2 Template Provider in the future)

src/ipc/capnp/mining.capnp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {
3131
getCoinbaseTx @4 (context: Proxy.Context) -> (result: Data);
3232
getCoinbaseCommitment @5 (context: Proxy.Context) -> (result: Data);
3333
getWitnessCommitmentIndex @6 (context: Proxy.Context) -> (result: Int32);
34+
getCoinbaseMerklePath @7 (context: Proxy.Context) -> (result: List(Data));
3435
}
3536

3637
struct BlockCreateOptions $Proxy.wrap("node::BlockCreateOptions") {

src/node/interfaces.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <chain.h>
99
#include <chainparams.h>
1010
#include <common/args.h>
11+
#include <consensus/merkle.h>
1112
#include <consensus/validation.h>
1213
#include <deploymentstatus.h>
1314
#include <external_signer.h>
@@ -910,6 +911,11 @@ class BlockTemplateImpl : public BlockTemplate
910911
return GetWitnessCommitmentIndex(m_block_template->block);
911912
}
912913

914+
std::vector<uint256> getCoinbaseMerklePath() override
915+
{
916+
return BlockMerkleBranch(m_block_template->block);
917+
}
918+
913919
const std::unique_ptr<CBlockTemplate> m_block_template;
914920
};
915921

0 commit comments

Comments
 (0)