mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 15:51:34 +02:00
ready to debug transfer filtering
This commit is contained in:
@@ -84,7 +84,6 @@ namespace monero {
|
||||
* @returns the merged tx
|
||||
*/
|
||||
void mergeTx(vector<shared_ptr<MoneroTxWallet>>& txs, const shared_ptr<MoneroTxWallet>& tx, bool skipIfAbsent) {
|
||||
cout << "mergeTx(txs, txs)" << endl;
|
||||
if (tx->id == boost::none) throw runtime_error("Tx id is not initialized");
|
||||
for (const auto& aTx: txs) {
|
||||
|
||||
@@ -754,7 +753,7 @@ namespace monero {
|
||||
}
|
||||
|
||||
shared_ptr<MoneroTxWallet> MoneroWallet::buildTxWithIncomingTransfer(const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const {
|
||||
cout << "buildTxWithIncomingTransfer()" << endl;
|
||||
//cout << "buildTxWithIncomingTransfer()" << endl;
|
||||
|
||||
// construct block
|
||||
shared_ptr<MoneroBlock> block = shared_ptr<MoneroBlock>(new MoneroBlock());
|
||||
|
||||
@@ -121,6 +121,9 @@ namespace monero {
|
||||
// --------------------------------- REQUESTS -------------------------------
|
||||
|
||||
bool MoneroTransferRequest::meetsCriteria(MoneroTransfer* transfer) const {
|
||||
cout << "meetsCriteria()" << endl;
|
||||
|
||||
cout << "Common fields" << endl;
|
||||
|
||||
// filter on common fields
|
||||
if (isIncoming != boost::none && *isIncoming != *transfer->isIncoming) return false;
|
||||
@@ -128,6 +131,8 @@ namespace monero {
|
||||
if (amount != boost::none && *amount != *transfer->amount) return false;
|
||||
if (accountIndex != boost::none && *accountIndex != *transfer->accountIndex) return false;
|
||||
|
||||
cout << "incoming fields" << endl;
|
||||
|
||||
// TODO: could instead Monerotransfer->meetsCriteria(const MoneroTxRequest& req) and use inheritance instead of instanceof
|
||||
|
||||
// filter on incoming fields
|
||||
@@ -135,15 +140,19 @@ namespace monero {
|
||||
if (inTransfer != nullptr) {
|
||||
if (hasDestinations != boost::none) return false;
|
||||
if (address != boost::none && *address != *inTransfer->address) return false;
|
||||
if (find(addresses.begin(), addresses.end(), *inTransfer->address) == addresses.end()) return false;
|
||||
if (!addresses.empty() && find(addresses.begin(), addresses.end(), *inTransfer->address) == addresses.end()) return false;
|
||||
if (subaddressIndex != boost::none && *subaddressIndex == *inTransfer->subaddressIndex) return false;
|
||||
if (find(subaddressIndices.begin(), subaddressIndices.end(), *inTransfer->subaddressIndex) == subaddressIndices.end()) return false;
|
||||
if (!subaddressIndices.empty() && find(subaddressIndices.begin(), subaddressIndices.end(), *inTransfer->subaddressIndex) == subaddressIndices.end()) return false;
|
||||
}
|
||||
|
||||
cout << "outgoing fields" << endl;
|
||||
|
||||
// filter on outgoing fields
|
||||
MoneroOutgoingTransfer* outTransfer = dynamic_cast<MoneroOutgoingTransfer*>(transfer);
|
||||
if (outTransfer != nullptr) {
|
||||
|
||||
cout << "addresses" << endl;
|
||||
|
||||
// filter on addresses
|
||||
if (address != boost::none && (outTransfer->addresses.empty() || find(outTransfer->addresses.begin(), outTransfer->addresses.end(), address) == outTransfer->addresses.end())) return false; // TODO: will filter all transfers if they don't contain addresses
|
||||
if (!addresses.empty()) {
|
||||
@@ -159,6 +168,8 @@ namespace monero {
|
||||
if (!intersects) return false; // must have overlapping addresses
|
||||
}
|
||||
|
||||
cout << "subaddress indices" << endl;
|
||||
|
||||
// filter on subaddress indices
|
||||
if (subaddressIndex != boost::none && (outTransfer->subaddressIndices.empty() || find(outTransfer->subaddressIndices.begin(), outTransfer->subaddressIndices.end(), subaddressIndex) == outTransfer->subaddressIndices.end())) return false; // TODO: will filter all transfers if they don't contain subaddress indices
|
||||
if (!subaddressIndices.empty()) {
|
||||
@@ -174,6 +185,8 @@ namespace monero {
|
||||
if (!intersects) return false; // must have overlapping subaddress indices
|
||||
}
|
||||
|
||||
cout << "having destinations" << endl;
|
||||
|
||||
// filter on having destinations
|
||||
if (hasDestinations != boost::none) {
|
||||
if (*hasDestinations && outTransfer->destinations.empty()) return false;
|
||||
|
||||
Reference in New Issue
Block a user