From 7bafb952e8646ed35539d75973799aa31215fa61 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 3 Jun 2019 12:46:27 -0400 Subject: [PATCH] MoneroDaemon.h imports wallet2.h so BEGIN_KV_SERIALIZE_MAP() works; structs only use pointers pointing up the tree which are not serialized --- src/daemon/MoneroDaemon.h | 190 +++++++++++++++++++++++++++----------- src/wallet/MoneroWallet.h | 3 +- 2 files changed, 137 insertions(+), 56 deletions(-) diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/MoneroDaemon.h index f765bc9..8ed4b99 100644 --- a/src/daemon/MoneroDaemon.h +++ b/src/daemon/MoneroDaemon.h @@ -1,5 +1,6 @@ #include "include_base_utils.h" #include "common/util.h" +#include "wallet/wallet2.h" // TODO: this is imported so BEGIN_KV_SERIALIZE_MAP works; more precise import? using namespace std; @@ -29,60 +30,8 @@ namespace monero { }; // forward declarations - struct MoneroTx; - - /** - * Models a Monero block header which contains information about the block. - */ - struct MoneroBlockHeader { - string id; - uint64_t height; - uint64_t timestamp; - uint64_t size; - uint64_t weight; - uint64_t longTermWeight; - uint64_t depth; - uint64_t difficulty; - uint64_t cumulativeDifficulty; - uint32_t majorVersion; - uint32_t minorVersion; - uint64_t nonce; - string coinbaseTxId; - uint32_t numTxs; - bool orphanStatus; - string prevId; - uint64_t reward; - }; - - /** - * Models a Monero block in the blockchain. - */ - struct MoneroBlock : public MoneroBlockHeader { - string hex; - MoneroTx* coinbaseTx; - vector txs; - vector txIds; - }; - - /** - * Models a Monero key image. - */ - struct MoneroKeyImage { - string hex; - string signature; - }; - - /** - * Models a Monero transaction output. - */ - struct MoneroOutput { - MoneroTx* tx; - MoneroKeyImage* keyImage; - uint64_t amount; - uint32_t index; - vector ringOutputIndices; - string stealthPublicKey; - }; + struct MoneroBlock; + struct MoneroOutput; /** * Models a Monero transaction on the blockchain. @@ -126,5 +75,138 @@ namespace monero { uint32_t maxUsedBlockHeight; string maxUsedBlockId; vector signatures; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(id) + KV_SERIALIZE(version) + KV_SERIALIZE(isCoinbase) + KV_SERIALIZE(paymentId) + KV_SERIALIZE(fee) + KV_SERIALIZE(mixin) + KV_SERIALIZE(doNotRelay) + KV_SERIALIZE(isRelayed) + KV_SERIALIZE(isConfirmed) + KV_SERIALIZE(inTxPool) + KV_SERIALIZE(numConfirmations) + KV_SERIALIZE(unlockTime) + KV_SERIALIZE(lastRelayedTimestamp) + KV_SERIALIZE(receivedTimestamp) + KV_SERIALIZE(isDoubleSpend) + KV_SERIALIZE(key) + KV_SERIALIZE(fullHex) + KV_SERIALIZE(prunedHex) + KV_SERIALIZE(prunableHex) + KV_SERIALIZE(prunableHash) + KV_SERIALIZE(size) + KV_SERIALIZE(weight) + KV_SERIALIZE(vins) + KV_SERIALIZE(vouts) + KV_SERIALIZE(outputIndices) + KV_SERIALIZE(metadata) + KV_SERIALIZE(commonTxSets) + KV_SERIALIZE(extra) + KV_SERIALIZE(rctSignatures) + KV_SERIALIZE(rctSigPrunable) + KV_SERIALIZE(isKeptByBlock) + KV_SERIALIZE(isFailed) + KV_SERIALIZE(lastFailedHeight) + KV_SERIALIZE(lastFailedId) + KV_SERIALIZE(maxUsedBlockHeight) + KV_SERIALIZE(maxUsedBlockId) + KV_SERIALIZE(signatures) + END_KV_SERIALIZE_MAP() + }; + + /** + * Models a Monero block header which contains information about the block. + */ + struct MoneroBlockHeader { + string id; + uint64_t height; + uint64_t timestamp; + uint64_t size; + uint64_t weight; + uint64_t longTermWeight; + uint64_t depth; + uint64_t difficulty; + uint64_t cumulativeDifficulty; + uint32_t majorVersion; + uint32_t minorVersion; + uint64_t nonce; + string coinbaseTxId; + uint32_t numTxs; + bool orphanStatus; + string prevId; + uint64_t reward; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(id) + KV_SERIALIZE(height) + KV_SERIALIZE(timestamp) + KV_SERIALIZE(size) + KV_SERIALIZE(weight) + KV_SERIALIZE(longTermWeight) + KV_SERIALIZE(depth) + KV_SERIALIZE(difficulty) + KV_SERIALIZE(cumulativeDifficulty) + KV_SERIALIZE(majorVersion) + KV_SERIALIZE(minorVersion) + KV_SERIALIZE(nonce) + KV_SERIALIZE(coinbaseTxId) + KV_SERIALIZE(numTxs) + KV_SERIALIZE(orphanStatus) + KV_SERIALIZE(prevId) + KV_SERIALIZE(reward) + END_KV_SERIALIZE_MAP() + }; + + /** + * Models a Monero block in the blockchain. + */ + struct MoneroBlock : public MoneroBlockHeader { + string hex; + MoneroTx coinbaseTx; + vector txs; + vector txIds; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(hex) + KV_SERIALIZE(coinbaseTx) + KV_SERIALIZE(txs) + KV_SERIALIZE(txIds) + END_KV_SERIALIZE_MAP() + }; + + /** + * Models a Monero key image. + */ + struct MoneroKeyImage { + string hex; + string signature; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(hex) + KV_SERIALIZE(signature) + END_KV_SERIALIZE_MAP() + }; + + /** + * Models a Monero transaction output. + */ + struct MoneroOutput { + MoneroTx* tx; + MoneroKeyImage keyImage; + uint64_t amount; + uint32_t index; + vector ringOutputIndices; + string stealthPublicKey; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(keyImage) + KV_SERIALIZE(amount) + KV_SERIALIZE(index) + KV_SERIALIZE(ringOutputIndices) + KV_SERIALIZE(stealthPublicKey) + END_KV_SERIALIZE_MAP() }; } diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index 51780d2..a9524b9 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -1,5 +1,4 @@ #include "daemon/MoneroDaemon.h" -#include "wallet/wallet2.h" using namespace std; using namespace monero; @@ -145,7 +144,7 @@ namespace monero { * All transactions are returned except those that do not meet the criteria defined in this request. */ struct MoneroTxRequest : public MoneroTxWallet { - bool isOutgoing; + bool isOutgoing; // TODO: these are going to need to be pointers to indicate no preference bool isIncoming; vector txIds; bool hasPaymentId;