@@ -286,7 +286,7 @@ int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp
|
|||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
|
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight);
|
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight);
|
||||||
len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H);
|
len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H);
|
||||||
//fprintf(stderr,"hdr rwlen.%d\n",len);
|
//fprintf(stderr,"hdr rwlen.%d\n",len);
|
||||||
return(len);
|
return(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +305,7 @@ int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *p
|
|||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
|
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
|
||||||
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx);
|
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx);
|
||||||
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof);
|
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof);
|
||||||
|
fprintf(stderr,"len %d\n",len);
|
||||||
return(len);
|
return(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,14 +494,15 @@ int32_t NSPV_fastnotariescount(CTransaction tx,uint8_t elected[64][33],uint32_t
|
|||||||
continue;
|
continue;
|
||||||
char coinaddr[64]; Getscriptaddress(coinaddr,scriptPubKeys[j]);
|
char coinaddr[64]; Getscriptaddress(coinaddr,scriptPubKeys[j]);
|
||||||
NSPV_SignTx(mtx,vini,10000,scriptPubKeys[j],nTime); // sets SIG_TXHASH
|
NSPV_SignTx(mtx,vini,10000,scriptPubKeys[j],nTime); // sets SIG_TXHASH
|
||||||
|
//fprintf(stderr,"%s ",SIG_TXHASH.GetHex().c_str());
|
||||||
if ( (retval= pubkeys[j].Verify(SIG_TXHASH,vData[0])) != 0 )
|
if ( (retval= pubkeys[j].Verify(SIG_TXHASH,vData[0])) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"(vini.%d %s.%d) ",vini,coinaddr,retval);
|
//fprintf(stderr,"(vini.%d %s.%d) ",vini,coinaddr,retval);
|
||||||
mask |= (1LL << j);
|
mask |= (1LL << j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr," verified %llx\n",(long long)mask);
|
//fprintf(stderr," vini.%d verified %llx\n",vini,(long long)mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(bitweight(mask));
|
return(bitweight(mask));
|
||||||
@@ -571,7 +573,7 @@ int32_t NSPV_notarizationextract(int32_t verifyntz,int32_t *ntzheightp,uint256 *
|
|||||||
{
|
{
|
||||||
fprintf(stderr,"numsigs.%d error\n",numsigs);
|
fprintf(stderr,"numsigs.%d error\n",numsigs);
|
||||||
return(-3);
|
return(-3);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#define KOMODO_NSPV_DEFSH
|
#define KOMODO_NSPV_DEFSH
|
||||||
|
|
||||||
#define NSPV_POLLITERS 100
|
#define NSPV_POLLITERS 100
|
||||||
#define NSPV_POLLMICROS 50000
|
#define NSPV_POLLMICROS 10000
|
||||||
#define NSPV_MAXVINS 64
|
#define NSPV_MAXVINS 64
|
||||||
#define NSPV_AUTOLOGOUT 777
|
#define NSPV_AUTOLOGOUT 777
|
||||||
#define NSPV_BRANCHID 0x76b809bb
|
#define NSPV_BRANCHID 0x76b809bb
|
||||||
|
|||||||
@@ -363,7 +363,10 @@ uint8_t *NSPV_getrawtx(CTransaction &tx,uint256 &hashBlock,int32_t *txlenp,uint2
|
|||||||
*txlenp = 0;
|
*txlenp = 0;
|
||||||
{
|
{
|
||||||
if (!GetTransaction(txid, tx, hashBlock, false))
|
if (!GetTransaction(txid, tx, hashBlock, false))
|
||||||
|
{
|
||||||
|
//fprintf(stderr,"error getting transaction %s\n",txid.GetHex().c_str());
|
||||||
return(0);
|
return(0);
|
||||||
|
}
|
||||||
string strHex = EncodeHexTx(tx);
|
string strHex = EncodeHexTx(tx);
|
||||||
*txlenp = (int32_t)strHex.size() >> 1;
|
*txlenp = (int32_t)strHex.size() >> 1;
|
||||||
if ( *txlenp > 0 )
|
if ( *txlenp > 0 )
|
||||||
@@ -405,33 +408,38 @@ int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32
|
|||||||
return(-1);
|
return(-1);
|
||||||
ptr->txid = txid;
|
ptr->txid = txid;
|
||||||
ptr->vout = vout;
|
ptr->vout = vout;
|
||||||
ptr->height = height;
|
if ( height == 0 )
|
||||||
if ( height != 0 && (pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 )
|
ptr->height = komodo_blockheight(hashBlock);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const CTransaction&tx, block.vtx)
|
ptr->height = height;
|
||||||
|
if ((pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 )
|
||||||
{
|
{
|
||||||
if ( tx.GetHash() == txid )
|
BOOST_FOREACH(const CTransaction&tx, block.vtx)
|
||||||
{
|
{
|
||||||
flag = 1;
|
if ( tx.GetHash() == txid )
|
||||||
break;
|
{
|
||||||
|
flag = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if ( flag != 0 )
|
||||||
if ( flag != 0 )
|
|
||||||
{
|
|
||||||
set<uint256> setTxids;
|
|
||||||
CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION);
|
|
||||||
setTxids.insert(txid);
|
|
||||||
CMerkleBlock mb(block, setTxids);
|
|
||||||
ssMB << mb;
|
|
||||||
std::vector<uint8_t> proof(ssMB.begin(), ssMB.end());
|
|
||||||
ptr->txprooflen = (int32_t)proof.size();
|
|
||||||
//fprintf(stderr,"%s txproof.(%s)\n",txid.GetHex().c_str(),HexStr(proof).c_str());
|
|
||||||
if ( ptr->txprooflen > 0 )
|
|
||||||
{
|
{
|
||||||
ptr->txproof = (uint8_t *)calloc(1,ptr->txprooflen);
|
set<uint256> setTxids;
|
||||||
memcpy(ptr->txproof,&proof[0],ptr->txprooflen);
|
CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
|
setTxids.insert(txid);
|
||||||
|
CMerkleBlock mb(block, setTxids);
|
||||||
|
ssMB << mb;
|
||||||
|
std::vector<uint8_t> proof(ssMB.begin(), ssMB.end());
|
||||||
|
ptr->txprooflen = (int32_t)proof.size();
|
||||||
|
//fprintf(stderr,"%s txproof.(%s)\n",txid.GetHex().c_str(),HexStr(proof).c_str());
|
||||||
|
if ( ptr->txprooflen > 0 )
|
||||||
|
{
|
||||||
|
ptr->txproof = (uint8_t *)calloc(1,ptr->txprooflen);
|
||||||
|
memcpy(ptr->txproof,&proof[0],ptr->txprooflen);
|
||||||
|
}
|
||||||
|
//fprintf(stderr,"gettxproof slen.%d\n",(int32_t)(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen));
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"gettxproof slen.%d\n",(int32_t)(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr->unspentvalue = CCgettxout(txid,vout,1,1);
|
ptr->unspentvalue = CCgettxout(txid,vout,1,1);
|
||||||
@@ -529,6 +537,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
|
|||||||
//fprintf(stderr,"slen.%d\n",slen);
|
//fprintf(stderr,"slen.%d\n",slen);
|
||||||
if ( NSPV_rwinforesp(1,&response[1],&I) == slen )
|
if ( NSPV_rwinforesp(1,&response[1],&I) == slen )
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id);
|
||||||
pfrom->PushMessage("nSPV",response);
|
pfrom->PushMessage("nSPV",response);
|
||||||
pfrom->prevtimes[ind] = timestamp;
|
pfrom->prevtimes[ind] = timestamp;
|
||||||
}
|
}
|
||||||
@@ -705,16 +714,18 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
|
|||||||
memset(&P,0,sizeof(P));
|
memset(&P,0,sizeof(P));
|
||||||
if ( (slen= NSPV_gettxproof(&P,vout,txid,height)) > 0 )
|
if ( (slen= NSPV_gettxproof(&P,vout,txid,height)) > 0 )
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr,"slen.%d\n",slen);
|
||||||
response.resize(1 + slen);
|
response.resize(1 + slen);
|
||||||
response[0] = NSPV_TXPROOFRESP;
|
response[0] = NSPV_TXPROOFRESP;
|
||||||
if ( NSPV_rwtxproof(1,&response[1],&P) == slen )
|
if ( NSPV_rwtxproof(1,&response[1],&P) == slen )
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr,"send response\n");
|
||||||
pfrom->PushMessage("nSPV",response);
|
pfrom->PushMessage("nSPV",response);
|
||||||
pfrom->prevtimes[ind] = timestamp;
|
pfrom->prevtimes[ind] = timestamp;
|
||||||
}
|
}
|
||||||
NSPV_txproof_purge(&P);
|
NSPV_txproof_purge(&P);
|
||||||
}
|
} else fprintf(stderr,"gettxproof error.%d\n",slen);
|
||||||
}
|
} else fprintf(stderr,"txproof reqlen.%d\n",len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( request[0] == NSPV_SPENTINFO )
|
else if ( request[0] == NSPV_SPENTINFO )
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ struct NSPV_ntzsresp *NSPV_ntzsresp_add(struct NSPV_ntzsresp *ptr)
|
|||||||
if ( NSPV_ntzsresp_cache[i].reqheight == 0 )
|
if ( NSPV_ntzsresp_cache[i].reqheight == 0 )
|
||||||
break;
|
break;
|
||||||
if ( i == sizeof(NSPV_ntzsresp_cache)/sizeof(*NSPV_ntzsresp_cache) )
|
if ( i == sizeof(NSPV_ntzsresp_cache)/sizeof(*NSPV_ntzsresp_cache) )
|
||||||
i == (rand() % (sizeof(NSPV_ntzsresp_cache)/sizeof(*NSPV_ntzsresp_cache)));
|
i = (rand() % (sizeof(NSPV_ntzsresp_cache)/sizeof(*NSPV_ntzsresp_cache)));
|
||||||
NSPV_ntzsresp_purge(&NSPV_ntzsresp_cache[i]);
|
NSPV_ntzsresp_purge(&NSPV_ntzsresp_cache[i]);
|
||||||
NSPV_ntzsresp_copy(&NSPV_ntzsresp_cache[i],ptr);
|
NSPV_ntzsresp_copy(&NSPV_ntzsresp_cache[i],ptr);
|
||||||
fprintf(stderr,"ADD CACHE ntzsresp req.%d\n",ptr->reqheight);
|
fprintf(stderr,"ADD CACHE ntzsresp req.%d\n",ptr->reqheight);
|
||||||
@@ -98,7 +98,7 @@ struct NSPV_txproof *NSPV_txproof_add(struct NSPV_txproof *ptr)
|
|||||||
if ( NSPV_txproof_cache[i].txlen == 0 )
|
if ( NSPV_txproof_cache[i].txlen == 0 )
|
||||||
break;
|
break;
|
||||||
if ( i == sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache) )
|
if ( i == sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache) )
|
||||||
i == (rand() % (sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache)));
|
i = (rand() % (sizeof(NSPV_txproof_cache)/sizeof(*NSPV_txproof_cache)));
|
||||||
NSPV_txproof_purge(&NSPV_txproof_cache[i]);
|
NSPV_txproof_purge(&NSPV_txproof_cache[i]);
|
||||||
NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr);
|
NSPV_txproof_copy(&NSPV_txproof_cache[i],ptr);
|
||||||
fprintf(stderr,"ADD CACHE txproof %s\n",ptr->txid.GetHex().c_str());
|
fprintf(stderr,"ADD CACHE txproof %s\n",ptr->txid.GetHex().c_str());
|
||||||
@@ -121,7 +121,7 @@ struct NSPV_ntzsproofresp *NSPV_ntzsproof_add(struct NSPV_ntzsproofresp *ptr)
|
|||||||
if ( NSPV_ntzsproofresp_cache[i].common.hdrs == 0 )
|
if ( NSPV_ntzsproofresp_cache[i].common.hdrs == 0 )
|
||||||
break;
|
break;
|
||||||
if ( i == sizeof(NSPV_ntzsproofresp_cache)/sizeof(*NSPV_ntzsproofresp_cache) )
|
if ( i == sizeof(NSPV_ntzsproofresp_cache)/sizeof(*NSPV_ntzsproofresp_cache) )
|
||||||
i == (rand() % (sizeof(NSPV_ntzsproofresp_cache)/sizeof(*NSPV_ntzsproofresp_cache)));
|
i = (rand() % (sizeof(NSPV_ntzsproofresp_cache)/sizeof(*NSPV_ntzsproofresp_cache)));
|
||||||
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresp_cache[i]);
|
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresp_cache[i]);
|
||||||
NSPV_ntzsproofresp_copy(&NSPV_ntzsproofresp_cache[i],ptr);
|
NSPV_ntzsproofresp_copy(&NSPV_ntzsproofresp_cache[i],ptr);
|
||||||
fprintf(stderr,"ADD CACHE ntzsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
fprintf(stderr,"ADD CACHE ntzsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
||||||
@@ -442,7 +442,7 @@ UniValue NSPV_mempoolresp_json(struct NSPV_mempoolresp *ptr)
|
|||||||
UniValue result(UniValue::VOBJ),array(UniValue::VARR); int32_t i;
|
UniValue result(UniValue::VOBJ),array(UniValue::VARR); int32_t i;
|
||||||
result.push_back(Pair("result","success"));
|
result.push_back(Pair("result","success"));
|
||||||
for (i=0; i<ptr->numtxids; i++)
|
for (i=0; i<ptr->numtxids; i++)
|
||||||
array.push_back(Pair("txid",ptr->txids[i].GetHex().c_str()));
|
array.push_back(ptr->txids[i].GetHex().c_str());
|
||||||
result.push_back(Pair("txids",array));
|
result.push_back(Pair("txids",array));
|
||||||
result.push_back(Pair("address",ptr->coinaddr));
|
result.push_back(Pair("address",ptr->coinaddr));
|
||||||
result.push_back(Pair("isCC",ptr->CCflag));
|
result.push_back(Pair("isCC",ptr->CCflag));
|
||||||
@@ -476,7 +476,7 @@ UniValue NSPV_ntzsproof_json(struct NSPV_ntzsproofresp *ptr)
|
|||||||
result.push_back(Pair("prevtxlen",(int64_t)ptr->prevtxlen));
|
result.push_back(Pair("prevtxlen",(int64_t)ptr->prevtxlen));
|
||||||
result.push_back(Pair("nexttxid",ptr->nexttxid.GetHex()));
|
result.push_back(Pair("nexttxid",ptr->nexttxid.GetHex()));
|
||||||
result.push_back(Pair("nexttxidht",(int64_t)ptr->nexttxidht));
|
result.push_back(Pair("nexttxidht",(int64_t)ptr->nexttxidht));
|
||||||
result.push_back(Pair("nexttxlen",(int64_t)ptr->prevtxlen));
|
result.push_back(Pair("nexttxlen",(int64_t)ptr->nexttxlen));
|
||||||
result.push_back(Pair("numhdrs",(int64_t)ptr->common.numhdrs));
|
result.push_back(Pair("numhdrs",(int64_t)ptr->common.numhdrs));
|
||||||
result.push_back(Pair("headers",NSPV_headers_json(ptr->common.hdrs,ptr->common.numhdrs,ptr->common.prevht)));
|
result.push_back(Pair("headers",NSPV_headers_json(ptr->common.hdrs,ptr->common.numhdrs,ptr->common.prevht)));
|
||||||
result.push_back(Pair("lastpeer",NSPV_lastpeer));
|
result.push_back(Pair("lastpeer",NSPV_lastpeer));
|
||||||
@@ -544,11 +544,11 @@ UniValue NSPV_login(char *wifstr)
|
|||||||
|
|
||||||
UniValue NSPV_getinfo_req(int32_t reqht)
|
UniValue NSPV_getinfo_req(int32_t reqht)
|
||||||
{
|
{
|
||||||
uint8_t msg[64]; int32_t i,iter,len = 0; struct NSPV_inforesp I;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_inforesp I;
|
||||||
NSPV_inforesp_purge(&NSPV_inforesult);
|
NSPV_inforesp_purge(&NSPV_inforesult);
|
||||||
msg[len++] = NSPV_INFO;
|
msg[len++] = NSPV_INFO;
|
||||||
len += iguana_rwnum(1,&msg[len],sizeof(reqht),&reqht);
|
len += iguana_rwnum(1,&msg[len],sizeof(reqht),&reqht);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -582,7 +582,7 @@ uint32_t NSPV_blocktime(int32_t hdrheight)
|
|||||||
|
|
||||||
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); uint8_t msg[64]; int32_t i,iter,slen,len = 0;
|
UniValue result(UniValue::VOBJ); uint8_t msg[512]; int32_t i,iter,slen,len = 0;
|
||||||
//fprintf(stderr,"utxos %s NSPV addr %s\n",coinaddr,NSPV_address.c_str());
|
//fprintf(stderr,"utxos %s NSPV addr %s\n",coinaddr,NSPV_address.c_str());
|
||||||
if ( NSPV_utxosresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_utxosresult.coinaddr) == 0 && CCflag == NSPV_utxosresult.CCflag && skipcount == NSPV_utxosresult.skipcount )
|
if ( NSPV_utxosresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_utxosresult.coinaddr) == 0 && CCflag == NSPV_utxosresult.CCflag && skipcount == NSPV_utxosresult.skipcount )
|
||||||
return(NSPV_utxosresp_json(&NSPV_utxosresult));
|
return(NSPV_utxosresp_json(&NSPV_utxosresult));
|
||||||
@@ -601,7 +601,7 @@ UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
|||||||
memcpy(&msg[len],coinaddr,slen), len += slen;
|
memcpy(&msg[len],coinaddr,slen), len += slen;
|
||||||
msg[len++] = (CCflag != 0);
|
msg[len++] = (CCflag != 0);
|
||||||
len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
|
len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -619,7 +619,7 @@ UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
|||||||
|
|
||||||
UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); uint8_t msg[64]; int32_t i,iter,slen,len = 0;
|
UniValue result(UniValue::VOBJ); uint8_t msg[512]; int32_t i,iter,slen,len = 0;
|
||||||
if ( NSPV_txidsresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_txidsresult.coinaddr) == 0 && CCflag == NSPV_txidsresult.CCflag && skipcount == NSPV_txidsresult.skipcount )
|
if ( NSPV_txidsresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_txidsresult.coinaddr) == 0 && CCflag == NSPV_txidsresult.CCflag && skipcount == NSPV_txidsresult.skipcount )
|
||||||
return(NSPV_txidsresp_json(&NSPV_txidsresult));
|
return(NSPV_txidsresp_json(&NSPV_txidsresult));
|
||||||
if ( skipcount < 0 )
|
if ( skipcount < 0 )
|
||||||
@@ -638,7 +638,7 @@ UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
|||||||
msg[len++] = (CCflag != 0);
|
msg[len++] = (CCflag != 0);
|
||||||
len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
|
len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
|
||||||
//fprintf(stderr,"skipcount.%d\n",skipcount);
|
//fprintf(stderr,"skipcount.%d\n",skipcount);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -656,8 +656,11 @@ UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount)
|
|||||||
|
|
||||||
UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256 txid,int32_t vout)
|
UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256 txid,int32_t vout)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); uint8_t msg[512]; int32_t i,iter,slen,len = 0;
|
UniValue result(UniValue::VOBJ); uint8_t msg[512]; char zeroes[64]; int32_t i,iter,slen,len = 0;
|
||||||
NSPV_mempoolresp_purge(&NSPV_mempoolresult);
|
NSPV_mempoolresp_purge(&NSPV_mempoolresult);
|
||||||
|
memset(zeroes,0,sizeof(zeroes));
|
||||||
|
if ( coinaddr == 0 )
|
||||||
|
coinaddr = zeroes;
|
||||||
if ( coinaddr[0] != 0 && bitcoin_base58decode(msg,coinaddr) != 25 )
|
if ( coinaddr[0] != 0 && bitcoin_base58decode(msg,coinaddr) != 25 )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("result","error"));
|
result.push_back(Pair("result","error"));
|
||||||
@@ -673,7 +676,7 @@ UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256
|
|||||||
msg[len++] = slen;
|
msg[len++] = slen;
|
||||||
memcpy(&msg[len],coinaddr,slen), len += slen;
|
memcpy(&msg[len],coinaddr,slen), len += slen;
|
||||||
fprintf(stderr,"(%s) func.%d CC.%d %s/v%d len.%d\n",coinaddr,funcid,CCflag,txid.GetHex().c_str(),vout,len);
|
fprintf(stderr,"(%s) func.%d CC.%d %s/v%d len.%d\n",coinaddr,funcid,CCflag,txid.GetHex().c_str(),vout,len);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -730,7 +733,7 @@ bool NSPV_evalcode_inmempool(uint8_t evalcode,uint8_t funcid)
|
|||||||
|
|
||||||
UniValue NSPV_notarizations(int32_t reqheight)
|
UniValue NSPV_notarizations(int32_t reqheight)
|
||||||
{
|
{
|
||||||
uint8_t msg[64]; int32_t i,iter,len = 0; struct NSPV_ntzsresp N,*ptr;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_ntzsresp N,*ptr;
|
||||||
if ( (ptr= NSPV_ntzsresp_find(reqheight)) != 0 )
|
if ( (ptr= NSPV_ntzsresp_find(reqheight)) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FROM CACHE NSPV_notarizations.%d\n",reqheight);
|
fprintf(stderr,"FROM CACHE NSPV_notarizations.%d\n",reqheight);
|
||||||
@@ -740,7 +743,7 @@ UniValue NSPV_notarizations(int32_t reqheight)
|
|||||||
}
|
}
|
||||||
msg[len++] = NSPV_NTZS;
|
msg[len++] = NSPV_NTZS;
|
||||||
len += iguana_rwnum(1,&msg[len],sizeof(reqheight),&reqheight);
|
len += iguana_rwnum(1,&msg[len],sizeof(reqheight),&reqheight);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -756,7 +759,7 @@ UniValue NSPV_notarizations(int32_t reqheight)
|
|||||||
|
|
||||||
UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
|
UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
|
||||||
{
|
{
|
||||||
uint8_t msg[64]; int32_t i,iter,len = 0; struct NSPV_ntzsproofresp P,*ptr;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_ntzsproofresp P,*ptr;
|
||||||
if ( (ptr= NSPV_ntzsproof_find(prevtxid,nexttxid)) != 0 )
|
if ( (ptr= NSPV_ntzsproof_find(prevtxid,nexttxid)) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FROM CACHE NSPV_txidhdrsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
fprintf(stderr,"FROM CACHE NSPV_txidhdrsproof %s %s\n",ptr->prevtxid.GetHex().c_str(),ptr->nexttxid.GetHex().c_str());
|
||||||
@@ -768,7 +771,7 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
|
|||||||
msg[len++] = NSPV_NTZSPROOF;
|
msg[len++] = NSPV_NTZSPROOF;
|
||||||
len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid);
|
len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid);
|
||||||
len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid);
|
len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -794,7 +797,7 @@ UniValue NSPV_hdrsproof(int32_t prevht,int32_t nextht)
|
|||||||
|
|
||||||
UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
||||||
{
|
{
|
||||||
uint8_t msg[64]; int32_t i,iter,len = 0; struct NSPV_txproof P,*ptr;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_txproof P,*ptr;
|
||||||
if ( (ptr= NSPV_txproof_find(txid)) != 0 )
|
if ( (ptr= NSPV_txproof_find(txid)) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FROM CACHE NSPV_txproof %s\n",txid.GetHex().c_str());
|
fprintf(stderr,"FROM CACHE NSPV_txproof %s\n",txid.GetHex().c_str());
|
||||||
@@ -808,7 +811,7 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
|||||||
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
|
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
|
||||||
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
||||||
fprintf(stderr,"req txproof %s/v%d at height.%d\n",txid.GetHex().c_str(),vout,height);
|
fprintf(stderr,"req txproof %s/v%d at height.%d\n",txid.GetHex().c_str(),vout,height);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -825,12 +828,12 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
|
|||||||
|
|
||||||
UniValue NSPV_spentinfo(uint256 txid,int32_t vout)
|
UniValue NSPV_spentinfo(uint256 txid,int32_t vout)
|
||||||
{
|
{
|
||||||
uint8_t msg[64]; int32_t i,iter,len = 0; struct NSPV_spentinfo I;
|
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_spentinfo I;
|
||||||
NSPV_spentinfo_purge(&NSPV_spentresult);
|
NSPV_spentinfo_purge(&NSPV_spentresult);
|
||||||
msg[len++] = NSPV_SPENTINFO;
|
msg[len++] = NSPV_SPENTINFO;
|
||||||
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
|
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
|
||||||
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_SPENTINDEX,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_SPENTINDEX,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
@@ -859,7 +862,7 @@ UniValue NSPV_broadcast(char *hex)
|
|||||||
memcpy(&msg[len],data,n), len += n;
|
memcpy(&msg[len],data,n), len += n;
|
||||||
free(data);
|
free(data);
|
||||||
//fprintf(stderr,"send txid.%s\n",txid.GetHex().c_str());
|
//fprintf(stderr,"send txid.%s\n",txid.GetHex().c_str());
|
||||||
for (iter=0; iter<3; iter++);
|
for (iter=0; iter<3; iter++)
|
||||||
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<NSPV_POLLITERS; i++)
|
for (i=0; i<NSPV_POLLITERS; i++)
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
|
|||||||
|
|
||||||
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum)
|
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,int64_t extradata,uint32_t tiptime,int64_t &rewardsum)
|
||||||
{
|
{
|
||||||
struct NSPV_txproof *ptr; int32_t i,offset,retval = 0; int64_t rewards = 0; uint32_t nLockTime; std::vector<uint8_t> proof;
|
struct NSPV_txproof *ptr; int32_t i,offset,retval; int64_t rewards = 0; uint32_t nLockTime; std::vector<uint8_t> proof;
|
||||||
|
retval = skipvalidation != 0 ? 0 : -1;
|
||||||
|
|
||||||
//fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height);
|
//fprintf(stderr,"NSPV_gettx %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height);
|
||||||
if ( (ptr= NSPV_txproof_find(txid)) == 0 )
|
if ( (ptr= NSPV_txproof_find(txid)) == 0 )
|
||||||
{
|
{
|
||||||
@@ -78,7 +80,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
retval = -2001;
|
retval = -2001;
|
||||||
else if ( skipvalidation == 0 && ptr->unspentvalue <= 0 )
|
else if ( skipvalidation == 0 && ptr->unspentvalue <= 0 )
|
||||||
retval = -2002;
|
retval = -2002;
|
||||||
else if ( ASSETCHAINS_SYMBOL[0] == 0 && extradata >= 0 && tiptime != 0 )
|
else if ( ASSETCHAINS_SYMBOL[0] == 0 && tiptime != 0 )
|
||||||
{
|
{
|
||||||
rewards = komodo_interestnew(height,tx.vout[vout].nValue,tx.nLockTime,tiptime);
|
rewards = komodo_interestnew(height,tx.vout[vout].nValue,tx.nLockTime,tiptime);
|
||||||
if ( rewards != extradata )
|
if ( rewards != extradata )
|
||||||
@@ -117,11 +119,12 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
{
|
{
|
||||||
std::vector<uint256> txids; uint256 proofroot;
|
std::vector<uint256> txids; uint256 proofroot;
|
||||||
proofroot = BitcoinGetProofMerkleRoot(proof,txids);
|
proofroot = BitcoinGetProofMerkleRoot(proof,txids);
|
||||||
if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot )
|
if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot || txids[0] != txid )
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"txid.%s vs txids[0] %s\n",txid.GetHex().c_str(),txids[0].GetHex().c_str());
|
||||||
fprintf(stderr,"prooflen.%d proofroot.%s vs %s\n",(int32_t)proof.size(),proofroot.GetHex().c_str(),NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot.GetHex().c_str());
|
fprintf(stderr,"prooflen.%d proofroot.%s vs %s\n",(int32_t)proof.size(),proofroot.GetHex().c_str(),NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot.GetHex().c_str());
|
||||||
retval = -2003;
|
retval = -2003;
|
||||||
}
|
} else retval = 0;
|
||||||
}
|
}
|
||||||
} else retval = -2005;
|
} else retval = -2005;
|
||||||
} else retval = -2004;
|
} else retval = -2004;
|
||||||
@@ -242,7 +245,7 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C
|
|||||||
if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 )
|
if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,branchid) != 0 )
|
||||||
{
|
{
|
||||||
UpdateTransaction(mtx,vini,sigdata);
|
UpdateTransaction(mtx,vini,sigdata);
|
||||||
//fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
||||||
return(true);
|
return(true);
|
||||||
} //else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
} //else fprintf(stderr,"sigerr SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
||||||
return(false);
|
return(false);
|
||||||
@@ -321,12 +324,21 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
|
|||||||
len >>= 1;
|
len >>= 1;
|
||||||
data.resize(len);
|
data.resize(len);
|
||||||
decode_hex(&data[0],len,destaddr);
|
decode_hex(&data[0],len,destaddr);
|
||||||
scriptPubKey = CScript() << data << OP_CHECKCRYPTOCONDITION;
|
if ( data[len-1] == OP_CHECKCRYPTOCONDITION )
|
||||||
|
{
|
||||||
|
data.resize(--len);
|
||||||
|
scriptPubKey = CScript() << data << OP_CHECKCRYPTOCONDITION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.push_back(Pair("result","error"));
|
||||||
|
result.push_back(Pair("error","only CC hex allowed for now"));
|
||||||
|
return(result); }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.push_back(Pair("result","error"));
|
result.push_back(Pair("result","error"));
|
||||||
result.push_back(Pair("error","invalid destaddr"));
|
result.push_back(Pair("error","invalid destaddr/CCvout hex"));
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ int32_t getkmdseason(int32_t height)
|
|||||||
return(i+1);
|
return(i+1);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
};
|
}
|
||||||
|
|
||||||
int32_t getacseason(uint32_t timestamp)
|
int32_t getacseason(uint32_t timestamp)
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ int32_t getacseason(uint32_t timestamp)
|
|||||||
return(i+1);
|
return(i+1);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
};
|
}
|
||||||
|
|
||||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
|
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7091,7 +7091,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
||||||
//if ( KOMODO_NSPV != 0 )
|
//if ( KOMODO_NSPV != 0 )
|
||||||
//if ( strCommand != "version" && strCommand != "verack" )
|
//if ( strCommand != "version" && strCommand != "verack" )
|
||||||
// fprintf(stderr, "recv: %s peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)pfrom->GetId());
|
// fprintf(stderr, "recv: %s (%u bytes) peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)vRecv.size(), (int32_t)pfrom->GetId());
|
||||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||||
{
|
{
|
||||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||||
@@ -7287,7 +7287,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[
|
else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[
|
||||||
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion)
|
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion)
|
||||||
{
|
{
|
||||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
LogPrintf("peer=%d using obsolete version %i vs %d; disconnecting\n", pfrom->id, pfrom->nVersion,(int32_t)chainparams.GetConsensus().vUpgrades[
|
||||||
|
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion);
|
||||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
||||||
strprintf("Version must be %d or greater",
|
strprintf("Version must be %d or greater",
|
||||||
chainparams.GetConsensus().vUpgrades[
|
chainparams.GetConsensus().vUpgrades[
|
||||||
|
|||||||
@@ -972,6 +972,7 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
|
|||||||
return EncodeViewingKey(vk);
|
return EncodeViewingKey(vk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int32_t KOMODO_NSPV;
|
||||||
UniValue NSPV_getinfo_req(int32_t reqht);
|
UniValue NSPV_getinfo_req(int32_t reqht);
|
||||||
UniValue NSPV_login(char *wifstr);
|
UniValue NSPV_login(char *wifstr);
|
||||||
UniValue NSPV_logout();
|
UniValue NSPV_logout();
|
||||||
@@ -992,6 +993,8 @@ UniValue nspv_getinfo(const UniValue& params, bool fHelp)
|
|||||||
int32_t reqht = 0;
|
int32_t reqht = 0;
|
||||||
if ( fHelp || params.size() > 1 )
|
if ( fHelp || params.size() > 1 )
|
||||||
throw runtime_error("nspv_getinfo [hdrheight]\n");
|
throw runtime_error("nspv_getinfo [hdrheight]\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
if ( params.size() == 1 )
|
if ( params.size() == 1 )
|
||||||
reqht = atoi((char *)params[0].get_str().c_str());
|
reqht = atoi((char *)params[0].get_str().c_str());
|
||||||
return(NSPV_getinfo_req(reqht));
|
return(NSPV_getinfo_req(reqht));
|
||||||
@@ -1001,6 +1004,8 @@ UniValue nspv_logout(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
if ( fHelp || params.size() != 0 )
|
if ( fHelp || params.size() != 0 )
|
||||||
throw runtime_error("nspv_logout\n");
|
throw runtime_error("nspv_logout\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
return(NSPV_logout());
|
return(NSPV_logout());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1008,6 +1013,8 @@ UniValue nspv_login(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
if ( fHelp || params.size() != 1 )
|
if ( fHelp || params.size() != 1 )
|
||||||
throw runtime_error("nspv_login wif\n");
|
throw runtime_error("nspv_login wif\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
return(NSPV_login((char *)params[0].get_str().c_str()));
|
return(NSPV_login((char *)params[0].get_str().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1016,6 +1023,8 @@ UniValue nspv_listunspent(const UniValue& params, bool fHelp)
|
|||||||
int32_t skipcount = 0,CCflag = 0;
|
int32_t skipcount = 0,CCflag = 0;
|
||||||
if ( fHelp || params.size() > 3 )
|
if ( fHelp || params.size() > 3 )
|
||||||
throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n");
|
throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
if ( params.size() == 0 )
|
if ( params.size() == 0 )
|
||||||
{
|
{
|
||||||
if ( NSPV_address.size() != 0 )
|
if ( NSPV_address.size() != 0 )
|
||||||
@@ -1039,6 +1048,8 @@ UniValue nspv_mempool(const UniValue& params, bool fHelp)
|
|||||||
memset(&txid,0,sizeof(txid));
|
memset(&txid,0,sizeof(txid));
|
||||||
if ( fHelp || params.size() > 5 )
|
if ( fHelp || params.size() > 5 )
|
||||||
throw runtime_error("nspv_mempool func(0 all, 1 address recv, 2 txid/vout spent, 3 txid inmempool) address isCC [txid vout]]]\n");
|
throw runtime_error("nspv_mempool func(0 all, 1 address recv, 2 txid/vout spent, 3 txid inmempool) address isCC [txid vout]]]\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
funcid = atoi((char *)params[0].get_str().c_str());
|
funcid = atoi((char *)params[0].get_str().c_str());
|
||||||
coinaddr = (char *)params[1].get_str().c_str();
|
coinaddr = (char *)params[1].get_str().c_str();
|
||||||
CCflag = atoi((char *)params[2].get_str().c_str());
|
CCflag = atoi((char *)params[2].get_str().c_str());
|
||||||
@@ -1057,6 +1068,8 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
|
|||||||
int32_t skipcount = 0,CCflag = 0;
|
int32_t skipcount = 0,CCflag = 0;
|
||||||
if ( fHelp || params.size() > 3 )
|
if ( fHelp || params.size() > 3 )
|
||||||
throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
|
throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
if ( params.size() == 0 )
|
if ( params.size() == 0 )
|
||||||
{
|
{
|
||||||
if ( NSPV_address.size() != 0 )
|
if ( NSPV_address.size() != 0 )
|
||||||
@@ -1080,6 +1093,8 @@ UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
|
|||||||
uint256 txid; int32_t vout;
|
uint256 txid; int32_t vout;
|
||||||
if ( fHelp || params.size() != 2 )
|
if ( fHelp || params.size() != 2 )
|
||||||
throw runtime_error("nspv_spentinfo txid vout\n");
|
throw runtime_error("nspv_spentinfo txid vout\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
txid = Parseuint256((char *)params[0].get_str().c_str());
|
txid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
vout = atoi((char *)params[1].get_str().c_str());
|
vout = atoi((char *)params[1].get_str().c_str());
|
||||||
return(NSPV_spentinfo(txid,vout));
|
return(NSPV_spentinfo(txid,vout));
|
||||||
@@ -1090,6 +1105,8 @@ UniValue nspv_notarizations(const UniValue& params, bool fHelp)
|
|||||||
int32_t height;
|
int32_t height;
|
||||||
if ( fHelp || params.size() != 1 )
|
if ( fHelp || params.size() != 1 )
|
||||||
throw runtime_error("nspv_notarizations height\n");
|
throw runtime_error("nspv_notarizations height\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
height = atoi((char *)params[0].get_str().c_str());
|
height = atoi((char *)params[0].get_str().c_str());
|
||||||
return(NSPV_notarizations(height));
|
return(NSPV_notarizations(height));
|
||||||
}
|
}
|
||||||
@@ -1099,6 +1116,8 @@ UniValue nspv_hdrsproof(const UniValue& params, bool fHelp)
|
|||||||
int32_t prevheight,nextheight;
|
int32_t prevheight,nextheight;
|
||||||
if ( fHelp || params.size() != 2 )
|
if ( fHelp || params.size() != 2 )
|
||||||
throw runtime_error("nspv_hdrsproof prevheight nextheight\n");
|
throw runtime_error("nspv_hdrsproof prevheight nextheight\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
prevheight = atoi((char *)params[0].get_str().c_str());
|
prevheight = atoi((char *)params[0].get_str().c_str());
|
||||||
nextheight = atoi((char *)params[1].get_str().c_str());
|
nextheight = atoi((char *)params[1].get_str().c_str());
|
||||||
return(NSPV_hdrsproof(prevheight,nextheight));
|
return(NSPV_hdrsproof(prevheight,nextheight));
|
||||||
@@ -1109,6 +1128,8 @@ UniValue nspv_txproof(const UniValue& params, bool fHelp)
|
|||||||
uint256 txid; int32_t height;
|
uint256 txid; int32_t height;
|
||||||
if ( fHelp || params.size() != 2 )
|
if ( fHelp || params.size() != 2 )
|
||||||
throw runtime_error("nspv_txproof txid height\n");
|
throw runtime_error("nspv_txproof txid height\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
txid = Parseuint256((char *)params[0].get_str().c_str());
|
txid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
height = atoi((char *)params[1].get_str().c_str());
|
height = atoi((char *)params[1].get_str().c_str());
|
||||||
return(NSPV_txproof(0,txid,height));
|
return(NSPV_txproof(0,txid,height));
|
||||||
@@ -1118,7 +1139,9 @@ UniValue nspv_spend(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
uint64_t satoshis;
|
uint64_t satoshis;
|
||||||
if ( fHelp || params.size() != 2 )
|
if ( fHelp || params.size() != 2 )
|
||||||
throw runtime_error("nspv_spend destaddr amount\n");
|
throw runtime_error("nspv_spend address amount\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
if ( NSPV_address.size() == 0 )
|
if ( NSPV_address.size() == 0 )
|
||||||
throw runtime_error("to nspv_send you need an active nspv_login\n");
|
throw runtime_error("to nspv_send you need an active nspv_login\n");
|
||||||
satoshis = atof(params[1].get_str().c_str())*COIN + 0.0000000049;
|
satoshis = atof(params[1].get_str().c_str())*COIN + 0.0000000049;
|
||||||
@@ -1132,5 +1155,7 @@ UniValue nspv_broadcast(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
if ( fHelp || params.size() != 1 )
|
if ( fHelp || params.size() != 1 )
|
||||||
throw runtime_error("nspv_broadcast hex\n");
|
throw runtime_error("nspv_broadcast hex\n");
|
||||||
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||||
return(NSPV_broadcast((char *)params[0].get_str().c_str()));
|
return(NSPV_broadcast((char *)params[0].get_str().c_str()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user