mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 01:33:20 +02:00
Add block_height field in struct Confirmation
At wallet loading, we rely on chain state querying to retrieve height of txn, to do so we ensure that lock order is respected between cs_main and cs_wallet. If wallet loaded is the wallet-tool one, all wallet txn will show up with a height of zero. It doesn't matter as confirmation height is not used by wallet-tool. Reorder arguments and document Confirmation calls to avoid ambiguity. Fixes nits left from #16624
This commit is contained in:
@@ -364,10 +364,12 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
|
||||
std::vector<uint256> vMatch;
|
||||
std::vector<unsigned int> vIndex;
|
||||
unsigned int txnIndex = 0;
|
||||
Optional<int> height;
|
||||
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) == merkleBlock.header.hashMerkleRoot) {
|
||||
|
||||
auto locked_chain = pwallet->chain().lock();
|
||||
if (locked_chain->getBlockHeight(merkleBlock.header.GetHash()) == nullopt) {
|
||||
height = locked_chain->getBlockHeight(merkleBlock.header.GetHash());
|
||||
if (height == nullopt) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
|
||||
}
|
||||
|
||||
@@ -382,7 +384,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Something wrong with merkleblock");
|
||||
}
|
||||
|
||||
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, merkleBlock.header.GetHash(), txnIndex);
|
||||
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, *height, merkleBlock.header.GetHash(), txnIndex);
|
||||
wtx.m_confirm = confirm;
|
||||
|
||||
auto locked_chain = pwallet->chain().lock();
|
||||
|
||||
Reference in New Issue
Block a user