Create generic evalcode CC funds
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
CC *MakeAssetCond(CPubKey pk);
|
CC *MakeAssetCond(CPubKey pk);
|
||||||
CC *MakeFaucetCond(CPubKey pk);
|
//CC *MakeFaucetCond(CPubKey pk);
|
||||||
CC *MakeRewardsCond(CPubKey pk);
|
CC *MakeRewardsCond(CPubKey pk);
|
||||||
|
|
||||||
//BTCD Address: RAssetsAtGnvwgK9gVHBbAU4sVTah1hAm5
|
//BTCD Address: RAssetsAtGnvwgK9gVHBbAU4sVTah1hAm5
|
||||||
@@ -123,7 +123,7 @@ CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv)
|
|||||||
else return(nullpk);
|
else return(nullpk);
|
||||||
}
|
}
|
||||||
|
|
||||||
CC *MakeCC(uint8_t evalcode,CPubKey pk)
|
/*CC *MakeCC(uint8_t evalcode,CPubKey pk)
|
||||||
{
|
{
|
||||||
if ( evalcode == EVAL_ASSETS || evalcode == EVAL_FAUCET || evalcode == EVAL_REWARDS )
|
if ( evalcode == EVAL_ASSETS || evalcode == EVAL_FAUCET || evalcode == EVAL_REWARDS )
|
||||||
{
|
{
|
||||||
@@ -133,7 +133,7 @@ CC *MakeCC(uint8_t evalcode,CPubKey pk)
|
|||||||
CC *Sig = CCNewThreshold(1, pks);
|
CC *Sig = CCNewThreshold(1, pks);
|
||||||
return CCNewThreshold(2, {assetCC, Sig});
|
return CCNewThreshold(2, {assetCC, Sig});
|
||||||
} else return(0);
|
} else return(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
||||||
{
|
{
|
||||||
@@ -152,7 +152,8 @@ bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk)
|
|||||||
}
|
}
|
||||||
else if ( evalcode == EVAL_FAUCET )
|
else if ( evalcode == EVAL_FAUCET )
|
||||||
{
|
{
|
||||||
if ( (payoutCond= MakeFaucetCond(pk)) != 0 )
|
if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 )
|
||||||
|
//if ( (payoutCond= MakeFaucetCond(pk)) != 0 )
|
||||||
{
|
{
|
||||||
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
||||||
cc_free(payoutCond);
|
cc_free(payoutCond);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ extern char FaucetCChexstr[67];
|
|||||||
|
|
||||||
// CCcustom
|
// CCcustom
|
||||||
bool IsFaucetInput(CScript const& scriptSig);
|
bool IsFaucetInput(CScript const& scriptSig);
|
||||||
CC *MakeFaucetCond(CPubKey pk);
|
//CC *MakeFaucetCond(CPubKey pk);
|
||||||
|
|
||||||
std::string FaucetFund(uint64_t txfee,uint64_t funds);
|
std::string FaucetFund(uint64_t txfee,uint64_t funds);
|
||||||
std::string FaucetGet(uint64_t txfee);
|
std::string FaucetGet(uint64_t txfee);
|
||||||
|
|||||||
@@ -37,10 +37,11 @@ static uint256 zeroid;
|
|||||||
|
|
||||||
// CCcustom
|
// CCcustom
|
||||||
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv);
|
CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv);
|
||||||
CC *MakeCC(uint8_t evalcode,CPubKey pk);
|
//CC *MakeCC(uint8_t evalcode,CPubKey pk);
|
||||||
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
|
bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk);
|
||||||
|
|
||||||
// CCutils
|
// CCutils
|
||||||
|
CC *MakeCCcond1(uint8_t evalcode,CPubKey pk);
|
||||||
CC* GetCryptoCondition(CScript const& scriptSig);
|
CC* GetCryptoCondition(CScript const& scriptSig);
|
||||||
bool IsCCInput(CScript const& scriptSig);
|
bool IsCCInput(CScript const& scriptSig);
|
||||||
uint256 revuint256(uint256 txid);
|
uint256 revuint256(uint256 txid);
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ std::string FinalizeCCTx(uint8_t evalcode,CMutableTransaction &mtx,CPubKey mypk,
|
|||||||
Myprivkey(myprivkey);
|
Myprivkey(myprivkey);
|
||||||
unspendablepk = GetUnspendable(evalcode,unspendablepriv);
|
unspendablepk = GetUnspendable(evalcode,unspendablepriv);
|
||||||
GetCCaddress(evalcode,myaddr,mypk);
|
GetCCaddress(evalcode,myaddr,mypk);
|
||||||
mycond = MakeCC(evalcode,mypk);
|
mycond = MakeCCcond1(evalcode,mypk);
|
||||||
GetCCaddress(evalcode,unspendable,unspendablepk);
|
GetCCaddress(evalcode,unspendable,unspendablepk);
|
||||||
othercond = MakeCC(evalcode,unspendablepk);
|
othercond = MakeCCcond1(evalcode,unspendablepk);
|
||||||
//fprintf(stderr,"myCCaddr.(%s) %p vs unspendable.(%s) %p\n",myaddr,mycond,unspendable,othercond);
|
//fprintf(stderr,"myCCaddr.(%s) %p vs unspendable.(%s) %p\n",myaddr,mycond,unspendable,othercond);
|
||||||
memset(utxovalues,0,sizeof(utxovalues));
|
memset(utxovalues,0,sizeof(utxovalues));
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n; i++)
|
||||||
|
|||||||
@@ -19,6 +19,15 @@
|
|||||||
CCutils has low level functions that are universally useful for all contracts.
|
CCutils has low level functions that are universally useful for all contracts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
CC *MakeCCcond1(uint8_t evalcode,CPubKey pk)
|
||||||
|
{
|
||||||
|
std::vector<CC*> pks;
|
||||||
|
pks.push_back(CCNewSecp256k1(pk));
|
||||||
|
CC *condCC = CCNewEval(E_MARSHAL(ss << evalcode));
|
||||||
|
CC *Sig = CCNewThreshold(1, pks);
|
||||||
|
return CCNewThreshold(2, {condCC, Sig});
|
||||||
|
}
|
||||||
|
|
||||||
CC* GetCryptoCondition(CScript const& scriptSig)
|
CC* GetCryptoCondition(CScript const& scriptSig)
|
||||||
{
|
{
|
||||||
auto pc = scriptSig.begin();
|
auto pc = scriptSig.begin();
|
||||||
|
|||||||
@@ -26,19 +26,20 @@
|
|||||||
To implement this, we can simply make any faucet vout fund the faucet. Then we can limit the number of confirmed utxo by combining faucet outputs and then only using utxo which are confirmed. This combined with a vout size limit will drastically limit the funds that can be withdrawn from the faucet.
|
To implement this, we can simply make any faucet vout fund the faucet. Then we can limit the number of confirmed utxo by combining faucet outputs and then only using utxo which are confirmed. This combined with a vout size limit will drastically limit the funds that can be withdrawn from the faucet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CC *MakeFaucetCond(CPubKey pk)
|
/*CC *MakeFaucetCond(CPubKey pk)
|
||||||
{
|
{
|
||||||
std::vector<CC*> pks; uint8_t evalcode = EVAL_FAUCET;
|
std::vector<CC*> pks; uint8_t evalcode = EVAL_FAUCET;
|
||||||
pks.push_back(CCNewSecp256k1(pk));
|
pks.push_back(CCNewSecp256k1(pk));
|
||||||
CC *faucetCC = CCNewEval(E_MARSHAL(ss << evalcode));
|
CC *faucetCC = CCNewEval(E_MARSHAL(ss << evalcode));
|
||||||
CC *Sig = CCNewThreshold(1, pks);
|
CC *Sig = CCNewThreshold(1, pks);
|
||||||
return CCNewThreshold(2, {faucetCC, Sig});
|
return CCNewThreshold(2, {faucetCC, Sig});
|
||||||
}
|
}*/
|
||||||
|
|
||||||
CTxOut MakeFaucetVout(CAmount nValue,CPubKey pk)
|
CTxOut MakeFaucetVout(CAmount nValue,CPubKey pk)
|
||||||
{
|
{
|
||||||
CTxOut vout;
|
CTxOut vout;
|
||||||
CC *payoutCond = MakeFaucetCond(pk);
|
//CC *payoutCond = MakeFaucetCond(pk);
|
||||||
|
CC *payoutCond = MakeCCcond1(EVAL_FAUCET,pk);
|
||||||
vout = CTxOut(nValue,CCPubKey(payoutCond));
|
vout = CTxOut(nValue,CCPubKey(payoutCond));
|
||||||
cc_free(payoutCond);
|
cc_free(payoutCond);
|
||||||
return(vout);
|
return(vout);
|
||||||
|
|||||||
Reference in New Issue
Block a user