CCaddress_balance and CCutxo
This commit is contained in:
@@ -179,7 +179,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
|
||||
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
|
||||
CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
|
||||
int64_t CCaddress_balance(char *coinaddr);
|
||||
int64_t CCaddress_balance(char *coinaddr,int32_t CCflag);
|
||||
CPubKey CCtxidaddr(char *txidaddr,uint256 txid);
|
||||
CPubKey CCCustomtxidaddr(char *txidaddr,uint256 txid,uint8_t taddr,uint8_t prefix,uint8_t prefix2);
|
||||
bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn,
|
||||
@@ -282,7 +282,7 @@ void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValu
|
||||
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool CCflag = true);
|
||||
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
|
||||
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs);
|
||||
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout);
|
||||
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag);
|
||||
|
||||
// curve25519 and sha256
|
||||
bits256 curve25519_shared(bits256 privkey,bits256 otherpub);
|
||||
|
||||
@@ -905,7 +905,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
|
||||
for (i=0; i<N; i++)
|
||||
{
|
||||
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkeys[i])) << OP_CHECKSIG);
|
||||
if ( CCaddress_balance(coinaddr) == 0 )
|
||||
if ( CCaddress_balance(coinaddr,0) == 0 )
|
||||
{
|
||||
CCerror = strprintf("M.%d N.%d but pubkeys[%d] has no balance",M,N,i);
|
||||
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
|
||||
@@ -505,7 +505,7 @@ std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid
|
||||
for (i=0; i<N; i++)
|
||||
{
|
||||
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(pubkeys[i])) << OP_CHECKSIG);
|
||||
if ( CCaddress_balance(coinaddr) == 0 )
|
||||
if ( CCaddress_balance(coinaddr,0) == 0 )
|
||||
{
|
||||
CCerror = strprintf("M.%d N.%d but pubkeys[%d] has no balance",M,N,i);
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
|
||||
@@ -441,7 +441,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height)
|
||||
mypk = pubkey2pk(Mypubkey());
|
||||
Marmarapk = GetUnspendable(cp,0);
|
||||
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG);
|
||||
if ( (val= CCaddress_balance(coinaddr)) < amount )
|
||||
if ( (val= CCaddress_balance(coinaddr,0)) < amount )
|
||||
val -= txfee;
|
||||
else val = amount;
|
||||
if ( val > txfee )
|
||||
@@ -1059,16 +1059,16 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_
|
||||
result.push_back(Pair("result","success"));
|
||||
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG);
|
||||
result.push_back(Pair("myaddress",coinaddr));
|
||||
result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr))));
|
||||
result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr,0))));
|
||||
|
||||
GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey());
|
||||
result.push_back(Pair("myCCactivated",coinaddr));
|
||||
result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr))));
|
||||
result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr,1))));
|
||||
result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,0,MARMARA_VINS))));
|
||||
|
||||
GetCCaddress(cp,coinaddr,Mypubkey());
|
||||
result.push_back(Pair("myCCaddress",coinaddr));
|
||||
result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr))));
|
||||
result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr,1))));
|
||||
|
||||
if ( refpk.size() == 33 )
|
||||
result.push_back(Pair("issuer",HexStr(refpk)));
|
||||
|
||||
@@ -864,10 +864,10 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr)
|
||||
result.push_back(Pair("txidoprets",a));
|
||||
txidpk = CCtxidaddr(txidaddr,createtxid);
|
||||
GetCCaddress1of2(cp,fundsaddr,Paymentspk,txidpk);
|
||||
funds = CCaddress_balance(fundsaddr);
|
||||
funds = CCaddress_balance(fundsaddr,1);
|
||||
result.push_back(Pair(fundsaddr,ValueFromAmount(funds)));
|
||||
GetCCaddress(cp,fundsopretaddr,Paymentspk);
|
||||
fundsopret = CCaddress_balance(fundsopretaddr);
|
||||
fundsopret = CCaddress_balance(fundsopretaddr,1);
|
||||
result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret)));
|
||||
result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret)));
|
||||
result.push_back(Pair("result","success"));
|
||||
|
||||
@@ -650,7 +650,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2
|
||||
else
|
||||
{
|
||||
GetCCaddress(cp,coinaddr,rewardspk);
|
||||
if ( (amount= CCutxovalue(coinaddr,locktxid,0)) == 0 )
|
||||
if ( (amount= CCutxovalue(coinaddr,locktxid,0,1)) == 0 )
|
||||
{
|
||||
fprintf(stderr,"%s locktxid/v0 is spent\n",coinaddr);
|
||||
CCerror = "locktxid/v0 is spent";
|
||||
|
||||
@@ -2844,7 +2844,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
||||
pk = buf2pk(pub33);
|
||||
GetCCaddress(cp,CCaddr,pk);
|
||||
result.push_back(Pair("sudokuaddr",CCaddr));
|
||||
balance = CCaddress_balance(CCaddr);
|
||||
balance = CCaddress_balance(CCaddr,1);
|
||||
result.push_back(Pair("amount",ValueFromAmount(balance)));
|
||||
if ( sudoku_captcha(1,timestamps,komodo_nextheight()) < 0 )
|
||||
{
|
||||
|
||||
@@ -5369,11 +5369,11 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
|
||||
sprintf(str,"%sCCAddress",name);
|
||||
result.push_back(Pair(str,cp->unspendableCCaddr));
|
||||
sprintf(str,"%sCCBalance",name);
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr))));
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr,1))));
|
||||
sprintf(str,"%sNormalAddress",name);
|
||||
result.push_back(Pair(str,cp->normaladdr));
|
||||
sprintf(str,"%sNormalBalance",name);
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr))));
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr,0))));
|
||||
if (strcmp(name,"Gateways")==0) result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40"));
|
||||
if ((strcmp(name,"Channels")==0 || strcmp(name,"Heir")==0) && pubkey.size() == 33)
|
||||
{
|
||||
@@ -5402,7 +5402,7 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
|
||||
sprintf(str,"PubkeyCCaddress(%s)",name);
|
||||
result.push_back(Pair(str,destaddr));
|
||||
sprintf(str,"PubkeyCCbalance(%s)",name);
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(destaddr))));
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(destaddr,0))));
|
||||
}
|
||||
}
|
||||
if ( GetCCaddress(cp,destaddr,pubkey2pk(Mypubkey())) != 0 )
|
||||
@@ -5410,12 +5410,12 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
|
||||
sprintf(str,"myCCAddress(%s)",name);
|
||||
result.push_back(Pair(str,destaddr));
|
||||
sprintf(str,"myCCbalance(%s)",name);
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(destaddr))));
|
||||
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(destaddr,1))));
|
||||
}
|
||||
if ( Getscriptaddress(destaddr,(CScript() << Mypubkey() << OP_CHECKSIG)) != 0 )
|
||||
{
|
||||
result.push_back(Pair("myaddress",destaddr));
|
||||
result.push_back(Pair("mybalance",ValueFromAmount(CCaddress_balance(destaddr))));
|
||||
result.push_back(Pair("mybalance",ValueFromAmount(CCaddress_balance(destaddr,0))));
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user