Browse Source

Merge branch 'dpowconfs' of github.com:MyHush/hush into dpowconfs

pull/152/head
Jonathan "Duke" Leto 6 years ago
parent
commit
0faf48c0be
  1. 1
      qa/pull-tester/rpc-tests.sh
  2. 15
      qa/rpc-tests/dpowconfs.py
  3. 7
      src/komodo_rpcblockchain.h
  4. 16
      src/wallet/rpcwallet.cpp

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'

15
qa/rpc-tests/dpowconfs.py

@ -18,18 +18,19 @@ class DPoWConfsTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.is_network_split = False
self.nodes.append(start_node(0, self.options.tmpdir, [['-dpowconfs=1']]))
self.nodes.append(start_node(0, self.options.tmpdir))
self.sync_all()
def run_test(self):
self.nodes[0].generate(3)
self.nodes[0].generate(101)
rpc = self.nodes[0]
result = rpc.getinfo()
# regtest should have no notarization data, this test makes sure we do not see mainnet values as well!
assert_equal(result['notarized'],0)
assert_equal(result['notarizedhash'],'0000000000000000000000000000000000000000000000000000000000000000')
assert_equal(result['notarizedtxid'],'0000000000000000000000000000000000000000000000000000000000000000')
result = rpc.listunspent()
# no notarization data in regtest, yet
assert_equal( result[0]['confirmations'], 101 )
assert_equal( result[0]['rawconfirmations'], 101 )
print result
if __name__ == '__main__':
DPoWConfsTest().main()

7
src/komodo_rpcblockchain.h

@ -21,10 +21,15 @@
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)
{
if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 )
// 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 )
{

16
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;
@ -2419,8 +2420,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);
}
@ -2547,10 +2552,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))));

Loading…
Cancel
Save