Faucet
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user