diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-06-14 15:36:56 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-06-14 15:48:52 +0200 |
| commit | c94b89e90d6af3911f581addd8767466bc74a564 (patch) | |
| tree | 8dd78f45a6d151472c634a9274231019aeb64d9f /src/rpc/rawtransaction.cpp | |
| parent | Merge #10551: [Tests] Wallet encryption functional tests (diff) | |
| parent | gettxoutproof() should return consistent result (diff) | |
| download | discoin-c94b89e90d6af3911f581addd8767466bc74a564.tar.xz discoin-c94b89e90d6af3911f581addd8767466bc74a564.zip | |
Merge #9738: gettxoutproof() should return consistent result
6294f32 gettxoutproof() should return consistent result (John Newbery)
Tree-SHA512: 1c36f78ea07a3bdde09e9494207b4372d54bcd94ed2d56e339e78281f6693e26a93e4c3123453d5c0f6e994d0069d5a1c806786c4af71864f87ea4841611c379
Diffstat (limited to 'src/rpc/rawtransaction.cpp')
| -rw-r--r-- | src/rpc/rawtransaction.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 42f3762bf..527a4d697 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -218,9 +218,13 @@ UniValue gettxoutproof(const JSONRPCRequest& request) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); pblockindex = mapBlockIndex[hashBlock]; } else { - const Coin& coin = AccessByTxid(*pcoinsTip, oneTxid); - if (!coin.IsSpent() && coin.nHeight > 0 && coin.nHeight <= chainActive.Height()) { - pblockindex = chainActive[coin.nHeight]; + // Loop through txids and try to find which block they're in. Exit loop once a block is found. + for (const auto& tx : setTxids) { + const Coin& coin = AccessByTxid(*pcoinsTip, tx); + if (!coin.IsSpent()) { + pblockindex = chainActive[coin.nHeight]; + break; + } } } @@ -243,7 +247,7 @@ UniValue gettxoutproof(const JSONRPCRequest& request) if (setTxids.count(tx->GetHash())) ntxFound++; if (ntxFound != setTxids.size()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "(Not all) transactions not found in specified block"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Not all transactions found in specified or retrieved block"); CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); CMerkleBlock mb(block, setTxids); |