diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -119,6 +119,9 @@ //! Get num blocks. virtual int getNumBlocks() = 0; + //! Get best block hash. + virtual BlockHash getBestBlockHash() = 0; + //! Get last block time. virtual int64_t getLastBlockTime() = 0; @@ -236,16 +239,16 @@ handleBannedListChanged(BannedListChangedFn fn) = 0; //! Register handler for block tip messages. - using NotifyBlockTipFn = - std::function; + using NotifyBlockTipFn = std::function; virtual std::unique_ptr handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; //! Register handler for header tip messages. - using NotifyHeaderTipFn = - std::function; + using NotifyHeaderTipFn = std::function; virtual std::unique_ptr handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -193,6 +193,12 @@ LOCK(::cs_main); return ::ChainActive().Height(); } + BlockHash getBestBlockHash() override { + const CBlockIndex *tip = + WITH_LOCK(::cs_main, return ::ChainActive().Tip()); + return tip ? tip->GetBlockHash() + : Params().GenesisBlock().GetHash(); + } int64_t getLastBlockTime() override { LOCK(::cs_main); if (::ChainActive().Tip()) { @@ -323,7 +329,8 @@ return MakeHandler(::uiInterface.NotifyBlockTip_connect( [fn](SynchronizationState sync_state, const CBlockIndex *block) { - fn(sync_state, block->nHeight, block->GetBlockTime(), + fn(sync_state, block->GetBlockHash(), block->nHeight, + block->GetBlockTime(), GuessVerificationProgress(Params().TxData(), block)); })); } @@ -333,7 +340,8 @@ return MakeHandler(::uiInterface.NotifyHeaderTip_connect( [fn](SynchronizationState sync_state, const CBlockIndex *block) { - fn(sync_state, block->nHeight, block->GetBlockTime(), 0); + fn(sync_state, block->GetBlockHash(), block->nHeight, + block->GetBlockTime(), 0); })); } NodeContext *context() override { return m_context; } diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -5,7 +5,8 @@ #ifndef BITCOIN_INTERFACES_WALLET_H #define BITCOIN_INTERFACES_WALLET_H -#include // For Amount +#include // For Amount +#include #include // For CTxOut #include // For CKeyID and CScriptID (definitions needed in CTxDestination instantiation) #include