From 47b4875ef050c4a41bd04398021af8d605415cab Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Fri, 12 Jul 2024 16:08:38 +0200 Subject: [PATCH] Add getCoinbaseMerklePath() to Mining interface --- src/interfaces/mining.h | 7 +++++++ src/ipc/capnp/mining.capnp | 1 + src/node/interfaces.cpp | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h index 421c5ba762..209b629aaf 100644 --- a/src/interfaces/mining.h +++ b/src/interfaces/mining.h @@ -42,6 +42,13 @@ public: virtual CTransactionRef getCoinbaseTx() = 0; virtual std::vector getCoinbaseCommitment() = 0; virtual int getWitnessCommitmentIndex() = 0; + + /** + * Compute merkle path to the coinbase transaction + * + * @return merkle path ordered from the deepest + */ + virtual std::vector getCoinbaseMerklePath() = 0; }; //! Interface giving clients (RPC, Stratum v2 Template Provider in the future) diff --git a/src/ipc/capnp/mining.capnp b/src/ipc/capnp/mining.capnp index 4ea69d16c9..fe7b125efa 100644 --- a/src/ipc/capnp/mining.capnp +++ b/src/ipc/capnp/mining.capnp @@ -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") { diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 1fedcd6cfa..8ed06bd00d 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -910,6 +911,11 @@ public: return GetWitnessCommitmentIndex(m_block_template->block); } + std::vector getCoinbaseMerklePath() override + { + return BlockMerkleBranch(m_block_template->block); + } + const std::unique_ptr m_block_template; };