Compare commits

...

45 Commits

Author SHA1 Message Date
Jonathan "Duke" Leto 864cfa7a54 Add dpowconfs to listreceivedbyaddress and z_listreceivedbyaddress 5 years ago
Jonathan "Duke" Leto 33a456ce02 Give example/recommended nodes to add 5 years ago
Jonathan "Duke" Leto 257f419ba0 Fix doc typo 6 years ago
Jonathan "Duke" Leto b5ec988021 Rationalize currency unit to HUSH, which is used to generate RPC documentation 6 years ago
Duke Leto fcd07fa9b4
Merge pull request #152 from MyHush/dpowconfs 6 years ago
Duke Leto 6ce55a0ae0
Merge pull request #154 from MyHush/getsnapshot 6 years ago
Jonathan "Duke" Leto 8312618647 Fix compile issues 6 years ago
Jonathan "Duke" Leto 94d8710140 Port getsnapshot from KMD to Hush 6 years ago
Jonathan "Duke" Leto 623f3dfdee Add another test to verify that getinfo.notarizedhash is set correctly 6 years ago
Jonathan "Duke" Leto 70e5e01f4e Set notarized hash correctly in regtest 6 years ago
Jonathan "Duke" Leto 799c4c1ec7 Working dpowconfs tests for listunspent 6 years ago
Jonathan "Duke" Leto 2f14564c79 Notarizations in regtest. Every 7th block is notarized in regtest 6 years ago
Jonathan "Duke" Leto 0faf48c0be Merge branch 'dpowconfs' of github.com:MyHush/hush into dpowconfs 6 years ago
Jonathan "Duke" Leto 67d8ebb2ff Try to fake some notarizations in regtest so we can test things 6 years ago
Duke Leto ab04057210
Merge pull request #153 from MyHush/dpow_datadir 6 years ago
Jonathan "Duke" Leto 791b6a408e Add dpowconfs to listunspent, z_listunspent and add basic tests 6 years ago
Jonathan "Duke" Leto 0f47de0bdc Fix compiler errors 6 years ago
Jonathan "Duke" Leto 3068f19054 Use correct datadir for notarizations file 6 years ago
Jonathan "Duke" Leto 5f47971df8 KMD statepointer and utils is not needed, use globals 6 years ago
Jonathan "Duke" Leto 271389623f Add basic regtests for dpowconfs 6 years ago
Jonathan "Duke" Leto ad146967bc More dpowconfs 6 years ago
Jonathan "Duke" Leto 7122a6d004 More dpowconfs 6 years ago
Jonathan "Duke" Leto 04ca2ee4a1 Get -dpowconfs CLI arg 6 years ago
Jonathan "Duke" Leto b46080bb6c Latest code with bugfix 6 years ago
Jonathan "Duke" Leto b03d169e13 Return new rawconfirmations key and dpowconfs in wallet tx json 6 years ago
Jonathan "Duke" Leto ad411f2075 Start adding DPoW confs 6 years ago
Duke Leto 3ff1205367
Merge pull request #151 from MyHush/getchaintips 6 years ago
Jonathan "Duke" Leto 52e6bd74ca Make getchaintips tests pass (they never worked previously, because of assumptions about the number of blocks mined in regtest inherited from BTC/ZEC) and add test for new minBranchLen argument 6 years ago
Jonathan "Duke" Leto 9e54048778 Fix getchaintips to only include currently active chain tip when it makes sense 6 years ago
FireMartZ ad9cb03132 Merge remote-tracking branch 'remotes/origin/v2.0.0-rc' into dev 6 years ago
FireMartZ 38c1e0ebaf Add getchaintips parameter 0 in the convertible list. 6 years ago
Jonathan "Duke" Leto aa00b0421c Make getchaintips work correctly via curl, but still get 'JSON value is not an integer as expected' from hush-cli 6 years ago
Jonathan "Duke" Leto dcb5f16c93 Merge branch 'dev' into getchaintips 6 years ago
Martin 24d581ff8a Define HAVE_CONFIG_H to windres to fetch version from config/bitcoin-config.h 6 years ago
FireMartZ 401b860f65
Merge pull request #148 from MyHush/master 6 years ago
FireMartZ f25acdf47b Move dpow print outs from stdout to debug log file. 6 years ago
Jonathan "Duke" Leto 09b31a9ae9 Merge branch 'dev' of github.com:MyHush/hush into dev 6 years ago
FireMartZ c7d6ba61c4
Update INSTALL.md 6 years ago
Martin b4f1a4ce23 Merge branch 'v2.0.0-rc' of https://github.com/MyHush/hush into v2.0.0-rc 6 years ago
Martin 17a9a39026 Update debian package script. 6 years ago
FireMartZ 7e81c6dd0b
Update debian package name. 6 years ago
FireMartZ bc7396110a
Update MAC build instructions. 6 years ago
Jonathan "Duke" Leto f5d84d3705 Organize install instructions and clarify some stuff 6 years ago
Jonathan "Duke" Leto cae75b122c Organize install instructions and clarify some stuff 6 years ago
Jonathan "Duke" Leto 4e66ca4026 WIP optional min branch length argument to getchaintips, which makes it easier to see mining attacks 6 years ago
  1. 8
      README.md
  2. 2
      doc/payment-disclosure.md
  3. 1
      qa/pull-tester/rpc-tests.sh
  4. 51
      qa/rpc-tests/dpowconfs.py
  5. 18
      qa/rpc-tests/getchaintips.py
  6. 2
      src/Makefile.am
  7. 3
      src/amount.cpp
  8. 13
      src/komodo_defs.h
  9. 19
      src/komodo_rpcblockchain.h
  10. 55
      src/komodo_validation011.h
  11. 20
      src/main.cpp
  12. 33
      src/rpcblockchain.cpp
  13. 1
      src/rpcclient.cpp
  14. 54
      src/rpcmisc.cpp
  15. 9
      src/rpcrawtransaction.cpp
  16. 1
      src/rpcserver.cpp
  17. 1
      src/rpcserver.h
  18. 126
      src/txdb.cpp
  19. 2
      src/txdb.h
  20. 56
      src/wallet/rpcwallet.cpp
  21. 4
      zcutil/build-debian-package.sh

