CC fixes for nSPV and others (#30)

- Remove adding txfee inputs for gateways claim
- FULLNODE and SUPERLITE macros
- Filter SetCCtxids with txid from oprert
- Fix for nServices of fullnode
- Use SetCCtxids_nSPV for some more CCs
- Fix addnormalinputs and add checking if utxo spent in mempool
This commit is contained in:
Mihailo Milenkovic
2019-08-12 14:16:46 +03:00
committed by GitHub
parent 450ac5c5ea
commit a7204d9f85
24 changed files with 184 additions and 95 deletions

View File

@@ -973,10 +973,17 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
}
extern int32_t KOMODO_NSPV;
#ifndef KOMODO_NSPV_FULLNODE
#define KOMODO_NSPV_FULLNODE (KOMODO_NSPV <= 0)
#endif // !KOMODO_NSPV_FULLNODE
#ifndef KOMODO_NSPV_SUPERLITE
#define KOMODO_NSPV_SUPERLITE (KOMODO_NSPV > 0)
#endif // !KOMODO_NSPV_SUPERLITE
uint256 zeroid;
UniValue NSPV_getinfo_req(int32_t reqht);
UniValue NSPV_login(char *wifstr);
UniValue NSPV_logout();
UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,int32_t filter);
UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,int32_t filter, uint256 filtertxid);
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount,int32_t filter);
UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256 txid,int32_t vout);
UniValue NSPV_broadcast(char *hex);
@@ -993,7 +1000,7 @@ UniValue nspv_getinfo(const UniValue& params, bool fHelp)
int32_t reqht = 0;
if ( fHelp || params.size() > 1 )
throw runtime_error("nspv_getinfo [hdrheight]\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 1 )
reqht = atoi((char *)params[0].get_str().c_str());
@@ -1004,7 +1011,7 @@ UniValue nspv_logout(const UniValue& params, bool fHelp)
{
if ( fHelp || params.size() != 0 )
throw runtime_error("nspv_logout\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_logout());
}
@@ -1013,7 +1020,7 @@ UniValue nspv_login(const UniValue& params, bool fHelp)
{
if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_login wif\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_login((char *)params[0].get_str().c_str()));
}
@@ -1023,7 +1030,7 @@ UniValue nspv_listunspent(const UniValue& params, bool fHelp)
int32_t skipcount = 0,CCflag = 0;
if ( fHelp || params.size() > 3 )
throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 0 )
{
@@ -1048,7 +1055,7 @@ UniValue nspv_mempool(const UniValue& params, bool fHelp)
memset(&txid,0,sizeof(txid));
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");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
funcid = atoi((char *)params[0].get_str().c_str());
coinaddr = (char *)params[1].get_str().c_str();
@@ -1068,12 +1075,12 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
int32_t skipcount = 0,CCflag = 0;
if ( fHelp || params.size() > 3 )
throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 0 )
{
if ( NSPV_address.size() != 0 )
return(NSPV_addresstxids((char *)NSPV_address.c_str(),0,0,0));
return(NSPV_addresstxids((char *)NSPV_address.c_str(),0,0,0,zeroid));
else throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
}
if ( params.size() >= 1 )
@@ -1083,7 +1090,7 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
if ( params.size() == 3 )
skipcount = atoi((char *)params[2].get_str().c_str());
//fprintf(stderr,"call txids cc.%d skip.%d\n",CCflag,skipcount);
return(NSPV_addresstxids((char *)params[0].get_str().c_str(),CCflag,skipcount,0));
return(NSPV_addresstxids((char *)params[0].get_str().c_str(),CCflag,skipcount,0,zeroid));
}
else throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
}
@@ -1093,7 +1100,7 @@ UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
uint256 txid; int32_t vout;
if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_spentinfo txid vout\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
txid = Parseuint256((char *)params[0].get_str().c_str());
vout = atoi((char *)params[1].get_str().c_str());
@@ -1105,7 +1112,7 @@ UniValue nspv_notarizations(const UniValue& params, bool fHelp)
int32_t height;
if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_notarizations height\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
height = atoi((char *)params[0].get_str().c_str());
return(NSPV_notarizations(height));
@@ -1116,7 +1123,7 @@ UniValue nspv_hdrsproof(const UniValue& params, bool fHelp)
int32_t prevheight,nextheight;
if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_hdrsproof prevheight nextheight\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
prevheight = atoi((char *)params[0].get_str().c_str());
nextheight = atoi((char *)params[1].get_str().c_str());
@@ -1128,7 +1135,7 @@ UniValue nspv_txproof(const UniValue& params, bool fHelp)
uint256 txid; int32_t height;
if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_txproof txid height\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
txid = Parseuint256((char *)params[0].get_str().c_str());
height = atoi((char *)params[1].get_str().c_str());
@@ -1140,7 +1147,7 @@ UniValue nspv_spend(const UniValue& params, bool fHelp)
uint64_t satoshis;
if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_spend address amount\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( NSPV_address.size() == 0 )
throw runtime_error("to nspv_send you need an active nspv_login\n");
@@ -1155,7 +1162,7 @@ UniValue nspv_broadcast(const UniValue& params, bool fHelp)
{
if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_broadcast hex\n");
if ( KOMODO_NSPV <= 0 )
if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_broadcast((char *)params[0].get_str().c_str()));
}