From 824325ac281b969cf3c70bdd0c719882be57d524 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Jan 2019 23:31:30 -1100 Subject: [PATCH] MarmaraSignature --- src/cc/marmara.cpp | 29 ++++++++++++++++++++++++++++- src/komodo_bitcoind.h | 23 ++++++++++++----------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index ca216069a..906d268be 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -500,7 +500,34 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) return(result); } -// jl777: decide on what unlockht settlement change should have +int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew); +{ + uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector pubkeys; struct CCcontract_info *cp,C; uint64_t txfee + txfee = 10000; + vout = txNew.vin[0].prevout.n; + if ( GetTransaction(txNew.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts ) + { + cp = CCinit(&C,EVAL_MARMARA); + mypk = pubkey2pk(Mypubkey()); + mtx.vout.resize(2); + mtx.vout[1].scriptPubKey = tx.vout[numvouts - 1].scriptPubKey; + mtx.vout[1].nValue = 0; + pubkeys.push_back(mypk); + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tx.vout[numvouts - 1].scriptPubKey,pubkeys); + if ( rawtx.size() > 0 ) + { + siglen = mtx.vin[0].scriptSig.size(); + ptr = mtx.vin[0].scriptSig.data(); + for (i=0; i from utxo making change UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 77dfbf6ad..383f4bf40 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2081,6 +2081,8 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod return(0); } +int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew); + int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) { static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime; @@ -2264,22 +2266,21 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( ASSETCHAINS_MARMARA == 0 ) { signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId); - } - else - { - fprintf(stderr,"add opreturn and CCFinalizetx\n"); - // add opreturn - // signSuccess = CCFinalizetx(...) - } - if (!signSuccess) - fprintf(stderr,"failed to create signature\n"); - else - { UpdateTransaction(txNew,0,sigdata); ptr = (uint8_t *)&sigdata.scriptSig[0]; siglen = sigdata.scriptSig.size(); for (i=0; i