From b5910e55c71dc13b8c1a33ed07854a3bfce1428a Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 2 May 2019 23:35:22 +0800 Subject: [PATCH 1/3] . --- src/cc/payments.cpp | 12 ++++++------ src/init.cpp | 2 +- src/main.cpp | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 7ab3e8202..814d6823c 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -894,16 +894,16 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk)); opret = EncodePaymentsFundOpRet(txid); // Use the below one along with other FinalizeCCTx/return, to get the ccvout scriptpubkey - /*std::vector> vData = std::vector>(); + std::vector> vData = std::vector>(); if ( makeCCopret(opret, vData) ) - mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk,&vData)); */ + mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk,&vData)); } - rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); - //rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,CScript()); // use this one to get ccvout scriptpubkey. + //rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,CScript()); // use this one to get ccvout scriptpubkey. if ( params != 0 ) free_json(params); - //return(payments_rawtxresult(result,rawtx,0)); // disable sending for CCvout, as we only need to decode the tx. - return(payments_rawtxresult(result,rawtx,1)); + return(payments_rawtxresult(result,rawtx,0)); // disable sending for CCvout, as we only need to decode the tx. + //return(payments_rawtxresult(result,rawtx,1)); } else { diff --git a/src/init.cpp b/src/init.cpp index bab2aba77..107e3e476 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1627,7 +1627,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) break; } - if ( ASSETCHAINS_CC != 0 && KOMODO_SNAPSHOT_INTERVAL != 0 && chainActive.Height() > KOMODO_SNAPSHOT_INTERVAL ) + if ( ASSETCHAINS_CC != 0 && KOMODO_SNAPSHOT_INTERVAL != 0 && chainActive.Height() >= KOMODO_SNAPSHOT_INTERVAL ) { if ( !komodo_dailysnapshot(chainActive.Height()) ) { diff --git a/src/main.cpp b/src/main.cpp index ef1a1a40b..2e57f419e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4251,7 +4251,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * komodo_pricesupdate(pindexNew->GetHeight(),pblock); if ( ASSETCHAINS_SAPLING <= 0 && pindexNew->nTime > KOMODO_SAPLING_ACTIVATION - 24*3600 ) komodo_activate_sapling(pindexNew); - if ( ASSETCHAINS_CC != 0 && KOMODO_SNAPSHOT_INTERVAL != 0 && (pindexNew->GetHeight() % KOMODO_SNAPSHOT_INTERVAL) == 0 && pindexNew->GetHeight() > KOMODO_SNAPSHOT_INTERVAL ) + if ( ASSETCHAINS_CC != 0 && KOMODO_SNAPSHOT_INTERVAL != 0 && (pindexNew->GetHeight() % KOMODO_SNAPSHOT_INTERVAL) == 0 && pindexNew->GetHeight() >= KOMODO_SNAPSHOT_INTERVAL ) { uint64_t start = time(NULL); if ( !komodo_dailysnapshot(pindexNew->GetHeight()) ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8a671b322..754ec5318 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -8047,10 +8047,10 @@ UniValue opreturn_burn(const UniValue& params, bool fHelp) throw runtime_error("not enough normals\n"); CScript opret; uint8_t *ptr; - opret << OP_RETURN; + opret << OP_RETURN << 0; int32_t len = strlen(strHex.c_str()); len >>=1; - opret.resize(len+1); + opret.resize(len+2); ptr = (uint8_t *)&opret[1]; decode_hex(ptr,len,(char *)strHex.c_str()); mtx.vout.push_back(CTxOut(nAmount,opret)); From 4d8a0547b317457e594d62b18e459b9fddbd7ff5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 2 May 2019 23:39:07 +0800 Subject: [PATCH 2/3] revert RPC --- src/komodo_bitcoind.h | 2 +- src/wallet/rpcwallet.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a1510a34e..292d5f8df 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2063,7 +2063,7 @@ bool komodo_appendACscriptpub() ASSETCHAINS_SCRIPTPUB.pop_back(); ASSETCHAINS_SCRIPTPUB.pop_back(); // remove last 2 chars. // get OP_RETURN from txid and append the HexStr of it to scriptpub // encoded opreturn incorrectly on TESTHC chain, once we no longer need this it can be changed to a straight +1 to drop OP_RETURN opcode. - ASSETCHAINS_SCRIPTPUB.append(HexStr(tx.vout[i].scriptPubKey.begin()+(strcmp("TESTHC",ASSETCHAINS_SYMBOL) == 0 ? 3 : 1), tx.vout[i].scriptPubKey.end())); + ASSETCHAINS_SCRIPTPUB.append(HexStr(tx.vout[i].scriptPubKey.begin()+3, tx.vout[i].scriptPubKey.end())); //fprintf(stderr, "ac_script.%s\n",ASSETCHAINS_SCRIPTPUB.c_str()); didinit = true; return true; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 754ec5318..888c60e0e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -8045,14 +8045,21 @@ UniValue opreturn_burn(const UniValue& params, bool fHelp) int64_t normalInputs = AddNormalinputs(mtx, myPubkey, nAmount, 60); if (normalInputs < nAmount) throw runtime_error("not enough normals\n"); - - CScript opret; uint8_t *ptr; + + CScript opret; uint8_t scripthex[8192]; + + decode_hex(scripthex,strHex.size()/2,(char *)strHex.c_str()); + std::string test; + test.append((char*)scripthex); + std::vector opretdata(test.begin(), test.end()); + opret << OP_RETURN << E_MARSHAL(ss << opretdata); + /*CScript opret; uint8_t *ptr; opret << OP_RETURN << 0; int32_t len = strlen(strHex.c_str()); len >>=1; opret.resize(len+2); ptr = (uint8_t *)&opret[1]; - decode_hex(ptr,len,(char *)strHex.c_str()); + decode_hex(ptr,len,(char *)strHex.c_str()); */ mtx.vout.push_back(CTxOut(nAmount,opret)); ret.push_back(Pair("hex",FinalizeCCTx(0, cp, mtx, myPubkey, 10000, CScript()))); return(ret); From 7fc288161e8c90114f69759c52528106d458f730 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 3 May 2019 00:03:19 +0800 Subject: [PATCH 3/3] recomment paymentsfund --- src/cc/payments.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index 814d6823c..7ab3e8202 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -894,16 +894,16 @@ UniValue PaymentsFund(struct CCcontract_info *cp,char *jsonstr) mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk)); opret = EncodePaymentsFundOpRet(txid); // Use the below one along with other FinalizeCCTx/return, to get the ccvout scriptpubkey - std::vector> vData = std::vector>(); + /*std::vector> vData = std::vector>(); if ( makeCCopret(opret, vData) ) - mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk,&vData)); + mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,amount,Paymentspk,&vData)); */ } - //rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); - rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,CScript()); // use this one to get ccvout scriptpubkey. + rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,opret); + //rawtx = FinalizeCCTx(0,cp,mtx,mypk,PAYMENTS_TXFEE,CScript()); // use this one to get ccvout scriptpubkey. if ( params != 0 ) free_json(params); - return(payments_rawtxresult(result,rawtx,0)); // disable sending for CCvout, as we only need to decode the tx. - //return(payments_rawtxresult(result,rawtx,1)); + //return(payments_rawtxresult(result,rawtx,0)); // disable sending for CCvout, as we only need to decode the tx. + return(payments_rawtxresult(result,rawtx,1)); } else {