@@ -2051,7 +2051,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
|
||||
total += txout.nValue;
|
||||
//fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]);
|
||||
}
|
||||
else fprintf(stderr, "NOT MATCHED AmountPaid.%lu AmountToPay.%lu notaryid.%i\n", pblock->vtx[0].vout[n].nValue, AmountToPay, NotarisationNotaries[n-1]);
|
||||
else fprintf(stderr, "NOT MATCHED AmountPaid.%llu AmountToPay.%llu notaryid.%i\n", (long long)pblock->vtx[0].vout[n].nValue, (long long)AmountToPay, NotarisationNotaries[n-1]);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
@@ -2347,7 +2347,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
numSN = komodo_notaries(notarypubkeys, height, pblock->nTime);
|
||||
if ( pblock->vtx[1].vin.size() < numSN/5 )
|
||||
{
|
||||
fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%li\n",height,numSN/5,pblock->vtx[1].vin.size());
|
||||
fprintf(stderr, "ht.%i does not meet minsigs.%i sigs.%lld\n",height,numSN/5,(long long)pblock->vtx[1].vin.size());
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max)
|
||||
int32_t i;
|
||||
if ( sizeof(banned_txids)/sizeof(*banned_txids) > max )
|
||||
{
|
||||
fprintf(stderr,"komodo_bannedset: buffer too small %ld vs %d\n",sizeof(banned_txids)/sizeof(*banned_txids),max);
|
||||
fprintf(stderr,"komodo_bannedset: buffer too small %d vs %d\n",(int32_t)(sizeof(banned_txids)/sizeof(*banned_txids)),max);
|
||||
StartShutdown();
|
||||
}
|
||||
for (i=0; i<sizeof(banned_txids)/sizeof(*banned_txids); i++)
|
||||
@@ -1289,7 +1289,7 @@ long komodo_stateind_validate(struct komodo_state *sp,char *indfname,uint8_t *fi
|
||||
if ( (inds= OS_fileptr(&fsize,indfname)) != 0 )
|
||||
{
|
||||
lastfpos = 0;
|
||||
fprintf(stderr,"inds.%p validate %s fsize.%ld datalen.%ld n.%ld lastfpos.%ld\n",inds,indfname,fsize,datalen,fsize / sizeof(uint32_t),lastfpos);
|
||||
fprintf(stderr,"inds.%p validate %s fsize.%ld datalen.%ld n.%d lastfpos.%ld\n",inds,indfname,fsize,datalen,(int32_t)(fsize / sizeof(uint32_t)),lastfpos);
|
||||
if ( (fsize % sizeof(uint32_t)) == 0 )
|
||||
{
|
||||
n = (int32_t)(fsize / sizeof(uint32_t));
|
||||
@@ -1380,7 +1380,7 @@ int32_t komodo_faststateinit(struct komodo_state *sp,char *fname,char *symbol,ch
|
||||
if ( (indfp= fopen(indfname,"rb+")) != 0 )
|
||||
{
|
||||
lastfpos = fpos = validated;
|
||||
fprintf(stderr,"datalen.%ld validated %ld -> indcounter %u, prevpos100 %u offset.%ld\n",datalen,validated,indcounter,prevpos100,indcounter * sizeof(uint32_t));
|
||||
fprintf(stderr,"datalen.%ld validated %ld -> indcounter %u, prevpos100 %u offset.%d\n",datalen,validated,indcounter,prevpos100,(int32_t)(indcounter * sizeof(uint32_t)));
|
||||
if ( fpos < datalen )
|
||||
{
|
||||
fseek(indfp,indcounter * sizeof(uint32_t),SEEK_SET);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
// interest calculations are currently just using what is returned, it should calculate it from scratch
|
||||
|
||||
// bruteforce sig -> NN pubkey validator
|
||||
// CC signing
|
||||
// make sure to sanity check all vector lengths on receipt
|
||||
// make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database)
|
||||
@@ -28,7 +27,6 @@
|
||||
#ifndef KOMODO_NSPV_H
|
||||
#define KOMODO_NSPV_H
|
||||
|
||||
#define NSPV_SKIPFULLVALIDATION 1 // changing to 0 issues 26 remote gettransaction, per utxo! need to change to bruteforcer
|
||||
#define NSPV_POLLITERS 10
|
||||
#define NSPV_POLLMICROS 100777
|
||||
#define NSPV_MAXVINS 64
|
||||
@@ -53,6 +51,8 @@
|
||||
#define NSPV_BROADCASTRESP 0x0d
|
||||
|
||||
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx);
|
||||
extern uint256 SIG_TXHASH;
|
||||
uint32_t NSPV_blocktime(int32_t hdrheight);
|
||||
|
||||
int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,uint16_t len,uint8_t *buf)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ struct NSPV_utxosresp
|
||||
char coinaddr[64];
|
||||
int64_t total,interest;
|
||||
int32_t nodeheight;
|
||||
uint16_t numutxos,pad16;
|
||||
uint16_t numutxos; uint8_t CCflag,pad8;
|
||||
};
|
||||
|
||||
int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosresp *ptr) // check mempool
|
||||
@@ -157,7 +157,8 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->total),&ptr->total);
|
||||
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->pad16),&ptr->pad16);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad8),&ptr->pad8);
|
||||
if ( rwflag != 0 )
|
||||
{
|
||||
memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr));
|
||||
@@ -421,6 +422,45 @@ int32_t NSPV_txextract(CTransaction &tx,uint8_t *data,int32_t datalen)
|
||||
else return(-1);
|
||||
}
|
||||
|
||||
bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey);
|
||||
|
||||
int32_t NSPV_fastnotariescount(CTransaction tx,uint8_t elected[64][33])
|
||||
{
|
||||
CPubKey pubkeys[64]; uint8_t sig[512]; CScript scriptPubKeys[64]; CMutableTransaction mtx(tx); int32_t vini,j,siglen,retval; uint64_t mask = 0; char *str; std::vector<std::vector<unsigned char>> vData;
|
||||
for (j=0; j<64; j++)
|
||||
{
|
||||
pubkeys[j] = buf2pk(elected[j]);
|
||||
scriptPubKeys[j] = (CScript() << ParseHex(HexStr(pubkeys[j])) << OP_CHECKSIG);
|
||||
//fprintf(stderr,"%d %s\n",j,HexStr(pubkeys[j]).c_str());
|
||||
}
|
||||
fprintf(stderr,"txid %s\n",tx.GetHash().GetHex().c_str());
|
||||
//for (vini=0; vini<tx.vin.size(); vini++)
|
||||
// mtx.vin[vini].scriptSig.resize(0);
|
||||
for (vini=0; vini<tx.vin.size(); vini++)
|
||||
{
|
||||
CScript::const_iterator pc = tx.vin[vini].scriptSig.begin();
|
||||
if ( tx.vin[vini].scriptSig.GetPushedData(pc,vData) != 0 )
|
||||
{
|
||||
vData[0].pop_back();
|
||||
for (j=0; j<64; j++)
|
||||
{
|
||||
if ( ((1LL << j) & mask) != 0 )
|
||||
continue;
|
||||
char coinaddr[64]; Getscriptaddress(coinaddr,scriptPubKeys[j]);
|
||||
NSPV_SignTx(mtx,vini,10000,scriptPubKeys[j]); // sets SIG_TXHASH
|
||||
if ( (retval= pubkeys[j].Verify(SIG_TXHASH,vData[0])) != 0 )
|
||||
{
|
||||
fprintf(stderr,"(vini.%d %s.%d) ",vini,coinaddr,retval);
|
||||
mask |= (1LL << j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf(stderr," verified %llx\n",(long long)mask);
|
||||
}
|
||||
}
|
||||
return(bitweight(mask));
|
||||
}
|
||||
|
||||
/*
|
||||
NSPV_notariescount is the slowest process during full validation as it requires looking up 13 transactions.
|
||||
one way that would be 10000x faster would be to bruteforce validate the signatures in each vin, against all 64 pubkeys! for a valid tx, that is on average 13*32 secp256k1/sapling verify operations, which is much faster than even a single network request.
|
||||
@@ -428,7 +468,6 @@ int32_t NSPV_txextract(CTransaction &tx,uint8_t *data,int32_t datalen)
|
||||
It could be that the fullnode side could calculate this and send it back to the superlite side as any hash that would validate 13 different ways has to be the valid txhash.
|
||||
However, since the vouts being spent by the notaries are highly constrained p2pk vouts, the txhash can be deduced if a specific notary pubkey is indeed the signer
|
||||
*/
|
||||
|
||||
int32_t NSPV_notariescount(CTransaction tx,uint8_t elected[64][33])
|
||||
{
|
||||
uint8_t *script; CTransaction vintx; int32_t i,j,utxovout,scriptlen,numsigs = 0;
|
||||
@@ -479,9 +518,10 @@ int32_t NSPV_notarizationextract(int32_t verifyntz,int32_t *ntzheightp,uint256 *
|
||||
GetOpReturnData(tx.vout[1].scriptPubKey,opret);
|
||||
if ( opret.size() >= 32*2+4 )
|
||||
{
|
||||
sleep(1);
|
||||
*desttxidp = NSPV_opretextract(ntzheightp,blockhashp,symbol,opret,tx.GetHash());
|
||||
komodo_notaries(elected,*ntzheightp,0);
|
||||
if ( verifyntz != 0 && (numsigs= NSPV_notariescount(tx,elected)) < 12 )
|
||||
komodo_notaries(elected,*ntzheightp,NSPV_blocktime(*ntzheightp));
|
||||
if ( verifyntz != 0 && (numsigs= NSPV_fastnotariescount(tx,elected)) < 12 )
|
||||
{
|
||||
fprintf(stderr,"numsigs.%d error\n",numsigs);
|
||||
return(-3);
|
||||
|
||||
@@ -137,14 +137,15 @@ int32_t NSPV_getinfo(struct NSPV_inforesp *ptr,int32_t reqheight)
|
||||
} else return(-1);
|
||||
}
|
||||
|
||||
int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr) // check mempool
|
||||
int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr,bool isCC) // check mempool
|
||||
{
|
||||
int64_t total = 0,interest=0; uint32_t locktime; int32_t tipheight,maxlen,txheight,n = 0,len = 0;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
SetCCunspents(unspentOutputs,coinaddr,false);
|
||||
SetCCunspents(unspentOutputs,coinaddr,isCC);
|
||||
maxlen = MAX_BLOCK_SIZE(tipheight) - 512;
|
||||
maxlen /= sizeof(*ptr->utxos);
|
||||
strncpy(ptr->coinaddr,coinaddr,sizeof(ptr->coinaddr)-1);
|
||||
ptr->CCflag = isCC;
|
||||
if ( (ptr->numutxos= (int32_t)unspentOutputs.size()) >= 0 && ptr->numutxos < maxlen )
|
||||
{
|
||||
tipheight = chainActive.LastTip()->GetHeight();
|
||||
@@ -362,12 +363,17 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
|
||||
if ( timestamp > pfrom->prevtimes[ind] )
|
||||
{
|
||||
struct NSPV_utxosresp U; char coinaddr[64];
|
||||
if ( len < 64 && request[1] == len-2 )
|
||||
if ( len < 64 && (request[1] == len-2 || request[1] == len-3) )
|
||||
{
|
||||
uint8_t isCC = 0;
|
||||
memcpy(coinaddr,&request[2],request[1]);
|
||||
coinaddr[request[1]] = 0;
|
||||
if ( request[1] == len-3 )
|
||||
isCC = (request[len-1] != 0);
|
||||
if ( isCC != 0 )
|
||||
fprintf(stderr,"%s isCC.%d\n",coinaddr,isCC);
|
||||
memset(&U,0,sizeof(U));
|
||||
if ( (slen= NSPV_getaddressutxos(&U,coinaddr)) > 0 )
|
||||
if ( (slen= NSPV_getaddressutxos(&U,coinaddr,isCC)) > 0 )
|
||||
{
|
||||
response.resize(1 + slen);
|
||||
response[0] = NSPV_UTXOSRESP;
|
||||
|
||||
@@ -276,6 +276,7 @@ UniValue NSPV_utxosresp_json(struct NSPV_utxosresp *ptr)
|
||||
result.push_back(Pair("result","success"));
|
||||
result.push_back(Pair("utxos",NSPV_utxoresp_json(ptr->utxos,ptr->numutxos)));
|
||||
result.push_back(Pair("address",ptr->coinaddr));
|
||||
result.push_back(Pair("isCC",ptr->CCflag));
|
||||
result.push_back(Pair("height",(int64_t)ptr->nodeheight));
|
||||
result.push_back(Pair("numutxos",(int64_t)ptr->numutxos));
|
||||
result.push_back(Pair("balance",(double)ptr->total/COIN));
|
||||
@@ -385,7 +386,21 @@ UniValue NSPV_getinfo_req(int32_t reqht)
|
||||
return(NSPV_getinfo_json(&NSPV_inforesult));
|
||||
}
|
||||
|
||||
UniValue NSPV_addressutxos(char *coinaddr)
|
||||
uint32_t NSPV_blocktime(int32_t hdrheight)
|
||||
{
|
||||
if ( hdrheight > 0 )
|
||||
{
|
||||
NSPV_getinfo_req(hdrheight);
|
||||
if ( NSPV_inforesult.hdrheight == hdrheight )
|
||||
{
|
||||
fprintf(stderr,"NSPV_blocktime ht.%d -> t%u\n",hdrheight,NSPV_inforesult.H.nTime);
|
||||
return(NSPV_inforesult.H.nTime);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); uint8_t msg[64]; int32_t i,iter,slen,len = 0;
|
||||
//fprintf(stderr,"utxos %s NSPV addr %s\n",coinaddr,NSPV_address.c_str());
|
||||
@@ -400,14 +415,14 @@ UniValue NSPV_addressutxos(char *coinaddr)
|
||||
msg[len++] = NSPV_UTXOS;
|
||||
msg[len++] = slen;
|
||||
memcpy(&msg[len],coinaddr,slen), len += slen;
|
||||
msg[len] = 0;
|
||||
msg[len++] = (CCflag != 0);
|
||||
for (iter=0; iter<3; iter++);
|
||||
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
|
||||
{
|
||||
for (i=0; i<NSPV_POLLITERS; i++)
|
||||
{
|
||||
usleep(NSPV_POLLMICROS);
|
||||
if ( NSPV_utxosresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_utxosresult.coinaddr) == 0 )
|
||||
if ( NSPV_utxosresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_utxosresult.coinaddr) == 0 && CCflag == NSPV_utxosresult.CCflag )
|
||||
return(NSPV_utxosresp_json(&NSPV_utxosresult));
|
||||
}
|
||||
} else sleep(1);
|
||||
|
||||
@@ -135,8 +135,9 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C
|
||||
if ( ProduceSignature(TransactionSignatureCreator(&keystore,&txNewConst,vini,utxovalue,SIGHASH_ALL),scriptPubKey,sigdata,NSPV_BRANCHID) != 0 )
|
||||
{
|
||||
UpdateTransaction(mtx,vini,sigdata);
|
||||
// fprintf(stderr,"SIG_TXHASH %s vini.%d %.8f\n",SIG_TXHASH.GetHex().c_str(),vini,(double)utxovalue/COIN);
|
||||
return(true);
|
||||
} // else fprintf(stderr,"signing error for SignTx vini.%d %.8f\n",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);
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ std::string NSPV_signtx(UniValue &retcodes,CMutableTransaction &mtx,uint64_t txf
|
||||
utxovout = mtx.vin[i].prevout.n;
|
||||
if ( i > 0 )
|
||||
sleep(1);
|
||||
validation = NSPV_gettransaction(NSPV_SKIPFULLVALIDATION,utxovout,mtx.vin[i].prevout.hash,used[i].height,vintx);
|
||||
validation = NSPV_gettransaction(0,utxovout,mtx.vin[i].prevout.hash,used[i].height,vintx);
|
||||
retcodes.push_back(validation);
|
||||
if ( validation != -1 ) // most others are degraded security
|
||||
{
|
||||
@@ -217,9 +218,9 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a
|
||||
result.push_back(Pair("error","couldnt getinfo"));
|
||||
return(result);
|
||||
}
|
||||
if ( strcmp(NSPV_utxosresult.coinaddr,srcaddr) != 0 || NSPV_utxosresult.nodeheight < NSPV_inforesult.height )
|
||||
NSPV_addressutxos(srcaddr);
|
||||
if ( strcmp(NSPV_utxosresult.coinaddr,srcaddr) != 0 || NSPV_utxosresult.nodeheight < NSPV_inforesult.height )
|
||||
if ( NSPV_utxosresult.CCflag != 0 || strcmp(NSPV_utxosresult.coinaddr,srcaddr) != 0 || NSPV_utxosresult.nodeheight < NSPV_inforesult.height )
|
||||
NSPV_addressutxos(srcaddr,0);
|
||||
if ( NSPV_utxosresult.CCflag != 0 || strcmp(NSPV_utxosresult.coinaddr,srcaddr) != 0 || NSPV_utxosresult.nodeheight < NSPV_inforesult.height )
|
||||
{
|
||||
result.push_back(Pair("result","error"));
|
||||
result.push_back(Pair("address",NSPV_utxosresult.coinaddr));
|
||||
|
||||
@@ -2125,7 +2125,7 @@ void komodo_args(char *argv0)
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS);
|
||||
if ( ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
||||
{
|
||||
fprintf(stderr, "set founders reward.%li\n",ASSETCHAINS_FOUNDERS_REWARD);
|
||||
fprintf(stderr, "set founders reward.%lld\n",(long long)ASSETCHAINS_FOUNDERS_REWARD);
|
||||
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD);
|
||||
}
|
||||
}
|
||||
@@ -2348,7 +2348,7 @@ void komodo_args(char *argv0)
|
||||
if ( strcmp("PIRATE",ASSETCHAINS_SYMBOL) == 0 && ASSETCHAINS_HALVING[0] == 77777 )
|
||||
{
|
||||
ASSETCHAINS_HALVING[0] *= 5;
|
||||
fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%lu\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,ASSETCHAINS_LASTERA);
|
||||
fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%llu\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,(long long)ASSETCHAINS_LASTERA);
|
||||
}
|
||||
else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 )
|
||||
dpowconfs = 0;
|
||||
|
||||
@@ -762,7 +762,7 @@ bool komodo_dailysnapshot(int32_t height)
|
||||
// include only top 3999 address.
|
||||
if ( vAddressSnapshot.size() > 3999 ) vAddressSnapshot.resize(3999);
|
||||
lastSnapShotHeight = undo_height;
|
||||
fprintf(stderr, "vAddressSnapshot.size.%li\n", vAddressSnapshot.size());
|
||||
fprintf(stderr, "vAddressSnapshot.size.%d\n", (int32_t)vAddressSnapshot.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4322,7 +4322,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
||||
fprintf(stderr, "daily snapshot failed, please reindex your chain\n");
|
||||
StartShutdown();
|
||||
}
|
||||
fprintf(stderr, "snapshot completed in: %lu seconds\n", time(NULL)-start);
|
||||
fprintf(stderr, "snapshot completed in: %d seconds\n", (int32_t)(time(NULL)-start));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -35,24 +35,24 @@ using namespace std;
|
||||
|
||||
typedef vector<unsigned char> valtype;
|
||||
extern uint8_t ASSETCHAINS_TXPOW;
|
||||
uint256 SIG_TXHASH;
|
||||
|
||||
TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
|
||||
|
||||
bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& address, const CScript& scriptCode, uint32_t consensusBranchId, CKey *pprivKey, void *extraData) const
|
||||
{
|
||||
CKey key;
|
||||
if (pprivKey)
|
||||
key = *pprivKey;
|
||||
else if (!keystore || !keystore->GetKey(address, key))
|
||||
return false;
|
||||
|
||||
uint256 hash;
|
||||
CKey key; uint256 hash;
|
||||
try {
|
||||
hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, consensusBranchId);
|
||||
} catch (logic_error ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SIG_TXHASH = hash;
|
||||
if (pprivKey)
|
||||
key = *pprivKey;
|
||||
else if (!keystore || !keystore->GetKey(address, key))
|
||||
return false;
|
||||
|
||||
if (scriptCode.IsPayToCryptoCondition())
|
||||
{
|
||||
CC *cc = (CC *)extraData;
|
||||
|
||||
@@ -975,7 +975,7 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
|
||||
UniValue NSPV_getinfo_req(int32_t reqht);
|
||||
UniValue NSPV_login(char *wifstr);
|
||||
UniValue NSPV_logout();
|
||||
UniValue NSPV_addressutxos(char *coinaddr);
|
||||
UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag);
|
||||
UniValue NSPV_broadcast(char *hex);
|
||||
UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis);
|
||||
UniValue NSPV_spentinfo(uint256 txid,int32_t vout);
|
||||
@@ -1011,17 +1011,22 @@ UniValue nspv_login(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue nspv_listunspent(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if ( fHelp || params.size() > 1 )
|
||||
throw runtime_error("nspv_listunspent address\n");
|
||||
int32_t CCflag = 0;
|
||||
if ( fHelp || params.size() > 2 )
|
||||
throw runtime_error("nspv_listunspent address [isCC]\n");
|
||||
if ( params.size() == 0 )
|
||||
{
|
||||
if ( NSPV_address.size() != 0 )
|
||||
return(NSPV_addressutxos((char *)NSPV_address.c_str()));
|
||||
else throw runtime_error("nspv_listunspent address\n");
|
||||
return(NSPV_addressutxos((char *)NSPV_address.c_str(),0));
|
||||
else throw runtime_error("nspv_listunspent address [isCC]\n");
|
||||
}
|
||||
if ( params.size() == 1 )
|
||||
return(NSPV_addressutxos((char *)params[0].get_str().c_str()));
|
||||
else throw runtime_error("nspv_listunspent address\n");
|
||||
if ( params.size() >= 1 )
|
||||
{
|
||||
if ( params.size() == 2 )
|
||||
CCflag = atoi((char *)params[1].get_str().c_str());
|
||||
return(NSPV_addressutxos((char *)params[0].get_str().c_str(),CCflag));
|
||||
}
|
||||
else throw runtime_error("nspv_listunspent address [isCC]\n");
|
||||
}
|
||||
|
||||
UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
|
||||
|
||||
Reference in New Issue
Block a user