Channelsopen
This commit is contained in:
@@ -18,8 +18,10 @@
|
|||||||
#define CC_CHANNELS_H
|
#define CC_CHANNELS_H
|
||||||
|
|
||||||
#include "CCinclude.h"
|
#include "CCinclude.h"
|
||||||
|
#define CHANNELS_MAXPAYMENTS 1000
|
||||||
|
|
||||||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx);
|
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx);
|
||||||
|
std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int32_t payment);
|
||||||
|
|
||||||
// CCcustom
|
// CCcustom
|
||||||
UniValue ChannelsInfo();
|
UniValue ChannelsInfo();
|
||||||
|
|||||||
@@ -92,7 +92,10 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
|||||||
CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv);
|
CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv);
|
||||||
|
|
||||||
// CCutils
|
// CCutils
|
||||||
|
void endiancpy(uint8_t *dest,uint8_t *src,int32_t len);
|
||||||
|
uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv);
|
||||||
CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk);
|
CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk);
|
||||||
|
CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2);
|
||||||
CC *MakeCCcond1(uint8_t evalcode,CPubKey pk);
|
CC *MakeCCcond1(uint8_t evalcode,CPubKey pk);
|
||||||
CC* GetCryptoCondition(CScript const& scriptSig);
|
CC* GetCryptoCondition(CScript const& scriptSig);
|
||||||
bool IsCCInput(CScript const& scriptSig);
|
bool IsCCInput(CScript const& scriptSig);
|
||||||
@@ -104,6 +107,7 @@ char *pubkey33_str(char *dest,uint8_t *pubkey33);
|
|||||||
uint256 Parseuint256(char *hexstr);
|
uint256 Parseuint256(char *hexstr);
|
||||||
CPubKey pubkey2pk(std::vector<uint8_t> pubkey);
|
CPubKey pubkey2pk(std::vector<uint8_t> pubkey);
|
||||||
bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk);
|
bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk);
|
||||||
|
bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2);
|
||||||
bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue);
|
bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue);
|
||||||
bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t numvins,int32_t preventCCvouts,int32_t numvouts);
|
bool PreventCC(Eval* eval,const CTransaction &tx,int32_t preventCCvins,int32_t numvins,int32_t preventCCvouts,int32_t numvouts);
|
||||||
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "CCinclude.h"
|
#include "CCinclude.h"
|
||||||
|
|
||||||
#define EVAL_LOTTO 0xe9
|
#define EVAL_LOTTO 0xe9
|
||||||
uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv);
|
|
||||||
|
|
||||||
bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx);
|
bool LottoValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,16 @@
|
|||||||
CCutils has low level functions that are universally useful for all contracts.
|
CCutils has low level functions that are universally useful for all contracts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void endiancpy(uint8_t *dest,uint8_t *src,int32_t len)
|
||||||
|
{
|
||||||
|
int32_t i,j=0;
|
||||||
|
#if defined(WORDS_BIGENDIAN)
|
||||||
|
for (i=31; i>=0; i--)
|
||||||
|
dest[j++] = src[i];
|
||||||
|
#else
|
||||||
|
memcpy(dest,src,len);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2)
|
CC *MakeCCcond1of2(uint8_t evalcode,CPubKey pk1,CPubKey pk2)
|
||||||
{
|
{
|
||||||
@@ -48,6 +58,15 @@ CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk)
|
|||||||
return(vout);
|
return(vout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2)
|
||||||
|
{
|
||||||
|
CTxOut vout;
|
||||||
|
CC *payoutCond = MakeCCcond1of2(evalcode,pk,pk2);
|
||||||
|
vout = CTxOut(nValue,CCPubKey(payoutCond));
|
||||||
|
cc_free(payoutCond);
|
||||||
|
return(vout);
|
||||||
|
}
|
||||||
|
|
||||||
CC* GetCryptoCondition(CScript const& scriptSig)
|
CC* GetCryptoCondition(CScript const& scriptSig)
|
||||||
{
|
{
|
||||||
auto pc = scriptSig.begin();
|
auto pc = scriptSig.begin();
|
||||||
@@ -167,6 +186,18 @@ bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk)
|
|||||||
return(destaddr[0] != 0);
|
return(destaddr[0] != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetCCaddress1of2(struct CCcontract_info *cp,char *destaddr,CPubKey pk,CPubKey pk2)
|
||||||
|
{
|
||||||
|
CC *payoutCond;
|
||||||
|
destaddr[0] = 0;
|
||||||
|
if ( (payoutCond= MakeCCcond1of2(cp->evalcode,pk,pk2)) != 0 )
|
||||||
|
{
|
||||||
|
Getscriptaddress(destaddr,CCPubKey(payoutCond));
|
||||||
|
cc_free(payoutCond);
|
||||||
|
}
|
||||||
|
return(destaddr[0] != 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue)
|
bool ConstrainVout(CTxOut vout,int32_t CCflag,char *cmpaddr,int64_t nValue)
|
||||||
{
|
{
|
||||||
char destaddr[64];
|
char destaddr[64];
|
||||||
|
|||||||
@@ -35,6 +35,14 @@
|
|||||||
|
|
||||||
For efficiency we want to allow batch spend with multiple secrets to claim a single total
|
For efficiency we want to allow batch spend with multiple secrets to claim a single total
|
||||||
|
|
||||||
|
Second iteration:
|
||||||
|
As implementing it, some efficieny gains to be made with a slightly different approach.
|
||||||
|
Instead of separate secrets for each amount, a hashchain will be used, each releasing the same amount
|
||||||
|
|
||||||
|
To spend, the prior value in the hash chain is published, or can publish N deep. validation takes N hashes.
|
||||||
|
|
||||||
|
Also, in order to be able to track open channels, a tag is needed to be sent and better to send to a normal CC address for a pubkey to isolate the transactions for channel opens.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// start of consensus code
|
// start of consensus code
|
||||||
@@ -129,6 +137,13 @@ 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
|
||||||
|
|
||||||
|
CScript EncodeChannelsOpRet(uint8_t funcid,int32_t numpayments,int32_t payment,uint256 hashchain)
|
||||||
|
{
|
||||||
|
CScript opret; uint8_t evalcode = EVAL_CHANNELS;
|
||||||
|
opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << numpayments << payment << hashchain);
|
||||||
|
return(opret);
|
||||||
|
}
|
||||||
|
|
||||||
int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs)
|
int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs)
|
||||||
{
|
{
|
||||||
char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector<uint8_t> origpubkey; CTransaction vintx; int32_t vout,n = 0;
|
char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector<uint8_t> origpubkey; CTransaction vintx; int32_t vout,n = 0;
|
||||||
@@ -157,58 +172,33 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
|
|||||||
return(totalinputs);
|
return(totalinputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ChannelsGet(uint64_t txfee,int64_t nValue)
|
std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int32_t payment)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Channelspk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash;
|
CMutableTransaction mtx; uint8_t hash[32],hashdest[32]; uint64_t funds; int32_t i; uint256 hashchain,entropy,hentropy; CPubKey mypk; CScript opret; struct CCcontract_info *cp,C;
|
||||||
cp = CCinit(&C,EVAL_CHANNELS);
|
if ( numpayments <= 0 || payment <= 0 || numpayments > CHANNELS_MAXPAYMENTS )
|
||||||
if ( txfee == 0 )
|
|
||||||
txfee = 10000;
|
|
||||||
Channelspk = GetUnspendable(cp,0);
|
|
||||||
mypk = pubkey2pk(Mypubkey());
|
|
||||||
if ( (inputs= AddChannelsInputs(cp,mtx,Channelspk,nValue+txfee,60)) > 0 )
|
|
||||||
{
|
{
|
||||||
if ( inputs > nValue )
|
CCerror = strprintf(stderr,"invalid ChannelsFund param numpayments.%d max.%d payment.%d\n",numpayments,CHANNELS_MAXPAYMENTS,payment);
|
||||||
CCchange = (inputs - nValue - txfee);
|
fprintf(stderr,"%s\n",CCerror.c_str());
|
||||||
if ( CCchange != 0 )
|
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,CCchange,Channelspk));
|
|
||||||
mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
|
||||||
fprintf(stderr,"start at %u\n",(uint32_t)time(NULL));
|
|
||||||
j = rand() & 0xfffffff;
|
|
||||||
for (i=0; i<1000000; i++,j++)
|
|
||||||
{
|
|
||||||
tmpmtx = mtx;
|
|
||||||
rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_CHANNELS << (uint8_t)'G' << j));
|
|
||||||
if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 )
|
|
||||||
{
|
|
||||||
len >>= 1;
|
|
||||||
decode_hex(buf,len,(char *)rawhex.c_str());
|
|
||||||
hash = bits256_doublesha256(0,buf,len);
|
|
||||||
if ( (hash.bytes[0] & 0xff) == 0 && (hash.bytes[31] & 0xff) == 0 )
|
|
||||||
{
|
|
||||||
fprintf(stderr,"found valid txid after %d iterations %u\n",i,(uint32_t)time(NULL));
|
|
||||||
return(rawhex);
|
|
||||||
}
|
|
||||||
//fprintf(stderr,"%02x%02x ",hash.bytes[0],hash.bytes[31]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL));
|
|
||||||
return("");
|
return("");
|
||||||
} else fprintf(stderr,"cant find Channels inputs\n");
|
}
|
||||||
return("");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ChannelsFund(uint64_t txfee,int64_t funds)
|
|
||||||
{
|
|
||||||
CMutableTransaction mtx; CPubKey mypk,Channelspk; CScript opret; struct CCcontract_info *cp,C;
|
|
||||||
cp = CCinit(&C,EVAL_CHANNELS);
|
cp = CCinit(&C,EVAL_CHANNELS);
|
||||||
if ( txfee == 0 )
|
if ( txfee == 0 )
|
||||||
txfee = 10000;
|
txfee = 10000;
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
Channelspk = GetUnspendable(cp,0);
|
funds = numpayments * payment;
|
||||||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 )
|
if ( AddNormalinputs(mtx,mypk,funds+2*txfee,64) > 0 )
|
||||||
{
|
{
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,funds,Channelspk));
|
hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash);
|
||||||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
|
endiancpy(hash,&hentropy,32);
|
||||||
|
for (i=0; i<numpayments; i++)
|
||||||
|
{
|
||||||
|
vcalc_sha256(0,hashdest,hash,32);
|
||||||
|
memcpy(hash,hashdest,32);
|
||||||
|
}
|
||||||
|
endiancpy((uint8_t *)&hashchain,hashdest,32);
|
||||||
|
mtx.vout.push_back(MakeCC1of2vout(EVAL_CHANNELS,funds,mypk,destpub));
|
||||||
|
mtx.vout.push_back(MakeCC1(EVAL_CHANNELS,txfee,mypk));
|
||||||
|
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('O',numpayments,payment,hashchain)));
|
||||||
}
|
}
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,17 +167,6 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid)
|
|||||||
} // small memory leak per DiceQueue
|
} // small memory leak per DiceQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
void endiancpy(uint8_t *dest,uint8_t *src,int32_t len)
|
|
||||||
{
|
|
||||||
int32_t i,j=0;
|
|
||||||
#if defined(WORDS_BIGENDIAN)
|
|
||||||
for (i=31; i>=0; i--)
|
|
||||||
dest[j++] = src[i];
|
|
||||||
#else
|
|
||||||
memcpy(dest,src,len);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
CPubKey DiceFundingPk(CScript scriptPubKey)
|
CPubKey DiceFundingPk(CScript scriptPubKey)
|
||||||
{
|
{
|
||||||
CPubKey pk; uint8_t *ptr,*dest; int32_t i;
|
CPubKey pk; uint8_t *ptr,*dest; int32_t i;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging) {
|
|||||||
if (blocksToDeprecation == 0 || forceLogging) {
|
if (blocksToDeprecation == 0 || forceLogging) {
|
||||||
auto msg = strprintf(_("This version has been deprecated as of block height %d."),
|
auto msg = strprintf(_("This version has been deprecated as of block height %d."),
|
||||||
DEPRECATION_HEIGHT) + " " +
|
DEPRECATION_HEIGHT) + " " +
|
||||||
_("You should upgrade to the latest version of Zcash.");
|
_("You should upgrade to the latest version of Komodo.");
|
||||||
if (!disableDeprecation) {
|
if (!disableDeprecation) {
|
||||||
msg += " " + strprintf(_("To disable deprecation for this version, set %s%s."),
|
msg += " " + strprintf(_("To disable deprecation for this version, set %s%s."),
|
||||||
"-disabledeprecation=", CLIENT_VERSION_STR);
|
"-disabledeprecation=", CLIENT_VERSION_STR);
|
||||||
@@ -48,11 +48,11 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging) {
|
|||||||
if (disableDeprecation) {
|
if (disableDeprecation) {
|
||||||
msg = strprintf(_("This version will be deprecated at block height %d."),
|
msg = strprintf(_("This version will be deprecated at block height %d."),
|
||||||
DEPRECATION_HEIGHT) + " " +
|
DEPRECATION_HEIGHT) + " " +
|
||||||
_("You should upgrade to the latest version of Zcash.");
|
_("You should upgrade to the latest version of Komodo.");
|
||||||
} else {
|
} else {
|
||||||
msg = strprintf(_("This version will be deprecated at block height %d, and will automatically shut down."),
|
msg = strprintf(_("This version will be deprecated at block height %d, and will automatically shut down."),
|
||||||
DEPRECATION_HEIGHT) + " " +
|
DEPRECATION_HEIGHT) + " " +
|
||||||
_("You should upgrade to the latest version of Zcash.") + " " +
|
_("You should upgrade to the latest version of Komodo.") + " " +
|
||||||
strprintf(_("To disable deprecation for this version, set %s%s."),
|
strprintf(_("To disable deprecation for this version, set %s%s."),
|
||||||
"-disabledeprecation=", CLIENT_VERSION_STR);
|
"-disabledeprecation=", CLIENT_VERSION_STR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1590,7 +1590,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
InitWarning(msg);
|
InitWarning(msg);
|
||||||
}
|
}
|
||||||
else if (nLoadWalletRet == DB_TOO_NEW)
|
else if (nLoadWalletRet == DB_TOO_NEW)
|
||||||
strErrors << _("Error loading wallet.dat: Wallet requires newer version of Zcash") << "\n";
|
strErrors << _("Error loading wallet.dat: Wallet requires newer version of Komodo") << "\n";
|
||||||
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||||
{
|
{
|
||||||
strErrors << _("Wallet needed to be rewritten: restart Zcash to complete") << "\n";
|
strErrors << _("Wallet needed to be rewritten: restart Zcash to complete") << "\n";
|
||||||
|
|||||||
@@ -4186,8 +4186,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
else if ( ASSETCHAINS_STAKED != 0 && (i == (block.vtx.size() - 1)) && komodo_isPoS((CBlock *)&block) != 0 )
|
else if ( ASSETCHAINS_STAKED != 0 && (i == (block.vtx.size() - 1)) && komodo_isPoS((CBlock *)&block) != 0 )
|
||||||
continue;
|
continue;
|
||||||
Tx = tx;
|
Tx = tx;
|
||||||
if ( myAddtomempool(Tx) == false ) // can happen with out of order tx in block on resync
|
if ( myAddtomempool(Tx) == false ) // happens with out of order tx in block on resync
|
||||||
//if ( AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL) == false )
|
|
||||||
rejects++;
|
rejects++;
|
||||||
}
|
}
|
||||||
if ( rejects == 0 || rejects == lastrejects )
|
if ( rejects == 0 || rejects == lastrejects )
|
||||||
|
|||||||
@@ -375,7 +375,8 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "MofN", "mofnaddress", &mofnaddress, true },
|
{ "MofN", "mofnaddress", &mofnaddress, true },
|
||||||
|
|
||||||
/* Channels */
|
/* Channels */
|
||||||
{ "channels", "channelsaddress", &channelsaddress, true },
|
{ "channels", "channelsaddress", &channelsaddress, true },
|
||||||
|
{ "channels", "channelsopen", &channelsopen, true },
|
||||||
|
|
||||||
/* Oracles */
|
/* Oracles */
|
||||||
{ "oracles", "oraclesaddress", &oraclesaddress, true },
|
{ "oracles", "oraclesaddress", &oraclesaddress, true },
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ extern UniValue pegsaddress(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue triggersaddress(const UniValue& params, bool fHelp);
|
extern UniValue triggersaddress(const UniValue& params, bool fHelp);
|
||||||
extern UniValue paymentsaddress(const UniValue& params, bool fHelp);
|
extern UniValue paymentsaddress(const UniValue& params, bool fHelp);
|
||||||
extern UniValue gatewaysaddress(const UniValue& params, bool fHelp);
|
extern UniValue gatewaysaddress(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue channelsopen(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
//extern UniValue tokenswapask(const UniValue& params, bool fHelp);
|
//extern UniValue tokenswapask(const UniValue& params, bool fHelp);
|
||||||
//extern UniValue tokenfillswap(const UniValue& params, bool fHelp);
|
//extern UniValue tokenfillswap(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void ThreadSendAlert()
|
|||||||
// 4000 or higher will put the RPC into safe mode
|
// 4000 or higher will put the RPC into safe mode
|
||||||
alert.nPriority = 4000;
|
alert.nPriority = 4000;
|
||||||
alert.strComment = "";
|
alert.strComment = "";
|
||||||
alert.strStatusBar = "Your client version 1.0.10 has degraded networking behavior. Please update to the most recent version of Zcash (1.0.10-1 or later).";
|
alert.strStatusBar = "Your client version 1.0.10 has degraded networking behavior. Please update to the most recent version of Komodo (1.0.10-1 or later).";
|
||||||
alert.strRPCError = alert.strStatusBar;
|
alert.strRPCError = alert.strStatusBar;
|
||||||
|
|
||||||
// Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
|
// Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
|
||||||
|
|||||||
@@ -4852,6 +4852,7 @@ int32_t ensure_CCrequirements()
|
|||||||
#include "../cc/CCfsm.h"
|
#include "../cc/CCfsm.h"
|
||||||
#include "../cc/CCauction.h"
|
#include "../cc/CCauction.h"
|
||||||
#include "../cc/CClotto.h"
|
#include "../cc/CClotto.h"
|
||||||
|
#include "../cc/CCchannels.h"
|
||||||
|
|
||||||
UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned char> &pubkey)
|
UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned char> &pubkey)
|
||||||
{
|
{
|
||||||
@@ -4882,6 +4883,26 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue channelsaddress(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::vector<unsigned char> destpubkey; CPubKey pk,pk2; char destaddr[64];
|
||||||
|
cp = CCinit(&C,EVAL_CHANNELS);
|
||||||
|
if ( fHelp || params.size() != 1 )
|
||||||
|
throw runtime_error("channelsaddress destpubkey\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");
|
||||||
|
destpubkey = ParseHex(params[0].get_str().c_str());
|
||||||
|
pk = pubkey2pk(Mypubkey());
|
||||||
|
pk2 = pubkey2pk(destpubkey);
|
||||||
|
result = CCaddress(cp,(char *)"Channels",pubkey);
|
||||||
|
result.push_back(Pair("otherpubkey", params[0].get_str()));
|
||||||
|
GetCCaddress1of2(cp,destaddr,pk,pk2);
|
||||||
|
result.push_back(Pair("sendaddr",destaddr));
|
||||||
|
GetCCaddress1of2(cp,destaddr,pk2,pk);
|
||||||
|
result.push_back(Pair("recvaddr",destaddr));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
UniValue oraclesaddress(const UniValue& params, bool fHelp)
|
UniValue oraclesaddress(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||||
@@ -4960,19 +4981,6 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp)
|
|||||||
return(CCaddress(cp,(char *)"Gateways",pubkey));
|
return(CCaddress(cp,(char *)"Gateways",pubkey));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue channelsaddress(const UniValue& params, bool fHelp)
|
|
||||||
{
|
|
||||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
|
||||||
cp = CCinit(&C,EVAL_CHANNELS);
|
|
||||||
if ( fHelp || params.size() > 1 )
|
|
||||||
throw runtime_error("channelsaddress [pubkey]\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");
|
|
||||||
if ( params.size() == 1 )
|
|
||||||
pubkey = ParseHex(params[0].get_str().c_str());
|
|
||||||
return(CCaddress(cp,(char *)"Channels",pubkey));
|
|
||||||
}
|
|
||||||
|
|
||||||
UniValue mofnaddress(const UniValue& params, bool fHelp)
|
UniValue mofnaddress(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||||
@@ -5079,6 +5087,27 @@ UniValue tokenaddress(const UniValue& params, bool fHelp)
|
|||||||
return(CCaddress(cp,(char *)"Assets",pubkey));
|
return(CCaddress(cp,(char *)"Assets",pubkey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue channelsopen(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
UniValue result(UniValue::VOBJ); char destaddr[64]; int32_t numpayments,payment; std::vector<unsigned char> destpub; struct CCcontract_info *cp,C;
|
||||||
|
cp = CCinit(&C,EVAL_CHANNELS);
|
||||||
|
if ( fHelp || params.size() != 3 )
|
||||||
|
throw runtime_error("channelsopen destpubkey numpayments payment\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");
|
||||||
|
LOCK(cs_main);
|
||||||
|
destpub = ParseHex(params[0].get_str().c_str());
|
||||||
|
numpayments = atoi(params[1].get_str().c_str());
|
||||||
|
payment = atoi(params[2].get_str().c_str());
|
||||||
|
hex = ChannelOpen(0,pubkey2pk(destpub),numpayments,payment);
|
||||||
|
if ( hex.size() > 0 )
|
||||||
|
{
|
||||||
|
result.push_back(Pair("result", "success"));
|
||||||
|
result.push_back(Pair("hex", hex));
|
||||||
|
} else ERR_RESULT("couldnt create channelsopen transaction");
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
UniValue rewardscreatefunding(const UniValue& params, bool fHelp)
|
UniValue rewardscreatefunding(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); char *name; int64_t funds,APR,minseconds,maxseconds,mindeposit; std::string hex;
|
UniValue result(UniValue::VOBJ); char *name; int64_t funds,APR,minseconds,maxseconds,mindeposit; std::string hex;
|
||||||
|
|||||||
Reference in New Issue
Block a user