forked from hush/hush3
![jameslee777@yahoo.com](/assets/img/avatar_default.png)
17 changed files with 1651 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
|
|||
#ifndef CC_CHANNELS_H |
|||
#define CC_CHANNELS_H |
|||
|
|||
#include "CCinclude.h" |
|||
|
|||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); |
|||
|
|||
// CCcustom
|
|||
UniValue ChannelsInfo(); |
|||
|
|||
#endif |
@ -0,0 +1,27 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
|
|||
#ifndef CC_CHANNELS_H |
|||
#define CC_CHANNELS_H |
|||
|
|||
#include "CCinclude.h" |
|||
|
|||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); |
|||
|
|||
// CCcustom
|
|||
UniValue ChannelsInfo(); |
|||
|
|||
#endif |
@ -0,0 +1,27 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
|
|||
#ifndef CC_CHANNELS_H |
|||
#define CC_CHANNELS_H |
|||
|
|||
#include "CCinclude.h" |
|||
|
|||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); |
|||
|
|||
// CCcustom
|
|||
UniValue ChannelsInfo(); |
|||
|
|||
#endif |
@ -0,0 +1,27 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
|
|||
#ifndef CC_CHANNELS_H |
|||
#define CC_CHANNELS_H |
|||
|
|||
#include "CCinclude.h" |
|||
|
|||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); |
|||
|
|||
// CCcustom
|
|||
UniValue ChannelsInfo(); |
|||
|
|||
#endif |
@ -0,0 +1,27 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
|
|||
#ifndef CC_CHANNELS_H |
|||
#define CC_CHANNELS_H |
|||
|
|||
#include "CCinclude.h" |
|||
|
|||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); |
|||
|
|||
// CCcustom
|
|||
UniValue ChannelsInfo(); |
|||
|
|||
#endif |
@ -0,0 +1,27 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
|
|||
#ifndef CC_CHANNELS_H |
|||
#define CC_CHANNELS_H |
|||
|
|||
#include "CCinclude.h" |
|||
|
|||
bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); |
|||
|
|||
// CCcustom
|
|||
UniValue ChannelsInfo(); |
|||
|
|||
#endif |
@ -0,0 +1,210 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
#include "CCGateways.h" |
|||
|
|||
/*
|
|||
*/ |
|||
|
|||
// start of consensus code
|
|||
|
|||
int64_t IsGatewaysvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) |
|||
{ |
|||
char destaddr[64]; |
|||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|||
{ |
|||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) |
|||
return(tx.vout[v].nValue); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) |
|||
{ |
|||
static uint256 zerohash; |
|||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
//fprintf(stderr,"vini.%d\n",i);
|
|||
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) |
|||
{ |
|||
//fprintf(stderr,"vini.%d check mempool\n",i);
|
|||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) |
|||
return eval->Invalid("cant find vinTx"); |
|||
else |
|||
{ |
|||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
|||
if ( hashBlock == zerohash ) |
|||
return eval->Invalid("cant Gateways from mempool"); |
|||
if ( (assetoshis= IsGatewaysvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) |
|||
inputs += assetoshis; |
|||
} |
|||
} |
|||
} |
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
|||
if ( (assetoshis= IsGatewaysvout(cp,tx,i)) != 0 ) |
|||
outputs += assetoshis; |
|||
} |
|||
if ( inputs != outputs+txfee ) |
|||
{ |
|||
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); |
|||
return eval->Invalid("mismatched inputs != outputs + txfee"); |
|||
} |
|||
else return(true); |
|||
} |
|||
|
|||
bool GatewaysValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) |
|||
{ |
|||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; |
|||
return(false); |
|||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
preventCCvins = preventCCvouts = -1; |
|||
if ( numvouts < 1 ) |
|||
return eval->Invalid("no vouts"); |
|||
else |
|||
{ |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) |
|||
{ |
|||
return eval->Invalid("illegal normal vini"); |
|||
} |
|||
} |
|||
//fprintf(stderr,"check amounts\n");
|
|||
if ( GatewaysExactAmounts(cp,eval,tx,1,10000) == false ) |
|||
{ |
|||
fprintf(stderr,"Gatewaysget invalid amount\n"); |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
txid = tx.GetHash(); |
|||
memcpy(hash,&txid,sizeof(hash)); |
|||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); |
|||
if ( retval != 0 ) |
|||
fprintf(stderr,"Gatewaysget validated\n"); |
|||
else fprintf(stderr,"Gatewaysget invalid\n"); |
|||
return(retval); |
|||
} |
|||
} |
|||
} |
|||
// end of consensus code
|
|||
|
|||
// helper functions for rpc calls in rpcwallet.cpp
|
|||
|
|||
int64_t AddGatewaysInputs(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; |
|||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; |
|||
GetCCaddress(cp,coinaddr,pk); |
|||
SetCCunspents(unspentOutputs,coinaddr); |
|||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) |
|||
{ |
|||
txid = it->first.txhash; |
|||
vout = (int32_t)it->first.index; |
|||
// no need to prevent dup
|
|||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) |
|||
{ |
|||
if ( (nValue= IsGatewaysvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) |
|||
{ |
|||
if ( total != 0 && maxinputs != 0 ) |
|||
mtx.vin.push_back(CTxIn(txid,vout,CScript())); |
|||
nValue = it->second.satoshis; |
|||
totalinputs += nValue; |
|||
n++; |
|||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return(totalinputs); |
|||
} |
|||
|
|||
std::string GatewaysGet(uint64_t txfee,int64_t nValue) |
|||
{ |
|||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Gatewayspk; 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; |
|||
cp = CCinit(&C,EVAL_GATEWAYS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
Gatewayspk = GetUnspendable(cp,0); |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
if ( (inputs= AddGatewaysInputs(cp,mtx,Gatewayspk,nValue+txfee,60)) > 0 ) |
|||
{ |
|||
if ( inputs > nValue ) |
|||
CCchange = (inputs - nValue - txfee); |
|||
if ( CCchange != 0 ) |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,CCchange,Gatewayspk)); |
|||
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_GATEWAYS << (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(""); |
|||
} else fprintf(stderr,"cant find Gateways inputs\n"); |
|||
return(""); |
|||
} |
|||
|
|||
std::string GatewaysFund(uint64_t txfee,int64_t funds) |
|||
{ |
|||
CMutableTransaction mtx; CPubKey mypk,Gatewayspk; CScript opret; struct CCcontract_info *cp,C; |
|||
cp = CCinit(&C,EVAL_GATEWAYS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
Gatewayspk = GetUnspendable(cp,0); |
|||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) |
|||
{ |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_GATEWAYS,funds,Gatewayspk)); |
|||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); |
|||
} |
|||
return(""); |
|||
} |
|||
|
|||
UniValue GatewaysInfo() |
|||
{ |
|||
UniValue result(UniValue::VOBJ); char numstr[64]; |
|||
CMutableTransaction mtx; CPubKey Gatewayspk; struct CCcontract_info *cp,C; int64_t funding; |
|||
result.push_back(Pair("result","success")); |
|||
result.push_back(Pair("name","Gateways")); |
|||
cp = CCinit(&C,EVAL_GATEWAYS); |
|||
Gatewayspk = GetUnspendable(cp,0); |
|||
funding = AddGatewaysInputs(cp,mtx,Gatewayspk,0,0); |
|||
sprintf(numstr,"%.8f",(double)funding/COIN); |
|||
result.push_back(Pair("funding",numstr)); |
|||
return(result); |
|||
} |
|||
|
@ -0,0 +1,210 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
#include "CCOracles.h" |
|||
|
|||
/*
|
|||
*/ |
|||
|
|||
// start of consensus code
|
|||
|
|||
int64_t IsOraclesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) |
|||
{ |
|||
char destaddr[64]; |
|||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|||
{ |
|||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) |
|||
return(tx.vout[v].nValue); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
bool OraclesExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) |
|||
{ |
|||
static uint256 zerohash; |
|||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
//fprintf(stderr,"vini.%d\n",i);
|
|||
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) |
|||
{ |
|||
//fprintf(stderr,"vini.%d check mempool\n",i);
|
|||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) |
|||
return eval->Invalid("cant find vinTx"); |
|||
else |
|||
{ |
|||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
|||
if ( hashBlock == zerohash ) |
|||
return eval->Invalid("cant Oracles from mempool"); |
|||
if ( (assetoshis= IsOraclesvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) |
|||
inputs += assetoshis; |
|||
} |
|||
} |
|||
} |
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
|||
if ( (assetoshis= IsOraclesvout(cp,tx,i)) != 0 ) |
|||
outputs += assetoshis; |
|||
} |
|||
if ( inputs != outputs+txfee ) |
|||
{ |
|||
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); |
|||
return eval->Invalid("mismatched inputs != outputs + txfee"); |
|||
} |
|||
else return(true); |
|||
} |
|||
|
|||
bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) |
|||
{ |
|||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; |
|||
return(false); |
|||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
preventCCvins = preventCCvouts = -1; |
|||
if ( numvouts < 1 ) |
|||
return eval->Invalid("no vouts"); |
|||
else |
|||
{ |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) |
|||
{ |
|||
return eval->Invalid("illegal normal vini"); |
|||
} |
|||
} |
|||
//fprintf(stderr,"check amounts\n");
|
|||
if ( OraclesExactAmounts(cp,eval,tx,1,10000) == false ) |
|||
{ |
|||
fprintf(stderr,"Oraclesget invalid amount\n"); |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
txid = tx.GetHash(); |
|||
memcpy(hash,&txid,sizeof(hash)); |
|||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); |
|||
if ( retval != 0 ) |
|||
fprintf(stderr,"Oraclesget validated\n"); |
|||
else fprintf(stderr,"Oraclesget invalid\n"); |
|||
return(retval); |
|||
} |
|||
} |
|||
} |
|||
// end of consensus code
|
|||
|
|||
// helper functions for rpc calls in rpcwallet.cpp
|
|||
|
|||
int64_t AddOraclesInputs(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; |
|||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; |
|||
GetCCaddress(cp,coinaddr,pk); |
|||
SetCCunspents(unspentOutputs,coinaddr); |
|||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) |
|||
{ |
|||
txid = it->first.txhash; |
|||
vout = (int32_t)it->first.index; |
|||
// no need to prevent dup
|
|||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) |
|||
{ |
|||
if ( (nValue= IsOraclesvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) |
|||
{ |
|||
if ( total != 0 && maxinputs != 0 ) |
|||
mtx.vin.push_back(CTxIn(txid,vout,CScript())); |
|||
nValue = it->second.satoshis; |
|||
totalinputs += nValue; |
|||
n++; |
|||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return(totalinputs); |
|||
} |
|||
|
|||
std::string OraclesGet(uint64_t txfee,int64_t nValue) |
|||
{ |
|||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Oraclespk; 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; |
|||
cp = CCinit(&C,EVAL_ORACLES); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
Oraclespk = GetUnspendable(cp,0); |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
if ( (inputs= AddOraclesInputs(cp,mtx,Oraclespk,nValue+txfee,60)) > 0 ) |
|||
{ |
|||
if ( inputs > nValue ) |
|||
CCchange = (inputs - nValue - txfee); |
|||
if ( CCchange != 0 ) |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_ORACLES,CCchange,Oraclespk)); |
|||
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_ORACLES << (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(""); |
|||
} else fprintf(stderr,"cant find Oracles inputs\n"); |
|||
return(""); |
|||
} |
|||
|
|||
std::string OraclesFund(uint64_t txfee,int64_t funds) |
|||
{ |
|||
CMutableTransaction mtx; CPubKey mypk,Oraclespk; CScript opret; struct CCcontract_info *cp,C; |
|||
cp = CCinit(&C,EVAL_ORACLES); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
Oraclespk = GetUnspendable(cp,0); |
|||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) |
|||
{ |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_ORACLES,funds,Oraclespk)); |
|||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); |
|||
} |
|||
return(""); |
|||
} |
|||
|
|||
UniValue OraclesInfo() |
|||
{ |
|||
UniValue result(UniValue::VOBJ); char numstr[64]; |
|||
CMutableTransaction mtx; CPubKey Oraclespk; struct CCcontract_info *cp,C; int64_t funding; |
|||
result.push_back(Pair("result","success")); |
|||
result.push_back(Pair("name","Oracles")); |
|||
cp = CCinit(&C,EVAL_ORACLES); |
|||
Oraclespk = GetUnspendable(cp,0); |
|||
funding = AddOraclesInputs(cp,mtx,Oraclespk,0,0); |
|||
sprintf(numstr,"%.8f",(double)funding/COIN); |
|||
result.push_back(Pair("funding",numstr)); |
|||
return(result); |
|||
} |
|||
|
@ -0,0 +1,210 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
#include "CCPayments.h" |
|||
|
|||
/*
|
|||
*/ |
|||
|
|||
// start of consensus code
|
|||
|
|||
int64_t IsPaymentsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) |
|||
{ |
|||
char destaddr[64]; |
|||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|||
{ |
|||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) |
|||
return(tx.vout[v].nValue); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
bool PaymentsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) |
|||
{ |
|||
static uint256 zerohash; |
|||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
//fprintf(stderr,"vini.%d\n",i);
|
|||
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) |
|||
{ |
|||
//fprintf(stderr,"vini.%d check mempool\n",i);
|
|||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) |
|||
return eval->Invalid("cant find vinTx"); |
|||
else |
|||
{ |
|||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
|||
if ( hashBlock == zerohash ) |
|||
return eval->Invalid("cant Payments from mempool"); |
|||
if ( (assetoshis= IsPaymentsvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) |
|||
inputs += assetoshis; |
|||
} |
|||
} |
|||
} |
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
|||
if ( (assetoshis= IsPaymentsvout(cp,tx,i)) != 0 ) |
|||
outputs += assetoshis; |
|||
} |
|||
if ( inputs != outputs+txfee ) |
|||
{ |
|||
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); |
|||
return eval->Invalid("mismatched inputs != outputs + txfee"); |
|||
} |
|||
else return(true); |
|||
} |
|||
|
|||
bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) |
|||
{ |
|||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; |
|||
return(false); |
|||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
preventCCvins = preventCCvouts = -1; |
|||
if ( numvouts < 1 ) |
|||
return eval->Invalid("no vouts"); |
|||
else |
|||
{ |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) |
|||
{ |
|||
return eval->Invalid("illegal normal vini"); |
|||
} |
|||
} |
|||
//fprintf(stderr,"check amounts\n");
|
|||
if ( PaymentsExactAmounts(cp,eval,tx,1,10000) == false ) |
|||
{ |
|||
fprintf(stderr,"Paymentsget invalid amount\n"); |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
txid = tx.GetHash(); |
|||
memcpy(hash,&txid,sizeof(hash)); |
|||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); |
|||
if ( retval != 0 ) |
|||
fprintf(stderr,"Paymentsget validated\n"); |
|||
else fprintf(stderr,"Paymentsget invalid\n"); |
|||
return(retval); |
|||
} |
|||
} |
|||
} |
|||
// end of consensus code
|
|||
|
|||
// helper functions for rpc calls in rpcwallet.cpp
|
|||
|
|||
int64_t AddPaymentsInputs(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; |
|||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; |
|||
GetCCaddress(cp,coinaddr,pk); |
|||
SetCCunspents(unspentOutputs,coinaddr); |
|||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) |
|||
{ |
|||
txid = it->first.txhash; |
|||
vout = (int32_t)it->first.index; |
|||
// no need to prevent dup
|
|||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) |
|||
{ |
|||
if ( (nValue= IsPaymentsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) |
|||
{ |
|||
if ( total != 0 && maxinputs != 0 ) |
|||
mtx.vin.push_back(CTxIn(txid,vout,CScript())); |
|||
nValue = it->second.satoshis; |
|||
totalinputs += nValue; |
|||
n++; |
|||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return(totalinputs); |
|||
} |
|||
|
|||
std::string PaymentsGet(uint64_t txfee,int64_t nValue) |
|||
{ |
|||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Paymentspk; 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; |
|||
cp = CCinit(&C,EVAL_PAYMENTS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
Paymentspk = GetUnspendable(cp,0); |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
if ( (inputs= AddPaymentsInputs(cp,mtx,Paymentspk,nValue+txfee,60)) > 0 ) |
|||
{ |
|||
if ( inputs > nValue ) |
|||
CCchange = (inputs - nValue - txfee); |
|||
if ( CCchange != 0 ) |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,CCchange,Paymentspk)); |
|||
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_PAYMENTS << (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(""); |
|||
} else fprintf(stderr,"cant find Payments inputs\n"); |
|||
return(""); |
|||
} |
|||
|
|||
std::string PaymentsFund(uint64_t txfee,int64_t funds) |
|||
{ |
|||
CMutableTransaction mtx; CPubKey mypk,Paymentspk; CScript opret; struct CCcontract_info *cp,C; |
|||
cp = CCinit(&C,EVAL_PAYMENTS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
Paymentspk = GetUnspendable(cp,0); |
|||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) |
|||
{ |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_PAYMENTS,funds,Paymentspk)); |
|||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); |
|||
} |
|||
return(""); |
|||
} |
|||
|
|||
UniValue PaymentsInfo() |
|||
{ |
|||
UniValue result(UniValue::VOBJ); char numstr[64]; |
|||
CMutableTransaction mtx; CPubKey Paymentspk; struct CCcontract_info *cp,C; int64_t funding; |
|||
result.push_back(Pair("result","success")); |
|||
result.push_back(Pair("name","Payments")); |
|||
cp = CCinit(&C,EVAL_PAYMENTS); |
|||
Paymentspk = GetUnspendable(cp,0); |
|||
funding = AddPaymentsInputs(cp,mtx,Paymentspk,0,0); |
|||
sprintf(numstr,"%.8f",(double)funding/COIN); |
|||
result.push_back(Pair("funding",numstr)); |
|||
return(result); |
|||
} |
|||
|
@ -0,0 +1,210 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
#include "CCPegs.h" |
|||
|
|||
/*
|
|||
*/ |
|||
|
|||
// start of consensus code
|
|||
|
|||
int64_t IsPegsvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) |
|||
{ |
|||
char destaddr[64]; |
|||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|||
{ |
|||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) |
|||
return(tx.vout[v].nValue); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
bool PegsExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) |
|||
{ |
|||
static uint256 zerohash; |
|||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
//fprintf(stderr,"vini.%d\n",i);
|
|||
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) |
|||
{ |
|||
//fprintf(stderr,"vini.%d check mempool\n",i);
|
|||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) |
|||
return eval->Invalid("cant find vinTx"); |
|||
else |
|||
{ |
|||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
|||
if ( hashBlock == zerohash ) |
|||
return eval->Invalid("cant Pegs from mempool"); |
|||
if ( (assetoshis= IsPegsvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) |
|||
inputs += assetoshis; |
|||
} |
|||
} |
|||
} |
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
|||
if ( (assetoshis= IsPegsvout(cp,tx,i)) != 0 ) |
|||
outputs += assetoshis; |
|||
} |
|||
if ( inputs != outputs+txfee ) |
|||
{ |
|||
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); |
|||
return eval->Invalid("mismatched inputs != outputs + txfee"); |
|||
} |
|||
else return(true); |
|||
} |
|||
|
|||
bool PegsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) |
|||
{ |
|||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; |
|||
return(false); |
|||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
preventCCvins = preventCCvouts = -1; |
|||
if ( numvouts < 1 ) |
|||
return eval->Invalid("no vouts"); |
|||
else |
|||
{ |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) |
|||
{ |
|||
return eval->Invalid("illegal normal vini"); |
|||
} |
|||
} |
|||
//fprintf(stderr,"check amounts\n");
|
|||
if ( PegsExactAmounts(cp,eval,tx,1,10000) == false ) |
|||
{ |
|||
fprintf(stderr,"Pegsget invalid amount\n"); |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
txid = tx.GetHash(); |
|||
memcpy(hash,&txid,sizeof(hash)); |
|||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); |
|||
if ( retval != 0 ) |
|||
fprintf(stderr,"Pegsget validated\n"); |
|||
else fprintf(stderr,"Pegsget invalid\n"); |
|||
return(retval); |
|||
} |
|||
} |
|||
} |
|||
// end of consensus code
|
|||
|
|||
// helper functions for rpc calls in rpcwallet.cpp
|
|||
|
|||
int64_t AddPegsInputs(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; |
|||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; |
|||
GetCCaddress(cp,coinaddr,pk); |
|||
SetCCunspents(unspentOutputs,coinaddr); |
|||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) |
|||
{ |
|||
txid = it->first.txhash; |
|||
vout = (int32_t)it->first.index; |
|||
// no need to prevent dup
|
|||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) |
|||
{ |
|||
if ( (nValue= IsPegsvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) |
|||
{ |
|||
if ( total != 0 && maxinputs != 0 ) |
|||
mtx.vin.push_back(CTxIn(txid,vout,CScript())); |
|||
nValue = it->second.satoshis; |
|||
totalinputs += nValue; |
|||
n++; |
|||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return(totalinputs); |
|||
} |
|||
|
|||
std::string PegsGet(uint64_t txfee,int64_t nValue) |
|||
{ |
|||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Pegspk; 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; |
|||
cp = CCinit(&C,EVAL_PEGS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
Pegspk = GetUnspendable(cp,0); |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
if ( (inputs= AddPegsInputs(cp,mtx,Pegspk,nValue+txfee,60)) > 0 ) |
|||
{ |
|||
if ( inputs > nValue ) |
|||
CCchange = (inputs - nValue - txfee); |
|||
if ( CCchange != 0 ) |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_PEGS,CCchange,Pegspk)); |
|||
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_PEGS << (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(""); |
|||
} else fprintf(stderr,"cant find Pegs inputs\n"); |
|||
return(""); |
|||
} |
|||
|
|||
std::string PegsFund(uint64_t txfee,int64_t funds) |
|||
{ |
|||
CMutableTransaction mtx; CPubKey mypk,Pegspk; CScript opret; struct CCcontract_info *cp,C; |
|||
cp = CCinit(&C,EVAL_PEGS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
Pegspk = GetUnspendable(cp,0); |
|||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) |
|||
{ |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_PEGS,funds,Pegspk)); |
|||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); |
|||
} |
|||
return(""); |
|||
} |
|||
|
|||
UniValue PegsInfo() |
|||
{ |
|||
UniValue result(UniValue::VOBJ); char numstr[64]; |
|||
CMutableTransaction mtx; CPubKey Pegspk; struct CCcontract_info *cp,C; int64_t funding; |
|||
result.push_back(Pair("result","success")); |
|||
result.push_back(Pair("name","Pegs")); |
|||
cp = CCinit(&C,EVAL_PEGS); |
|||
Pegspk = GetUnspendable(cp,0); |
|||
funding = AddPegsInputs(cp,mtx,Pegspk,0,0); |
|||
sprintf(numstr,"%.8f",(double)funding/COIN); |
|||
result.push_back(Pair("funding",numstr)); |
|||
return(result); |
|||
} |
|||
|
@ -0,0 +1,210 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
#include "CCPrices.h" |
|||
|
|||
/*
|
|||
*/ |
|||
|
|||
// start of consensus code
|
|||
|
|||
int64_t IsPricesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) |
|||
{ |
|||
char destaddr[64]; |
|||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|||
{ |
|||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) |
|||
return(tx.vout[v].nValue); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
bool PricesExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) |
|||
{ |
|||
static uint256 zerohash; |
|||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
//fprintf(stderr,"vini.%d\n",i);
|
|||
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) |
|||
{ |
|||
//fprintf(stderr,"vini.%d check mempool\n",i);
|
|||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) |
|||
return eval->Invalid("cant find vinTx"); |
|||
else |
|||
{ |
|||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
|||
if ( hashBlock == zerohash ) |
|||
return eval->Invalid("cant Prices from mempool"); |
|||
if ( (assetoshis= IsPricesvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) |
|||
inputs += assetoshis; |
|||
} |
|||
} |
|||
} |
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
|||
if ( (assetoshis= IsPricesvout(cp,tx,i)) != 0 ) |
|||
outputs += assetoshis; |
|||
} |
|||
if ( inputs != outputs+txfee ) |
|||
{ |
|||
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); |
|||
return eval->Invalid("mismatched inputs != outputs + txfee"); |
|||
} |
|||
else return(true); |
|||
} |
|||
|
|||
bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) |
|||
{ |
|||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; |
|||
return(false); |
|||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
preventCCvins = preventCCvouts = -1; |
|||
if ( numvouts < 1 ) |
|||
return eval->Invalid("no vouts"); |
|||
else |
|||
{ |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) |
|||
{ |
|||
return eval->Invalid("illegal normal vini"); |
|||
} |
|||
} |
|||
//fprintf(stderr,"check amounts\n");
|
|||
if ( PricesExactAmounts(cp,eval,tx,1,10000) == false ) |
|||
{ |
|||
fprintf(stderr,"Pricesget invalid amount\n"); |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
txid = tx.GetHash(); |
|||
memcpy(hash,&txid,sizeof(hash)); |
|||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); |
|||
if ( retval != 0 ) |
|||
fprintf(stderr,"Pricesget validated\n"); |
|||
else fprintf(stderr,"Pricesget invalid\n"); |
|||
return(retval); |
|||
} |
|||
} |
|||
} |
|||
// end of consensus code
|
|||
|
|||
// helper functions for rpc calls in rpcwallet.cpp
|
|||
|
|||
int64_t AddPricesInputs(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; |
|||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; |
|||
GetCCaddress(cp,coinaddr,pk); |
|||
SetCCunspents(unspentOutputs,coinaddr); |
|||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) |
|||
{ |
|||
txid = it->first.txhash; |
|||
vout = (int32_t)it->first.index; |
|||
// no need to prevent dup
|
|||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) |
|||
{ |
|||
if ( (nValue= IsPricesvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) |
|||
{ |
|||
if ( total != 0 && maxinputs != 0 ) |
|||
mtx.vin.push_back(CTxIn(txid,vout,CScript())); |
|||
nValue = it->second.satoshis; |
|||
totalinputs += nValue; |
|||
n++; |
|||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return(totalinputs); |
|||
} |
|||
|
|||
std::string PricesGet(uint64_t txfee,int64_t nValue) |
|||
{ |
|||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Pricespk; 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; |
|||
cp = CCinit(&C,EVAL_PRICES); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
Pricespk = GetUnspendable(cp,0); |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
if ( (inputs= AddPricesInputs(cp,mtx,Pricespk,nValue+txfee,60)) > 0 ) |
|||
{ |
|||
if ( inputs > nValue ) |
|||
CCchange = (inputs - nValue - txfee); |
|||
if ( CCchange != 0 ) |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_PRICES,CCchange,Pricespk)); |
|||
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_PRICES << (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(""); |
|||
} else fprintf(stderr,"cant find Prices inputs\n"); |
|||
return(""); |
|||
} |
|||
|
|||
std::string PricesFund(uint64_t txfee,int64_t funds) |
|||
{ |
|||
CMutableTransaction mtx; CPubKey mypk,Pricespk; CScript opret; struct CCcontract_info *cp,C; |
|||
cp = CCinit(&C,EVAL_PRICES); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
Pricespk = GetUnspendable(cp,0); |
|||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) |
|||
{ |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_PRICES,funds,Pricespk)); |
|||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); |
|||
} |
|||
return(""); |
|||
} |
|||
|
|||
UniValue PricesInfo() |
|||
{ |
|||
UniValue result(UniValue::VOBJ); char numstr[64]; |
|||
CMutableTransaction mtx; CPubKey Pricespk; struct CCcontract_info *cp,C; int64_t funding; |
|||
result.push_back(Pair("result","success")); |
|||
result.push_back(Pair("name","Prices")); |
|||
cp = CCinit(&C,EVAL_PRICES); |
|||
Pricespk = GetUnspendable(cp,0); |
|||
funding = AddPricesInputs(cp,mtx,Pricespk,0,0); |
|||
sprintf(numstr,"%.8f",(double)funding/COIN); |
|||
result.push_back(Pair("funding",numstr)); |
|||
return(result); |
|||
} |
|||
|
@ -0,0 +1,210 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2018 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
|
|||
#include "CCTriggers.h" |
|||
|
|||
/*
|
|||
*/ |
|||
|
|||
// start of consensus code
|
|||
|
|||
int64_t IsTriggersvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) |
|||
{ |
|||
char destaddr[64]; |
|||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) |
|||
{ |
|||
if ( Getscriptaddress(destaddr,tx.vout[v].scriptPubKey) > 0 && strcmp(destaddr,cp->unspendableCCaddr) == 0 ) |
|||
return(tx.vout[v].nValue); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
bool TriggersExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) |
|||
{ |
|||
static uint256 zerohash; |
|||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
//fprintf(stderr,"vini.%d\n",i);
|
|||
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 ) |
|||
{ |
|||
//fprintf(stderr,"vini.%d check mempool\n",i);
|
|||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 ) |
|||
return eval->Invalid("cant find vinTx"); |
|||
else |
|||
{ |
|||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
|||
if ( hashBlock == zerohash ) |
|||
return eval->Invalid("cant Triggers from mempool"); |
|||
if ( (assetoshis= IsTriggersvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) |
|||
inputs += assetoshis; |
|||
} |
|||
} |
|||
} |
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
|||
if ( (assetoshis= IsTriggersvout(cp,tx,i)) != 0 ) |
|||
outputs += assetoshis; |
|||
} |
|||
if ( inputs != outputs+txfee ) |
|||
{ |
|||
fprintf(stderr,"inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs); |
|||
return eval->Invalid("mismatched inputs != outputs + txfee"); |
|||
} |
|||
else return(true); |
|||
} |
|||
|
|||
bool TriggersValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx) |
|||
{ |
|||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64]; |
|||
return(false); |
|||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; |
|||
numvins = tx.vin.size(); |
|||
numvouts = tx.vout.size(); |
|||
preventCCvins = preventCCvouts = -1; |
|||
if ( numvouts < 1 ) |
|||
return eval->Invalid("no vouts"); |
|||
else |
|||
{ |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 ) |
|||
{ |
|||
return eval->Invalid("illegal normal vini"); |
|||
} |
|||
} |
|||
//fprintf(stderr,"check amounts\n");
|
|||
if ( TriggersExactAmounts(cp,eval,tx,1,10000) == false ) |
|||
{ |
|||
fprintf(stderr,"Triggersget invalid amount\n"); |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
txid = tx.GetHash(); |
|||
memcpy(hash,&txid,sizeof(hash)); |
|||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts); |
|||
if ( retval != 0 ) |
|||
fprintf(stderr,"Triggersget validated\n"); |
|||
else fprintf(stderr,"Triggersget invalid\n"); |
|||
return(retval); |
|||
} |
|||
} |
|||
} |
|||
// end of consensus code
|
|||
|
|||
// helper functions for rpc calls in rpcwallet.cpp
|
|||
|
|||
int64_t AddTriggersInputs(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; |
|||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; |
|||
GetCCaddress(cp,coinaddr,pk); |
|||
SetCCunspents(unspentOutputs,coinaddr); |
|||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) |
|||
{ |
|||
txid = it->first.txhash; |
|||
vout = (int32_t)it->first.index; |
|||
// no need to prevent dup
|
|||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) |
|||
{ |
|||
if ( (nValue= IsTriggersvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) |
|||
{ |
|||
if ( total != 0 && maxinputs != 0 ) |
|||
mtx.vin.push_back(CTxIn(txid,vout,CScript())); |
|||
nValue = it->second.satoshis; |
|||
totalinputs += nValue; |
|||
n++; |
|||
if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return(totalinputs); |
|||
} |
|||
|
|||
std::string TriggersGet(uint64_t txfee,int64_t nValue) |
|||
{ |
|||
CMutableTransaction mtx,tmpmtx; CPubKey mypk,Triggerspk; 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; |
|||
cp = CCinit(&C,EVAL_TRIGGERS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
Triggerspk = GetUnspendable(cp,0); |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
if ( (inputs= AddTriggersInputs(cp,mtx,Triggerspk,nValue+txfee,60)) > 0 ) |
|||
{ |
|||
if ( inputs > nValue ) |
|||
CCchange = (inputs - nValue - txfee); |
|||
if ( CCchange != 0 ) |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_TRIGGERS,CCchange,Triggerspk)); |
|||
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_TRIGGERS << (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(""); |
|||
} else fprintf(stderr,"cant find Triggers inputs\n"); |
|||
return(""); |
|||
} |
|||
|
|||
std::string TriggersFund(uint64_t txfee,int64_t funds) |
|||
{ |
|||
CMutableTransaction mtx; CPubKey mypk,Triggerspk; CScript opret; struct CCcontract_info *cp,C; |
|||
cp = CCinit(&C,EVAL_TRIGGERS); |
|||
if ( txfee == 0 ) |
|||
txfee = 10000; |
|||
mypk = pubkey2pk(Mypubkey()); |
|||
Triggerspk = GetUnspendable(cp,0); |
|||
if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) |
|||
{ |
|||
mtx.vout.push_back(MakeCC1vout(EVAL_TRIGGERS,funds,Triggerspk)); |
|||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); |
|||
} |
|||
return(""); |
|||
} |
|||
|
|||
UniValue TriggersInfo() |
|||
{ |
|||
UniValue result(UniValue::VOBJ); char numstr[64]; |
|||
CMutableTransaction mtx; CPubKey Triggerspk; struct CCcontract_info *cp,C; int64_t funding; |
|||
result.push_back(Pair("result","success")); |
|||
result.push_back(Pair("name","Triggers")); |
|||
cp = CCinit(&C,EVAL_TRIGGERS); |
|||
Triggerspk = GetUnspendable(cp,0); |
|||
funding = AddTriggersInputs(cp,mtx,Triggerspk,0,0); |
|||
sprintf(numstr,"%.8f",(double)funding/COIN); |
|||
result.push_back(Pair("funding",numstr)); |
|||
return(result); |
|||
} |
|||
|
Loading…
Reference in new issue