8
README.md

@ -33,7 +33,13 @@ See [INSTALL.md](https://github.com/MyHush/hush/blob/master/INSTALL.md).
Bootstrap Nodes
---------------
Choose to add any of the following bootstrap nodes, per your preferred network configuration, to speed up peer discovery. Utilize `addnode=HOSTNAME` in your `hush.conf` file.
Choose to add any of the following bootstrap nodes, per your preferred network configuration, to speed up peer discovery. Utilize `addnode=HOSTNAME` in your `hush.conf` file. For example:
addnode=explorer.myhush.org
addnode=dnsseed.myhush.org
addnode=dnsseed2.myhush.org
addnode=dnsseed.bleuzero.com
addnode=dnsseed.hush.quebec
**IPV4**
* dnsseed.myhush.org

2
doc/payment-disclosure.md

@ -28,7 +28,7 @@ The ZIP describes a method of proving that a payment was sent to a shielded addr
### Example Use Case
Alice the customer sends 10 ZEC to Bob the merchant at the shielded address shown on their website. However, Bob is not sure if he received the funds.
Alice the customer sends 10 HUSH to Bob the merchant at the shielded address shown on their website. However, Bob is not sure if he received the funds.
Alice's node is running with payment disclosure enabled, so Alice generates a payment disclosure and provides it to Bob, who verifies the payment was made.

1
qa/pull-tester/rpc-tests.sh

@ -11,6 +11,7 @@ export BITCOIND=${REAL_BITCOIND}
#Run the tests
testScripts=(
'dpowconfs.py'
'dpow.py'
'paymentdisclosure.py'
'prioritisetransaction.py'

51
qa/rpc-tests/dpowconfs.py

@ -0,0 +1,51 @@
#!/usr/bin/env python2
# Copyright (c) 2018 The Hush developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \
start_node, stop_node, wait_bitcoinds
class DPoWConfsTest(BitcoinTestFramework):
def setup_chain(self):
print("Initializing test directory "+self.options.tmpdir)
num_nodes = 1
initialize_chain_clean(self.options.tmpdir, num_nodes)
def setup_network(self):
self.nodes = []
self.is_network_split = False
self.nodes.append(start_node(0, self.options.tmpdir))
self.sync_all()
def run_test(self):
rpc = self.nodes[0]
# 98 is notarized, next will be 105. Must mine at least 101
# blocks for 100 block maturity rule
blockhashes = rpc.generate(101)
# block 98, this is 0 indexed
notarizedhash = blockhashes[97]
print rpc.getinfo()
taddr = rpc.getnewaddress()
rpc.sendtoaddress(taddr, 1987.420)
rpc.generate(2)
info = rpc.getinfo()
assert_equal( info['notarizedhash'], notarizedhash)
result = rpc.listunspent()
# this xtn has 2 raw confs, but not in a notarized block,
# so dpowconfs holds it at 1
for res in result:
if (res['address'] == taddr and res['generated'] == 'false'):
assert_equal( result[0]['confirmations'], 1 )
assert_equal( result[0]['rawconfirmations'], 2 )
if __name__ == '__main__':
DPoWConfsTest().main()

18
qa/rpc-tests/getchaintips.py

@ -13,13 +13,15 @@ from test_framework.util import assert_equal
class GetChainTipsTest (BitcoinTestFramework):
def run_test (self):
BitcoinTestFramework.run_test (self)
rpc = self.nodes[0]
#for node in self.nodes:
# node.generate(200)
tips = self.nodes[0].getchaintips ()
tips = self.nodes[0].getchaintips()
assert_equal (len (tips), 1)
assert_equal (tips[0]['branchlen'], 0)
assert_equal (tips[0]['height'], 200)
assert_equal (tips[0]['status'], 'active')
assert_equal (tips[0]['branchlen'], 0)
assert_equal (tips[0]['height'], 0)
# Split the network and build two chains of different lengths.
self.split_network ()
@ -31,14 +33,14 @@ class GetChainTipsTest (BitcoinTestFramework):
assert_equal (len (tips), 1)
shortTip = tips[0]
assert_equal (shortTip['branchlen'], 0)
assert_equal (shortTip['height'], 210)
assert_equal (shortTip['height'], 10)
assert_equal (tips[0]['status'], 'active')
tips = self.nodes[3].getchaintips ()
assert_equal (len (tips), 1)
longTip = tips[0]
assert_equal (longTip['branchlen'], 0)
assert_equal (longTip['height'], 220)
assert_equal (longTip['height'], 20)
assert_equal (tips[0]['status'], 'active')
# Join the network halves and check that we now have two tips
@ -55,5 +57,9 @@ class GetChainTipsTest (BitcoinTestFramework):
tips[1]['status'] = 'active'
assert_equal (tips[1], shortTip)
# test optional minBranchLen
tips = self.nodes[0].getchaintips(42)
assert_equal (len (tips), 0)
if __name__ == '__main__':
GetChainTipsTest ().main ()

2
src/Makefile.am

@ -613,7 +613,7 @@ clean-local:
.rc.o:
@test -f $(WINDRES)
$(AM_V_GEN) $(WINDRES) -DWINDRES_PREPROC -i $< -o $@
$(AM_V_GEN) $(WINDRES) -DWINDRES_PREPROC -DHAVE_CONFIG_H -i $< -o $@
.mm.o:
$(AM_V_CXX) $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \

3
src/amount.cpp

@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2018 The Hush developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -7,7 +8,7 @@
#include "tinyformat.h"
const std::string CURRENCY_UNIT = "ZEC";
const std::string CURRENCY_UNIT = "HUSH";
CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
{

13
src/komodo_defs.h

@ -0,0 +1,13 @@
#ifndef KOMODO_DEFS_H
#define KOMODO_DEFS_H
#define ASSETCHAINS_MINHEIGHT 128
#define KOMODO_ELECTION_GAP 2000
#define ROUNDROBIN_DELAY 61
#define KOMODO_ASSETCHAIN_MAXLEN 65
#define KOMODO_LIMITED_NETWORKSIZE 4
#define IGUANA_MAXSCRIPTSIZE 10001
#define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
#endif

19
src/komodo_rpcblockchain.h

@ -21,6 +21,25 @@
int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);
uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth);
extern char ASSETCHAINS_SYMBOL[65];
uint32_t DPOWCONFS = 1;
extern int32_t NOTARIZED_HEIGHT;
int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs)
{
// DPoW confs are on by default
int32_t dpowconfs = 1;
DPOWCONFS = GetArg("-dpowconfs",dpowconfs);
if ( DPOWCONFS != 0 && txheight > 0 && numconfs > 0 )
{
if ( NOTARIZED_HEIGHT > 0 )
{
if ( txheight < NOTARIZED_HEIGHT )
return(numconfs);
else return(1);
}
}
return(numconfs);
}
int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
{

55
src/komodo_validation011.h

@ -142,7 +142,7 @@ int32_t komodo_importaddress(std::string addr)
return(1);
}
}
printf("%s -> komodo_importaddress failed valid.%d\n",addr.c_str(),address.IsValid());
LogPrint("dpow","%s -> komodo_importaddress failed valid.%d\n",addr.c_str(),address.IsValid());
}
return(-1);
}
@ -514,7 +514,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
if ( n > 0 )
{
bytes[0] = unhex(hex[0]);
printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex));
LogPrint("dpow","decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex));
}
bytes++;
hex++;
@ -754,7 +754,7 @@ void komodo_importpubkeys()
//fprintf(stderr,"pubkey=%s, addr=%s\n", pubkey, addr.c_str() );
if ( (val= komodo_importaddress(addr)) < 0 )
LogPrintf("dpow: error importing (%s)\n",addr.c_str());
LogPrint("dpow","dpow: error importing (%s)\n",addr.c_str());
else if ( val == 0 )
dispflag++;
}
@ -954,7 +954,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n
{
if ( NPOINTS[i].nHeight >= nHeight )
{
LogPrintf("dpow: flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,NPOINTS[i].nHeight,nHeight,last_NPOINTSi,NUM_NPOINTS);
LogPrint("dpow","dpow: flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,NPOINTS[i].nHeight,nHeight,last_NPOINTSi,NUM_NPOINTS);
flag = 1;
break;
}
@ -1006,8 +1006,8 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
#else
sep = "/";
#endif
sprintf(fname,"%s%snotarizations%s",GetDefaultDataDir().string().c_str(), sep.c_str(), suffix.c_str());
LogPrintf("dpow: fname.(%s)\n",fname);
sprintf(fname,"%s%snotarizations%s",GetDataDir().string().c_str(), sep.c_str(), suffix.c_str());
LogPrint("dpow","dpow: fname.(%s)\n",fname);
if ( (fp= fopen(fname,"rb+")) == 0 )
fp = fopen(fname,"wb+");
else
@ -1030,12 +1030,12 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
NOTARIZED_MOMDEPTH = np->MoMdepth;
//fprintf(stderr,"%d ",np->notarized_height);
fpos = ftell(fp);
} else LogPrintf("dpow: %s error with notarization ht.%d %s\n",ASSETCHAINS_SYMBOL,N.notarized_height,pindex->GetBlockHash().ToString().c_str());
} else LogPrint("dpow","dpow: %s error with notarization ht.%d %s\n",ASSETCHAINS_SYMBOL,N.notarized_height,pindex->GetBlockHash().ToString().c_str());
}
if ( ftell(fp) != fpos )
fseek(fp,fpos,SEEK_SET);
}
LogPrintf("dpow: finished loading %s [pubkey %s]\n",fname,NOTARY_PUBKEY.c_str());
LogPrint("dpow","dpow: finished loading %s [pubkey %s]\n",fname,NOTARY_PUBKEY.c_str());
didinit = 1;
}
if ( notarized_height == 0 )
@ -1045,16 +1045,16 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
}
if ( notarized_height >= nHeight )
{
LogPrintf("dpow: komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
LogPrint("dpow","dpow: komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
return;
}
pindex = komodo_chainactive(notarized_height);
if ( pindex == 0 || pindex->GetBlockHash() != notarized_hash || notarized_height != pindex->nHeight )
{
LogPrintf("dpow: komodo_notarized_update reject nHeight.%d notarized_height.%d:%d\n",nHeight,notarized_height,(int32_t)pindex->nHeight);
LogPrint("dpow","dpow: komodo_notarized_update reject nHeight.%d notarized_height.%d:%d\n",nHeight,notarized_height,(int32_t)pindex->nHeight);
return;
}
LogPrintf("dpow: komodo_notarized_update nHeight.%d notarized_height.%d prev.%d\n",nHeight,notarized_height,NPOINTS!=0?NPOINTS[NUM_NPOINTS-1].notarized_height:-1);
LogPrint("dpow","dpow: komodo_notarized_update nHeight.%d notarized_height.%d prev.%d\n",nHeight,notarized_height,NPOINTS!=0?NPOINTS[NUM_NPOINTS-1].notarized_height:-1);
portable_mutex_lock(&komodo_mutex);
NPOINTS = (struct notarized_checkpoint *)realloc(NPOINTS,(NUM_NPOINTS+1) * sizeof(*NPOINTS));
np = &NPOINTS[NUM_NPOINTS++];
@ -1073,7 +1073,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
{
if ( fwrite(np,1,sizeof(*np),fp) == sizeof(*np) )
fflush(fp);
else LogPrintf("dpow: error writing notarization to %d\n",(int32_t)ftell(fp));
else LogPrint("dpow","dpow: error writing notarization to %d\n",(int32_t)ftell(fp));
}
// add to stored notarizations
portable_mutex_unlock(&komodo_mutex);
@ -1092,7 +1092,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has
{
notary = mapBlockIndex[notarized_hash];
if ( IS_NOTARY )
printf("nHeight.%d -> (%d %s)\n",pindex->nHeight,notarized_height,notarized_hash.ToString().c_str());
LogPrint("dpow","nHeight.%d -> (%d %s)\n",pindex->nHeight,notarized_height,notarized_hash.ToString().c_str());
if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg
{
if ( nHeight < notarized_height )
@ -1132,7 +1132,7 @@ void komodo_voutupdate(int32_t txi,int32_t vout,uint8_t *scriptbuf,int32_t scrip
opretlen = scriptbuf[len++];
opretlen += (scriptbuf[len++] << 8);
}
printf("opretlen.%d vout.%d [%s].(%s)\n",opretlen,vout,(char *)&scriptbuf[len+32*2+4],ASSETCHAINS_SYMBOL);
LogPrint("dpow","opretlen.%d vout.%d [%s].(%s)\n",opretlen,vout,(char *)&scriptbuf[len+32*2+4],ASSETCHAINS_SYMBOL);
if ( vout == 1 && opretlen-3 >= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
{
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&hash);
@ -1158,12 +1158,12 @@ void komodo_voutupdate(int32_t txi,int32_t vout,uint8_t *scriptbuf,int32_t scrip
}
else
{
LogPrintf("dpow: VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,MoM.ToString().c_str(),MoMdepth);
LogPrint("dpow","dpow: VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,MoM.ToString().c_str(),MoMdepth);
}
}
komodo_notarized_update(height,*notarizedheightp,hash,desttxid,MoM,MoMdepth);
LogPrintf("dpow: %s ht.%d NOTARIZED.%d %s %sTXID.%s lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,hash.ToString().c_str(),"KMD",desttxid.ToString().c_str(),opretlen,len);
} else LogPrintf("dpow: notarized.%d ht %d vs prev %d vs height.%d\n",notarized,*notarizedheightp,NOTARIZED_HEIGHT,height);
LogPrint("dpow","dpow: %s ht.%d NOTARIZED.%d %s %sTXID.%s lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,hash.ToString().c_str(),"KMD",desttxid.ToString().c_str(),opretlen,len);
} else LogPrint("dpow","dpow: notarized.%d ht %d vs prev %d vs height.%d\n",notarized,*notarizedheightp,NOTARIZED_HEIGHT,height);
}
}
}
@ -1172,6 +1172,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
{
static int32_t hwmheight;
uint64_t signedmask; uint8_t scriptbuf[4096],pubkeys[64][33],scriptPubKey[35]; uint256 zero; int32_t i,j,k,m,numnotaries,notarized,scriptlen,numvalid,specialtx,notarizedheight,len,numvouts,numvins,height,txn_count;
uint256 txhash;
if ( KOMODO_NEEDPUBKEYS != 0 )
{
@ -1187,7 +1188,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
else
{
if ( pindex->nHeight != hwmheight )
LogPrintf("dpow: %s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",ASSETCHAINS_SYMBOL,hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight);
LogPrint("dpow","dpow: %s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",ASSETCHAINS_SYMBOL,hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight);
}
if ( pindex != 0 )
@ -1197,7 +1198,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
//fprintf(stderr, "txn_count=%d\n", txn_count);
for (i=0; i<txn_count; i++)
{
//txhash = block.vtx[i]->GetHash();
txhash = block.vtx[i].GetHash();
numvouts = block.vtx[i].vout.size();
specialtx = notarizedheight = notarized = 0;
signedmask = 0;
@ -1224,12 +1225,18 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
numvalid = bitweight(signedmask);
if ( numvalid >= KOMODO_MINRATIFY )
notarized = 1;
if ( Params().NetworkIDString() == "regtest" && ( height%7 == 0) ) {
notarized = 1;
NOTARIZED_HEIGHT = height;
NOTARIZED_HASH = block.GetHash();
NOTARIZED_DESTTXID = txhash;
}
if ( IS_NOTARY )
printf("(tx.%d: ",i);
LogPrint("dpow","(tx.%d: ",i);
for (j=0; j<numvouts; j++)
{
if ( IS_NOTARY )
printf("%.8f ",dstr(block.vtx[i].vout[j].nValue));
LogPrint("dpow","%.8f ",dstr(block.vtx[i].vout[j].nValue));
len = block.vtx[i].vout[j].scriptPubKey.size();
if ( len >= (int32_t)sizeof(uint32_t) && len <= (int32_t)sizeof(scriptbuf) )
{
@ -1238,10 +1245,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
}
if ( NOTARY_PUBKEY33[0] != 0 )
printf(") ");
LogPrint("dpow",") ");
if ( NOTARY_PUBKEY33[0] != 0 )
printf("%s ht.%d\n",ASSETCHAINS_SYMBOL,height);
LogPrintf("dpow: [%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx);
LogPrint("dpow","%s ht.%d\n",ASSETCHAINS_SYMBOL,height);
LogPrint("dpow","dpow: [%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx);
}
} else LogPrint("dpow","komodo_connectblock: unexpected null pindex\n");

20
src/main.cpp

@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2017 The Hush developers
// Copyright (c) 2017-2018 The Hush developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -560,6 +560,24 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
CCoinsViewCache *pcoinsTip = NULL;
CBlockTreeDB *pblocktree = NULL;
UniValue hush_snapshot(int top)
{
LOCK(cs_main);
int64_t total = -1;
UniValue result(UniValue::VOBJ);
if (fAddressIndex) {
if ( pblocktree != 0 ) {
result = pblocktree->Snapshot(top);
} else {
fprintf(stderr,"null pblocktree! Make sure to start with -addressindex=1\n");
}
} else {
fprintf(stderr,"getsnapshot requires -addressindex=1\n");
}
return(result);
}
//////////////////////////////////////////////////////////////////////////////
//
// mapOrphanTransactions

33
src/rpcblockchain.cpp

@ -32,6 +32,7 @@ using namespace std;
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty)
{
@ -112,7 +113,8 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations)));
result.push_back(Pair("rawconfirmations", confirmations));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", blockindex->nVersion));
result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex()));
@ -144,7 +146,8 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
} else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block is an orphan");
}
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations)));
result.push_back(Pair("rawconfirmations", confirmations));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
@ -248,7 +251,8 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations)));
result.push_back(Pair("rawconfirmations", confirmations));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
@ -805,7 +809,10 @@ UniValue gettxout(const UniValue& params, bool fHelp)
if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT)
ret.push_back(Pair("confirmations", 0));
else
ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
{
ret.push_back(Pair("confirmations", komodo_dpowconfs(coins.nHeight,pindex->nHeight - coins.nHeight + 1)));
ret.push_back(Pair("rawconfirmations", pindex->nHeight - coins.nHeight + 1));
}
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));
UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
@ -965,7 +972,7 @@ struct CompareBlocksByHeight
UniValue getchaintips(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
if (fHelp || params.size() > 1)
throw runtime_error(
"getchaintips\n"
"Return information about all known tips in the block tree,"
@ -998,6 +1005,10 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
LOCK(cs_main);
int minBranchLen = 0;
if (params.size() > 0)
minBranchLen = params[0].get_int();
/* Build up a list of chain tips. We start with the list of all
known blocks, and successively remove blocks that appear as pprev
of another block. */
@ -1011,18 +1022,22 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
setTips.erase(pprev);
}
// Always report the currently active tip.
setTips.insert(chainActive.Tip());
if (minBranchLen == 0) {
// insert currently active tip
setTips.insert(chainActive.Tip());
}
/* Construct the output array. */
UniValue res(UniValue::VARR);
BOOST_FOREACH(const CBlockIndex* block, setTips)
{
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
if (branchLen < minBranchLen)
continue;
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", block->nHeight));
obj.push_back(Pair("hash", block->phashBlock->GetHex()));
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
obj.push_back(Pair("branchlen", branchLen));
string status;

1
src/rpcclient.cpp

@ -46,6 +46,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "getbalance", 1 },
{ "getbalance", 2 },
{ "getblockhash", 0 },
{ "getchaintips", 0 },
{ "move", 2 },
{ "move", 3 },
{ "sendfrom", 2 },

54
src/rpcmisc.cpp

@ -1056,3 +1056,57 @@ UniValue getspentinfo(const UniValue& params, bool fHelp)
return obj;
}
UniValue hush_snapshot(int top);
UniValue getsnapshot(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); int64_t total; int32_t top = 0;
if (params.size() > 0 && !params[0].isNull()) {
top = atoi(params[0].get_str().c_str());
if (top <= 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer");
}
if ( fHelp || params.size() > 1)
{
throw runtime_error(
"getsnapshot\n"
"\nReturns a snapshot of (address,amount) pairs at current height (requires addressindex to be enabled).\n"
"\nArguments:\n"
" \"top\" (number, optional) Only return this many addresses, i.e. top N richlist\n"
"\nResult:\n"
"{\n"
" \"addresses\": [\n"
" {\n"
" \"addr\": \"t1EBhzvATA8mrfVK82E5TgPzzjtagCL420\",\n"
" \"amount\": \"100.0\"\n"
" },\n"
" {\n"
" \"addr\": \"t1EBhzvATAJmrfVL82E57gPzzjtaggDuke\",\n"
" \"amount\": \"23.45\"\n"
" }\n"
" ],\n"
" \"total\": 123.45 (numeric) Total amount in snapshot\n"
" \"average\": 61.7, (numeric) Average amount in each address \n"
" \"utxos\": 14, (number) Total number of UTXOs in snapshot\n"
" \"total_addresses\": 2, (number) Total number of addresses in snapshot,\n"
" \"start_height\": 91, (number) Block height snapshot began\n"
" \"ending_height\": 91 (number) Block height snapsho finished,\n"
" \"start_time\": 1531982752, (number) Unix epoch time snapshot started\n"
" \"end_time\": 1531982752 (number) Unix epoch time snapshot finished\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getsnapshot","")
+ HelpExampleRpc("getsnapshot", "1000")
);
}
result = hush_snapshot(top);
if ( result.size() > 0 ) {
result.push_back(Pair("end_time", (int) time(NULL)));
} else {
result.push_back(Pair("error", "no addressindex"));
}
return(result);
}

