This commit is contained in:
jl777
2018-07-23 06:02:25 -11:00
parent 3f030864cd
commit 6ff08712db
3 changed files with 23 additions and 0 deletions

View File

@@ -347,6 +347,7 @@ static const CRPCCommand vRPCCommands[] =
/* faucet */
{ "faucet", "faucetfund", &faucetfund, true },
{ "faucet", "faucetget", &faucetget, true },
{ "faucet", "faucetaddress", &faucetaddress, true },
/* tokens */
{ "tokens", "tokenorders", &tokenorders, true },

View File

@@ -223,6 +223,7 @@ extern UniValue tokenswapask(const UniValue& params, bool fHelp);
extern UniValue tokenfillswap(const UniValue& params, bool fHelp);
extern UniValue faucetfund(const UniValue& params, bool fHelp);
extern UniValue faucetget(const UniValue& params, bool fHelp);
UniValue faucetaddress(const UniValue& params, bool fHelp);
extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp
//extern UniValue getnewaddress64(const UniValue& params, bool fHelp); // in rpcwallet.cpp

View File

@@ -4842,6 +4842,27 @@ int32_t ensure_CCrequirements()
#include "../cc/CCfaucet.h"
UniValue faucetaddress(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::vector<unsigned char> pubkey; char destaddr[64];
if ( fHelp || params.size() > 1 )
throw runtime_error("faucetaddress [pubkey]\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
result.push_back(Pair("result", "success"));
if ( GetCCaddress(FAUCET_ASSETS,destaddr,pubkey2pk(pubkey)) != 0 )
result.push_back(Pair("AssetsCCaddress",destaddr));
if ( params.size() == 1 )
{
pubkey = ParseHex(params[0].get_str().c_str());
if ( GetCCaddress(FAUCET_ASSETS,destaddr,pubkey2pk(pubkey)) != 0 )
result.push_back(Pair("CCaddress",destaddr));
}
if ( GetCCaddress(FAUCET_ASSETS,destaddr,pubkey2pk(Mypubkey())) != 0 )
result.push_back(Pair("myCCaddress",destaddr));
return(result);
}
UniValue faucetfund(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); uint64_t funds; std::string hex;