diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index f78d47031..0b4dd5578 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -31,7 +31,7 @@ extern char AssetsCChexstr[67]; bool IsAssetsInput(CScript const& scriptSig); // CCassetsCore -CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); +//CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk); CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description); CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,uint64_t price,std::vector origpubkey); uint8_t DecodeAssetOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &assetid2,uint64_t &price,std::vector &origpubkey); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index 65f537089..16422bc3b 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -97,7 +97,7 @@ bool SetAssetFillamounts(int32_t sellflag,uint64_t &received_nValue,uint64_t &re } else return(false); } -CC *MakeAssetCond(CPubKey pk) +/*CC *MakeAssetCond(CPubKey pk) { std::vector pks; uint8_t evalcode = EVAL_ASSETS; pks.push_back(CCNewSecp256k1(pk)); @@ -109,11 +109,11 @@ CC *MakeAssetCond(CPubKey pk) CTxOut MakeAssetsVout(CAmount nValue,CPubKey pk) { CTxOut vout; - CC *payoutCond = MakeAssetCond(pk); + CC *payoutCond = MakeCCcond1(EVAL_ASSETS,pk); vout = CTxOut(nValue,CCPubKey(payoutCond)); cc_free(payoutCond); return(vout); -} +}*/ CScript EncodeAssetCreateOpRet(uint8_t funcid,std::vector origpubkey,std::string name,std::string description) { diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index 7c290ff56..29fb299c0 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -104,7 +104,7 @@ std::string CreateAsset(uint64_t txfee,uint64_t assetsupply,std::string name,std mypk = pubkey2pk(Mypubkey()); if ( AddNormalinputs(mtx,mypk,assetsupply+2*txfee,64) > 0 ) { - mtx.vout.push_back(MakeAssetsVout(assetsupply,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,assetsupply,mypk)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(AssetsCChexstr) << OP_CHECKSIG)); return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeAssetCreateOpRet('c',Mypubkey(),name,description))); } @@ -129,9 +129,9 @@ std::string AssetTransfer(uint64_t txfee,uint256 assetid,std::vector de if ( inputs > total ) CCchange = (inputs - total); //for (i=0; i 0 ) { - mtx.vout.push_back(MakeAssetsVout(bidamount,GetUnspendable(EVAL_ASSETS,0))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,bidamount,GetUnspendable(EVAL_ASSETS,0))); return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeAssetOpRet('b',assetid,zeroid,pricetotal,Mypubkey()))); } return(0); @@ -163,11 +163,11 @@ std::string CreateSell(uint64_t txfee,uint64_t askamount,uint256 assetid,uint256 { if ( (inputs= AddAssetInputs(mtx,mypk,assetid,askamount,60)) > 0 ) { - mtx.vout.push_back(MakeAssetsVout(askamount,GetUnspendable(EVAL_ASSETS,0))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount,GetUnspendable(EVAL_ASSETS,0))); if ( inputs > askamount ) CCchange = (inputs - askamount); if ( CCchange != 0 ) - mtx.vout.push_back(MakeAssetsVout(CCchange,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); if ( assetid2 == zeroid ) opret = EncodeAssetOpRet('s',assetid,zeroid,pricetotal,Mypubkey()); else opret = EncodeAssetOpRet('e',assetid,assetid2,pricetotal,Mypubkey()); @@ -208,7 +208,7 @@ std::string CancelSell(uint64_t txfee,uint256 assetid,uint256 asktxid) { askamount = vintx.vout[0].nValue; mtx.vin.push_back(CTxIn(asktxid,0,CScript())); - mtx.vout.push_back(MakeAssetsVout(askamount,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount,mypk)); return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeAssetOpRet('x',assetid,zeroid,0,Mypubkey()))); } } @@ -233,11 +233,11 @@ std::string FillBuyOffer(uint64_t txfee,uint256 assetid,uint256 bidtxid,uint64_t if ( inputs > fillamount ) CCchange = (inputs - fillamount); SetAssetFillamounts(0,paid_amount,remaining_required,bidamount,fillamount,origprice); - mtx.vout.push_back(MakeAssetsVout(bidamount - paid_amount,GetUnspendable(EVAL_ASSETS,0))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,bidamount - paid_amount,GetUnspendable(EVAL_ASSETS,0))); mtx.vout.push_back(CTxOut(paid_amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); - mtx.vout.push_back(MakeAssetsVout(fillamount,pubkey2pk(origpubkey))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,fillamount,pubkey2pk(origpubkey))); if ( CCchange != 0 ) - mtx.vout.push_back(MakeAssetsVout(CCchange,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); fprintf(stderr,"remaining %llu -> origpubkey\n",(long long)remaining_required); return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeAssetOpRet('B',assetid,zeroid,remaining_required,origpubkey))); } else fprintf(stderr,"filltx wasnt for assetid\n"); @@ -267,11 +267,11 @@ std::string FillSell(uint64_t txfee,uint256 assetid,uint256 assetid2,uint256 ask if ( assetid2 == zeroid && inputs > fillamount ) CCchange = (inputs - fillamount); SetAssetFillamounts(1,paid_amount,remaining_required,askamount,fillamount,totalunits); - mtx.vout.push_back(MakeAssetsVout(askamount - paid_amount,GetUnspendable(EVAL_ASSETS,0))); - mtx.vout.push_back(MakeAssetsVout(paid_amount,mypk)); - mtx.vout.push_back(MakeAssetsVout(fillamount,pubkey2pk(origpubkey))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount - paid_amount,GetUnspendable(EVAL_ASSETS,0))); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,paid_amount,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,fillamount,pubkey2pk(origpubkey))); if ( CCchange != 0 ) - mtx.vout.push_back(MakeAssetsVout(CCchange,mypk)); + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); fprintf(stderr,"remaining %llu -> origpubkey\n",(long long)remaining_required); return(FinalizeCCTx(EVAL_ASSETS,mtx,mypk,txfee,EncodeAssetOpRet(assetid2==zeroid?'E':'S',assetid,assetid2,remaining_required,origpubkey))); } else fprintf(stderr,"filltx not enough utxos\n"); diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index a3fdef385..f627a5537 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -26,9 +26,9 @@ This allows creation of a special address(es) for each contract type, which has the privkey public. That allows anybody to properly sign and spend it, but with the constraints on what is allowed in the validation code, the contract functionality can be implemented. */ -CC *MakeAssetCond(CPubKey pk); +//CC *MakeAssetCond(CPubKey pk); //CC *MakeFaucetCond(CPubKey pk); -CC *MakeRewardsCond(CPubKey pk); +//CC *MakeRewardsCond(CPubKey pk); //BTCD Address: RAssetsAtGnvwgK9gVHBbAU4sVTah1hAm5 //BTCD Privkey: UvtvQVgVScXEYm4J3r4nE4nbFuGXSVM5pKec8VWXwgG9dmpWBuDh @@ -143,7 +143,7 @@ bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk) pk = GetUnspendable(evalcode,0); if ( evalcode == EVAL_ASSETS ) { - if ( (payoutCond= MakeAssetCond(pk)) != 0 ) + if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 ) { Getscriptaddress(destaddr,CCPubKey(payoutCond)); cc_free(payoutCond); @@ -162,7 +162,7 @@ bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk) } else if ( evalcode == EVAL_REWARDS ) { - if ( (payoutCond= MakeRewardsCond(pk)) != 0 ) + if ( (payoutCond= MakeCCcond1(evalcode,pk)) != 0 ) { Getscriptaddress(destaddr,CCPubKey(payoutCond)); cc_free(payoutCond); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 1573deca2..f5f7e9a01 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -41,6 +41,7 @@ CPubKey GetUnspendable(uint8_t evalcode,uint8_t *unspendablepriv); bool GetCCaddress(uint8_t evalcode,char *destaddr,CPubKey pk); // CCutils +CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk); CC *MakeCCcond1(uint8_t evalcode,CPubKey pk); CC* GetCryptoCondition(CScript const& scriptSig); bool IsCCInput(CScript const& scriptSig); diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 4a0d4c72a..e65b8dc29 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -19,6 +19,15 @@ CCutils has low level functions that are universally useful for all contracts. */ +CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk) +{ + CTxOut vout; + CC *payoutCond = MakeCCcond1(evalcode,pk); + vout = CTxOut(nValue,CCPubKey(payoutCond)); + cc_free(payoutCond); + return(vout); +} + CC *MakeCCcond1(uint8_t evalcode,CPubKey pk) { std::vector pks; diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 778e2293b..c50d6252f 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -33,7 +33,7 @@ CC *faucetCC = CCNewEval(E_MARSHAL(ss << evalcode)); CC *Sig = CCNewThreshold(1, pks); return CCNewThreshold(2, {faucetCC, Sig}); -}*/ +} CTxOut MakeFaucetVout(CAmount nValue,CPubKey pk) { @@ -43,7 +43,7 @@ CTxOut MakeFaucetVout(CAmount nValue,CPubKey pk) vout = CTxOut(nValue,CCPubKey(payoutCond)); cc_free(payoutCond); return(vout); -} +}*/ uint64_t IsFaucetvout(const CTransaction& tx,int32_t v) { @@ -186,7 +186,7 @@ std::string FaucetFund(uint64_t txfee,uint64_t funds) faucetpk = GetUnspendable(EVAL_FAUCET,0); if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) { - mtx.vout.push_back(MakeFaucetVout(funds,faucetpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,funds,faucetpk)); return(FinalizeCCTx(EVAL_FAUCET,mtx,mypk,txfee,opret)); } return(0); @@ -204,7 +204,7 @@ std::string FaucetGet(uint64_t txfee) if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); if ( CCchange != 0 ) - mtx.vout.push_back(MakeFaucetVout(CCchange,faucetpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_FAUCET,CCchange,faucetpk)); mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); return(FinalizeCCTx(EVAL_FAUCET,mtx,mypk,txfee,opret)); } else fprintf(stderr,"cant find faucet inputs\n"); diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index b4e931821..5253035ac 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -28,7 +28,7 @@ uint64_t RewardsCalc(uint64_t claim,uint256 txid) return(reward); } -CC *MakeRewardsCond(CPubKey pk) +/*CC *MakeRewardsCond(CPubKey pk) { std::vector pks; uint8_t evalcode = EVAL_REWARDS; pks.push_back(CCNewSecp256k1(pk)); @@ -40,11 +40,11 @@ CC *MakeRewardsCond(CPubKey pk) CTxOut MakeRewardsVout(CAmount nValue,CPubKey pk) { CTxOut vout; - CC *payoutCond = MakeRewardsCond(pk); + CC *payoutCond = MakeCCcond1(EVAL_REWARDS,pk); vout = CTxOut(nValue,CCPubKey(payoutCond)); cc_free(payoutCond); return(vout); -} +}*/ uint64_t IsRewardsvout(const CTransaction& tx,int32_t v) { @@ -183,7 +183,7 @@ std::string RewardsFund(uint64_t txfee,uint64_t funds,uint64_t APR,uint64_t mins rewardspk = GetUnspendable(EVAL_REWARDS,0); if ( AddNormalinputs(mtx,mypk,funds+2*txfee,64) > 0 ) { - mtx.vout.push_back(MakeRewardsVout(funds,rewardspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_REWARDS,funds,rewardspk)); mtx.vout.push_back(CTxOut(APR,CScript() << ParseHex(HexStr(rewardspk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(minseconds,CScript() << ParseHex(HexStr(rewardspk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(maxseconds,CScript() << ParseHex(HexStr(rewardspk)) << OP_CHECKSIG)); @@ -202,7 +202,7 @@ std::string RewardsLock(uint64_t txfee,uint64_t amount) mypk = pubkey2pk(Mypubkey()); if ( AddNormalinputs(mtx,mypk,amount+2*txfee,64) > 0 ) { - mtx.vout.push_back(MakeRewardsVout(amount,rewardspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_REWARDS,amount,rewardspk)); // specify destination pubkey, funding txid //opret = ;// return(FinalizeCCTx(EVAL_REWARDS,mtx,mypk,txfee,opret)); @@ -224,7 +224,7 @@ std::string RewardsUnlock(uint64_t txfee) if ( inputs > (reward+txfee) ) CCchange = (inputs - reward - txfee); if ( CCchange != 0 ) - mtx.vout.push_back(MakeRewardsVout(CCchange,rewardspk)); + mtx.vout.push_back(MakeCC1vout(EVAL_REWARDS,CCchange,rewardspk)); mtx.vout.push_back(CTxOut(claim+reward,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); return(FinalizeCCTx(EVAL_REWARDS,mtx,mypk,txfee,opret)); }