This commit is contained in:
jl777
2018-07-22 13:06:46 -11:00
parent 1659202766
commit 65a961ff06
8 changed files with 81 additions and 6 deletions

View File

@@ -111,3 +111,38 @@ bool ProcessFaucet(Eval* eval, std::vector<uint8_t> paramsNull,const CTransactio
return(true);
} else return(false);
}
std::string FaucetFund(uint64_t txfee,uint64_t funds)
{
CMutableTransaction mtx; CPubKey mypk,faucetpk; CScript opret;
if ( txfee == 0 )
txfee = 10000;
mypk = pubkey2pk(Mypubkey());
faucetpk = GetUnspendable(EVAL_FAUCET,0);
if ( AddNormalinputs(mtx,mypk,funds+2*txfee,64) > 0 )
{
mtx.vout.push_back(MakeFaucetVout(funds,faucetpk));
return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,opret));
}
return(0);
}
std::string FaucetGet(uint64_t txfee)
{
CMutableTransaction mtx; CPubKey mypk,faucetpk; CScript opret; uint64_t inputs,CCchange=0,nValue=COIN;
if ( txfee == 0 )
txfee = 10000;
faucetpk = GetUnspendable(EVAL_FAUCET,0);
mypk = pubkey2pk(Mypubkey());
if ( (inputs= AddFaucetInputs(mtx,faucetpk,nValue+txfee,60)) > 0 )
{
if ( inputs > nValue )
CCchange = (inputs - nValue - txfee);
if ( CCchange != 0 )
mtx.vout.push_back(MakeFaucetVout(CCchange,faucetpk));
mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,opret));
}
return(0);
}