|
|
@ -290,7 +290,7 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) |
|
|
|
"\nArguments:\n" |
|
|
|
"\nArguments:\n" |
|
|
|
"1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" |
|
|
|
"1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" |
|
|
|
"\nResult:\n" |
|
|
|
"\nResult:\n" |
|
|
|
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" |
|
|
|
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof can not be validated.\n" |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); |
|
|
|
CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); |
|
|
@ -306,11 +306,16 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) |
|
|
|
|
|
|
|
|
|
|
|
LOCK(cs_main); |
|
|
|
LOCK(cs_main); |
|
|
|
|
|
|
|
|
|
|
|
if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()])) |
|
|
|
if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]) || mapBlockIndex[merkleBlock.header.GetHash()]->nTx == 0) |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); |
|
|
|
|
|
|
|
|
|
|
|
for (const uint256& hash : vMatch) |
|
|
|
// Check if proof is valid, only add results if so
|
|
|
|
|
|
|
|
if (mapBlockIndex[merkleBlock.header.GetHash()]->nTx == merkleBlock.txn.GetNumTransactions()) { |
|
|
|
|
|
|
|
for (const uint256& hash : vMatch) { |
|
|
|
res.push_back(hash.GetHex()); |
|
|
|
res.push_back(hash.GetHex()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|