@@ -363,31 +363,26 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
363
363
// Search partial merkle tree in proof for our transaction and index in valid block
364
364
std::vector<uint256> vMatch;
365
365
std::vector<unsigned int > vIndex;
366
- unsigned int txnIndex = 0 ;
367
- Optional<int > height;
368
- if (merkleBlock.txn .ExtractMatches (vMatch, vIndex) == merkleBlock.header .hashMerkleRoot ) {
369
-
370
- auto locked_chain = pwallet->chain ().lock ();
371
- height = locked_chain->getBlockHeight (merkleBlock.header .GetHash ());
372
- if (height == nullopt) {
373
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found in chain" );
374
- }
375
-
376
- std::vector<uint256>::const_iterator it;
377
- if ((it = std::find (vMatch.begin (), vMatch.end (), hashTx))==vMatch.end ()) {
378
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Transaction given doesn't exist in proof" );
379
- }
366
+ if (merkleBlock.txn .ExtractMatches (vMatch, vIndex) != merkleBlock.header .hashMerkleRoot ) {
367
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Something wrong with merkleblock" );
368
+ }
380
369
381
- txnIndex = vIndex[it - vMatch.begin ()];
370
+ auto locked_chain = pwallet->chain ().lock ();
371
+ Optional<int > height = locked_chain->getBlockHeight (merkleBlock.header .GetHash ());
372
+ if (height == nullopt) {
373
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found in chain" );
382
374
}
383
- else {
384
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Something wrong with merkleblock" );
375
+
376
+ std::vector<uint256>::const_iterator it;
377
+ if ((it = std::find (vMatch.begin (), vMatch.end (), hashTx)) == vMatch.end ()) {
378
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Transaction given doesn't exist in proof" );
385
379
}
386
380
381
+ unsigned int txnIndex = vIndex[it - vMatch.begin ()];
382
+
387
383
CWalletTx::Confirmation confirm (CWalletTx::Status::CONFIRMED, *height, merkleBlock.header .GetHash (), txnIndex);
388
384
wtx.m_confirm = confirm;
389
385
390
- auto locked_chain = pwallet->chain ().lock ();
391
386
LOCK (pwallet->cs_wallet );
392
387
393
388
if (pwallet->IsMine (*wtx.tx )) {
0 commit comments