rpc: extend error-on-failure to GetSpentIndex

This commit is contained in:
Kittywhiskers Van Gogh 2024-06-26 18:25:19 +00:00
parent 9a6503d9e8
commit 488f0474a8
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -14,10 +14,10 @@ bool GetAddressIndex(const uint160& addressHash, const AddressType type,
const int32_t start, const int32_t end) const int32_t start, const int32_t end)
{ {
if (!fAddressIndex) if (!fAddressIndex)
return error("address index not enabled"); return error("Address index not enabled");
if (!pblocktree->ReadAddressIndex(addressHash, type, addressIndex, start, end)) if (!pblocktree->ReadAddressIndex(addressHash, type, addressIndex, start, end))
return error("unable to get txids for address"); return error("Unable to get txids for address");
return true; return true;
} }
@ -26,10 +26,10 @@ bool GetAddressUnspentIndex(const uint160& addressHash, const AddressType type,
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs) std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>>& unspentOutputs)
{ {
if (!fAddressIndex) if (!fAddressIndex)
return error("address index not enabled"); return error("Address index not enabled");
if (!pblocktree->ReadAddressUnspentIndex(addressHash, type, unspentOutputs)) if (!pblocktree->ReadAddressUnspentIndex(addressHash, type, unspentOutputs))
return error("unable to get txids for address"); return error("Unable to get txids for address");
return true; return true;
} }
@ -37,13 +37,13 @@ bool GetAddressUnspentIndex(const uint160& addressHash, const AddressType type,
bool GetSpentIndex(const CTxMemPool& mempool, const CSpentIndexKey& key, CSpentIndexValue& value) bool GetSpentIndex(const CTxMemPool& mempool, const CSpentIndexKey& key, CSpentIndexValue& value)
{ {
if (!fSpentIndex) if (!fSpentIndex)
return false; return error("Spent index not enabled");
if (mempool.getSpentIndex(key, value)) if (mempool.getSpentIndex(key, value))
return true; return true;
if (!pblocktree->ReadSpentIndex(key, value)) if (!pblocktree->ReadSpentIndex(key, value))
return false; return error("Unable to get spend information");
return true; return true;
} }