9
src/rpcrawtransaction.cpp

@ -29,6 +29,7 @@
#include <univalue.h>
using namespace std;
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
{
@ -183,7 +184,8 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue&
if (nConfirmations > 0) {
entry.push_back(Pair("height", nHeight));
entry.push_back(Pair("confirmations", nConfirmations));
entry.push_back(Pair("confirmations", komodo_dpowconfs(nHeight,nConfirmations)));
entry.push_back(Pair("rawconfirmations", nConfirmations));
entry.push_back(Pair("time", nBlockTime));
entry.push_back(Pair("blocktime", nBlockTime));
} else {
@ -242,7 +244,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
entry.push_back(Pair("height", pindex->nHeight));
entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight));
entry.push_back(Pair("rawconfirmations", 1 + chainActive.Height() - pindex->nHeight));
entry.push_back(Pair("confirmations", komodo_dpowconfs(pindex->nHeight,1 + chainActive.Height() - pindex->nHeight)));
entry.push_back(Pair("time", pindex->GetBlockTime()));
entry.push_back(Pair("blocktime", pindex->GetBlockTime()));
} else {
@ -1032,4 +1035,4 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
RelayTransaction(tx);
return hashTx.GetHex();
}
}

1
src/rpcserver.cpp

@ -335,6 +335,7 @@ static const CRPCCommand vRPCCommands[] =
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false },
{ "addressindex", "getaddresstxids", &getaddresstxids, false },
{ "addressindex", "getaddressbalance", &getaddressbalance, false },
{ "addressindex", "getsnapshot", &getsnapshot, false },
/* Utility functions */
{ "util", "createmultisig", &createmultisig, true },

