From f6f3fc8606daa33c70f7da575e399b89bfc558d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 11 Jul 2019 00:06:06 -1100 Subject: [PATCH] Rpcwallet bypass --- src/cc/faucet.cpp | 1 + src/wallet/rpcwallet.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index cf12fae69..25eb5271d 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -221,6 +221,7 @@ std::string FaucetFund(uint64_t txfee,int64_t funds) { CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fe038dc13..76924be44 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -7000,11 +7000,19 @@ UniValue faucetfund(const UniValue& params, bool fHelp) UniValue result(UniValue::VOBJ); int64_t funds; std::string hex; if ( fHelp || params.size() > 1 ) throw runtime_error("faucetfund amount\n"); + funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; + if ( KOMODO_NSPV != 0 ) + { + char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; + cp = CCinit(&C,EVAL_FAUCET); + v = MakeCC1vout(EVAL_FAUCET,funds,GetUnspendable(cp,0)); + Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkey2pk(Mypubkey()))) << OP_CHECKSIG); + return(NSPV_spend(srcaddr,HexStr(v.scriptPubKey.begin(),v.scriptPubKey.end()),funds)); + } if ( ensure_CCrequirements(EVAL_FAUCET) < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - //const CKeyStore& keystore = *pwalletMain; - //LOCK2(cs_main, pwalletMain->cs_wallet); - funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; + const CKeyStore& keystore = *pwalletMain; + LOCK2(cs_main, pwalletMain->cs_wallet); if (funds > 0) { hex = FaucetFund(0,(uint64_t) funds); if ( hex.size() > 0 )