WIP RPC that doesn't quite work yet
This commit is contained in:
@@ -856,6 +856,41 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp, const CPubKey& mypk
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue getblockmerkletree(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
|
{
|
||||||
|
if (fHelp || params.size() != 1 )
|
||||||
|
throw runtime_error(
|
||||||
|
"getblockmerkletree height\n"
|
||||||
|
"\nGet full merkletree for a given Hush or HSC block height.\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. height (int, required) block height\n"
|
||||||
|
"\nResult:\n"
|
||||||
|
"\"hex\" (string) the merkle tree hex encoded\n"
|
||||||
|
+ HelpExampleCli("getblockmerkletree", "290000")
|
||||||
|
+ HelpExampleRpc("getblockmerkletree", "290000")
|
||||||
|
);
|
||||||
|
|
||||||
|
CBlockIndex* phushblockindex;
|
||||||
|
uint256 blockRoot;
|
||||||
|
SaplingMerkleTree tree;
|
||||||
|
|
||||||
|
int nHeight = params[0].get_int();
|
||||||
|
if ( (nHeight < 1) || (nHeight > chainActive.LastTip()->GetHeight()) ) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid Hush or HSC block height parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
phushblockindex = chainActive[nHeight];
|
||||||
|
blockRoot = phushblockindex->pprev->hashFinalSaplingRoot;
|
||||||
|
if( pcoinsTip->GetSaplingAnchorAt(blockRoot, tree) ) {
|
||||||
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
|
ss << tree.path();
|
||||||
|
std::vector<unsigned char> merklepath(ss.begin(), ss.end());
|
||||||
|
//TODO: this returns the same, wrong data for all heights
|
||||||
|
return HexStr(merklepath);
|
||||||
|
} else {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Could not find merkletree");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
@@ -1877,6 +1912,7 @@ static const CRPCCommand commands[] =
|
|||||||
{ "blockchain", "getblockcount", &getblockcount, true },
|
{ "blockchain", "getblockcount", &getblockcount, true },
|
||||||
{ "blockchain", "getblock", &getblock, true },
|
{ "blockchain", "getblock", &getblock, true },
|
||||||
{ "blockchain", "getblockhash", &getblockhash, true },
|
{ "blockchain", "getblockhash", &getblockhash, true },
|
||||||
|
{ "blockchain", "getblockmerkletree", &getblockmerkletree, true },
|
||||||
{ "blockchain", "getblockheader", &getblockheader, true },
|
{ "blockchain", "getblockheader", &getblockheader, true },
|
||||||
{ "blockchain", "getchaintips", &getchaintips, true },
|
{ "blockchain", "getchaintips", &getchaintips, true },
|
||||||
{ "blockchain", "getchaintxstats", &getchaintxstats, true },
|
{ "blockchain", "getchaintxstats", &getchaintxstats, true },
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "getbalance", 1 },
|
{ "getbalance", 1 },
|
||||||
{ "getbalance", 2 },
|
{ "getbalance", 2 },
|
||||||
{ "getblockhash", 0 },
|
{ "getblockhash", 0 },
|
||||||
|
{ "getblockmerkletree", 0 },
|
||||||
{ "move", 2 },
|
{ "move", 2 },
|
||||||
{ "move", 3 },
|
{ "move", 3 },
|
||||||
{ "sendfrom", 2 },
|
{ "sendfrom", 2 },
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ public:
|
|||||||
IncrementalWitness<Depth, Hash> witness() const {
|
IncrementalWitness<Depth, Hash> witness() const {
|
||||||
return IncrementalWitness<Depth, Hash>(*this);
|
return IncrementalWitness<Depth, Hash>(*this);
|
||||||
}
|
}
|
||||||
|
MerklePath path(std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
ADD_SERIALIZE_METHODS;
|
||||||
|
|
||||||
@@ -135,7 +136,6 @@ private:
|
|||||||
|
|
||||||
// Collapsed "left" subtrees ordered toward the root of the tree.
|
// Collapsed "left" subtrees ordered toward the root of the tree.
|
||||||
std::vector<boost::optional<Hash>> parents;
|
std::vector<boost::optional<Hash>> parents;
|
||||||
MerklePath path(std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
|
|
||||||
Hash root(size_t depth, std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
|
Hash root(size_t depth, std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
|
||||||
bool is_complete(size_t depth = Depth) const;
|
bool is_complete(size_t depth = Depth) const;
|
||||||
size_t next_depth(size_t skip) const;
|
size_t next_depth(size_t skip) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user