1
src/rpcserver.h

@ -179,6 +179,7 @@ extern UniValue getaddressutxos(const UniValue& params, bool fHelp);
extern UniValue getaddressdeltas(const UniValue& params, bool fHelp);
extern UniValue getaddresstxids(const UniValue& params, bool fHelp);
extern UniValue getaddressbalance(const UniValue& params, bool fHelp);
extern UniValue getsnapshot(const UniValue& params, bool fHelp);
extern UniValue getpeerinfo(const UniValue& params, bool fHelp);
extern UniValue ping(const UniValue& params, bool fHelp);

126
src/txdb.cpp

@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2018 The Hush developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -397,6 +398,131 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type,
return true;
}
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address);
extern UniValue CBlockTreeDB::Snapshot(int top)
{
char chType; int64_t total = 0; int64_t totalAddresses = 0; std::string address;
int64_t utxos = 0; int64_t ignoredAddresses;
boost::scoped_ptr<leveldb::Iterator> iter(NewIterator());
std::map <std::string, CAmount> addressAmounts;
std::vector <std::pair<CAmount, std::string>> vaddr;
UniValue result(UniValue::VOBJ);
result.push_back(Pair("start_time", (int) time(NULL)));
// TODO: do we have addresses we want to ignore?
std::map <std::string,int> ignoredMap = {
{"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1},
{"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} //Burnaddress for null privkey
};
int64_t startingHeight = chainActive.Height();
//fprintf(stderr, "Starting snapshot at height %lli\n", startingHeight);
for (iter->SeekToLast(); iter->Valid(); iter->Prev())
{
boost::this_thread::interruption_point();
try
{
leveldb::Slice slKey = iter->key();
CDataStream ssKey(slKey.data(), slKey.data()+slKey.size(), SER_DISK, CLIENT_VERSION);
CAddressIndexIteratorKey indexKey;
ssKey >> chType;
ssKey >> indexKey;
//fprintf(stderr, "chType=%d\n", chType);
if (chType == DB_ADDRESSUNSPENTINDEX)
{
try {
leveldb::Slice slValue = iter->value();
CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(), SER_DISK, CLIENT_VERSION);
CAmount nValue;
ssValue >> nValue;
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
if (ignored != ignoredMap.end()) {
fprintf(stderr,"ignoring %s\n", address.c_str());
ignoredAddresses++;
continue;
}
std::map <std::string, CAmount>::iterator pos = addressAmounts.find(address);
if (pos == addressAmounts.end()) {
// insert new address + utxo amount
//fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue);
addressAmounts[address] = nValue;
totalAddresses++;
} else {
// update unspent tally for this address
//fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue);
addressAmounts[address] += nValue;
}
//fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
// total += nValue;
utxos++;
} catch (const std::exception& e) {
fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what());
break;
}
}
} catch (const std::exception& e) {
fprintf(stderr, "DONE reading index entries\n");
break;
}
}
UniValue addresses(UniValue::VARR);
//fprintf(stderr, "total=%f, totalAddresses=%li, utxos=%li, ignored=%li\n", (double) total / COIN, totalAddresses, utxos, ignoredAddresses);
for (std::pair<std::string, CAmount> element : addressAmounts) {
vaddr.push_back( make_pair(element.second, element.first) );
}
std::sort(vaddr.rbegin(), vaddr.rend());
UniValue obj(UniValue::VOBJ);
UniValue addressesSorted(UniValue::VARR);
int topN = 0;
for (std::vector<std::pair<CAmount, std::string>>::iterator it = vaddr.begin(); it!=vaddr.end(); ++it) {
UniValue obj(UniValue::VOBJ);
obj.push_back( make_pair("addr", it->second.c_str() ) );
char amount[32];
sprintf(amount, "%.8f", (double) it->first / COIN);
obj.push_back( make_pair("amount", amount) );
total += it->first;
addressesSorted.push_back(obj);
topN++;
// If requested, only show top N addresses in output JSON
if (top == topN)
break;
}
if (top)
totalAddresses = top;
if (totalAddresses > 0) {
// Array of all addreses with balances
result.push_back(make_pair("addresses", addressesSorted));
// Total amount in this snapshot, which is less than circulating supply if top parameter is used
result.push_back(make_pair("total", (double) total / COIN ));
// Average amount in each address of this snapshot
result.push_back(make_pair("average",(double) (total/COIN) / totalAddresses ));
}
// Total number of utxos processed in this snaphot
result.push_back(make_pair("utxos", utxos));
// Total number of addresses in this snaphot
result.push_back(make_pair("total_addresses", totalAddresses));
// Total number of ignored addresses in this snaphot
result.push_back(make_pair("ignored_addresses", ignoredAddresses));
// The snapshot began at this block height
result.push_back(make_pair("start_height", startingHeight));
// The snapshot finished at this block height
result.push_back(make_pair("ending_height", chainActive.Height()));
return(result);
}
bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey &timestampIndex) {
CLevelDBBatch batch;
batch.Write(make_pair(DB_TIMESTAMPINDEX, timestampIndex), 0);

2
src/txdb.h

@ -13,6 +13,7 @@
#include <string>
#include <utility>
#include <vector>
#include <univalue.h>
class CBlockFileInfo;
class CBlockIndex;
@ -95,6 +96,7 @@ public:
bool ReadFlag(const std::string &name, bool &fValue);
bool LoadBlockIndexGuts();
bool blockOnchainActive(const uint256 &hash);
UniValue Snapshot(int top);
};
#endif // BITCOIN_TXDB_H

