Browse Source

Merge branch 'dev' into dev

pull/119/head
jahway603 2 years ago
parent
commit
9443cd1fa2
  1. 44
      contrib/sdl_checkpoints.pl
  2. 34
      src/rpc/blockchain.cpp
  3. 1
      src/rpc/client.cpp

44
contrib/sdl_checkpoints.pl

@ -0,0 +1,44 @@
#!/usr/bin/perl
# Copyright (c) 2016-2022 The Hush developers
# Distributed under the GPLv3 software license, see the accompanying
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
# This script is used to generate the data used by the silentdragonlite-cli checkpoints.rs file
# https://git.hush.is/hush/silentdragonlite-cli/src/branch/master/lib/src/lightclient/checkpoints.rs#L24
use warnings;
use strict;
my $hush = "./src/hush-cli";
my $gethash = "$hush getblockhash";
my $gettree = "$hush getblockmerkletree";
my $start = shift || 300000;
my $end = shift || 840000;
my $stride = shift || 10000;
my $blocks = qx{$hush getblockcount};
if($?) {
print "ERROR, is hushd running? exiting...\n";
exit 1;
}
if ($end > $blocks) {
print "The block $end is beyond how many blocks this node knows about, exiting...\n";
exit 1;
}
if ($start < 1) {
print "Invalid start block $start, exiting...\n";
exit 1;
}
my $block = $start;
while (1) {
last if $block > $end;
my $blockhash = qx{$gethash $block};
my $merkle = qx{$gettree $block};
chomp $merkle;
chomp $blockhash;
print qq{($block,"$blockhash",\n\t"$merkle"\n),\n};
$block += $stride;
}

34
src/rpc/blockchain.cpp

@ -856,6 +856,39 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp, const CPubKey& mypk
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->hashFinalSaplingRoot;
if( pcoinsTip->GetSaplingAnchorAt(blockRoot, tree) ) {
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << tree;
return HexStr(ss.begin(), ss.end());
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Could not find merkletree");
}
}
UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
@ -1877,6 +1910,7 @@ static const CRPCCommand commands[] =
{ "blockchain", "getblockcount", &getblockcount, true },
{ "blockchain", "getblock", &getblock, true },
{ "blockchain", "getblockhash", &getblockhash, true },
{ "blockchain", "getblockmerkletree", &getblockmerkletree, true },
{ "blockchain", "getblockheader", &getblockheader, true },
{ "blockchain", "getchaintips", &getchaintips, true },
{ "blockchain", "getchaintxstats", &getchaintxstats, true },

1
src/rpc/client.cpp

@ -63,6 +63,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "getbalance", 1 },
{ "getbalance", 2 },
{ "getblockhash", 0 },
{ "getblockmerkletree", 0 },
{ "move", 2 },
{ "move", 3 },
{ "sendfrom", 2 },

Loading…
Cancel
Save