From 04b11f66d4ed94af7cee7b16a465ebd971cffca4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Jan 2019 02:07:01 -1100 Subject: [PATCH] Test --- src/cc/marmara.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 75fa385b4..0a2a5e13b 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -408,7 +408,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) { CMutableTransaction tmpmtx,mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; + UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; CPubKey Marmarapk,mypk,pk; int32_t unlockht,refunlockht,vout,ht,numvouts; int64_t nValue,val,inputsum=0,threshold,remains,change = 0; std::string rawtx,errorstr; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; uint8_t funcid; if ( txfee == 0 ) txfee = 10000; if ( (height & 1) != 0 ) @@ -417,8 +417,11 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); - inputsum = AddNormalinputs2(mtx,amount,MARMARA_VINS); - fprintf(stderr,"normal inputs %.8f\n",(double)inputsum/COIN); + if ( (val= CCaddress_balance(coinaddr)) < amount ) + val -= txfee; + if ( val > txfee ) + inputsum = AddNormalinputs2(mtx,val,MARMARA_VINS); + //fprintf(stderr,"normal inputs %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1of2vout(EVAL_MARMARA,amount,Marmarapk,mypk)); if ( inputsum < amount+txfee ) {