56
src/wallet/rpcwallet.cpp

@ -42,6 +42,7 @@ using namespace std;
using namespace libzcash;
extern UniValue TxJoinSplitToJSON(const CTransaction& tx);
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int64_t nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;
@ -77,15 +78,16 @@ void EnsureWalletIsUnlocked()
void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
{
int confirms = wtx.GetDepthInMainChain();
entry.push_back(Pair("confirmations", confirms));
entry.push_back(Pair("rawconfirmations", confirms));
if (wtx.IsCoinBase())
entry.push_back(Pair("generated", true));
if (confirms > 0)
{
entry.push_back(Pair("confirmations", komodo_dpowconfs((int32_t)mapBlockIndex[wtx.hashBlock]->nHeight,confirms)));
entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex()));
entry.push_back(Pair("blockindex", wtx.nIndex));
entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime()));
}
} else entry.push_back(Pair("confirmations", confirms));
uint256 hash = wtx.GetHash();
entry.push_back(Pair("txid", hash.GetHex()));
UniValue conflicts(UniValue::VARR);
@ -1199,7 +1201,8 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
obj.push_back(Pair("address", address.ToString()));
obj.push_back(Pair("account", strAccount));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
obj.push_back(Pair("rawconfirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : komodo_dpowconfs(nHeight, nConf))));
UniValue transactions(UniValue::VARR);
if (it != mapTally.end())
{
@ -1224,7 +1227,8 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
obj.push_back(Pair("involvesWatchonly", true));
obj.push_back(Pair("account", (*it).first));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
obj.push_back(Pair("rawconfirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : komodo_dpowconfs(nHeight, nConf))));
ret.push_back(obj);
}
}
@ -2324,13 +2328,13 @@ UniValue listunspent(const UniValue& params, bool fHelp)
"with between minconf and maxconf (inclusive) confirmations.\n"
"Optionally filter to only include txouts paid to specified addresses.\n"
"Results are an array of Objects, each of which has:\n"
"{txid, vout, scriptPubKey, amount, confirmations}\n"
"{txid, vout, scriptPubKey, amount, generated, confirmations, rawconfirmations}\n"
"\nArguments:\n"
"1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n"
"2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n"
"3. \"addresses\" (string) A json array of Hush addresses to filter\n"
" [\n"
" \"address\" (string) hush address\n"
" \"address\" (string) Hush address\n"
" ,...\n"
" ]\n"
"\nResult\n"
@ -2343,7 +2347,8 @@ UniValue listunspent(const UniValue& params, bool fHelp)
" \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
" \"scriptPubKey\" : \"key\", (string) the script key\n"
" \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n"
" \"confirmations\" : n (numeric) The number of confirmations\n"
" \"confirmations\" : n (numeric) The number of notarized DPoW confirmations\n"
" \"rawconfirmations\" : n (numeric) The number of raw confirmations\n"
" }\n"
" ,...\n"
"]\n"
@ -2418,8 +2423,12 @@ UniValue listunspent(const UniValue& params, bool fHelp)
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
}
}
int32_t txheight;
if ( chainActive.Tip() != NULL )
txheight = (chainActive.Tip()->nHeight - out.nDepth - 1);
entry.push_back(Pair("amount",ValueFromAmount(nValue)));
entry.push_back(Pair("confirmations",out.nDepth));
entry.push_back(Pair("rawconfirmations",out.nDepth));
entry.push_back(Pair("confirmations",komodo_dpowconfs(txheight,out.nDepth)));
entry.push_back(Pair("spendable", out.fSpendable));
results.push_back(entry);
}
@ -2454,7 +2463,8 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
" \"txid\" : \"txid\", (string) the transaction id \n"
" \"js_index\" : n (numeric) the joinsplit index\n"
" \"output_index\" : n (numeric) the output index of the joinsplit\n"
" \"confirmations\" : n (numeric) the number of confirmations\n"
" \"confirmations\" : n (numeric) the number of notarized DPoW confirmations\n"
" \"rawconfirmations\" : n (numeric) the number of raw confirmations\n"
" \"spendable\" : true|false (boolean) true if note is spendable, false if watchonly\n"
" \"address\" : \"address\", (string) the shielded address\n"
" \"amount\": xxxxx, (numeric) the amount of value in the note\n"
@ -2546,10 +2556,15 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
pwalletMain->GetUnspentFilteredNotes(entries, zaddrs, nMinDepth, nMaxDepth, !fIncludeWatchonly);
for (CUnspentNotePlaintextEntry & entry : entries) {
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("txid",entry.jsop.hash.ToString()));
int32_t txheight;
std::string txid = entry.jsop.hash.ToString();
obj.push_back(Pair("txid",txid));
obj.push_back(Pair("js_index", (int)entry.jsop.js ));
obj.push_back(Pair("output_index", (int)entry.jsop.n));
obj.push_back(Pair("confirmations", entry.nHeight));
if ( chainActive.Tip() != NULL )
txheight = (chainActive.Tip()->nHeight - entry.nHeight - 1);
obj.push_back(Pair("rawconfirmations", entry.nHeight));
obj.push_back(Pair("confirmations",komodo_dpowconfs(txheight,entry.nHeight)));
obj.push_back(Pair("spendable", pwalletMain->HaveSpendingKey(entry.address)));
obj.push_back(Pair("address", CZCPaymentAddress(entry.address).ToString()));
obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value))));
@ -3237,8 +3252,27 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
pwalletMain->GetFilteredNotes(entries, fromaddress, nMinDepth, false, false);
for (CNotePlaintextEntry & entry : entries) {
UniValue obj(UniValue::VOBJ);
int nHeight = 0;
CTransaction tx;
uint256 hashBlock;
if (GetTransaction(entry.jsop.hash, tx, hashBlock, true)) {
BlockMap::const_iterator it = mapBlockIndex.find(hashBlock);
if (it != mapBlockIndex.end()) {
nHeight = it->second->GetHeight();
fprintf(stderr,"blockHash %s height %d\n",hashBlock.ToString().c_str(), nHeight);
} else {
fprintf(stderr,"block hash %s does not exist!\n", hashBlock.ToString().c_str() );
}
} else {
fprintf(stderr,"tx hash %s does not exist!\n", entry.jsop.hash.ToString().c_str() );
}
obj.push_back(Pair("txid",entry.jsop.hash.ToString()));
obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value))));
obj.push_back(Pair("rawconfirmations", entry.confirmations));
obj.push_back(Pair("confirmations", komodo_dpowconfs(nHeight, entry.confirmations)));
std::string data(entry.plaintext.memo.begin(), entry.plaintext.memo.end());
obj.push_back(Pair("memo", HexStr(data)));
result.push_back(obj);

4
zcutil/build-debian-package.sh

@ -51,8 +51,8 @@ cp $SRC_DOC/man/hushd.1 $DEB_MAN
cp $SRC_DOC/man/hush-cli.1 $DEB_MAN
cp $SRC_DOC/man/hush-fetch-params.1 $DEB_MAN
# Copy bash completion files
cp $SRC_PATH/contrib/bitcoind.bash-completion $DEB_CMP/hushd
cp $SRC_PATH/contrib/bitcoin-cli.bash-completion $DEB_CMP/hush-cli
cp $SRC_PATH/contrib/hushd.bash-completion $DEB_CMP/hushd
cp $SRC_PATH/contrib/hush-cli.bash-completion $DEB_CMP/hush-cli
# Gzip files
gzip --best -n $DEB_DOC/changelog
gzip --best -n $DEB_DOC/changelog.Debian

Loading…
Cancel
Save