From 6e730ec1504d564f4e1431d4da7c8402aaf570c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 6 Jul 2019 09:56:25 -1100 Subject: [PATCH] +getinfo fields --- src/komodo_nSPV.h | 13 ++++++++++++- src/komodo_nSPV_fullnode.h | 1 - src/komodo_nSPV_superlite.h | 18 +++++++++++------- src/komodo_nSPV_wallet.h | 2 -- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 1df9aedf4..18f85a036 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -16,13 +16,24 @@ // todo: // make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database) + +// determine if it makes sense to be scanning mempool for the utxo/spentinfo requests, maybe can add isspent flag to txproof, or just use getspentinfo if broadcast fails + // validate proofs +// interest calculations are currently just using what is returned, it should calculate it from scratch + +// need to validate incoming data and update only if it is valid and more recent // make sure to sanity check all vector lengths on receipt -// determine if it makes sense to be scanning mempool for the utxo/spentinfo requests #ifndef KOMODO_NSPV_H #define KOMODO_NSPV_H +#define NSPV_POLLITERS 15 +#define NSPV_POLLMICROS 100000 +#define NSPV_MAXVINS 64 +#define NSPV_AUTOLOGOUT 777 +#define NSPV_BRANCHID 0x76b809bb + // nSPV defines and struct definitions with serialization and purge functions #define NSPV_INFO 0x00 diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 5a05d01ae..ee837e6ad 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -17,7 +17,6 @@ #ifndef KOMODO_NSPVFULLNODE_H #define KOMODO_NSPVFULLNODE_H -// on fullnode: // NSPV_get... functions need to return the exact serialized length, which is the size of the structure minus size of pointers, plus size of allocated data #include "notarisationdb.h" diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 916fea8aa..71281d087 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -21,12 +21,6 @@ // no caching, no optimizations, no reducing the number of ntzsproofs needed by detecting overlaps, etc. // advantage is that it is simpler to implement and understand to create a design for a more performant version -// interest calculations are currently just using what is returned, it should calculate it from scratch -// need to validate incoming data and update only if it is valid and more recent - -#define NSPV_POLLITERS 15 -#define NSPV_POLLMICROS 100000 -#define NSPV_MAXVINS 64 CAmount AmountFromValue(const UniValue& value); int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr); @@ -113,8 +107,18 @@ UniValue NSPV_ntz_json(struct NSPV_ntz *ptr) UniValue _NSPV_getinfo_json(struct NSPV_inforesp *ptr) { - UniValue result(UniValue::VOBJ); + UniValue result(UniValue::VOBJ); int32_t expiration; uint32_t timestamp = (uint32_t)time(NULL); result.push_back(Pair("result","success")); + if ( NSPV_address.size() != 0 ) + { + result.push_back(Pair("address",NSPV_address)); + result.push_back(Pair("pubkey",NSPV_pubkeystr)); + } + if ( NSPV_logintime != 0 ) + { + expiration = (NSPV_logintime + NSPV_AUTOLOGOUT - timestamp); + result.push_back(Pair("wifexpires",expiration)); + } result.push_back(Pair("height",(int64_t)ptr->height)); result.push_back(Pair("chaintip",ptr->blockhash.GetHex())); result.push_back(Pair("notarization",NSPV_ntz_json(&ptr->notarization))); diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index 3ebc7523c..7db65b60e 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -20,8 +20,6 @@ // nSPV wallet uses superlite functions (and some komodod built in functions) to implement nSPV_spend extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); -#define NSPV_AUTOLOGOUT 777 -#define NSPV_BRANCHID 0x76b809bb /*struct NSPV_ntzproofshared