From 7eaff5d90a579c3359d4abf83f309a1a62736d8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 27 Nov 2018 08:31:51 -1100 Subject: [PATCH 01/49] Possible fix for sapling CC --- src/cc/CCinclude.h | 1 + src/cc/faucet.cpp | 3 ++- src/komodo_bitcoind.h | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 5cf549706..ddfecd47a 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -105,6 +105,7 @@ extern CWallet* pwalletMain; #endif bool GetAddressUnspent(uint160 addressHash, int type,std::vector > &unspentOutputs); CBlockIndex *komodo_getblockindex(uint256 hash); +int32_t komodo_nextheight(); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index baa32b856..ed457f234 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -214,7 +214,8 @@ std::string FaucetGet(uint64_t txfee) std::string FaucetFund(uint64_t txfee,int64_t funds) { - CMutableTransaction mtx; CPubKey mypk,faucetpk; CScript opret; struct CCcontract_info *cp,C; + 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/komodo_bitcoind.h b/src/komodo_bitcoind.h index 943c8c413..53c4afb08 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1062,6 +1062,14 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 return(0); } +int32_t komodo_nextheight() +{ + int32_t longest = komodo_longestchain(); + if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) >= longest ) + return(ht+1); + else return(longest + 1); +} + int32_t komodo_isrealtime(int32_t *kmdheightp) { struct komodo_state *sp; CBlockIndex *pindex; From 7d69cacf371991dc7bad9dcd9d53f81731f853d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 27 Nov 2018 08:36:05 -1100 Subject: [PATCH 02/49] Ht --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 53c4afb08..34bd7e514 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1064,7 +1064,7 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_nextheight() { - int32_t longest = komodo_longestchain(); + int32_t ht,longest = komodo_longestchain(); if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) >= longest ) return(ht+1); else return(longest + 1); From 561a4a15ebe5b4e39d977bb619ebaef2ee659ef8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 27 Nov 2018 08:37:10 -1100 Subject: [PATCH 03/49] CBlockIndex *pindex; --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 34bd7e514..1a0fad409 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1064,7 +1064,7 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_nextheight() { - int32_t ht,longest = komodo_longestchain(); + CBlockIndex *pindex; int32_t ht,longest = komodo_longestchain(); if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) >= longest ) return(ht+1); else return(longest + 1); From a0e51c46b16c52726dfa4bd8b541c951c855c1ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 27 Nov 2018 23:00:15 -1100 Subject: [PATCH 04/49] Sapling CC tx support --- src/cc/CCassetstx.cpp | 33 ++++++++++++++++++++++----------- src/cc/auction.cpp | 9 ++++++--- src/cc/betprotocol.cpp | 12 ++++++------ src/cc/channels.cpp | 12 ++++++++---- src/cc/dice.cpp | 12 ++++++++---- src/cc/faucet.cpp | 6 ++++-- src/cc/fsm.cpp | 6 ++++-- src/cc/gateways.cpp | 24 ++++++++++++++++-------- src/cc/heir.cpp | 9 ++++++--- src/cc/lotto.cpp | 9 ++++++--- src/cc/oracles.cpp | 15 ++++++++++----- src/cc/payments.cpp | 9 ++++++--- src/cc/pegs.cpp | 9 ++++++--- src/cc/prices.cpp | 9 ++++++--- src/cc/rewards.cpp | 12 ++++++++---- src/cc/triggers.cpp | 9 ++++++--- 16 files changed, 128 insertions(+), 67 deletions(-) diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index b374f00d4..ef208f87c 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -56,7 +56,8 @@ int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK int64_t GetAssetBalance(CPubKey pk,uint256 tokenid) { - CMutableTransaction mtx; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_ASSETS); return(AddAssetInputs(cp,mtx,pk,tokenid,0,0)); } @@ -186,7 +187,8 @@ UniValue AssetOrders(uint256 refassetid) std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std::string description) { - CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; struct CCcontract_info *cp,C; if ( assetsupply < 0 ) { fprintf(stderr,"negative assetsupply %lld\n",(long long)assetsupply); @@ -212,7 +214,8 @@ std::string CreateAsset(int64_t txfee,int64_t assetsupply,std::string name,std:: std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total) { - CMutableTransaction mtx; CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; uint64_t mask; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; if ( total < 0 ) { fprintf(stderr,"negative total %lld\n",(long long)total); @@ -247,7 +250,8 @@ std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector des std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector destpubkey,int64_t total,int32_t evalcode) { - CMutableTransaction mtx; CPubKey mypk; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; int64_t CCchange=0,inputs=0; struct CCcontract_info *cp,C; if ( total < 0 ) { fprintf(stderr,"negative total %lld\n",(long long)total); @@ -273,7 +277,8 @@ std::string AssetConvert(int64_t txfee,uint256 assetid,std::vector dest std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64_t pricetotal) { - CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; uint256 hashBlock; CTransaction vintx; std::vector origpubkey; std::string name,description; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; struct CCcontract_info *cp,C; uint256 hashBlock; CTransaction vintx; std::vector origpubkey; std::string name,description; if ( bidamount < 0 || pricetotal < 0 ) { fprintf(stderr,"negative bidamount %lld, pricetotal %lld\n",(long long)bidamount,(long long)pricetotal); @@ -303,7 +308,8 @@ std::string CreateBuyOffer(int64_t txfee,int64_t bidamount,uint256 assetid,int64 std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t pricetotal) { - CMutableTransaction mtx; CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; if ( askamount < 0 || pricetotal < 0 ) { fprintf(stderr,"negative askamount %lld, askamount %lld\n",(long long)pricetotal,(long long)askamount); @@ -335,7 +341,8 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 assetid2,int64_t pricetotal) { - CMutableTransaction mtx; CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; uint64_t mask; int64_t inputs,CCchange; CScript opret; struct CCcontract_info *cp,C; fprintf(stderr,"asset swaps disabled\n"); return(""); if ( askamount < 0 || pricetotal < 0 ) @@ -374,7 +381,8 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) { - CMutableTransaction mtx; CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t bidamount; CPubKey mypk; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t bidamount; CPubKey mypk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_ASSETS); if ( txfee == 0 ) txfee = 10000; @@ -395,7 +403,8 @@ std::string CancelBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid) std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) { - CMutableTransaction mtx; CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction vintx; uint64_t mask; uint256 hashBlock; int64_t askamount; CPubKey mypk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_ASSETS); if ( txfee == 0 ) txfee = 10000; @@ -416,7 +425,8 @@ std::string CancelSell(int64_t txfee,uint256 assetid,uint256 asktxid) std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t fillamount) { - CTransaction vintx; uint256 hashBlock; CMutableTransaction mtx; CPubKey mypk; std::vector origpubkey; int32_t bidvout=0; uint64_t mask; int64_t origprice,bidamount,paid_amount,remaining_required,inputs,CCchange=0; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction vintx; uint256 hashBlock; CPubKey mypk; std::vector origpubkey; int32_t bidvout=0; uint64_t mask; int64_t origprice,bidamount,paid_amount,remaining_required,inputs,CCchange=0; struct CCcontract_info *cp,C; if ( fillamount < 0 ) { fprintf(stderr,"negative fillamount %lld\n",(long long)fillamount); @@ -456,7 +466,8 @@ std::string FillBuyOffer(int64_t txfee,uint256 assetid,uint256 bidtxid,int64_t f std::string FillSell(int64_t txfee,uint256 assetid,uint256 assetid2,uint256 asktxid,int64_t fillunits) { - CTransaction vintx,filltx; uint256 hashBlock; CMutableTransaction mtx; CPubKey mypk; std::vector origpubkey; double dprice; uint64_t mask; int32_t askvout=0; int64_t received_assetoshis,total_nValue,orig_assetoshis,paid_nValue,remaining_nValue,inputs,CCchange=0; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction vintx,filltx; uint256 hashBlock; CPubKey mypk; std::vector origpubkey; double dprice; uint64_t mask; int32_t askvout=0; int64_t received_assetoshis,total_nValue,orig_assetoshis,paid_nValue,remaining_nValue,inputs,CCchange=0; struct CCcontract_info *cp,C; if ( fillunits < 0 ) { CCerror = strprintf("negative fillunits %lld\n",(long long)fillunits); diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index 77650405e..1bc8533ec 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -150,7 +150,8 @@ int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount) { - CMutableTransaction mtx; CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; @@ -170,7 +171,8 @@ std::string AuctionBid(uint64_t txfee,uint256 itemhash,int64_t amount) std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid) { - CMutableTransaction mtx; CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Auctionpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; @@ -190,7 +192,8 @@ std::string AuctionDeliver(uint64_t txfee,uint256 itemhash,uint256 bidtxid) std::string AuctionPost(uint64_t txfee,uint256 itemhash,int64_t minbid,char *title,char *description) { - CMutableTransaction mtx; CPubKey mypk,Auctionpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Auctionpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_AUCTION); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/betprotocol.cpp b/src/cc/betprotocol.cpp index 41a05a797..fe3ae31c6 100644 --- a/src/cc/betprotocol.cpp +++ b/src/cc/betprotocol.cpp @@ -53,7 +53,7 @@ CC* BetProtocol::MakeDisputeCond() */ CMutableTransaction BetProtocol::MakeSessionTx(CAmount spendFee) { - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CC *disputeCond = MakeDisputeCond(); mtx.vout.push_back(CTxOut(spendFee, CCPubKey(disputeCond))); @@ -70,7 +70,7 @@ CMutableTransaction BetProtocol::MakeSessionTx(CAmount spendFee) CMutableTransaction BetProtocol::MakeDisputeTx(uint256 signedSessionTxHash, uint256 vmResultHash) { - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CC *disputeCond = MakeDisputeCond(); mtx.vin.push_back(CTxIn(signedSessionTxHash, 0, CScript())); @@ -84,7 +84,7 @@ CMutableTransaction BetProtocol::MakeDisputeTx(uint256 signedSessionTxHash, uint CMutableTransaction BetProtocol::MakePostEvidenceTx(uint256 signedSessionTxHash, int playerIdx, std::vector state) { - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(signedSessionTxHash, playerIdx+1, CScript())); mtx.vout.push_back(CTxOut(0, CScript() << OP_RETURN << state)); @@ -115,7 +115,7 @@ CC* BetProtocol::MakePayoutCond(uint256 signedSessionTxHash) CMutableTransaction BetProtocol::MakeStakeTx(CAmount totalPayout, uint256 signedSessionTxHash) { - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CC *payoutCond = MakePayoutCond(signedSessionTxHash); mtx.vout.push_back(CTxOut(totalPayout, CCPubKey(payoutCond))); @@ -128,7 +128,7 @@ CMutableTransaction BetProtocol::MakeStakeTx(CAmount totalPayout, uint256 signed CMutableTransaction BetProtocol::MakeAgreePayoutTx(std::vector payouts, uint256 signedStakeTxHash) { - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(signedStakeTxHash, 0, CScript())); mtx.vout = payouts; return mtx; @@ -138,7 +138,7 @@ CMutableTransaction BetProtocol::MakeAgreePayoutTx(std::vector payouts, CMutableTransaction BetProtocol::MakeImportPayoutTx(std::vector payouts, CTransaction signedDisputeTx, uint256 signedStakeTxHash, MoMProof momProof) { - CMutableTransaction mtx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); mtx.vin.push_back(CTxIn(signedStakeTxHash, 0, CScript())); mtx.vout = payouts; CScript proofData; diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 6ef09bfc5..60f907c27 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -430,7 +430,8 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64_t payment) { - CMutableTransaction mtx; uint8_t hash[32],hashdest[32]; uint64_t funds; int32_t i; uint256 hashchain,entropy,hentropy; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + uint8_t hash[32],hashdest[32]; uint64_t funds; int32_t i; uint256 hashchain,entropy,hentropy; CPubKey mypk; struct CCcontract_info *cp,C; if ( numpayments <= 0 || payment <= 0 || numpayments > CHANNELS_MAXPAYMENTS ) @@ -464,7 +465,8 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint256 secret) { - CMutableTransaction mtx; CPubKey mypk,srcpub,destpub; uint256 txid,hashchain,gensecret,hashblock,entropy,hentropy,prevtxid,param3; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,srcpub,destpub; uint256 txid,hashchain,gensecret,hashblock,entropy,hentropy,prevtxid,param3; struct CCcontract_info *cp,C; int32_t i,funcid,prevdepth,numvouts,numpayments,totalnumpayments; int64_t payment,change,funds,param2; uint8_t hash[32],hashdest[32]; @@ -569,7 +571,8 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 std::string ChannelClose(uint64_t txfee,uint256 opentxid) { - CMutableTransaction mtx; CPubKey mypk,srcpub,destpub; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,srcpub,destpub; struct CCcontract_info *cp,C; CTransaction channelOpenTx; uint256 hashblock,tmp_txid,prevtxid,hashchain; int32_t numvouts,numpayments; @@ -616,7 +619,8 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) { - CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; int64_t funds,payment,param2; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk; struct CCcontract_info *cp,C; int64_t funds,payment,param2; int32_t i,numpayments,numvouts,param1; uint256 hashchain,hashblock,txid,prevtxid,param3,entropy,hentropy,secret; CTransaction channelOpenTx,channelCloseTx,prevTx; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a434a407a..37d6bfd41 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1329,7 +1329,8 @@ UniValue DiceList() std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks) { - CMutableTransaction mtx; uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CCcontract_info *cp,C; if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 1 || maxodds > 9999 || timeoutblocks < 0 || timeoutblocks > 1440 ) { CCerror = "invalid parameter error"; @@ -1363,7 +1364,8 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { - CMutableTransaction mtx; CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CCcontract_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CScript fundingPubKey,scriptPubKey; uint256 entropy,hentropy; CPubKey mypk,dicepk; uint64_t sbits; struct CCcontract_info *cp,C; int64_t minbet,maxbet,maxodds,timeoutblocks; if ( amount < 0 ) { CCerror = "amount must be positive"; @@ -1406,7 +1408,8 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet,int32_t odds) { - CMutableTransaction mtx; CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CScript fundingPubKey; CPubKey mypk,dicepk; uint64_t sbits,entropyval,entropyval2; int64_t funding,minbet,maxbet,maxodds,timeoutblocks; uint256 entropytxid,entropytxid2,entropy,hentropy; struct CCcontract_info *cp,C; if ( bet < 0 ) { CCerror = "bet must be positive"; @@ -1464,7 +1467,8 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) { - CMutableTransaction mtx,savemtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; + CMutableTransaction savemtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; entropyused = zeroid; *resultp = 0; funcid = 0; diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index ed457f234..afd97c1aa 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -174,7 +174,8 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub std::string FaucetGet(uint64_t txfee) { - CMutableTransaction mtx,tmpmtx; CPubKey mypk,faucetpk; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,faucetpk; int64_t inputs,CCchange=0,nValue=FAUCETSIZE; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_FAUCET); if ( txfee == 0 ) txfee = 10000; @@ -232,7 +233,8 @@ std::string FaucetFund(uint64_t txfee,int64_t funds) UniValue FaucetInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx; CPubKey faucetpk; struct CCcontract_info *cp,C; int64_t funding; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey faucetpk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Faucet")); cp = CCinit(&C,EVAL_FAUCET); diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index 676537929..e75c53bcc 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -157,7 +157,8 @@ std::string FSMList() std::string FSMCreate(uint64_t txfee,std::string name,std::string states) { - CMutableTransaction mtx; CPubKey mypk,fsmpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,fsmpk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_FSM); if ( txfee == 0 ) txfee = 10000; @@ -177,7 +178,8 @@ std::string FSMCreate(uint64_t txfee,std::string name,std::string states) std::string FSMInfo(uint256 fsmtxid) { - CMutableTransaction mtx; CPubKey mypk,fsmpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,fsmpk; int64_t funds = 0; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_FSM); mypk = pubkey2pk(Mypubkey()); fsmpk = GetUnspendable(cp,0); diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 1abe73259..94d662193 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -748,7 +748,8 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t totalsupply,uint256 oracletxid,uint8_t M,uint8_t N,std::vector pubkeys) { - CMutableTransaction mtx; CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CCcontract_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction oracletx; uint8_t taddr,prefix,prefix2; CPubKey mypk,gatewayspk; CScript opret; uint256 hashBlock; struct CCcontract_info *cp,C; std::string name,description,format; int32_t i,numvouts; int64_t fullsupply; char destaddr[64],coinaddr[64],str[65],*fstr; cp = CCinit(&C,EVAL_GATEWAYS); if ( strcmp((char *)"KMD",coin.c_str()) == 0 ) { @@ -833,7 +834,8 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::string refcoin,uint256 cointxid,int32_t claimvout,std::string deposithex,std::vectorproof,CPubKey destpub,int64_t amount) { - CMutableTransaction mtx; CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction bindtx; CPubKey mypk,gatewayspk; uint256 oracletxid,merkleroot,mhash,hashBlock,tokenid,txid; int64_t totalsupply; int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2; std::string coin; struct CCcontract_info *cp,C; std::vector pubkeys,publishers; std::vectortxids; char str[67],depositaddr[64],txidaddr[64]; @@ -899,7 +901,8 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,uint256 deposittxid,CPubKey destpub,int64_t amount) { - CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction tx; CPubKey mypk,gatewayspk,tmpdestpub; struct CCcontract_info *cp,C; uint8_t M,N,taddr,prefix,prefix2; std::string coin, deposithex; std::vector msigpubkeys,publishers; int64_t totalsupply,depositamount,tmpamount,inputs,CCchange=0; int32_t numvouts,claimvout,height; std::vector proof; uint256 hashBlock,assetid,oracletxid,tmptxid,cointxid; char str[65],depositaddr[64],coinaddr[64],destaddr[64]; std::vector txids; @@ -962,7 +965,8 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount) { - CMutableTransaction mtx; CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction tx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; uint256 assetid,hashBlock,oracletxid; int32_t numvouts; int64_t totalsupply,inputs,CCchange=0; uint8_t M,N,taddr,prefix,prefix2; std::string coin; std::vector msigpubkeys; char depositaddr[64],str[65],coinaddr[64]; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1001,7 +1005,8 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string hex) { - CMutableTransaction mtx; CPubKey mypk,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx; std::vector > unspentOutputs; char txidaddr[65]; int32_t maxK,K=0; uint256 tmptxid,parttxid,hashBlock; cp = CCinit(&C,EVAL_GATEWAYS); @@ -1040,7 +1045,8 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,std::string hex) { - CMutableTransaction mtx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); gatewayspk = GetUnspendable(cp,0); @@ -1054,7 +1060,8 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 withdrawtxid,std::str std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string refcoin) { - CMutableTransaction mtx; CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,gatewayspk; struct CCcontract_info *cp,C; char txidaddr[65]; cp = CCinit(&C,EVAL_GATEWAYS); mypk = pubkey2pk(Mypubkey()); if ( txfee == 0 ) @@ -1247,7 +1254,8 @@ UniValue GatewaysList() UniValue GatewaysInfo(uint256 bindtxid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CMutableTransaction mtx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::string coin; char str[67],numstr[65],depositaddr[64],gatewaysassets[64]; uint8_t M,N; std::vector pubkeys; uint8_t taddr,prefix,prefix2; uint256 tokenid,oracletxid,hashBlock; CTransaction tx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int32_t i; int64_t totalsupply,remaining; result.push_back(Pair("result","success")); result.push_back(Pair("name","Gateways")); cp = CCinit(&C,EVAL_GATEWAYS); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index cdbc7918e..24aa35f59 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -143,7 +143,8 @@ int64_t AddHeirInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe std::string HeirGet(uint64_t txfee,int64_t nValue) { - CMutableTransaction mtx,tmpmtx; CPubKey mypk,Heirpk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Heirpk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_HEIR); if ( txfee == 0 ) txfee = 10000; @@ -183,7 +184,8 @@ std::string HeirGet(uint64_t txfee,int64_t nValue) std::string HeirFund(uint64_t txfee,int64_t funds) { - CMutableTransaction mtx; CPubKey mypk,Heirpk; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Heirpk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_HEIR); if ( txfee == 0 ) txfee = 10000; @@ -199,8 +201,9 @@ std::string HeirFund(uint64_t txfee,int64_t funds) UniValue HeirInfo() { + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx; CPubKey Heirpk; struct CCcontract_info *cp,C; int64_t funding; + CPubKey Heirpk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Heir")); cp = CCinit(&C,EVAL_HEIR); diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index 26ce11c7f..e89f2692a 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -283,7 +283,8 @@ UniValue LottoList() std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t ticketsize,int32_t odds,int32_t firstheight,int32_t period) { - CMutableTransaction mtx; uint256 entropy,hentropy; CPubKey mypk,lottopk; uint64_t sbits; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + uint256 entropy,hentropy; CPubKey mypk,lottopk; uint64_t sbits; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; @@ -301,7 +302,8 @@ std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t tic std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets) { - CMutableTransaction mtx; CPubKey mypk,lottopk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,lottopk; CScript opret; int64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; @@ -321,7 +323,8 @@ std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets) std::string LottoWinner(uint64_t txfee) { - CMutableTransaction mtx; CPubKey mypk,lottopk; int64_t winnings = 0; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,lottopk; int64_t winnings = 0; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_LOTTO); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index e3cd89166..135f822dc 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -728,7 +728,8 @@ int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubK std::string OracleCreate(int64_t txfee,std::string name,std::string description,std::string format) { - CMutableTransaction mtx; CPubKey mypk,Oraclespk; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Oraclespk; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_ORACLES); if ( name.size() > 32 || description.size() > 4096 || format.size() > 4096 ) { @@ -749,7 +750,8 @@ std::string OracleCreate(int64_t txfee,std::string name,std::string description, std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee) { - CMutableTransaction mtx; CPubKey mypk,markerpubkey,batonpk; struct CCcontract_info *cp,C; char markeraddr[64],batonaddr[64]; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,markerpubkey,batonpk; struct CCcontract_info *cp,C; char markeraddr[64],batonaddr[64]; cp = CCinit(&C,EVAL_ORACLES); if ( txfee == 0 ) txfee = 10000; @@ -772,7 +774,8 @@ std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee) std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,int64_t amount) { - CMutableTransaction mtx; CPubKey mypk,markerpubkey; struct CCcontract_info *cp,C; char markeraddr[64]; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,markerpubkey; struct CCcontract_info *cp,C; char markeraddr[64]; cp = CCinit(&C,EVAL_ORACLES); if ( txfee == 0 ) txfee = 10000; @@ -789,7 +792,8 @@ std::string OracleSubscribe(int64_t txfee,uint256 oracletxid,CPubKey publisher,i std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector data) { - CMutableTransaction mtx; CScript pubKey; CPubKey mypk,batonpk; int64_t datafee,inputs,CCchange = 0; struct CCcontract_info *cp,C; uint256 batontxid; char coinaddr[64],batonaddr[64]; std::vector prevdata; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CScript pubKey; CPubKey mypk,batonpk; int64_t datafee,inputs,CCchange = 0; struct CCcontract_info *cp,C; uint256 batontxid; char coinaddr[64],batonaddr[64]; std::vector prevdata; cp = CCinit(&C,EVAL_ORACLES); mypk = pubkey2pk(Mypubkey()); if ( data.size() > 8192 ) @@ -879,7 +883,8 @@ UniValue OracleInfo(uint256 origtxid) { UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector > unspentOutputs; - CMutableTransaction mtx; CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CCcontract_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction regtx,tx; std::string name,description,format; uint256 hashBlock,txid,oracletxid,batontxid; CPubKey pk; struct CCcontract_info *cp,C; int64_t datafee,funding; char str[67],markeraddr[64],numstr[64],batonaddr[64]; std::vector data; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,origtxid); if ( GetTransaction(origtxid,tx,hashBlock,false) == 0 ) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index de92da9ed..70f1ab914 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -144,7 +144,8 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP std::string PaymentsGet(uint64_t txfee,int64_t nValue) { - CMutableTransaction mtx,tmpmtx; CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Paymentspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_PAYMENTS); if ( txfee == 0 ) txfee = 10000; @@ -184,7 +185,8 @@ std::string PaymentsGet(uint64_t txfee,int64_t nValue) std::string PaymentsFund(uint64_t txfee,int64_t funds) { - CMutableTransaction mtx; CPubKey mypk,Paymentspk; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Paymentspk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_PAYMENTS); if ( txfee == 0 ) txfee = 10000; @@ -201,7 +203,8 @@ std::string PaymentsFund(uint64_t txfee,int64_t funds) UniValue PaymentsInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx; CPubKey Paymentspk; struct CCcontract_info *cp,C; int64_t funding; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey Paymentspk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Payments")); cp = CCinit(&C,EVAL_PAYMENTS); diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 1de818fe9..403dfb87a 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -151,7 +151,8 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe std::string PegsGet(uint64_t txfee,int64_t nValue) { - CMutableTransaction mtx,tmpmtx; CPubKey mypk,Pegspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Pegspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_PEGS); if ( txfee == 0 ) txfee = 10000; @@ -191,7 +192,8 @@ std::string PegsGet(uint64_t txfee,int64_t nValue) std::string PegsFund(uint64_t txfee,int64_t funds) { - CMutableTransaction mtx; CPubKey mypk,Pegspk; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Pegspk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_PEGS); if ( txfee == 0 ) txfee = 10000; @@ -208,7 +210,8 @@ std::string PegsFund(uint64_t txfee,int64_t funds) UniValue PegsInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx; CPubKey Pegspk; struct CCcontract_info *cp,C; int64_t funding; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey Pegspk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Pegs")); cp = CCinit(&C,EVAL_PEGS); diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 2ec19902e..50787fd34 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -182,7 +182,8 @@ UniValue PricesList() // bettoken std::string PricesCreateFunding(uint64_t txfee,uint256 bettoken,uint256 oracletxid,uint64_t margin,uint64_t mode,uint256 longtoken,uint256 shorttoken,int32_t maxleverage,int64_t funding,std::vector pubkeys) { - CMutableTransaction mtx; CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction oracletx; int64_t fullsupply,inputs,CCchange=0; uint256 hashBlock; char str[65],coinaddr[64],houseaddr[64]; CPubKey mypk,pricespk; int32_t i,N,numvouts; struct CCcontract_info *cp,C; if ( funding < 100*COIN || maxleverage <= 0 || maxleverage > 10000 ) { CCerror = "invalid parameter error"; @@ -293,7 +294,8 @@ UniValue PricesInfo(uint256 fundingtxid) std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount) { - CMutableTransaction mtx; struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,CCchange = 0; uint64_t funding,mode; int32_t margin,maxleverage; char houseaddr[64],myaddr[64]; std::vectorpubkeys; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,CCchange = 0; uint64_t funding,mode; int32_t margin,maxleverage; char houseaddr[64],myaddr[64]; std::vectorpubkeys; if ( amount < 10000 ) { CCerror = "amount must be positive"; @@ -343,7 +345,8 @@ std::string PricesAddFunding(uint64_t txfee,uint256 refbettoken,uint256 fundingt std::string PricesBet(uint64_t txfee,uint256 refbettoken,uint256 fundingtxid,int64_t amount,int32_t leverage) { - CMutableTransaction mtx; struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + struct CCcontract_info *cp,C; CPubKey pricespk,planpk,mypk; uint256 hashBlock,oracletxid,longtoken,shorttoken,tokenid,bettoken; CTransaction tx; int64_t balance,supply,exposure,inputs,inputs2,longexposure,netexposure,shortexposure,CCchange = 0,CCchange2 = 0; uint64_t funding,mode; int32_t dir,margin,maxleverage; char houseaddr[64],myaddr[64],exposureaddr[64]; std::vectorpubkeys; if ( amount < 0 ) { amount = -amount; diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 06002f9c0..7e4626b19 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -500,7 +500,8 @@ UniValue RewardsList() std::string RewardsCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t APR,int64_t minseconds,int64_t maxseconds,int64_t mindeposit) { - CMutableTransaction mtx; CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; if ( funds < COIN || mindeposit < 0 || minseconds < 0 || maxseconds < 0 ) { fprintf(stderr,"negative parameter error\n"); @@ -534,7 +535,8 @@ std::string RewardsCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int6 std::string RewardsAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount) { - CMutableTransaction mtx; CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,rewardspk; CScript opret; uint64_t sbits,a,b,c,d; struct CCcontract_info *cp,C; if ( amount < 0 ) { fprintf(stderr,"negative parameter error\n"); @@ -568,7 +570,8 @@ std::string RewardsAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,i std::string RewardsLock(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t deposit) { - CMutableTransaction mtx; CPubKey mypk,rewardspk; CScript opret; uint64_t lockedfunds,sbits,funding,APR,minseconds,maxseconds,mindeposit; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,rewardspk; CScript opret; uint64_t lockedfunds,sbits,funding,APR,minseconds,maxseconds,mindeposit; struct CCcontract_info *cp,C; if ( deposit < txfee ) { CCerror = "deposit amount less than txfee"; @@ -611,7 +614,8 @@ std::string RewardsLock(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 locktxid) { - CMutableTransaction mtx,firstmtx; CTransaction tx; char coinaddr[64]; CPubKey mypk,rewardspk; CScript scriptPubKey,ignore; uint256 hashBlock; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; int64_t funding,reward=0,amount=0,inputs,CCchange=0; struct CCcontract_info *cp,C; + CMutableTransaction firstmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CTransaction tx; char coinaddr[64]; CPubKey mypk,rewardspk; CScript scriptPubKey,ignore; uint256 hashBlock; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; int64_t funding,reward=0,amount=0,inputs,CCchange=0; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_REWARDS); if ( txfee == 0 ) txfee = 10000; diff --git a/src/cc/triggers.cpp b/src/cc/triggers.cpp index cc39683cd..ce6f10f58 100644 --- a/src/cc/triggers.cpp +++ b/src/cc/triggers.cpp @@ -143,7 +143,8 @@ int64_t AddTriggersInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP std::string TriggersGet(uint64_t txfee,int64_t nValue) { - CMutableTransaction mtx,tmpmtx; CPubKey mypk,Triggerspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Triggerspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; cp = CCinit(&C,EVAL_TRIGGERS); if ( txfee == 0 ) txfee = 10000; @@ -183,7 +184,8 @@ std::string TriggersGet(uint64_t txfee,int64_t nValue) std::string TriggersFund(uint64_t txfee,int64_t funds) { - CMutableTransaction mtx; CPubKey mypk,Triggerspk; CScript opret; struct CCcontract_info *cp,C; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey mypk,Triggerspk; CScript opret; struct CCcontract_info *cp,C; cp = CCinit(&C,EVAL_TRIGGERS); if ( txfee == 0 ) txfee = 10000; @@ -200,7 +202,8 @@ std::string TriggersFund(uint64_t txfee,int64_t funds) UniValue TriggersInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx; CPubKey Triggerspk; struct CCcontract_info *cp,C; int64_t funding; + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CPubKey Triggerspk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); result.push_back(Pair("name","Triggers")); cp = CCinit(&C,EVAL_TRIGGERS); From a3911bbf3dc3efdcefa74548db9f310a72eb839b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 27 Nov 2018 23:02:57 -1100 Subject: [PATCH 05/49] int32_t komodo_nextheight(); --- src/cc/betprotocol.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/betprotocol.cpp b/src/cc/betprotocol.cpp index fe3ae31c6..3efa4ae37 100644 --- a/src/cc/betprotocol.cpp +++ b/src/cc/betprotocol.cpp @@ -25,6 +25,7 @@ #include "cc/utils.h" #include "primitives/transaction.h" +int32_t komodo_nextheight(); std::vector BetProtocol::PlayerConditions() { From a23af09cda6e89cbac25e31792388602251d8bb9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 28 Nov 2018 00:35:31 -1100 Subject: [PATCH 06/49] Prevent sapling activation until ac_sapling set --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index edd1b6605..8586f5840 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5624,7 +5624,8 @@ bool static LoadBlockIndexDB() if ( (pindex= chainActive.LastTip()) != 0 ) { fprintf(stderr,"set sapling height, if possible from ht.%d %u\n",(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime); - komodo_activate_sapling(pindex); + if ( ASSETCHAINS_SAPLING <= 0 ) + komodo_activate_sapling(pindex); } return true; } From ea5b152c583a07f04f823251e70895ebfe87894b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 28 Nov 2018 00:40:11 -1100 Subject: [PATCH 07/49] Move print --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 8586f5840..80819f296 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5623,9 +5623,11 @@ bool static LoadBlockIndexDB() CBlockIndex *pindex; if ( (pindex= chainActive.LastTip()) != 0 ) { - fprintf(stderr,"set sapling height, if possible from ht.%d %u\n",(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime); if ( ASSETCHAINS_SAPLING <= 0 ) + { + fprintf(stderr,"set sapling height, if possible from ht.%d %u\n",(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime); komodo_activate_sapling(pindex); + } } return true; } From b0abf90f699d5897b9da4ec6ecef61980656e6ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 28 Nov 2018 04:06:49 -1100 Subject: [PATCH 08/49] Fix null ptr in dice status --- src/cc/dice.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 37d6bfd41..8d750b1ed 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -245,9 +245,12 @@ bool mySenddicetransaction(std::string res,uint256 entropyused,int32_t entropyvo { RelayTransaction(tx); fprintf(stderr,"rebroadcast.%c and clear [%d] and broadcast entropyused.%s bettxid.%s -> %s\n",funcid,i,entropyused.GetHex().c_str(),bettxid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); - if ( ptr->rawtx.empty() == 0 ) - ptr->rawtx.clear(); - ptr->txid = zeroid; + if ( ptr != 0 ) + { + if ( ptr->rawtx.empty() == 0 ) + ptr->rawtx.clear(); + ptr->txid = zeroid; + } //fprintf(stderr,"error adding funcid.%c E.%s bet.%s -> %s to mempool, probably Disable replacement feature size.%d\n",funcid,entropyused.GetHex().c_str(),bettxid.GetHex().c_str(),tx.GetHash().GetHex().c_str(),(int32_t)ptr->rawtx.size()); } } else fprintf(stderr,"error duplicate entropyused different bettxid\n"); From 30eae48849a4e7c189de6a5d7f04fabdc148f2cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 28 Nov 2018 21:53:27 -1100 Subject: [PATCH 09/49] Mempool fixes in the CC path --- src/main.cpp | 3 ++- src/rpc/misc.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 80819f296..1ca925482 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4678,7 +4678,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C const uint256 &hash = tx.GetHash(); if ( tx.vjoinsplit.size() == 0 ) { transactionsToRemove.push_back(tx); - tmpmempool.addUnchecked(hash,e,!IsInitialBlockDownload()); + tmpmempool.addUnchecked(hash,e,true); } } BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) { @@ -4756,6 +4756,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // here we add back all txs from the temp mempool to the main mempool. // which removes any tx locally that were invalid after the block arrives. int invalidtxs = 0; + LOCK(mempool.cs); BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { CTransaction tx = e.GetTx(); CValidationState state; bool fMissingInputs,fOverrideFees = false; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 26c273236..e0bbe86c3 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -56,7 +56,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -#define KOMODO_VERSION "0.3.1" +#define KOMODO_VERSION "0.3.2" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; From 05d0f6c0b346ed760913765c01933eac77a5e645 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 29 Nov 2018 01:58:48 -1100 Subject: [PATCH 10/49] +comments --- src/cc/gateways.cpp | 1 + src/komodo_defs.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 94d662193..da9b57766 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -707,6 +707,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)vintx.vout[vout].nValue/COIN); if ( assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { + // call IsAssetsVout? //fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); diff --git a/src/komodo_defs.h b/src/komodo_defs.h index a4d5a2df3..e604e1779 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -13,7 +13,7 @@ #define KOMODO_FIRSTFUNGIBLEID 100 #define KOMODO_SAPLING_ACTIVATION 1544832000 // Dec 15th, 2018 #define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019 - + extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); From 9ad8bfa16e325fd66cca8379abae65dab375310e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 29 Nov 2018 03:02:27 -1100 Subject: [PATCH 11/49] Prevent spurious reindexing --- src/init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 701a33e97..f3d728933 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1486,7 +1486,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex, dbCompression, dbMaxOpenFiles); fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX); pblocktree->ReadFlag("addressindex", checkval); - if ( checkval != fAddressIndex ) + if ( checkval != fAddressIndex && fAddressIndex != 0 ) { pblocktree->WriteFlag("addressindex", fAddressIndex); fprintf(stderr,"set addressindex, will reindex. could take a while.\n"); @@ -1494,7 +1494,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX); pblocktree->ReadFlag("spentindex", checkval); - if ( checkval != fSpentIndex ) + if ( checkval != fSpentIndex && fSpentIndex != 0 ) { pblocktree->WriteFlag("spentindex", fSpentIndex); fprintf(stderr,"set spentindex, will reindex. could take a while.\n"); From d89fe8b560d1dee34cdb62d63fcabea0af22c577 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 30 Nov 2018 01:52:39 +0800 Subject: [PATCH 12/49] fix bitcoin-cli.cpp includes --- src/bitcoin-cli.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 5d818eb5b..64830d463 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -16,6 +16,8 @@ #include #include #include "support/events.h" +uint16_t BITCOIND_RPCPORT = 7771; +char ASSETCHAINS_SYMBOL[65]; #include @@ -64,27 +66,6 @@ public: }; -#define FROM_CLI -#include "uint256.h" -#include "arith_uint256.h" - -#include "komodo_structs.h" - -#include "komodo_globals.h" -#include "komodo_utils.h" -#include "komodo_cJSON.c" -#include "komodo_notary.h" - -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) -{ - -} - -uint32_t komodo_heightstamp(int32_t height) -{ - return(0); -} - // // This function returns either one of EXIT_ codes when it's expected to stop the process or // CONTINUE_EXECUTION when it's expected to continue further. @@ -99,7 +80,11 @@ static int AppInitRPC(int argc, char* argv[]) // Parameters // ParseParameters(argc, argv); - komodo_args(argv[0]); + std:string name; + name = GetArg("-ac_name",""); + if ( !name.empty() ) + strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); + if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { From c9e9081c8ac94144626cecb982d633e36f796396 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 29 Nov 2018 07:00:04 -1100 Subject: [PATCH 13/49] Rebase --- src/cc/gateways.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index da9b57766..94d662193 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -707,7 +707,6 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)vintx.vout[vout].nValue/COIN); if ( assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { - // call IsAssetsVout? //fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From 933e1b4220e6c472458dad1ec4543ae1de17be7a Mon Sep 17 00:00:00 2001 From: dim71 Date: Sat, 1 Dec 2018 03:08:24 +0500 Subject: [PATCH 14/49] added check for bad tx (sending from normal vins to cc vouts) to asset validation and tx creation code --- src/cc/CCassets.h | 5 +- src/cc/CCassetsCore.cpp | 99 ++++++++++++++++++++++++++++++---------- src/cc/CCassetstx.cpp | 42 +++++++++++++---- src/cc/assets.cpp | 68 +++++++++++++++++++++++++-- src/wallet/rpcwallet.cpp | 50 ++++++++++++++------ 5 files changed, 212 insertions(+), 52 deletions(-) diff --git a/src/cc/CCassets.h b/src/cc/CCassets.h index a48195970..67bed7941 100644 --- a/src/cc/CCassets.h +++ b/src/cc/CCassets.h @@ -35,7 +35,7 @@ CScript EncodeAssetOpRet(uint8_t funcid,uint256 assetid,uint256 assetid2,int64_t bool DecodeAssetCreateOpRet(const CScript &scriptPubKey,std::vector &origpubkey,std::string &name,std::string &description); uint8_t DecodeAssetOpRet(const CScript &scriptPubKey,uint256 &assetid,uint256 &assetid2,int64_t &price,std::vector &origpubkey); bool SetAssetOrigpubkey(std::vector &origpubkey,int64_t &price,const CTransaction &tx); -int64_t IsAssetvout(int64_t &price,std::vector &origpubkey,const CTransaction& tx,int32_t v,uint256 refassetid); +int64_t IsAssetvout(int32_t maxAssetExactAmountDepth, struct CCcontract_info *cp, Eval* eval, int64_t &price,std::vector &origpubkey,const CTransaction& tx,int32_t v,uint256 refassetid); bool ValidateBidRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateAskRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); bool ValidateSwapRemainder(int64_t remaining_price,int64_t remaining_nValue,int64_t orig_nValue,int64_t received_nValue,int64_t paidprice,int64_t totalprice); @@ -44,7 +44,8 @@ bool SetAskFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValu bool SetSwapFillamounts(int64_t &paid,int64_t &remaining_price,int64_t orig_nValue,int64_t &received,int64_t totalprice); int64_t AssetValidateBuyvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 refassetid); int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpprice,std::vector &tmporigpubkey,char *CCaddr,char *origaddr,const CTransaction &tx,uint256 assetid); -bool AssetExactAmounts(struct CCcontract_info *cp,int64_t &inputs,int32_t starti,int64_t &outputs,Eval* eval,const CTransaction &tx,uint256 assetid); +bool AssetExactAmounts(int32_t maxDepth, struct CCcontract_info *cp,int64_t &inputs,int32_t starti,int64_t &outputs,Eval* eval,const CTransaction &tx,uint256 assetid); +//bool AssetExactAmounts(bool doValidateTx, struct CCcontract_info *cp, int64_t &inputs, int32_t starti, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid, std::vector &ccVinsTxs); // CCassetstx int64_t GetAssetBalance(CPubKey pk,uint256 tokenid); diff --git a/src/cc/CCassetsCore.cpp b/src/cc/CCassetsCore.cpp index c9b975c3c..3fce95f0c 100644 --- a/src/cc/CCassetsCore.cpp +++ b/src/cc/CCassetsCore.cpp @@ -342,25 +342,54 @@ bool GetAssetorigaddrs(struct CCcontract_info *cp,char *CCaddr,char *destaddr,co else return(false); } -int64_t IsAssetvout(int64_t &price,std::vector &origpubkey,const CTransaction& tx,int32_t v,uint256 refassetid) + +// Checks if the vout is a really Asset CC vout +// if maxAssetExactAmountDepth > 0, it also validates the vin transaction itself: +// it should be either sum(cc vins) == sum(cc vouts) or the transaction is the 'tokenbase' ('c') tx +int64_t IsAssetvout(int32_t maxAssetExactAmountDepth, struct CCcontract_info *cp, Eval* eval, int64_t &price,std::vector &origpubkey,const CTransaction& tx,int32_t v,uint256 refassetid) { uint256 assetid,assetid2; int64_t nValue=0; int32_t n; uint8_t funcid; + if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) // maybe check address too? { - n = tx.vout.size(); + + if (maxAssetExactAmountDepth > 0) { + //validate all tx + int64_t myCCVinsAmount = 0, myCCVoutsAmount = 0; + std::vector ccVinsTxs; + + //std::cerr << "IsAssetvout() validate=yes" << std::endl; + const bool validateVinTxs = false; + bool isEqualAmounts = AssetExactAmounts(maxAssetExactAmountDepth, cp, myCCVinsAmount, 0, myCCVoutsAmount, eval, tx, refassetid); + + // if ccInputs != ccOutputs and it is not the tokenbase tx means it is possibly fake tx (dimxy): + if (!isEqualAmounts && refassetid != tx.GetHash()) { // checking that this is the true tokenbase tx, by verifying that funcid=c, is done further in this function (dimxy) + std::cerr << "IsAssetvout() detected bad tx=" << tx.GetHash().GetHex() << ": cc inputs != cc outputs and not the 'tokenbase' tx" << std::endl; + return 0; + } + } + + + n = tx.vout.size(); + if (v >= n - 1) { // just moved this up (dimxy) + std::cerr << "isAssetVout() internal err: (v >= n - 1), returning 0" << std::endl; + return(0); + } nValue = tx.vout[v].nValue; - //fprintf(stderr,"CC vout v.%d of n.%d %.8f\n",v,n,(double)nValue/COIN); - if ( v >= n-1 ) - return(0); + + // fprintf(stderr,"IsAssetvout() CC vout v.%d of n=%d amount=%.8f\n",v,n,(double)nValue/COIN); + if ( (funcid= DecodeAssetOpRet(tx.vout[n-1].scriptPubKey,assetid,assetid2,price,origpubkey)) == 0 ) { - fprintf(stderr,"null decodeopret v.%d\n",v); + fprintf(stderr,"IsAssetvout() null decodeopret v.%d\n",v); return(0); } else if ( funcid == 'c' ) { - if ( refassetid == tx.GetHash() && v == 0 ) - return(nValue); + if (refassetid == tx.GetHash() && v == 0) { + std::cerr << "isAssetVout() this is the tokenbase 'c' tx, txid=" << tx.GetHash().GetHex() << " returning nValue=" << nValue << std::endl; + return(nValue); + } } else if ( (funcid == 'b' || funcid == 'B') && v == 0 ) // critical! 'b'/'B' vout0 is NOT asset return(0); @@ -368,7 +397,7 @@ int64_t IsAssetvout(int64_t &price,std::vector &origpubkey,const CTrans { if ( assetid == refassetid ) { - //fprintf(stderr,"returning %.8f\n",(double)nValue/COIN); + fprintf(stderr,"IsAssetvout() returning %.8f\n",(double)nValue/COIN); return(nValue); } } @@ -443,29 +472,37 @@ int64_t AssetValidateSellvin(struct CCcontract_info *cp,Eval* eval,int64_t &tmpp fprintf(stderr,"AssetValidateSellvin\n"); if ( (nValue= AssetValidateCCvin(cp,eval,CCaddr,origaddr,tx,1,vinTx)) == 0 ) return(0); - if ( (assetoshis= IsAssetvout(tmpprice,tmporigpubkey,vinTx,0,assetid)) == 0 ) + if ( (assetoshis= IsAssetvout(1, cp, NULL, tmpprice,tmporigpubkey,vinTx,0,assetid)) == 0 ) return eval->Invalid("invalid missing CC vout0 for sellvin"); else return(assetoshis); } -bool AssetExactAmounts(struct CCcontract_info *cp,int64_t &inputs,int32_t starti,int64_t &outputs,Eval* eval,const CTransaction &tx,uint256 assetid) + +// overload with additional params for deep tx validation (dimxy) +bool AssetExactAmounts(int maxDepth, struct CCcontract_info *cp, int64_t &inputs, int32_t starti, int64_t &outputs, Eval* eval, const CTransaction &tx, uint256 assetid) { CTransaction vinTx; uint256 hashBlock,id,id2; int32_t i,flag,numvins,numvouts; int64_t assetoshis; std::vector tmporigpubkey; int64_t tmpprice; numvins = tx.vin.size(); numvouts = tx.vout.size(); inputs = outputs = 0; + + maxDepth--; + for (i=starti; iismyvin)(tx.vin[i].scriptSig) != 0 ) - { - if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) + { + //std::cerr << "AssetExactAmounts() eval is true=" << (eval != NULL) << " ismyvin=ok for_i=" << i << std::endl; + // we are really not inside validation! -- dimxy + if ( (eval && eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0) || (!eval && !myGetTransaction(tx.vin[i].prevout.hash, vinTx, hashBlock)) ) { - fprintf(stderr,"i.%d starti.%d numvins.%d\n",i,starti,numvins); - return eval->Invalid("always should find vin, but didnt"); - } - else if ( (assetoshis= IsAssetvout(tmpprice,tmporigpubkey,vinTx,tx.vin[i].prevout.n,assetid)) != 0 ) + fprintf(stderr,"AssetExactAmounts() cannot read vintx i.%d starti.%d numvins.%d\n", i,starti,numvins); + return (!eval) ? false : eval->Invalid("always should find vin, but didnt"); + + } // false means 'don't go deeper' -- dimxy + else if ( (assetoshis= IsAssetvout( maxDepth, cp, eval, tmpprice,tmporigpubkey,vinTx,tx.vin[i].prevout.n,assetid)) != 0 ) { - fprintf(stderr,"vin%d %llu, ",i,(long long)assetoshis); + fprintf(stderr,"AssetExactAmounts() vin%d %llu, ",i,(long long)assetoshis); inputs += assetoshis; } else @@ -473,33 +510,47 @@ bool AssetExactAmounts(struct CCcontract_info *cp,int64_t &inputs,int32_t starti if ( vinTx.vout[i].scriptPubKey.IsPayToCryptoCondition() != 0 && DecodeAssetOpRet(vinTx.vout[vinTx.vout.size()-1].scriptPubKey,id,id2,tmpprice,tmporigpubkey) == 't' && id == assetid ) { assetoshis = vinTx.vout[i].nValue; - fprintf(stderr,"vin%d %llu special case, ",i,(long long)assetoshis); + fprintf(stderr,"AssetExactAmounts() vin%d assetoshis=%llu special case, ",i,(long long)assetoshis); inputs += assetoshis; } } } } + + if ( DecodeAssetOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,id,id2,tmpprice,tmporigpubkey) == 't' && id == assetid ) flag = 1; else flag = 0; + for (i=0; i 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + fprintf(stderr,"AddAssetInputs() check destaddress=%s vout amount=%.8f\n",destaddr,(double)vintx.vout[vout].nValue/COIN); + if ( (nValue= IsAssetvout(1, cp, NULL, price,origpubkey,vintx,vout,assetid)) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); nValue = it->second.satoshis; totalinputs += nValue; + //std::cerr << "AddAssetInputs() adding input nValue=" << nValue << std::endl; n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) break; } } } + + //std::cerr << "AddAssetInputs() found totalinputs=" << totalinputs << std::endl; return(totalinputs); } @@ -235,6 +238,11 @@ std::string AssetTransfer(int64_t txfee,uint256 assetid,std::vector des mask = ~((1LL << mtx.vin.size()) - 1); if ( (inputs= AddAssetInputs(cp,mtx,mypk,assetid,total,60)) > 0 ) { + + if (inputs < total) { //added dimxy + std::cerr << "AssetTransfer(): insufficient funds" << std::endl; + return (""); + } if ( inputs > total ) CCchange = (inputs - total); //for (i=0; i 0 ) { - if ( inputs < askamount ) - askamount = inputs; + if (inputs < askamount) { + //askamount = inputs; + std::cerr << "CreateSell(): insufficient tokens for ask" << std::endl; + return (""); + } + mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,askamount,GetUnspendable(cp,0))); if ( inputs > askamount ) CCchange = (inputs - askamount); @@ -333,9 +348,14 @@ std::string CreateSell(int64_t txfee,int64_t askamount,uint256 assetid,int64_t p mtx.vout.push_back(MakeCC1vout(EVAL_ASSETS,CCchange,mypk)); opret = EncodeAssetOpRet('s',assetid,zeroid,pricetotal,Mypubkey()); return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); - } else fprintf(stderr,"need some assets to place ask\n"); + } + else { + fprintf(stderr, "need some assets to place ask\n"); + } } - fprintf(stderr,"need some native coins to place ask\n"); + else { // dimxy added 'else', because it was misleading message before + fprintf(stderr, "need some native coins to place ask\n"); + } return(""); } @@ -373,9 +393,15 @@ std::string CreateSwap(int64_t txfee,int64_t askamount,uint256 assetid,uint256 a opret = EncodeAssetOpRet('e',assetid,assetid2,pricetotal,Mypubkey()); } return(FinalizeCCTx(mask,cp,mtx,mypk,txfee,opret)); - } else fprintf(stderr,"need some assets to place ask\n"); + } + else { + fprintf(stderr, "need some assets to place ask\n"); + } } - fprintf(stderr,"need some native coins to place ask\n"); + else { // dimxy added 'else', because it was misleading message before + fprintf(stderr,"need some native coins to place ask\n"); + } + return(""); } diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 41a0ed7b1..92c1ddaac 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -129,6 +129,64 @@ vout.n-1: opreturn [EVAL_ASSETS] ['E'] [assetid vin0+1] [assetid vin2] [remaining asset2 required] [origpubkey] */ + + +// Recursively browses and verifies tx's vins to make sure no fake tokens have been 'planted' +// This func should be call with maxlevels = 2 +// on the first level it validates that current tx does not have invalid non-cc inputs +// on the second level it validates that all cc inputs of this tx also don't have 'feeding' non-cc inputs +/* +bool ValidateInputsTraversal(int32_t maxlevels, struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint256 assetid) +{ + int64_t dummyPrice; + std::vector dummyPubkey; + uint256 dummyAsset, dummyAsset2; + + int32_t numvins = tx.vin.size(); + int32_t numvouts = tx.vout.size(); + + // check it for the sake of.. + if (numvouts == 0) + return false; + + uint8_t funcId = DecodeAssetOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyAsset, dummyAsset2, dummyPrice, dummyPubkey); + + // this is initial tokenbase tx: + if (tx.GetHash() == assetid && funcId == 'c') { + std::cerr << "ValidateInputsTraversal() found initial tx=" << assetid.GetHex() << std::endl; + return true; + } + + int64_t myCCVinsAmount = 0; + int64_t myCCVoutsAmount = 0; + std::vector ccVinsTxs; + + bool isCCEqual = AssetExactAmounts(cp, myCCVinsAmount, 0, myCCVoutsAmount, eval, tx, assetid); + if (!isCCEqual) { //Note: for the spending tx (1-st level) this condition is also checked in AssetsValidate() itself -- dimxy + std::cerr << "ValidateInputsTraversal() found bad uxto txid=" << tx.GetHash().GetHex() << " ccVinsAmount=" << myCCVinsAmount << " ccVoutsAmount=" << myCCVoutsAmount << std::endl; + eval->Invalid("deep search found bad non-cc uxto"); + return false; + } + + // recursively validate vins' txs (only for one level - see maxlevels var): + bool allVinTxsGood = true; + + if (--maxlevels > 0) { + for (int32_t i = 0; i < ccVinsTxs.size(); i++) { + if (!ValidateInputsTraversal(maxlevels, cp, eval, ccVinsTxs[i], assetid)) { + allVinTxsGood = false; + break; + } + } + } + + std::cerr << "ValidateInputsTraversal() for txid=" << tx.GetHash().GetHex() << " allVinTxsGood=" << std::boolalpha << allVinTxsGood << std::endl; + + return allVinTxsGood; +} +*/ + +// tx validation bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) { static uint256 zero; @@ -155,9 +213,13 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx else starti = 1; if ( assetid == zero ) return eval->Invalid("illegal assetid"); - else if ( AssetExactAmounts(cp,inputs,starti,outputs,eval,tx,assetid) == false ) + else if ( AssetExactAmounts(2, cp,inputs,starti,outputs,eval,tx,assetid) == false ) return eval->Invalid("asset inputs != outputs"); } + +// if( !ValidateInputsTraversal(2, cp, eval, tx, assetid) ) +// return false; + switch ( funcid ) { case 'c': // create wont be called to be verified as it has no CC inputs @@ -321,7 +383,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx } fprintf(stderr,"fill validated\n"); break; - case 'E': // fillexchange + case 'E': // fillexchange return eval->Invalid("unexpected assets fillexchange funcid"); break; // disable asset swaps //vin.0: normal input @@ -333,7 +395,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx //vout.3: CC output for asset2 change (if any) //vout.3/4: normal output for change (if any) //vout.n-1: opreturn [EVAL_ASSETS] ['E'] [assetid vin0+1] [assetid vin2] [remaining asset2 required] [origpubkey] - if ( AssetExactAmounts(cp,inputs,1,outputs,eval,tx,assetid2) == false ) + if ( AssetExactAmounts(1, cp,inputs,1,outputs,eval,tx,assetid2) == false ) eval->Invalid("asset2 inputs != outputs"); if ( (assetoshis= AssetValidateSellvin(cp,eval,totalunits,tmporigpubkey,CCaddr,origaddr,tx,assetid)) == 0 ) return(false); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f3b344ecd..9000358d9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5310,6 +5310,7 @@ int32_t ensure_CCrequirements() #include "../cc/CCOracles.h" #include "../cc/CCGateways.h" #include "../cc/CCPrices.h" +#include "../cc/CCHeir.h" UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector &pubkey) { @@ -5531,15 +5532,25 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) UniValue heiraddress(const UniValue& params, bool fHelp) { - struct CCcontract_info *cp,C; std::vector pubkey; + struct CCcontract_info *cp,C; std::vector destPubkey; + cp = CCinit(&C,EVAL_HEIR); - if ( fHelp || params.size() > 1 ) - throw runtime_error("heiraddress [pubkey]\n"); + if ( fHelp || (params.size() != 4 && params.size() != 3)) + throw runtime_error("heiraddress func txid amount [destpubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); - if ( params.size() == 1 ) - pubkey = ParseHex(params[0].get_str().c_str()); - return(CCaddress(cp,(char *)"Heir",pubkey)); + //if ( params.size() == 1 ) + // pubkey = ParseHex(params[0].get_str().c_str()); + + char funcid = ((char *)params[0].get_str().c_str())[0]; + uint256 assetid = Parseuint256((char *)params[1].get_str().c_str()); + int64_t funds = atof(params[2].get_str().c_str()) * COIN ; + if(params.size() == 4) + destPubkey = ParseHex(params[3].get_str().c_str()); + + return HeirFundBad(funcid, assetid, funds, destPubkey); + + //return(CCaddress(cp,(char *)"Heir",pubkey)); } UniValue lottoaddress(const UniValue& params, bool fHelp) @@ -6837,7 +6848,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); name = params[0].get_str(); - supply = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + supply = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; // what for is this '+0.00000000499999'? it will be lost while converting double to int64_t (dimxy) if ( name.size() == 0 || name.size() > 32) { ERR_RESULT("Token name must not be empty and up to 32 characters"); @@ -6877,7 +6888,8 @@ UniValue tokentransfer(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); std::vector pubkey(ParseHex(params[1].get_str().c_str())); - amount = atol(params[2].get_str().c_str()); + //amount = atol(params[2].get_str().c_str()); + amount = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance if ( tokenid == zeroid ) { ERR_RESULT("invalid tokenid"); @@ -6913,7 +6925,8 @@ UniValue tokenconvert(const UniValue& params, bool fHelp) evalcode = atoi(params[0].get_str().c_str()); tokenid = Parseuint256((char *)params[1].get_str().c_str()); std::vector pubkey(ParseHex(params[2].get_str().c_str())); - amount = atol(params[3].get_str().c_str()); + //amount = atol(params[3].get_str().c_str()); + amount = atoll(params[3].get_str().c_str()); // dimxy changed to prevent loss of significance if ( tokenid == zeroid ) { ERR_RESULT("invalid tokenid"); @@ -6946,7 +6959,8 @@ UniValue tokenbid(const UniValue& params, bool fHelp) 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); - numtokens = atoi(params[0].get_str().c_str()); + //numtokens = atoi(params[0].get_str().c_str()); + numtokens = atoll(params[0].get_str().c_str()); // dimxy changed to prevent loss of significance tokenid = Parseuint256((char *)params[1].get_str().c_str()); price = atof(params[2].get_str().c_str()); bidamount = (price * numtokens) * COIN + 0.0000000049999; @@ -7014,7 +7028,8 @@ UniValue tokenfillbid(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); bidtxid = Parseuint256((char *)params[1].get_str().c_str()); - fillamount = atol(params[2].get_str().c_str()); + // fillamount = atol(params[2].get_str().c_str()); + fillamount = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance if ( fillamount <= 0 ) { ERR_RESULT("fillamount must be positive"); @@ -7043,10 +7058,12 @@ UniValue tokenask(const UniValue& params, bool fHelp) 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); - numtokens = atoi(params[0].get_str().c_str()); + //numtokens = atoi(params[0].get_str().c_str()); + numtokens = atoll(params[0].get_str().c_str()); // dimxy changed to prevent loss of significance tokenid = Parseuint256((char *)params[1].get_str().c_str()); price = atof(params[2].get_str().c_str()); askamount = (price * numtokens) * COIN + 0.0000000049999; + //std::cerr << std::boolalpha << "tokenask(): (tokenid == zeroid) is " << (tokenid == zeroid) << " (numtokens <= 0) is " << (numtokens <= 0) << " (price <= 0) is " << (price <= 0) << " (askamount <= 0) is " << (askamount <= 0) << std::endl; if ( tokenid == zeroid || numtokens <= 0 || price <= 0 || askamount <= 0 ) { ERR_RESULT("invalid parameter"); @@ -7075,7 +7092,8 @@ UniValue tokenswapask(const UniValue& params, bool fHelp) 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); - numtokens = atoi(params[0].get_str().c_str()); + //numtokens = atoi(params[0].get_str().c_str()); + numtokens = atoll(params[0].get_str().c_str()); // dimxy changed to prevent loss of significance tokenid = Parseuint256((char *)params[1].get_str().c_str()); otherid = Parseuint256((char *)params[2].get_str().c_str()); price = atof(params[3].get_str().c_str()); @@ -7129,7 +7147,8 @@ UniValue tokenfillask(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); tokenid = Parseuint256((char *)params[0].get_str().c_str()); asktxid = Parseuint256((char *)params[1].get_str().c_str()); - fillunits = atol(params[2].get_str().c_str()); + //fillunits = atol(params[2].get_str().c_str()); + fillunits = atoll(params[2].get_str().c_str()); // dimxy changed to prevent loss of significance if ( fillunits <= 0 ) { ERR_RESULT("fillunits must be positive"); @@ -7169,7 +7188,8 @@ UniValue tokenfillswap(const UniValue& params, bool fHelp) tokenid = Parseuint256((char *)params[0].get_str().c_str()); otherid = Parseuint256((char *)params[1].get_str().c_str()); asktxid = Parseuint256((char *)params[2].get_str().c_str()); - fillunits = atol(params[3].get_str().c_str()); + //fillunits = atol(params[3].get_str().c_str()); + fillunits = atoll(params[3].get_str().c_str()); // dimxy changed to prevent loss of significance hex = FillSell(0,tokenid,otherid,asktxid,fillunits); if (fillunits > 0) { if ( hex.size() > 0 ) { From a25af8d781ecb891b6fb145cd4cc3b0773b3d605 Mon Sep 17 00:00:00 2001 From: dim71 Date: Sat, 1 Dec 2018 03:28:07 +0500 Subject: [PATCH 15/49] removed unused commented function --- src/cc/assets.cpp | 56 ----------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 92c1ddaac..378c427a9 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -131,60 +131,6 @@ -// Recursively browses and verifies tx's vins to make sure no fake tokens have been 'planted' -// This func should be call with maxlevels = 2 -// on the first level it validates that current tx does not have invalid non-cc inputs -// on the second level it validates that all cc inputs of this tx also don't have 'feeding' non-cc inputs -/* -bool ValidateInputsTraversal(int32_t maxlevels, struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint256 assetid) -{ - int64_t dummyPrice; - std::vector dummyPubkey; - uint256 dummyAsset, dummyAsset2; - - int32_t numvins = tx.vin.size(); - int32_t numvouts = tx.vout.size(); - - // check it for the sake of.. - if (numvouts == 0) - return false; - - uint8_t funcId = DecodeAssetOpRet(tx.vout[numvouts - 1].scriptPubKey, dummyAsset, dummyAsset2, dummyPrice, dummyPubkey); - - // this is initial tokenbase tx: - if (tx.GetHash() == assetid && funcId == 'c') { - std::cerr << "ValidateInputsTraversal() found initial tx=" << assetid.GetHex() << std::endl; - return true; - } - - int64_t myCCVinsAmount = 0; - int64_t myCCVoutsAmount = 0; - std::vector ccVinsTxs; - - bool isCCEqual = AssetExactAmounts(cp, myCCVinsAmount, 0, myCCVoutsAmount, eval, tx, assetid); - if (!isCCEqual) { //Note: for the spending tx (1-st level) this condition is also checked in AssetsValidate() itself -- dimxy - std::cerr << "ValidateInputsTraversal() found bad uxto txid=" << tx.GetHash().GetHex() << " ccVinsAmount=" << myCCVinsAmount << " ccVoutsAmount=" << myCCVoutsAmount << std::endl; - eval->Invalid("deep search found bad non-cc uxto"); - return false; - } - - // recursively validate vins' txs (only for one level - see maxlevels var): - bool allVinTxsGood = true; - - if (--maxlevels > 0) { - for (int32_t i = 0; i < ccVinsTxs.size(); i++) { - if (!ValidateInputsTraversal(maxlevels, cp, eval, ccVinsTxs[i], assetid)) { - allVinTxsGood = false; - break; - } - } - } - - std::cerr << "ValidateInputsTraversal() for txid=" << tx.GetHash().GetHex() << " allVinTxsGood=" << std::boolalpha << allVinTxsGood << std::endl; - - return allVinTxsGood; -} -*/ // tx validation bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn) @@ -217,8 +163,6 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx return eval->Invalid("asset inputs != outputs"); } -// if( !ValidateInputsTraversal(2, cp, eval, tx, assetid) ) -// return false; switch ( funcid ) { From 800396d7461b67045bc489560266c97966d89f26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 12:13:03 -1100 Subject: [PATCH 16/49] Allow duplicated destination for sendmany --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f3b344ecd..8f0a692b4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1319,9 +1319,9 @@ UniValue sendmany(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Zcash address: ") + name_); } - if (destinations.count(dest)) { + /*if (destinations.count(dest)) { throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_); - } + }*/ destinations.insert(dest); CScript scriptPubKey = GetScriptForDestination(dest); From e23cb3e0d291e81236be7113db0eb08618fd0b4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 12:22:02 -1100 Subject: [PATCH 17/49] Partial revert of heir address to build --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 26f56b395..c65bdd746 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5548,9 +5548,9 @@ UniValue heiraddress(const UniValue& params, bool fHelp) if(params.size() == 4) destPubkey = ParseHex(params[3].get_str().c_str()); - return HeirFundBad(funcid, assetid, funds, destPubkey); + //return HeirFundBad(funcid, assetid, funds, destPubkey); - //return(CCaddress(cp,(char *)"Heir",pubkey)); + return(CCaddress(cp,(char *)"Heir",destPubkey)); } UniValue lottoaddress(const UniValue& params, bool fHelp) From 7c59f227c5a1025e645687770fd8eb0b2c6ee569 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 13:09:25 -1100 Subject: [PATCH 18/49] Allow bigger auto diceaddfunds --- src/cc/dice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 8d750b1ed..597f2cb38 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -98,7 +98,7 @@ What is needed is for the dealer node to track the entropy tx that was already b #include "../compat/endian.h" #define MAX_ENTROPYUSED 8192 -#define DICE_MINUTXOS 10000 +#define DICE_MINUTXOS 15000 extern int32_t KOMODO_INSYNC; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; @@ -1392,7 +1392,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 } if ( scriptPubKey == fundingPubKey ) { - if ( AddNormalinputs(mtx,mypk,amount+2*txfee,1) > 0 ) + if ( AddNormalinputs(mtx,mypk,amount+2*txfee,60) > 0 ) { hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,dicepk)); @@ -1667,7 +1667,7 @@ void *dealer0_loop(void *_arg) n = sqrt(DICE_MINUTXOS - entropytxs) + 10; for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) { if ( DecodeHexTx(tx,res) != 0 ) From db83c122c7c1cc121c61faeed8b86d8626758cf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 13:59:03 -1100 Subject: [PATCH 19/49] Reduce network traffic --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1ca925482..de9fe34c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5202,11 +5202,11 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo CheckBlockIndex(); if (!ret && futureblock == 0) { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) + /*if ( ASSETCHAINS_SYMBOL[0] == 0 ) { //fprintf(stderr,"request headers from failed process block peer\n"); pfrom->PushMessage("getheaders", chainActive.GetLocator(chainActive.LastTip()), uint256()); - } + }*/ komodo_longestchain(); return error("%s: AcceptBlock FAILED", __func__); } From 3043dffcf58a15d7b94f822fbfc616d7f4c79e18 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 1 Dec 2018 12:52:38 +0800 Subject: [PATCH 20/49] fix getblocktemplate --- src/rpc/mining.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index aed10944c..25b75c301 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -606,9 +606,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return BIP22ValidationResult(state); } } - - if (strMode != "template") - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + else + { + strMode = "template"; + } bool fvNodesEmpty; { From 46a6e1db66556165c6e35f144df96ab67ae7bf51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 22:37:48 -1100 Subject: [PATCH 21/49] +prints --- src/cc/dice.cpp | 4 +++- src/wallet/rpcwallet.cpp | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 597f2cb38..631951c0d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1664,7 +1664,9 @@ void *dealer0_loop(void *_arg) DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false); if ( entropytxs < DICE_MINUTXOS ) { - n = sqrt(DICE_MINUTXOS - entropytxs) + 10; + n = sqrt(DICE_MINUTXOS - entropytxs); + if ( n > 10 ) + n = 10; for (i=0; inTime+27,minage,hashbuf)) == 0 ) continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); - //fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); +fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; @@ -5215,7 +5215,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier break; m++; - //fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); +fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); } } else @@ -5225,7 +5225,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } eligible = besttime; winners++; - //fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); +fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) { earliest = eligible; @@ -5237,8 +5237,8 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } - } //else fprintf(stderr,"utxo not eligible\n"); - } //else fprintf(stderr,"no tipindex\n"); + } else fprintf(stderr,"utxo not eligible\n"); + } else fprintf(stderr,"no tipindex\n"); if ( numkp < 10000 && array != 0 ) { free(array); @@ -5273,11 +5273,11 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i Date: Fri, 30 Nov 2018 22:39:32 -1100 Subject: [PATCH 22/49] -print --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 953a24ef4..03f9c2b36 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5238,7 +5238,7 @@ fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",n fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } } else fprintf(stderr,"utxo not eligible\n"); - } else fprintf(stderr,"no tipindex\n"); + } if ( numkp < 10000 && array != 0 ) { free(array); From 15b9d33d79eecb5a95815c2f5542c3457ed584a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 22:42:53 -1100 Subject: [PATCH 23/49] Fix staking < 10000 utxo --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 03f9c2b36..941a696ca 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5151,7 +5151,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( *blocktimep > tipindex->nTime+60 ) *blocktimep = tipindex->nTime+60; //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); - if ( time(NULL) > lasttime+600 ) + if ( time(NULL) > lasttime+600 || array == 0 ) { if ( array != 0 ) { From dcc2079714f69c554bb762fd160ff6dfa812a18b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 22:49:26 -1100 Subject: [PATCH 24/49] Fix _komodo_eligible --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 941a696ca..a1eafc6e2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5083,7 +5083,7 @@ arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uin diff = 3600*24*30; if ( iter > 0 ) diff += segid*2; - coinage = ((uint64_t)kp->nValue/COIN * diff); + coinage = ((uint64_t)kp->nValue * diff); if ( blocktime+iter+segid*2 > prevtime+480 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); //if ( nHeight >= 2500 && blocktime+iter+segid*2 > prevtime+180 ) @@ -5188,7 +5188,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt } } lasttime = (uint32_t)time(NULL); -fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); +//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; i Date: Fri, 30 Nov 2018 22:54:07 -1100 Subject: [PATCH 25/49] Test --- src/wallet/rpcwallet.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a1eafc6e2..6a195c912 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5086,12 +5086,8 @@ arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uin coinage = ((uint64_t)kp->nValue * diff); if ( blocktime+iter+segid*2 > prevtime+480 ) coinage *= ((blocktime+iter+segid*2) - (prevtime+400)); - //if ( nHeight >= 2500 && blocktime+iter+segid*2 > prevtime+180 ) - // coinage *= ((blocktime+iter+segid*2) - (prevtime+60)); coinage256 = arith_uint256(coinage+1); hashval = ratio * (kp->hashval / coinage256); - //if ( nHeight >= 900 && nHeight < 916 ) - // hashval = (hashval / coinage256); return(hashval); } @@ -5170,19 +5166,23 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { - //fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); +fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; if ( nValue < COIN || !out.fSpendable ) continue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; + fprintf(stderr,"ExtractDestination\n"); if ( ExtractDestination(pk,address) != 0 ) { + fprintf(stderr,"IsMine\n"); if ( IsMine(*pwalletMain,address) == 0 ) continue; + fprintf(stderr,"GetTransaction\n"); if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) { + fprintf(stderr,"addutxo\n"); array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); } } From 257e996fff4bcb31606d104591b706f5fbab3f13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 22:59:10 -1100 Subject: [PATCH 26/49] Test --- src/wallet/rpcwallet.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6a195c912..c227835bd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5059,8 +5059,10 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk { *maxkp += 1000; array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp)); + fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); } kp = &array[(*numkp)++]; + fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); memset(kp,0,sizeof(*kp)); strcpy(kp->address,address); kp->txid = txid; @@ -5166,30 +5168,28 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt counter++; if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth ) { -fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); + fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth); continue; } CAmount nValue = out.tx->vout[out.i].nValue; if ( nValue < COIN || !out.fSpendable ) continue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"ExtractDestination\n"); if ( ExtractDestination(pk,address) != 0 ) { - fprintf(stderr,"IsMine\n"); if ( IsMine(*pwalletMain,address) == 0 ) continue; - fprintf(stderr,"GetTransaction\n"); if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) { - fprintf(stderr,"addutxo\n"); array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); + fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); } } } lasttime = (uint32_t)time(NULL); -//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); +fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } +fprintf(stderr,"numkp.%d\n",numkp); block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; i Date: Fri, 30 Nov 2018 23:07:15 -1100 Subject: [PATCH 27/49] Test --- src/wallet/rpcwallet.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c227835bd..d09c48a95 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5059,10 +5059,10 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk { *maxkp += 1000; array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp)); - fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); + //fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array); } kp = &array[(*numkp)++]; - fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); + //fprintf(stderr,"kp.%p num.%d\n",kp,*numkp); memset(kp,0,sizeof(*kp)); strcpy(kp->address,address); kp->txid = txid; @@ -5101,9 +5101,9 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - //for (int i=32; i>=0; i--) - // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); + for (int i=32; i>=0; i--) + fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { for (iter=0; iterGetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 ) { array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk); - fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); + //fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp); } } } lasttime = (uint32_t)time(NULL); -fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); +//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } -fprintf(stderr,"numkp.%d\n",numkp); +fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; i Date: Fri, 30 Nov 2018 23:11:02 -1100 Subject: [PATCH 28/49] Set blocktime for staking --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8fb2b4677..981fad63f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -463,8 +463,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight); - //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) - // blocktime = pindexPrev->GetMedianTimePast() + 60; if (ASSETCHAINS_LWMAPOS != 0) { uint32_t nBitsPOS; @@ -479,6 +477,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } else { + blocktime = GetAdjustedTime(); + //if ( blocktime > pindexPrev->GetMedianTimePast()+60 ) + // blocktime = pindexPrev->GetMedianTimePast() + 60; siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig); } From 552294da4ae83cf2196f8bc3caee91b669ab671d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 23:13:07 -1100 Subject: [PATCH 29/49] Max to min --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d09c48a95..31fcdc7e2 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5146,7 +5146,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( (minage= nHeight*3) > 6000 ) // about 100 blocks minage = 6000; komodo_segids(hashbuf,nHeight-101,100); - if ( *blocktimep > tipindex->nTime+60 ) + if ( *blocktimep < tipindex->nTime+60 ) *blocktimep = tipindex->nTime+60; //fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight); if ( time(NULL) > lasttime+600 || array == 0 ) From 94d569467ec78e7dd5fb05f9c4e88a0cb699d67c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 23:18:36 -1100 Subject: [PATCH 30/49] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1a0fad409..0893ece6d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1771,12 +1771,12 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) { if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 ) { + if ( slowflag == 0 ) // need all past 100 blocks to calculate PoW target + return(0); if ( ASSETCHAINS_STAKED == 100 && height > 100 ) // only PoS allowed! POSTEST64 return(-1); else { - if ( slowflag == 0 ) // need all past 100 blocks to calculate PoW target - return(0); if ( slowflag != 0 ) bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash > bnTarget ) From 345a7838c289f7fccc95890ec9ed60d9fb4f947a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 23:23:35 -1100 Subject: [PATCH 31/49] Test --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0893ece6d..fd18ad0a0 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1472,14 +1472,14 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { - //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); +fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } } //else return(-1); } - //fprintf(stderr,"slow.%d ht.%d isPoS.%d\n",slowflag,height,isPoS); +fprintf(stderr,"slow.%d ht.%d isPoS.%d\n",slowflag,height,isPoS); return(isPoS != 0); } @@ -1824,7 +1824,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } - //fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); +fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) return(-1); else return(0); From 803d74be34cc1ebe1cbbe540c6483273fcdfc4a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 23:30:26 -1100 Subject: [PATCH 32/49] Test --- src/komodo_bitcoind.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fd18ad0a0..e7ecf5f77 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1472,14 +1472,14 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { -fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); + //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } } //else return(-1); } -fprintf(stderr,"slow.%d ht.%d isPoS.%d\n",slowflag,height,isPoS); + //fprintf(stderr,"slow.%d ht.%d isPoS.%d\n",slowflag,height,isPoS); return(isPoS != 0); } @@ -1796,6 +1796,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) fprintf(stderr,"unexpected negative is_PoSblock.%d\n",is_PoSblock); return(-1); } + else if ( ASSETCHAINS_STAKED != 0 ) + failed = 0; } if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 ) { @@ -1824,7 +1826,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) return(-1); } } -fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); +//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed); if ( failed != 0 && possible == 0 && notaryid < 0 ) return(-1); else return(0); From 3777611fbc459b3e1a377edcfb2fe7b476a8e76a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 30 Nov 2018 23:34:51 -1100 Subject: [PATCH 33/49] Test --- src/wallet/rpcwallet.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 31fcdc7e2..46b8d1818 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5189,7 +5189,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt lasttime = (uint32_t)time(NULL); //fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp); } -fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); +//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep); block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57; for (i=winners=0; inTime+27,minage,hashbuf)) == 0 ) continue; eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address); -fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); +//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible > 0 ) { besttime = m = 0; @@ -5215,7 +5215,7 @@ fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible); if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier break; m++; -fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); +//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible); } } else @@ -5225,7 +5225,7 @@ fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u te } eligible = besttime; winners++; -fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); +//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible); if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) ) { earliest = eligible; @@ -5237,7 +5237,7 @@ fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",n *txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime; fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners); } - } else fprintf(stderr,"utxo not eligible\n"); + } //else fprintf(stderr,"utxo not eligible\n"); } if ( numkp < 10000 && array != 0 ) { @@ -5273,11 +5273,11 @@ fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",n for (i=0; i Date: Fri, 30 Nov 2018 23:36:57 -1100 Subject: [PATCH 34/49] -print --- src/wallet/rpcwallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 46b8d1818..cbba7cca9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5101,9 +5101,9 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod kp->hashval = UintToArith256(hash); segid = ((nHeight + kp->segid32) & 0x3f); hashval = _komodo_eligible(kp,ratio,blocktime,maxiters,minage,segid,nHeight,prevtime); - for (int i=32; i>=0; i--) - fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); - fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); + //for (int i=32; i>=0; i--) + // fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]); + //fprintf(stderr," b.%u minage.%d segid.%d ht.%d prev.%u\n",blocktime,minage,segid,nHeight,prevtime); if ( hashval <= bnTarget ) { for (iter=0; iter Date: Sat, 1 Dec 2018 01:19:33 -1100 Subject: [PATCH 35/49] Change entropy tx issuing --- src/cc/dice.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 631951c0d..ae9e01fce 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1652,21 +1652,28 @@ static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid; int32_t entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid; int32_t height,lastht,entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); exit(-1); } fprintf(stderr,"dealer0 node running\n"); + height = lastht = 0; while ( 1 ) { + while ( KOMODO_INSYNC == 0 || (height= KOMODO_INSYNC) == lastht ) + { + sleep(3); + } + lastht = height; + fprintf(stderr,"New height.%d\n",height); DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false); if ( entropytxs < DICE_MINUTXOS ) { n = sqrt(DICE_MINUTXOS - entropytxs); - if ( n > 10 ) - n = 10; + //if ( n > 10 ) + // n = 10; for (i=0; i Date: Sat, 1 Dec 2018 01:23:56 -1100 Subject: [PATCH 36/49] Limit to 10 --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ae9e01fce..a2909efc3 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1672,8 +1672,8 @@ void *dealer0_loop(void *_arg) if ( entropytxs < DICE_MINUTXOS ) { n = sqrt(DICE_MINUTXOS - entropytxs); - //if ( n > 10 ) - // n = 10; + if ( n > 10 ) + n = 10; for (i=0; i Date: Sat, 1 Dec 2018 01:50:35 -1100 Subject: [PATCH 37/49] AddNormalinputs2 bypass bitcoin wallet --- src/cc/CCinclude.h | 1 + src/cc/CCtx.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++ src/cc/dice.cpp | 2 +- 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index ddfecd47a..83c85e551 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -178,6 +178,7 @@ std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTr void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); void SetCCtxids(std::vector > &addressIndex,char *coinaddr); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout); // curve25519 and sha256 diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index b94e1372c..b683a7f51 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -431,3 +431,92 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3 #endif return(0); } + + +int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs) +{ + int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=64; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; + std::vector > unspentOutputs; + utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos)); + threshold = total/(maxinputs+1); + if ( maxinputs > maxutxos ) + maxutxos = maxinputs; + sum = 0; + Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG); + SetCCunspents(unspentOutputs,coinaddr); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + if ( it->second.satoshis < threshold ) + continue; + if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) + { + //fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout); + if ( mtx.vin.size() > 0 ) + { + for (i=0; i 0 ) + { + for (i=0; itxid = txid; + up->nValue = it->second.satoshis; + up->vout = vout; + sum += up->nValue; + //fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos); + if ( n >= maxutxos || sum >= total ) + break; + } + } + } + remains = total; + for (i=0; i0; i++) + { + below = above = 0; + abovei = belowi = -1; + if ( CC_vinselect(&abovei,&above,&belowi,&below,utxos,n,remains) < 0 ) + { + printf("error finding unspent i.%d of %d, %.8f vs %.8f\n",i,n,(double)remains/COIN,(double)total/COIN); + free(utxos); + return(0); + } + if ( belowi < 0 || abovei >= 0 ) + ind = abovei; + else ind = belowi; + if ( ind < 0 ) + { + printf("error finding unspent i.%d of %d, %.8f vs %.8f, abovei.%d belowi.%d ind.%d\n",i,n,(double)remains/COIN,(double)total/COIN,abovei,belowi,ind); + free(utxos); + return(0); + } + up = &utxos[ind]; + mtx.vin.push_back(CTxIn(up->txid,up->vout,CScript())); + totalinputs += up->nValue; + remains -= up->nValue; + utxos[ind] = utxos[--n]; + memset(&utxos[n],0,sizeof(utxos[n])); + //fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs); + if ( totalinputs >= total || (i+1) >= maxinputs ) + break; + } + free(utxos); + if ( totalinputs >= total ) + { + //fprintf(stderr,"return totalinputs %.8f\n",(double)totalinputs/COIN); + return(totalinputs); + } + return(0); +} diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a2909efc3..7af73241b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1392,7 +1392,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 } if ( scriptPubKey == fundingPubKey ) { - if ( AddNormalinputs(mtx,mypk,amount+2*txfee,60) > 0 ) + if ( AddNormalinputs2(mtx,amount+2*txfee,60) > 0 ) { hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,dicepk)); From 69f0b8631f6c028fec0768eb4c3e82a16c0d00e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 01:56:08 -1100 Subject: [PATCH 38/49] Remove 10 entropy cap --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7af73241b..9c8438fd4 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1672,8 +1672,8 @@ void *dealer0_loop(void *_arg) if ( entropytxs < DICE_MINUTXOS ) { n = sqrt(DICE_MINUTXOS - entropytxs); - if ( n > 10 ) - n = 10; + //if ( n > 10 ) + // n = 10; for (i=0; i Date: Sat, 1 Dec 2018 03:16:26 -1100 Subject: [PATCH 39/49] Verify entropy tx is confirmed for dealer0 --- src/cc/dice.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 9c8438fd4..4f923d754 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1505,7 +1505,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv { if ( vin0txid == zeroid || vin0vout < 0 ) { - if ( AddNormalinputs(mtx,mypk,2*txfee,3) == 0 ) // must be a single vin!! + if ( AddNormalinputs2(mtx,2*txfee,3) == 0 ) // must be a single vin!! { CCerror = "no txfee inputs for win/lose"; fprintf(stderr,"%s\n", CCerror.c_str() ); @@ -1652,7 +1652,7 @@ static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid; int32_t height,lastht,entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid,txid; int32_t height,lastht,entropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); @@ -1660,6 +1660,7 @@ void *dealer0_loop(void *_arg) } fprintf(stderr,"dealer0 node running\n"); height = lastht = 0; + entropytx = (CTransaction *)calloc(sizeof(*entropytx),DICE_MINUTXOS); while ( 1 ) { while ( KOMODO_INSYNC == 0 || (height= KOMODO_INSYNC) == lastht ) @@ -1674,7 +1675,7 @@ void *dealer0_loop(void *_arg) n = sqrt(DICE_MINUTXOS - entropytxs); //if ( n > 10 ) // n = 10; - for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) @@ -1686,10 +1687,30 @@ void *dealer0_loop(void *_arg) { fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); RelayTransaction(tx); + entropytxs[m++] = tx; } else break; } else break; } else break; } + for (i=0; i Date: Sat, 1 Dec 2018 03:17:26 -1100 Subject: [PATCH 40/49] numentropytxs --- src/cc/dice.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4f923d754..dd7ef11ab 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1652,7 +1652,7 @@ static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid,txid; int32_t height,lastht,entropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); @@ -1669,13 +1669,13 @@ void *dealer0_loop(void *_arg) } lastht = height; fprintf(stderr,"New height.%d\n",height); - DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false); - if ( entropytxs < DICE_MINUTXOS ) + DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,numentropytxs,false); + if ( numentropytxs < DICE_MINUTXOS ) { - n = sqrt(DICE_MINUTXOS - entropytxs); + n = sqrt(DICE_MINUTXOS - numentropytxs); //if ( n > 10 ) // n = 10; - for (i=m=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) @@ -1685,7 +1685,7 @@ void *dealer0_loop(void *_arg) LOCK(cs_main); if ( myAddtomempool(tx) != 0 ) { - fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); + fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - numentropytxs); RelayTransaction(tx); entropytxs[m++] = tx; } else break; From 760d30b22bdecc19f6cadeb49fb65ad2a030643b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:17:56 -1100 Subject: [PATCH 41/49] hashBlock --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index dd7ef11ab..3cb1a5a25 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1652,7 +1652,7 @@ static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 hashBlock,entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); From d6dfb8c2506326a9f39b28918e792a655972fa1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:18:45 -1100 Subject: [PATCH 42/49] numentropytxs --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 3cb1a5a25..0676900e4 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1660,7 +1660,7 @@ void *dealer0_loop(void *_arg) } fprintf(stderr,"dealer0 node running\n"); height = lastht = 0; - entropytx = (CTransaction *)calloc(sizeof(*entropytx),DICE_MINUTXOS); + entropytx = (CTransaction *)calloc(sizeof(*entropytxs),DICE_MINUTXOS); while ( 1 ) { while ( KOMODO_INSYNC == 0 || (height= KOMODO_INSYNC) == lastht ) From 2ee44287ade0860d1de384f40d517ecb1c95f3fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:19:24 -1100 Subject: [PATCH 43/49] Txs --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0676900e4..6d09eda07 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1660,7 +1660,7 @@ void *dealer0_loop(void *_arg) } fprintf(stderr,"dealer0 node running\n"); height = lastht = 0; - entropytx = (CTransaction *)calloc(sizeof(*entropytxs),DICE_MINUTXOS); + entropytxs = (CTransaction *)calloc(sizeof(*entropytxs),DICE_MINUTXOS); while ( 1 ) { while ( KOMODO_INSYNC == 0 || (height= KOMODO_INSYNC) == lastht ) From 4c1cab06b0bdc443855461a55fb0578c7d820a86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:32:40 -1100 Subject: [PATCH 44/49] +prints --- src/cc/dice.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6d09eda07..ff55be6ef 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1696,7 +1696,7 @@ void *dealer0_loop(void *_arg) { tx = entropytxs[i]; txid = tx.GetHash(); - fprintf(stderr,"found %d of %d: %s\n",i,m,txid.GetHex().c_str()); + fprintf(stderr,"check %d of %d: %s\n",i,m,txid.GetHex().c_str()); while ( 1 ) { if ( myGetTransaction(txid,entropytx,hashBlock) == 0 || hashBlock == zeroid ) @@ -1708,7 +1708,12 @@ void *dealer0_loop(void *_arg) RelayTransaction(tx); } sleep(10); - } else break; + } + else + { + fprintf(stderr,"found %s in %s\n",txid.GetHex().c_str(),hashBlock.GetHex().c_str()); + break; + } } } } From 2e8f9eda462090ffe43949610251ed4b9891b3ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:40:13 -1100 Subject: [PATCH 45/49] Test --- src/cc/dice.cpp | 2 +- src/main.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ff55be6ef..0581dc9ce 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1707,13 +1707,13 @@ void *dealer0_loop(void *_arg) fprintf(stderr,"resend ENTROPY %s: %d of %d\n",txid.GetHex().c_str(),i,m); RelayTransaction(tx); } - sleep(10); } else { fprintf(stderr,"found %s in %s\n",txid.GetHex().c_str(),hashBlock.GetHex().c_str()); break; } + sleep(10); } } } diff --git a/src/main.cpp b/src/main.cpp index de9fe34c3..564221f17 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1979,6 +1979,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate) bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) { + hashBlock = zeroid; // need a GetTransaction without lock so the validation code for assets can run without deadlock { //fprintf(stderr,"check mempool\n"); @@ -2022,6 +2023,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) { CBlockIndex *pindexSlow = NULL; + hashBlock = zeroid; LOCK(cs_main); From e5a4fcc4b82e8160f9671e38a0622958e0338e29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:42:33 -1100 Subject: [PATCH 46/49] memset(&hashBlock,0,sizeof(hashBlock)); --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 564221f17..942dc120e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1979,7 +1979,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate) bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) { - hashBlock = zeroid; + memset(&hashBlock,0,sizeof(hashBlock)); // need a GetTransaction without lock so the validation code for assets can run without deadlock { //fprintf(stderr,"check mempool\n"); @@ -2023,7 +2023,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) { CBlockIndex *pindexSlow = NULL; - hashBlock = zeroid; + memset(&hashBlock,0,sizeof(hashBlock)); LOCK(cs_main); From b0b80e69e68069da8d55537cc1856c83eeeff921 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 1 Dec 2018 03:59:11 -1100 Subject: [PATCH 47/49] Entropy tx size 1.0 --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0581dc9ce..6faaa1f0c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1677,7 +1677,7 @@ void *dealer0_loop(void *_arg) // n = 10; for (i=m=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) { if ( DecodeHexTx(tx,res) != 0 ) From d1e8c8c8fc68f7338bf7a41df4d5f092d7c02911 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 2 Dec 2018 17:44:05 +0000 Subject: [PATCH 48/49] Update assetchains.old --- src/assetchains.old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index 9164ca316..5389e54bd 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -27,7 +27,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -addnode=174.138.107.226 & +./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_saplinig=5000000 -addnode=174.138.107.226 & ./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 & ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & From 6bd19b0835c42ebec129f5388aa852d79b49909e Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 2 Dec 2018 17:47:13 +0000 Subject: [PATCH 49/49] added `-ac_saplinig=5000000` for OOT added `-ac_saplinig=5000000` for OOT --- src/assetchains.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 287a88c19..7bc6b7147 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -94,7 +94,8 @@ }, { "ac_name": "OOT", - "ac_supply": "216000000" + "ac_supply": "216000000", + "ac_sapling": "5000000" }, { "ac_name": "BNTN",