From 02efca37aeb97b2677cf0bb7427d40c55aff1bf8 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 17 Dec 2018 13:04:04 +0800 Subject: [PATCH 01/12] revert this change it is wrong, they need to be OR here. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 20f28d46a..a6c4778db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4710,7 +4710,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C CValidationState state; CTransaction Tx; const CTransaction &tx = (CTransaction)block.vtx[i]; - if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) + if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) continue; Tx = tx; if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync From 52a85f583e7554666f8c07728488d8b5b3d6e5ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 17 Dec 2018 02:55:47 -1100 Subject: [PATCH 02/12] Test merge --- 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 f8b507403..34035908d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4789,8 +4789,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (useAnySprout || useAnySapling || zaddrs.size() > 0) { // Get available notes std::vector sproutEntries; - std::vector saplingEntries; - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs); + std::vector saplingEntries,skipsapling; + pwalletMain->GetFilteredNotes(sproutEntries, useAnySprout != 0 ? saplingEntries : skipsapling, zaddrs); // If Sapling is not active, do not allow sending from a sapling addresses. if (!saplingActive && saplingEntries.size() > 0) { From 89c6763a8f1d3fae49b2fb1e38946ef076d20cd6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 17 Dec 2018 03:25:44 -1100 Subject: [PATCH 03/12] Mutually exclude merging sprout vs sapling --- 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 34035908d..1d6f056da 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4788,9 +4788,9 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) if (useAnySprout || useAnySapling || zaddrs.size() > 0) { // Get available notes - std::vector sproutEntries; + std::vector sproutEntries,skipsprout; std::vector saplingEntries,skipsapling; - pwalletMain->GetFilteredNotes(sproutEntries, useAnySprout != 0 ? saplingEntries : skipsapling, zaddrs); + pwalletMain->GetFilteredNotes(useAnySprout != 0 ? sproutEntries : skipsprout, useAnySapling != 0 ? saplingEntries : skipsapling, zaddrs); // If Sapling is not active, do not allow sending from a sapling addresses. if (!saplingActive && saplingEntries.size() > 0) { From 97fe83f4b3f969af56a0d4bded33c2b01d78750c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 17 Dec 2018 04:12:47 -1100 Subject: [PATCH 04/12] Test any sprout --- 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 1d6f056da..bd1ae56d6 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4790,7 +4790,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) // Get available notes std::vector sproutEntries,skipsprout; std::vector saplingEntries,skipsapling; - pwalletMain->GetFilteredNotes(useAnySprout != 0 ? sproutEntries : skipsprout, useAnySapling != 0 ? saplingEntries : skipsapling, zaddrs); + pwalletMain->GetFilteredNotes(sproutEntries, useAnySprout == 0 ? saplingEntries : skipsapling, zaddrs); // If Sapling is not active, do not allow sending from a sapling addresses. if (!saplingActive && saplingEntries.size() > 0) { From 56430117fe4df47e2c6e2ecff4280a8e231ca526 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Mon, 17 Dec 2018 17:56:06 +0100 Subject: [PATCH 05/12] Channels fix (#5) - Fix bug when destination invokes payment (wrong pubkeys in OP_RETURN - validation would fail) - Added channelslist RPC - Changed channelsinfo data to JSON format --- src/cc/CCchannels.h | 2 +- src/cc/channels.cpp | 220 ++++++++++++++++++++++----------------- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpcwallet.cpp | 9 ++ 5 files changed, 139 insertions(+), 94 deletions(-) diff --git a/src/cc/CCchannels.h b/src/cc/CCchannels.h index 7715a31b8..34c1edd7d 100644 --- a/src/cc/CCchannels.h +++ b/src/cc/CCchannels.h @@ -25,7 +25,7 @@ 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); std::string ChannelClose(uint64_t txfee,uint256 opentxid); std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid); - +UniValue ChannelsList(); // CCcustom UniValue ChannelsInfo(uint256 opentxid); diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 60f907c27..6c8b602c6 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -75,11 +75,11 @@ int64_t IsChannelsvout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey return(0); } -int64_t IsChannelsMarkervout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey srcpub,int32_t v) +int64_t IsChannelsMarkervout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey pubkey,int32_t v) { char destaddr[65],ccaddr[65]; - GetCCaddress(cp,ccaddr,srcpub); + GetCCaddress(cp,ccaddr,pubkey); if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) { if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,ccaddr) == 0 ) @@ -207,11 +207,11 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vin.1 is CC for channelPayment!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) return eval->Invalid("vin.2 is CC for channelPayment!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsvout(cp,tx,srcpub,destpub,0)==0 ) return eval->Invalid("vout.0 is CC for channelPayment!"); - else if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsMarkervout(cp,tx,srcpub,1)==0 ) return eval->Invalid("vout.1 is CC for channelPayment (marker to srcPub)!"); - else if ( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsMarkervout(cp,tx,destpub,2)==0 ) return eval->Invalid("vout.2 is CC for channelPayment (marker to dstPub)!"); else if ( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 ) return eval->Invalid("vout.3 is normal for channelPayment!"); @@ -269,11 +269,11 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vin.1 is CC for channelClose!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) return eval->Invalid("vin.2 is CC for channelClose!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsvout(cp,tx,srcpub,destpub,0)==0 ) return eval->Invalid("vout.0 is CC for channelClose!"); - else if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsMarkervout(cp,tx,srcpub,1)==0 ) return eval->Invalid("vout.1 is CC for channelClose (marker to srcPub)!"); - else if ( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsMarkervout(cp,tx,destpub,2)==0 ) return eval->Invalid("vout.2 is CC for channelClose (marker to dstPub)!"); else if ( param1 > CHANNELS_MAXPAYMENTS) return eval->Invalid("too many payment increments!"); @@ -314,9 +314,9 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & return eval->Invalid("vin.1 is CC for channelRefund!"); else if ( IsCCInput(tx.vin[2].scriptSig) == 0 ) return eval->Invalid("vin.2 is CC for channelRefund!"); - else if ( tx.vout[0].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsMarkervout(cp,tx,srcpub,0)==0 ) return eval->Invalid("vout.0 is CC for channelRefund (marker to srcPub)!"); - else if ( tx.vout[1].scriptPubKey.IsPayToCryptoCondition() == 0 ) + else if ( IsChannelsMarkervout(cp,tx,destpub,1)==0 ) return eval->Invalid("vout.1 is CC for channelRefund (marker to dstPub)!"); else if ( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 ) return eval->Invalid("vout.2 is normal for channelRefund!"); @@ -366,12 +366,12 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction & // helper functions for rpc calls in rpcwallet.cpp -int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, CTransaction openTx, uint256 &prevtxid) +int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, CTransaction openTx, uint256 &prevtxid, CPubKey mypk) { - char coinaddr[65]; int64_t param2,totalinputs = 0,numvouts; uint256 txid=zeroid,tmp_txid,hashBlock,param3; CTransaction tx; int32_t param1; + char coinaddr[65]; int64_t param2,totalinputs = 0,numvouts; uint256 txid=zeroid,tmp_txid,hashBlock,param3; CTransaction tx; int32_t marker,param1; std::vector > unspentOutputs; CPubKey srcpub,destpub; - uint8_t myprivkey[32]; + uint8_t myprivkey[32]; if ((numvouts=openTx.vout.size()) > 0 && DecodeChannelsOpRet(openTx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)=='O') { @@ -383,14 +383,15 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C fprintf(stderr,"invalid channel open txid\n"); return 0; } - + if (srcpub==mypk) marker=1; + else marker=2; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { if ( (int32_t)it->first.index==0 && GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts=tx.vout.size()) > 0) { if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) && - (totalinputs=IsChannelsvout(cp,tx,srcpub,destpub,0)+IsChannelsMarkervout(cp,tx,srcpub,1))>0) + (totalinputs=IsChannelsvout(cp,tx,srcpub,destpub,0)+IsChannelsMarkervout(cp,tx,srcpub,marker))>0) { txid = it->first.txhash; break; @@ -419,7 +420,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C { prevtxid=txid; mtx.vin.push_back(CTxIn(txid,0,CScript())); - mtx.vin.push_back(CTxIn(txid,1,CScript())); + mtx.vin.push_back(CTxIn(txid,marker,CScript())); Myprivkey(myprivkey); CCaddr2set(cp,EVAL_CHANNELS,srcpub,myprivkey,coinaddr); CCaddr3set(cp,EVAL_CHANNELS,destpub,myprivkey,coinaddr); @@ -483,7 +484,7 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 } if (AddNormalinputs(mtx,mypk,2*txfee,3) > 0) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid)) !=0 && (change=funds-amount-txfee)>=0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && (change=funds-amount-txfee)>=0) { if ((numvouts=channelOpenTx.vout.size()) > 0 && DecodeChannelsOpRet(channelOpenTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, totalnumpayments, payment, hashchain)=='O') { @@ -553,11 +554,11 @@ std::string ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint2 fprintf(stderr, "invalid channel open tx\n"); return (""); } - mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, mypk, destpub)); - mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); + mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub)); + mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,srcpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); mtx.vout.push_back(CTxOut(amount, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG)); - return (FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeChannelsOpRet('P', opentxid, mypk, destpub, prevdepth-numpayments, numpayments, secret))); + return (FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeChannelsOpRet('P', opentxid, srcpub, destpub, prevdepth-numpayments, numpayments, secret))); } else { @@ -600,12 +601,12 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid) } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid)) !=0 && funds-txfee>0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) { mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub)); - return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',opentxid,mypk,destpub,funds/payment,payment,zeroid))); + return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',opentxid,mypk,destpub,(funds-txfee)/payment,payment,zeroid))); } else { @@ -664,7 +665,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) } if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 ) { - if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid)) !=0 && funds-txfee>0) + if ((funds=AddChannelsInputs(cp,mtx,channelOpenTx,prevtxid,mypk)) !=0 && funds-txfee>0) { if ((GetTransaction(prevtxid,prevTx,hashblock,false) != 0) && (numvouts=prevTx.vout.size()) > 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, param1, param2, param3) != 0) @@ -696,84 +697,117 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid) } return(""); } - -UniValue ChannelsInfo(uint256 channeltxid) +UniValue ChannelsList() { - UniValue result(UniValue::VOBJ); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid; - struct CCcontract_info *cp,C; char myCCaddr[65],addr[65],str1[512],str2[256]; int32_t vout,numvouts,param1,numpayments; - int64_t nValue,param2,payment; CPubKey srcpub,destpub,mypk; - std::vector > txids; + UniValue result(UniValue::VOBJ); std::vector > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3; + CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1; + int64_t nValue,param2; - result.push_back(Pair("result","success")); cp = CCinit(&C,EVAL_CHANNELS); mypk = pubkey2pk(Mypubkey()); - if (channeltxid==zeroid) + GetCCaddress(cp,myCCaddr,mypk); + SetCCtxids(txids,myCCaddr); + result.push_back(Pair("result","success")); + result.push_back(Pair("name","Channels List")); + for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { - result.push_back(Pair("name","Channels Info")); - GetCCaddress(cp,myCCaddr,mypk); - SetCCtxids(txids,myCCaddr); - for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + txid = it->first.txhash; + vout = (int32_t)it->first.index; + nValue = (int64_t)it->second; + if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { - //int height = it->first.blockHeight; - txid = it->first.txhash; - vout = (int32_t)it->first.index; - nValue = (int64_t)it->second; - if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) - { - if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') - { - GetCCaddress1of2(cp,addr,srcpub,destpub); - sprintf(str1,"%s - %lld payments of %lld satoshi - %s",addr,(long long)param1,(long long)param2,tx.GetHash().ToString().c_str()); - result.push_back(Pair("Channel", str1)); - } - } - } - } - else - { - if (GetTransaction(channeltxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && - (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'O')) - { - GetCCaddress1of2(cp,addr,srcpub,destpub); - sprintf(str1,"Channel %s",addr); - result.push_back(Pair("name",str1)); - SetCCtxids(txids,addr); - prevtxid=zeroid; - for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) - { - - txid = it->first.txhash; - if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) - { - if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid) - { - sprintf(str1,"%lld payments of %lld satoshi",(long long)param1,(long long)param2); - result.push_back(Pair("Open", str1)); - } - else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid) - { - if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && - DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O') - { - Getscriptaddress(str2,tx.vout[3].scriptPubKey); - sprintf(str1,"%lld satoshi to %s, %lld payments left",(long long)(param2*payment),str2,(long long)param1); - result.push_back(Pair("Payment",str1)); - } - } - else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'C' && opentxid==channeltxid) - { - result.push_back(Pair("Close","channel")); - } - else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'R' && opentxid==channeltxid) - { - Getscriptaddress(str2,tx.vout[2].scriptPubKey); - sprintf(str1,"%lld satoshi back to %s",(long long)(param1*param2),str2); - result.push_back(Pair("Refund",str1)); - } - } - prevtxid=txid; + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') + { + GetCCaddress1of2(cp,addr,srcpub,destpub); + sprintf(str,"%s - %lld payments of %lld satoshi",addr,(long long)param1,(long long)param2); + result.push_back(Pair(txid.GetHex().data(),str)); } } } return(result); } + +UniValue ChannelsInfo(uint256 channeltxid) +{ + UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid; + struct CCcontract_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; + int64_t nValue,param2,payment; CPubKey srcpub,destpub,mypk; + std::vector > addressIndex; std::vector txids; + + cp = CCinit(&C,EVAL_CHANNELS); + mypk = pubkey2pk(Mypubkey()); + + if (GetTransaction(channeltxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 && + (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'O')) + { + GetCCaddress(cp,CCaddr,mypk); + Getscriptaddress(addr,CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG); + result.push_back(Pair("result","success")); + result.push_back(Pair("Channel CC address",CCaddr)); + result.push_back(Pair("Destination address",addr)); + result.push_back(Pair("Number of payments",param1)); + result.push_back(Pair("Denomination",param2)); + result.push_back(Pair("Amount",i64tostr(param1*param2)+" satoshi")); + SetCCtxids(addressIndex,CCaddr); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + { + if (GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid)) + txids.push_back(it->first.txhash); + } + BOOST_FOREACH(const CTxMemPoolEntry &e, mempool.mapTx) + { + const CTransaction &txmempool = e.GetTx(); + const uint256 &hash = txmempool.GetHash(); + + if ((numvouts=txmempool.vout.size()) > 0 && DecodeChannelsOpRet(txmempool.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'P' && tmp_txid==channeltxid) + txids.push_back(hash); + } + prevtxid=zeroid; + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) + { + txid=*it; + if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) + { + UniValue obj(UniValue::VOBJ); + if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid) + { + obj.push_back(Pair("Open",txid.GetHex().data())); + } + else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid) + { + if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && + DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O') + { + Getscriptaddress(str,tx.vout[3].scriptPubKey); + obj.push_back(Pair("Payment",txid.GetHex().data())); + obj.push_back(Pair("Number",param2)); + obj.push_back(Pair("Amount",param2*payment)); + obj.push_back(Pair("Destination",str)); + obj.push_back(Pair("Secret",param3.ToString().c_str())); + } + } + else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'C' && opentxid==channeltxid) + { + obj.push_back(Pair("Close",txid.GetHex().data())); + } + else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'R' && opentxid==channeltxid) + { + Getscriptaddress(str,tx.vout[2].scriptPubKey); + obj.push_back(Pair("Refund",txid.GetHex().data())); + obj.push_back(Pair("Amount",param1*param2)); + obj.push_back(Pair("Destination",str)); + } + array.push_back(obj); + } + prevtxid=txid; + } + result.push_back(Pair("Transactions",array)); + } + else + { + result.push_back(Pair("result","error")); + result.push_back(Pair("Error","Channel not found!")); + } + return(result); +} \ No newline at end of file diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1b6856be5..8dd32ab6a 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -394,6 +394,7 @@ static const CRPCCommand vRPCCommands[] = // Channels { "channels", "channelsaddress", &channelsaddress, true }, + { "channels", "channelslist", &channelslist, true }, { "channels", "channelsinfo", &channelsinfo, true }, { "channels", "channelsopen", &channelsopen, true }, { "channels", "channelspayment", &channelspayment, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 6638024b8..a129c21c0 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -271,6 +271,7 @@ extern UniValue gatewaysmarkdone(const UniValue& params, bool fHelp); extern UniValue gatewayspending(const UniValue& params, bool fHelp); extern UniValue gatewaysprocessed(const UniValue& params, bool fHelp); extern UniValue gatewaysmultisig(const UniValue& params, bool fHelp); +extern UniValue channelslist(const UniValue& params, bool fHelp); extern UniValue channelsinfo(const UniValue& params, bool fHelp); extern UniValue channelsopen(const UniValue& params, bool fHelp); extern UniValue channelspayment(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f8b507403..9391261d7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5672,6 +5672,15 @@ UniValue tokenaddress(const UniValue& params, bool fHelp) return(CCaddress(cp,(char *)"Assets",pubkey)); } +UniValue channelslist(const UniValue& params, bool fHelp) +{ + if ( fHelp || params.size() > 0 ) + throw runtime_error("channelsinfo\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"); + return(ChannelsList()); +} + UniValue channelsinfo(const UniValue& params, bool fHelp) { uint256 opentxid; From 7cbe71e5e05109b73601b2b2ca672d71d70a738c Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Dec 2018 02:27:29 +0800 Subject: [PATCH 06/12] Fix check_deposit banning peers on sync. --- src/komodo_gateway.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 102245723..262bf5107 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -90,7 +90,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout pax->marked = mark; //if ( height > 214700 || pax->height > 214700 ) // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - + } pthread_mutex_unlock(&komodo_mutex); return(pax); @@ -203,9 +203,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t // return(0); incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); //41e77b91cb68dc2aa02fa88550eae6b6d44db676a7e935337b6d1392d9718f03cb0200305c90660400000000fbcbeb1f000000bde801006201000058e7945ad08ddba1eac9c9b6c8e1e97e8016a2d152 - + // 41e94d736ec69d88c08b5d238abeeca609c02357a8317e0d56c328bcb1c259be5d0200485bc80200000000404b4c000000000059470200b80b000061f22ba7d19fe29ac3baebd839af8b7127d1f9075553440046bb4cc7a3b5cd39dffe7206507a3482a00780e617f68b273cce9817ed69298d02001069ca1b0000000080f0fa02000000005b470200b90b000061f22ba7d19fe29ac3baebd839af8b7127d1f90755 - + //for (i=0; i 1) || NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) { @@ -737,7 +737,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > 1000000 && strangeout != 0 ) return(-1); } - else if ( height > 814000 ) + else if ( height > 814000 && KOMODO_INSYNC != 0 ) { script = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); @@ -774,7 +774,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -1187,7 +1187,7 @@ void komodo_stateind_set(struct komodo_state *sp,uint32_t *inds,int32_t n,uint8_ printf("numR.%d numV.%d numN.%d count.%d\n",numR,numV,numN,count); /*else if ( func == 'K' ) // KMD height: stop after 1st else if ( func == 'T' ) // KMD height+timestamp: stop after 1st - + else if ( func == 'N' ) // notarization, scan backwards 1440+ blocks; else if ( func == 'V' ) // price feed: can stop after 1440+ else if ( func == 'R' ) // opreturn:*/ @@ -1521,4 +1521,3 @@ void komodo_passport_iteration() printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid); } } - From 8d2b0c3f31ecdd4dfe31ea785c637efe2df4443d Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 18 Dec 2018 17:09:37 +0800 Subject: [PATCH 07/12] Fix KMD check_deposit peer ban. --- src/komodo_gateway.h | 7 ++++++- src/main.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 262bf5107..5572364da 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -737,9 +737,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > 1000000 && strangeout != 0 ) return(-1); } - else if ( height > 814000 && KOMODO_INSYNC != 0 ) + else if ( height > 814000 ) { script = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; + //int32_t notary = komodo_electednotary(&num,script+1,height,0); + //if ( (-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)) < 0 ) + // fprintf(stderr, ">>>>>>> FAILED BLOCK.%d notary.%d insync.%d\n",height,notary,KOMODO_INSYNC); + //else + // fprintf(stderr, "<<<<<<< VALID BLOCK.%d notary.%d insync.%d\n",height,notary,KOMODO_INSYNC); return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); } } diff --git a/src/main.cpp b/src/main.cpp index a6c4778db..94f07f72e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4757,7 +4757,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (nSigOps > MAX_BLOCK_SIGOPS) return state.DoS(100, error("CheckBlock: out-of-bounds SigOpCount"), REJECT_INVALID, "bad-blk-sigops", true); - if ( komodo_check_deposit(height,block,(pindex==0||pindex->pprev==0)?0:pindex->pprev->nTime) < 0 ) + if ( fCheckPOW && komodo_check_deposit(height,block,(pindex==0||pindex->pprev==0)?0:pindex->pprev->nTime) < 0 ) { //static uint32_t counter; //if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) From 45d91c8f0d034c99a22f6072c299b1734375744e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Dec 2018 04:30:25 -1100 Subject: [PATCH 08/12] z_mergetoaddress loop at start of migrate --- src/cc/dapps/zmigrate.c | 78 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 3f26c50a1..61a863e16 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -647,6 +647,25 @@ int64_t z_getbalance(char *refcoin,char *acname,char *coinaddr) return (amount); } +int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + privkey[0] = 0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","")) != 0 ) + { + fprintf(stderr,"z_exportkey.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + return(-1); + } + else if ( retstr != 0 ) + { + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + strcpy(privkey,retstr); + free(retstr); + return(0); + } +} + int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) { cJSON *retjson; char *retstr; int64_t amount=0; @@ -664,6 +683,23 @@ int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) } } +int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr; int64_t amount=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress","","","","")) != 0 ) + { + fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + return(-1); + } + else if ( retstr != 0 ) + { + strcpy(coinaddr,retstr); + free(retstr); + return(0); + } +} + int64_t find_onetime_amount(char *coinstr,char *coinaddr) { cJSON *array,*item; int32_t i,n; char *addr; int64_t amount = 0; @@ -751,6 +787,39 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * } } +int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) +{ + cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; + sprintf(addr,"\"ANY_SPROUT\""); + //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); + if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) + { + /*{ + "remainingUTXOs": 0, + "remainingTransparentValue": 0.00000000, + "remainingNotes": 222, + "remainingShieldedValue": 5413.39093055, + "mergingUTXOs": 0, + "mergingTransparentValue": 0.00000000, + "mergingNotes": 10, + "mergingShieldedValue": 822.47447172, + "opid": "opid-f28f6261-4120-436c-aca5-859870a40a70" + }*/ + if ( (opstr= jstr(retjson,"opid")) != 0 ) + strcpy(opidstr,opstr); + retval = jint(retjson,"remainingNotes"); + fprintf(stderr,"%s\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_mergetoaddress.(%s) -> opid.(%s)\n",coinstr,retstr); + strcpy(opidstr,retstr); + free(retstr); + } + return(retval); +} + int32_t empty_mempool(char *coinstr,char *acname) { cJSON *array; int32_t n; @@ -907,11 +976,18 @@ int32_t main(int32_t argc,char **argv) } zsaddr = clonestr(argv[2]); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); - uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; + uint32_t lastopid; char coinaddr[64],privkey[1024],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; //stdamount = 500 * SATOSHIDEN; txfee = 10000; again: printf("start processing zmigrate\n"); + if ( z_getnewaddress(zcaddr,coinstr,"") == 0 ) + { + z_exportkey(privkey,coinstr,"",zcaddr); + printf("zcaddr.(%s) -> z_exportkey.(%s)\n",zcaddr,privkey); + while ( z_mergetoaddress(opidstr,coinstr,"",zcaddr) > 0 ) + ; + } lastopid = (uint32_t)time(NULL); finished = 0; while ( 1 ) From a7cd4c0d714a006d9daa29c3a81b4e346a5cbf7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Dec 2018 04:33:24 -1100 Subject: [PATCH 09/12] z_getnewaddress sprout --- src/cc/dapps/zmigrate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 61a863e16..018af2c3b 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -683,10 +683,10 @@ int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) } } -int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname) +int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr) { cJSON *retjson; char *retstr; int64_t amount=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress","","","","")) != 0 ) + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 ) { fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname); free_json(retjson); @@ -981,7 +981,7 @@ int32_t main(int32_t argc,char **argv) txfee = 10000; again: printf("start processing zmigrate\n"); - if ( z_getnewaddress(zcaddr,coinstr,"") == 0 ) + if ( z_getnewaddress(zcaddr,coinstr,"","sprout") == 0 ) { z_exportkey(privkey,coinstr,"",zcaddr); printf("zcaddr.(%s) -> z_exportkey.(%s)\n",zcaddr,privkey); From 92fc71b75385ab4c6e034aebd34fe8bffe706a2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Dec 2018 04:35:49 -1100 Subject: [PATCH 10/12] [] --- src/cc/dapps/zmigrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 018af2c3b..c11e84e06 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -790,7 +790,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) { cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; - sprintf(addr,"\"ANY_SPROUT\""); + sprintf(addr,"[\"ANY_SPROUT\"]"); //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) { @@ -980,7 +980,6 @@ int32_t main(int32_t argc,char **argv) //stdamount = 500 * SATOSHIDEN; txfee = 10000; again: - printf("start processing zmigrate\n"); if ( z_getnewaddress(zcaddr,coinstr,"","sprout") == 0 ) { z_exportkey(privkey,coinstr,"",zcaddr); @@ -988,6 +987,7 @@ again: while ( z_mergetoaddress(opidstr,coinstr,"",zcaddr) > 0 ) ; } + printf("start processing zmigrate\n"); lastopid = (uint32_t)time(NULL); finished = 0; while ( 1 ) From 45df5812401044b8422b5f72a52de9507a0533bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Dec 2018 04:36:36 -1100 Subject: [PATCH 11/12] Test --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index c11e84e06..3b32cbdd4 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -790,7 +790,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) { cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; - sprintf(addr,"[\"ANY_SPROUT\"]"); + sprintf(addr,"[\\""ANY_SPROUT\\""]"); //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) { From 776e52508347cc14dfa1fc1d786d897fb975e8bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 18 Dec 2018 04:38:02 -1100 Subject: [PATCH 12/12] \" --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 3b32cbdd4..2e3051902 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -790,7 +790,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) { cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; - sprintf(addr,"[\\""ANY_SPROUT\\""]"); + sprintf(addr,"[\\\"ANY_SPROUT\\\"]"); //printf("z_sendmany from.(%s) -> %s\n",addr,destaddr); if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) {