From e2ffc1e21f92f3d1ca4712e71d7883ffc69038cc Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 8 Jun 2019 09:37:19 -0400 Subject: [PATCH] defined MoneroTx.DEFAULT_PAYMENT_ID; initialize incoming transfer isCoinbase, isConfirmed, isFailed, isRelayed, inTxPool --- src/daemon/MoneroDaemon.cpp | 4 ++++ src/daemon/MoneroDaemon.h | 1 + src/wallet/MoneroWallet.cpp | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/daemon/MoneroDaemon.cpp b/src/daemon/MoneroDaemon.cpp index 3365a10..927e53a 100644 --- a/src/daemon/MoneroDaemon.cpp +++ b/src/daemon/MoneroDaemon.cpp @@ -9,6 +9,10 @@ */ namespace monero { + // ------------------------- INITIALIZE CONSTANTS --------------------------- + + const string MoneroTx::DEFAULT_PAYMENT_ID = string("0000000000000000"); + // -------------------------- MODEL SERIALIZATION --------------------------- string SerializableStruct::serialize() const { diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/MoneroDaemon.h index 1dc1e00..faaefd9 100644 --- a/src/daemon/MoneroDaemon.h +++ b/src/daemon/MoneroDaemon.h @@ -62,6 +62,7 @@ namespace monero { * Models a Monero transaction on the blockchain. */ struct MoneroTx : public SerializableStruct { + static const string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000" boost::optional> block; boost::optional id; boost::optional version; diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index 6e4b89d..e78dd14 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -693,10 +693,17 @@ namespace monero { tx->id = string_tools::pod_to_hex(pd.m_tx_hash); tx->paymentId = string_tools::pod_to_hex(payment_id); if (tx->paymentId->substr(16).find_first_not_of('0') == std::string::npos) tx->paymentId = tx->paymentId->substr(0, 16); // TODO monero core: this should be part of core wallet + if (tx->paymentId == MoneroTx::DEFAULT_PAYMENT_ID) tx->paymentId = boost::none; // clear default payment id tx->unlockTime = pd.m_unlock_time; tx->fee = pd.m_fee; tx->note = wallet2->get_tx_note(pd.m_tx_hash); - //entry.type = pd.m_coinbase ? "block" : "in"; // TODO: confirm how coinbase tx/transfers handled now in model, add test + if (tx->note->empty()) tx->note = boost::none; // clear empty note + tx->isCoinbase = pd.m_coinbase ? true : false; + tx->isConfirmed = true; + tx->isFailed = false; + tx->isRelayed = true; + tx->inTxPool = false; + //set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward()); // TODO MoneroIncomingTransfer incomingTransfer;