Add coinaddr to utxos
This commit is contained in:
@@ -119,6 +119,7 @@ int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp
|
|||||||
struct NSPV_utxosresp
|
struct NSPV_utxosresp
|
||||||
{
|
{
|
||||||
struct NSPV_utxoresp *utxos;
|
struct NSPV_utxoresp *utxos;
|
||||||
|
char coinaddr[64];
|
||||||
int64_t total,interest;
|
int64_t total,interest;
|
||||||
int32_t nodeheight;
|
int32_t nodeheight;
|
||||||
uint16_t numutxos,pad16;
|
uint16_t numutxos,pad16;
|
||||||
@@ -139,6 +140,16 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres
|
|||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest);
|
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest);
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
|
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16);
|
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16);
|
||||||
|
if ( rwflag != 0 )
|
||||||
|
{
|
||||||
|
memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr));
|
||||||
|
len += sizeof(ptr->coinaddr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(ptr->coinaddr,&serialized[len],sizeof(ptr->coinaddr));
|
||||||
|
len += sizeof(ptr->coinaddr);
|
||||||
|
}
|
||||||
return(len);
|
return(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,6 +480,7 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr) // check
|
|||||||
SetCCunspents(unspentOutputs,coinaddr,false);
|
SetCCunspents(unspentOutputs,coinaddr,false);
|
||||||
maxlen = MAX_BLOCK_SIZE(tipheight) - 512;
|
maxlen = MAX_BLOCK_SIZE(tipheight) - 512;
|
||||||
maxlen /= sizeof(*ptr->utxos);
|
maxlen /= sizeof(*ptr->utxos);
|
||||||
|
strncpy(ptr->coinaddr,coinaddr,sizeof(ptr->coinaddr)-1);
|
||||||
if ( (ptr->numutxos= (int32_t)unspentOutputs.size()) > 0 && ptr->numutxos < maxlen )
|
if ( (ptr->numutxos= (int32_t)unspentOutputs.size()) > 0 && ptr->numutxos < maxlen )
|
||||||
{
|
{
|
||||||
tipheight = chainActive.LastTip()->GetHeight();
|
tipheight = chainActive.LastTip()->GetHeight();
|
||||||
@@ -910,6 +922,7 @@ UniValue NSPV_utxosresp_json(struct NSPV_utxosresp *ptr)
|
|||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.push_back(Pair("result","success"));
|
result.push_back(Pair("result","success"));
|
||||||
result.push_back(Pair("utxos",NSPV_utxoresp_json(ptr->utxos,ptr->numutxos)));
|
result.push_back(Pair("utxos",NSPV_utxoresp_json(ptr->utxos,ptr->numutxos)));
|
||||||
|
result.push_back(Pair("address",ptr->coinaddr));
|
||||||
result.push_back(Pair("height",(int64_t)ptr->nodeheight));
|
result.push_back(Pair("height",(int64_t)ptr->nodeheight));
|
||||||
result.push_back(Pair("numutxos",(int64_t)ptr->numutxos));
|
result.push_back(Pair("numutxos",(int64_t)ptr->numutxos));
|
||||||
result.push_back(Pair("balance",(double)ptr->total/COIN));
|
result.push_back(Pair("balance",(double)ptr->total/COIN));
|
||||||
@@ -1218,12 +1231,19 @@ void komodo_nSPV(CNode *pto) // polling loop from SendMessages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 )
|
if ( KOMODO_NSPV != 0 )
|
||||||
{
|
{
|
||||||
len = 0;
|
if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 )
|
||||||
msg[len++] = NSPV_INFO;
|
{
|
||||||
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
|
len = 0;
|
||||||
|
msg[len++] = NSPV_INFO;
|
||||||
|
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue NSPV_send(char *srcaddr,char *destaddr,int64_t satoshis) // what its all about!
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
#endif // KOMODO_NSPV_H
|
#endif // KOMODO_NSPV_H
|
||||||
|
|||||||
@@ -424,6 +424,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "nSPV", "nspv_notarizations", &nspv_notarizations, true },
|
{ "nSPV", "nspv_notarizations", &nspv_notarizations, true },
|
||||||
{ "nSPV", "nspv_hdrsproof", &nspv_hdrsproof, true },
|
{ "nSPV", "nspv_hdrsproof", &nspv_hdrsproof, true },
|
||||||
{ "nSPV", "nspv_txproof", &nspv_txproof, true },
|
{ "nSPV", "nspv_txproof", &nspv_txproof, true },
|
||||||
|
{ "nSPV", "nspv_send", &nspv_send, true },
|
||||||
|
|
||||||
// rewards
|
// rewards
|
||||||
{ "rewards", "rewardslist", &rewardslist, true },
|
{ "rewards", "rewardslist", &rewardslist, true },
|
||||||
|
|||||||
@@ -462,6 +462,7 @@ extern UniValue nspv_spentinfo(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue nspv_notarizations(const UniValue& params, bool fHelp);
|
extern UniValue nspv_notarizations(const UniValue& params, bool fHelp);
|
||||||
extern UniValue nspv_hdrsproof(const UniValue& params, bool fHelp);
|
extern UniValue nspv_hdrsproof(const UniValue& params, bool fHelp);
|
||||||
extern UniValue nspv_txproof(const UniValue& params, bool fHelp);
|
extern UniValue nspv_txproof(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue nspv_send(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern UniValue getblocksubsidy(const UniValue& params, bool fHelp);
|
extern UniValue getblocksubsidy(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
|
|||||||
@@ -975,6 +975,7 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
|
|||||||
UniValue NSPV_getinfo_json();
|
UniValue NSPV_getinfo_json();
|
||||||
UniValue NSPV_login(char *wifstr);
|
UniValue NSPV_login(char *wifstr);
|
||||||
UniValue NSPV_addressutxos(char *coinaddr);
|
UniValue NSPV_addressutxos(char *coinaddr);
|
||||||
|
UniValue NSPV_send(char *srcaddr,char *destaddr,int64_t satoshis);
|
||||||
UniValue NSPV_spentinfo(uint256 txid,int32_t vout);
|
UniValue NSPV_spentinfo(uint256 txid,int32_t vout);
|
||||||
UniValue NSPV_notarizations(int32_t height);
|
UniValue NSPV_notarizations(int32_t height);
|
||||||
UniValue NSPV_hdrsproof(int32_t prevheight,int32_t nextheight);
|
UniValue NSPV_hdrsproof(int32_t prevheight,int32_t nextheight);
|
||||||
@@ -1043,3 +1044,17 @@ UniValue nspv_txproof(const UniValue& params, bool fHelp)
|
|||||||
height = atoi((char *)params[1].get_str().c_str());
|
height = atoi((char *)params[1].get_str().c_str());
|
||||||
return(NSPV_txproof(txid,height));
|
return(NSPV_txproof(txid,height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue nspv_send(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
uint64_t satoshis;
|
||||||
|
if ( fHelp || params.size() != 2 )
|
||||||
|
throw runtime_error("nspv_send destaddr amount\n");
|
||||||
|
if ( NSPV_address.size() == 0 )
|
||||||
|
throw runtime_error("to nspv_send you need an active nspv_login\n");
|
||||||
|
satoshis = atof(params[1].get_str().c_str())*COIN + 0.0000000049;
|
||||||
|
if ( satoshis < 1000 )
|
||||||
|
throw runtime_error("amount too small\n");
|
||||||
|
return(NSPV_send((char *)NSPV_address.c_str(),(char *)params[0].get_str().c_str(),satoshis));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user