2
.gitignore
vendored
2
.gitignore
vendored
@@ -124,3 +124,5 @@ src/komodo-tx.exe
|
|||||||
#output during builds, symbol tables?
|
#output during builds, symbol tables?
|
||||||
*.dSYM
|
*.dSYM
|
||||||
|
|
||||||
|
|
||||||
|
src/cryptoconditions/compile
|
||||||
|
|||||||
@@ -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 ChannelPayment(uint64_t txfee,uint256 opentxid,int64_t amount, uint256 secret);
|
||||||
std::string ChannelClose(uint64_t txfee,uint256 opentxid);
|
std::string ChannelClose(uint64_t txfee,uint256 opentxid);
|
||||||
std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid);
|
std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid);
|
||||||
|
UniValue ChannelsList();
|
||||||
// CCcustom
|
// CCcustom
|
||||||
UniValue ChannelsInfo(uint256 opentxid);
|
UniValue ChannelsInfo(uint256 opentxid);
|
||||||
|
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ int64_t IsChannelsvout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey
|
|||||||
return(0);
|
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];
|
char destaddr[65],ccaddr[65];
|
||||||
|
|
||||||
GetCCaddress(cp,ccaddr,srcpub);
|
GetCCaddress(cp,ccaddr,pubkey);
|
||||||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
{
|
{
|
||||||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,ccaddr) == 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!");
|
return eval->Invalid("vin.1 is CC for channelPayment!");
|
||||||
else if ( IsCCInput(tx.vin[2].scriptSig) == 0 )
|
else if ( IsCCInput(tx.vin[2].scriptSig) == 0 )
|
||||||
return eval->Invalid("vin.2 is CC for channelPayment!");
|
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!");
|
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)!");
|
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)!");
|
return eval->Invalid("vout.2 is CC for channelPayment (marker to dstPub)!");
|
||||||
else if ( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
else if ( tx.vout[3].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
return eval->Invalid("vout.3 is normal for channelPayment!");
|
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!");
|
return eval->Invalid("vin.1 is CC for channelClose!");
|
||||||
else if ( IsCCInput(tx.vin[2].scriptSig) == 0 )
|
else if ( IsCCInput(tx.vin[2].scriptSig) == 0 )
|
||||||
return eval->Invalid("vin.2 is CC for channelClose!");
|
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!");
|
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)!");
|
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)!");
|
return eval->Invalid("vout.2 is CC for channelClose (marker to dstPub)!");
|
||||||
else if ( param1 > CHANNELS_MAXPAYMENTS)
|
else if ( param1 > CHANNELS_MAXPAYMENTS)
|
||||||
return eval->Invalid("too many payment increments!");
|
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!");
|
return eval->Invalid("vin.1 is CC for channelRefund!");
|
||||||
else if ( IsCCInput(tx.vin[2].scriptSig) == 0 )
|
else if ( IsCCInput(tx.vin[2].scriptSig) == 0 )
|
||||||
return eval->Invalid("vin.2 is CC for channelRefund!");
|
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)!");
|
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)!");
|
return eval->Invalid("vout.1 is CC for channelRefund (marker to dstPub)!");
|
||||||
else if ( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
else if ( tx.vout[2].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
return eval->Invalid("vout.2 is normal for channelRefund!");
|
return eval->Invalid("vout.2 is normal for channelRefund!");
|
||||||
@@ -366,9 +366,9 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
|
|||||||
|
|
||||||
// helper functions for rpc calls in rpcwallet.cpp
|
// 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<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||||
CPubKey srcpub,destpub;
|
CPubKey srcpub,destpub;
|
||||||
uint8_t myprivkey[32];
|
uint8_t myprivkey[32];
|
||||||
@@ -383,14 +383,15 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C
|
|||||||
fprintf(stderr,"invalid channel open txid\n");
|
fprintf(stderr,"invalid channel open txid\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (srcpub==mypk) marker=1;
|
||||||
|
else marker=2;
|
||||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
|
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::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 ( (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 &&
|
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 &&
|
||||||
(tmp_txid==openTx.GetHash() || tx.GetHash()==openTx.GetHash()) &&
|
(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;
|
txid = it->first.txhash;
|
||||||
break;
|
break;
|
||||||
@@ -419,7 +420,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C
|
|||||||
{
|
{
|
||||||
prevtxid=txid;
|
prevtxid=txid;
|
||||||
mtx.vin.push_back(CTxIn(txid,0,CScript()));
|
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);
|
Myprivkey(myprivkey);
|
||||||
CCaddr2set(cp,EVAL_CHANNELS,srcpub,myprivkey,coinaddr);
|
CCaddr2set(cp,EVAL_CHANNELS,srcpub,myprivkey,coinaddr);
|
||||||
CCaddr3set(cp,EVAL_CHANNELS,destpub,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 (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')
|
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");
|
fprintf(stderr, "invalid channel open tx\n");
|
||||||
return ("");
|
return ("");
|
||||||
}
|
}
|
||||||
mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, mypk, destpub));
|
mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS, change, srcpub, destpub));
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk));
|
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,srcpub));
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub));
|
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub));
|
||||||
mtx.vout.push_back(CTxOut(amount, CScript() << ParseHex(HexStr(destpub)) << OP_CHECKSIG));
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -600,12 +601,12 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid)
|
|||||||
}
|
}
|
||||||
if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 )
|
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(MakeCC1of2vout(EVAL_CHANNELS, funds-txfee, mypk, destpub));
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk));
|
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk));
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,destpub));
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -664,7 +665,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
|
|||||||
}
|
}
|
||||||
if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 )
|
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 &&
|
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)
|
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("");
|
return("");
|
||||||
}
|
}
|
||||||
|
UniValue ChannelsList()
|
||||||
UniValue ChannelsInfo(uint256 channeltxid)
|
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid;
|
UniValue result(UniValue::VOBJ); std::vector<std::pair<CAddressIndexKey, CAmount> > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3;
|
||||||
struct CCcontract_info *cp,C; char myCCaddr[65],addr[65],str1[512],str2[256]; int32_t vout,numvouts,param1,numpayments;
|
CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1;
|
||||||
int64_t nValue,param2,payment; CPubKey srcpub,destpub,mypk;
|
int64_t nValue,param2;
|
||||||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids;
|
|
||||||
|
|
||||||
result.push_back(Pair("result","success"));
|
|
||||||
cp = CCinit(&C,EVAL_CHANNELS);
|
cp = CCinit(&C,EVAL_CHANNELS);
|
||||||
mypk = pubkey2pk(Mypubkey());
|
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<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++)
|
||||||
{
|
{
|
||||||
result.push_back(Pair("name","Channels Info"));
|
txid = it->first.txhash;
|
||||||
GetCCaddress(cp,myCCaddr,mypk);
|
vout = (int32_t)it->first.index;
|
||||||
SetCCtxids(txids,myCCaddr);
|
nValue = (int64_t)it->second;
|
||||||
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++)
|
if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 )
|
||||||
{
|
{
|
||||||
//int height = it->first.blockHeight;
|
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O')
|
||||||
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(str,"%s - %lld payments of %lld satoshi",addr,(long long)param1,(long long)param2);
|
||||||
GetCCaddress1of2(cp,addr,srcpub,destpub);
|
result.push_back(Pair(txid.GetHex().data(),str));
|
||||||
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<std::pair<CAddressIndexKey, CAmount> >::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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(result);
|
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<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> 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<std::pair<CAddressIndexKey, CAmount> >::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<uint256>::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);
|
||||||
|
}
|
||||||
@@ -647,6 +647,25 @@ int64_t z_getbalance(char *refcoin,char *acname,char *coinaddr)
|
|||||||
return (amount);
|
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)
|
int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname)
|
||||||
{
|
{
|
||||||
cJSON *retjson; char *retstr; int64_t amount=0;
|
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,char *typestr)
|
||||||
|
{
|
||||||
|
cJSON *retjson; char *retstr; int64_t amount=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);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
else if ( retstr != 0 )
|
||||||
|
{
|
||||||
|
strcpy(coinaddr,retstr);
|
||||||
|
free(retstr);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int64_t find_onetime_amount(char *coinstr,char *coinaddr)
|
int64_t find_onetime_amount(char *coinstr,char *coinaddr)
|
||||||
{
|
{
|
||||||
cJSON *array,*item; int32_t i,n; char *addr; int64_t amount = 0;
|
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)
|
int32_t empty_mempool(char *coinstr,char *acname)
|
||||||
{
|
{
|
||||||
cJSON *array; int32_t n;
|
cJSON *array; int32_t n;
|
||||||
@@ -907,10 +976,25 @@ int32_t main(int32_t argc,char **argv)
|
|||||||
}
|
}
|
||||||
zsaddr = clonestr(argv[2]);
|
zsaddr = clonestr(argv[2]);
|
||||||
printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr);
|
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;
|
//stdamount = 500 * SATOSHIDEN;
|
||||||
txfee = 10000;
|
txfee = 10000;
|
||||||
again:
|
again:
|
||||||
|
if ( z_getnewaddress(zcaddr,coinstr,"","sprout") == 0 )
|
||||||
|
{
|
||||||
|
z_exportkey(privkey,coinstr,"",zcaddr);
|
||||||
|
printf("zcaddr.(%s) -> z_exportkey.(%s)\n",zcaddr,privkey);
|
||||||
|
while ( 1 )
|
||||||
|
{
|
||||||
|
if ( have_pending_opid(coinstr,0) != 0 )
|
||||||
|
{
|
||||||
|
sleep(10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( z_mergetoaddress(opidstr,coinstr,"",zcaddr) <= 0 )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
printf("start processing zmigrate\n");
|
printf("start processing zmigrate\n");
|
||||||
lastopid = (uint32_t)time(NULL);
|
lastopid = (uint32_t)time(NULL);
|
||||||
finished = 0;
|
finished = 0;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ using namespace std;
|
|||||||
extern void ThreadSendAlert();
|
extern void ThreadSendAlert();
|
||||||
extern int32_t KOMODO_LOADINGBLOCKS;
|
extern int32_t KOMODO_LOADINGBLOCKS;
|
||||||
extern bool VERUS_MINTBLOCKS;
|
extern bool VERUS_MINTBLOCKS;
|
||||||
|
extern char ASSETCHAINS_SYMBOL[];
|
||||||
|
|
||||||
ZCJoinSplit* pzcashParams = NULL;
|
ZCJoinSplit* pzcashParams = NULL;
|
||||||
|
|
||||||
@@ -195,7 +196,10 @@ void Shutdown()
|
|||||||
/// for example if the data directory was found to be locked.
|
/// for example if the data directory was found to be locked.
|
||||||
/// Be sure that anything that writes files or flushes caches only does this if the respective
|
/// Be sure that anything that writes files or flushes caches only does this if the respective
|
||||||
/// module was initialized.
|
/// module was initialized.
|
||||||
RenameThread("verus-shutoff");
|
static char shutoffstr[128];
|
||||||
|
sprintf(shutoffstr,"%s-shutoff",ASSETCHAINS_SYMBOL);
|
||||||
|
//RenameThread("verus-shutoff");
|
||||||
|
RenameThread(shutoffstr);
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
|
|
||||||
StopHTTPRPC();
|
StopHTTPRPC();
|
||||||
|
|||||||
@@ -740,6 +740,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
|||||||
else if ( height > 814000 )
|
else if ( height > 814000 )
|
||||||
{
|
{
|
||||||
script = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0];
|
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));
|
return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1521,4 +1526,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);
|
printf("READY for %s RPC calls at %u! done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL),ASSETCHAINS_SYMBOL,refid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4710,7 +4710,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
CValidationState state;
|
CValidationState state;
|
||||||
CTransaction Tx;
|
CTransaction Tx;
|
||||||
const CTransaction &tx = (CTransaction)block.vtx[i];
|
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;
|
continue;
|
||||||
Tx = tx;
|
Tx = tx;
|
||||||
if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync
|
if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync
|
||||||
@@ -4757,7 +4757,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
if (nSigOps > MAX_BLOCK_SIGOPS)
|
if (nSigOps > MAX_BLOCK_SIGOPS)
|
||||||
return state.DoS(100, error("CheckBlock: out-of-bounds SigOpCount"),
|
return state.DoS(100, error("CheckBlock: out-of-bounds SigOpCount"),
|
||||||
REJECT_INVALID, "bad-blk-sigops", true);
|
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;
|
//static uint32_t counter;
|
||||||
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
||||||
|
|||||||
@@ -1441,7 +1441,7 @@ void static BitcoinMiner()
|
|||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
// notaries always default to staking
|
// notaries always default to staking
|
||||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0);
|
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0);
|
||||||
#else
|
#else
|
||||||
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
||||||
#endif
|
#endif
|
||||||
@@ -1831,7 +1831,7 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate);
|
//fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate);
|
||||||
if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 )
|
if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 && fGenerate )
|
||||||
{
|
{
|
||||||
if ( pwallet != NULL )
|
if ( pwallet != NULL )
|
||||||
nThreads = 1;
|
nThreads = 1;
|
||||||
|
|||||||
@@ -339,22 +339,25 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
|
|||||||
//if (nGenProcLimit == 0)
|
//if (nGenProcLimit == 0)
|
||||||
// fGenerate = false;
|
// fGenerate = false;
|
||||||
}
|
}
|
||||||
|
if ( ASSETCHAINS_LWMAPOS != 0 )
|
||||||
if (fGenerate && !nGenProcLimit)
|
|
||||||
{
|
{
|
||||||
VERUS_MINTBLOCKS = 1;
|
if (fGenerate && !nGenProcLimit)
|
||||||
fGenerate = GetBoolArg("-gen", false);
|
{
|
||||||
if ( ASSETCHAINS_STAKED == 0 )
|
VERUS_MINTBLOCKS = 1;
|
||||||
nGenProcLimit = KOMODO_MININGTHREADS;
|
fGenerate = GetBoolArg("-gen", false);
|
||||||
else
|
|
||||||
KOMODO_MININGTHREADS = nGenProcLimit;
|
KOMODO_MININGTHREADS = nGenProcLimit;
|
||||||
|
}
|
||||||
|
else if (!fGenerate)
|
||||||
|
{
|
||||||
|
VERUS_MINTBLOCKS = 0;
|
||||||
|
KOMODO_MININGTHREADS = 0;
|
||||||
|
}
|
||||||
|
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||||
}
|
}
|
||||||
else if (!fGenerate)
|
else
|
||||||
{
|
{
|
||||||
VERUS_MINTBLOCKS = 0;
|
KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||||
KOMODO_MININGTHREADS = 0;
|
|
||||||
}
|
}
|
||||||
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
|
||||||
|
|
||||||
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
||||||
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);
|
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
|
|
||||||
// Channels
|
// Channels
|
||||||
{ "channels", "channelsaddress", &channelsaddress, true },
|
{ "channels", "channelsaddress", &channelsaddress, true },
|
||||||
|
{ "channels", "channelslist", &channelslist, true },
|
||||||
{ "channels", "channelsinfo", &channelsinfo, true },
|
{ "channels", "channelsinfo", &channelsinfo, true },
|
||||||
{ "channels", "channelsopen", &channelsopen, true },
|
{ "channels", "channelsopen", &channelsopen, true },
|
||||||
{ "channels", "channelspayment", &channelspayment, true },
|
{ "channels", "channelspayment", &channelspayment, true },
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ extern UniValue gatewaysmarkdone(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue gatewayspending(const UniValue& params, bool fHelp);
|
extern UniValue gatewayspending(const UniValue& params, bool fHelp);
|
||||||
extern UniValue gatewaysprocessed(const UniValue& params, bool fHelp);
|
extern UniValue gatewaysprocessed(const UniValue& params, bool fHelp);
|
||||||
extern UniValue gatewaysmultisig(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 channelsinfo(const UniValue& params, bool fHelp);
|
||||||
extern UniValue channelsopen(const UniValue& params, bool fHelp);
|
extern UniValue channelsopen(const UniValue& params, bool fHelp);
|
||||||
extern UniValue channelspayment(const UniValue& params, bool fHelp);
|
extern UniValue channelspayment(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
@@ -169,9 +169,9 @@ void AsyncRPCOperation_sendmany::main() {
|
|||||||
|
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0));
|
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1));
|
||||||
#else
|
#else
|
||||||
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0));
|
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ void AsyncRPCOperation_shieldcoinbase::main() {
|
|||||||
|
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0));
|
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1));
|
||||||
#else
|
#else
|
||||||
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0));
|
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4788,9 +4788,9 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
if (useAnySprout || useAnySapling || zaddrs.size() > 0) {
|
if (useAnySprout || useAnySapling || zaddrs.size() > 0) {
|
||||||
// Get available notes
|
// Get available notes
|
||||||
std::vector<CSproutNotePlaintextEntry> sproutEntries;
|
std::vector<CSproutNotePlaintextEntry> sproutEntries,skipsprout;
|
||||||
std::vector<SaplingNoteEntry> saplingEntries;
|
std::vector<SaplingNoteEntry> saplingEntries,skipsapling;
|
||||||
pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs);
|
pwalletMain->GetFilteredNotes(sproutEntries, useAnySprout == 0 ? saplingEntries : skipsapling, zaddrs);
|
||||||
|
|
||||||
// If Sapling is not active, do not allow sending from a sapling addresses.
|
// If Sapling is not active, do not allow sending from a sapling addresses.
|
||||||
if (!saplingActive && saplingEntries.size() > 0) {
|
if (!saplingActive && saplingEntries.size() > 0) {
|
||||||
@@ -5672,6 +5672,15 @@ UniValue tokenaddress(const UniValue& params, bool fHelp)
|
|||||||
return(CCaddress(cp,(char *)"Assets",pubkey));
|
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)
|
UniValue channelsinfo(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
uint256 opentxid;
|
uint256 opentxid;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void post_wallet_load(){
|
|||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
// Generate coins in the background
|
// Generate coins in the background
|
||||||
if (pwalletMain || !GetArg("-mineraddress", "").empty())
|
if (pwalletMain || !GetArg("-mineraddress", "").empty())
|
||||||
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0));
|
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user