From 5e9d4665227ded744da612bd439adb62e4211783 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 30 Jun 2019 12:22:26 -0400 Subject: [PATCH] testGetTxsWithPaymentIds() passing --- src/wallet/MoneroWallet.cpp | 13 ++++++++++--- src/wallet/MoneroWalletModel.cpp | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index e2c596a..764cfb8 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -971,6 +971,8 @@ namespace monero { } } + //cout << "7" << endl; + // get unconfirmed incoming transfers if (isPool) { wallet2->update_pool_state(); // TODO monero-core: this should be encapsulated in wallet when unconfirmed transfers requested @@ -982,6 +984,8 @@ namespace monero { } } + //cout << "8" << endl; + // filter and return transfers vector> transfers; for (map>::const_iterator txIter = txMap.begin(); txIter != txMap.end(); txIter++) { @@ -1002,10 +1006,12 @@ namespace monero { } } - // remove unrequested txs - if (tx->outgoingTransfer == boost::none && tx->incomingTransfers.empty()) tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator? + // remove unrequested txs from block + if (tx->block != boost::none && tx->outgoingTransfer == boost::none && tx->incomingTransfers.empty()) { + tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator? + } } - //cout << "7" << endl; + //cout << "9" << endl; cout << "MoneroWallet.cpp getTransfers() returning " << transfers.size() << " transfers" << endl; return transfers; } @@ -1154,6 +1160,7 @@ namespace monero { outTransfer->amount = *txAmountsIter; // init other known fields + tx->paymentId = request.paymentId; tx->isConfirmed = false; tx->isCoinbase = false; tx->isFailed = false; // TODO: test and handle if true diff --git a/src/wallet/MoneroWalletModel.cpp b/src/wallet/MoneroWalletModel.cpp index dd2b4ff..5a6f6c3 100644 --- a/src/wallet/MoneroWalletModel.cpp +++ b/src/wallet/MoneroWalletModel.cpp @@ -86,7 +86,7 @@ namespace monero { if (isIncoming != boost::none) node.put("isIncoming", *isIncoming); if (!txIds.empty()) node.add_child("txIds", MoneroUtils::toPropertyTree(txIds)); if (hasPaymentId != boost::none) node.put("hasPaymentId", *hasPaymentId); - if (!paymentIds.empty()) throw runtime_error("paymentIds not implemented"); + if (!paymentIds.empty()) node.add_child("paymentIds", MoneroUtils::toPropertyTree(paymentIds)); if (minHeight != boost::none) node.put("minHeight", *minHeight); if (maxHeight != boost::none) node.put("maxHeight", *maxHeight); if (includeOutputs != boost::none) node.put("includeOutputs", *includeOutputs); @@ -97,18 +97,18 @@ namespace monero { bool MoneroTxRequest::meetsCriteria(MoneroTxWallet* tx) const { if (tx == nullptr) return false; - //cout << "MoneroTxRequest::meetsCriteria()" << endl; + cout << "MoneroTxRequest::meetsCriteria()" << endl; //cout << "Testing tx: " << tx->serialize() << endl; //cout << "1" << endl; // filter on tx - if (id != boost::none && *id != *tx->id) return false; - if (paymentId != boost::none && *paymentId != *tx->paymentId) return false; - if (isConfirmed != boost::none && *isConfirmed != *tx->isConfirmed) return false; - if (inTxPool != boost::none && *inTxPool != *tx->inTxPool) return false; - if (doNotRelay != boost::none && *doNotRelay != *tx->doNotRelay) return false; - if (isFailed != boost::none && *isFailed != *tx->isFailed) return false; - if (isCoinbase != boost::none && *isCoinbase != *tx->isCoinbase) return false; + if (id != boost::none && id != tx->id) return false; + if (paymentId != boost::none && paymentId != tx->paymentId) return false; + if (isConfirmed != boost::none && isConfirmed != tx->isConfirmed) return false; + if (inTxPool != boost::none && inTxPool != tx->inTxPool) return false; + if (doNotRelay != boost::none && doNotRelay != tx->doNotRelay) return false; + if (isFailed != boost::none && isFailed != tx->isFailed) return false; + if (isCoinbase != boost::none && isCoinbase != tx->isCoinbase) return false; //cout << "2" << endl; @@ -139,6 +139,9 @@ namespace monero { // filter on incoming if (isIncoming != boost::none) { + cout << "Is... incoming?" << endl; + cout << tx->getIsIncoming() << endl; + cout << isIncoming << endl; if (isIncoming != tx->getIsIncoming()) return false; } @@ -154,7 +157,7 @@ namespace monero { // filter on remaining fields boost::optional txHeight = tx->getHeight(); if (!txIds.empty() && find(txIds.begin(), txIds.end(), *tx->id) == txIds.end()) return false; - if (!paymentIds.empty() && find(paymentIds.begin(), paymentIds.end(), *tx->paymentId) == paymentIds.end()) return false; + if (!paymentIds.empty() && (tx->paymentId == boost::none || find(paymentIds.begin(), paymentIds.end(), *tx->paymentId) == paymentIds.end())) return false; if (getHeight() != boost::none && (txHeight == boost::none || *txHeight != *getHeight())) return false; if (minHeight != boost::none && (txHeight == boost::none || *txHeight < *minHeight)) return false; if (maxHeight != boost::none && (txHeight == boost::none || *txHeight > *maxHeight)) return false;