|
517 | 517 | ]
|
518 | 518 | },
|
519 | 519 |
|
| 520 | + { |
| 521 | + "path": "/tests/UnitTests/TestWalletService.cpp", |
| 522 | + "changes": [ |
| 523 | + { |
| 524 | + "action": "add_above", |
| 525 | + "marker": "virtual void deleteAddress(const std::string& address) override { }", |
| 526 | + "parameters": { |
| 527 | + "text": [ |
| 528 | + " virtual std::vector<CryptoNote::TransactionDetails> getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const override { return {}; }", |
| 529 | + " virtual std::vector<Crypto::PublicKey> extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const override { return {}; }" |
| 530 | + ] |
| 531 | + } |
| 532 | + } |
| 533 | + ] |
| 534 | + }, |
| 535 | + { |
| 536 | + "path": "/include/IWallet.h", |
| 537 | + "changes": [ |
| 538 | + { |
| 539 | + "action": "add_below", |
| 540 | + "marker": "#include \"CryptoNote.h\"", |
| 541 | + "parameters": { |
| 542 | + "text": [ |
| 543 | + "#include \"BlockchainExplorerData.h\"" |
| 544 | + ] |
| 545 | + } |
| 546 | + }, |
| 547 | + { |
| 548 | + "action": "add_below", |
| 549 | + "marker": "virtual std::vector<TransactionsInBlockInfo> getTransactions(uint32_t blockIndex, size_t count) const = 0;", |
| 550 | + "parameters": { |
| 551 | + "text": [ |
| 552 | + "virtual std::vector<CryptoNote::TransactionDetails> getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const = 0;", |
| 553 | + "virtual std::vector<Crypto::PublicKey> extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const = 0;" |
| 554 | + ] |
| 555 | + } |
| 556 | + } |
| 557 | + ] |
| 558 | + }, |
| 559 | + { |
| 560 | + "path": "/src/Wallet/WalletGreen.h", |
| 561 | + "changes": [ |
| 562 | + { |
| 563 | + "action": "add_below", |
| 564 | + "marker": "virtual std::vector<TransactionsInBlockInfo> getTransactions(uint32_t blockIndex, size_t count) const override;", |
| 565 | + "parameters": { |
| 566 | + "text": [ |
| 567 | + "virtual std::vector<CryptoNote::TransactionDetails> getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const override;", |
| 568 | + "virtual std::vector<Crypto::PublicKey> extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const override;" |
| 569 | + ] |
| 570 | + } |
| 571 | + } |
| 572 | + ] |
| 573 | + }, |
| 574 | + |
520 | 575 |
|
521 | 576 | {
|
522 | 577 | "path": "/src/Wallet/WalletGreen.cpp",
|
523 | 578 | "changes": [
|
| 579 | + { |
| 580 | + "action": "add_above", |
| 581 | + "marker": "std::vector<TransactionsInBlockInfo> WalletGreen::getTransactions(const Crypto::Hash& blockHash, size_t count) const {", |
| 582 | + "parameters": { |
| 583 | + "text": [ |
| 584 | + "std::vector<CryptoNote::TransactionDetails> WalletGreen::getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const {", |
| 585 | + " std::vector<TransactionDetails> txs;", |
| 586 | + " System::Event requestFinished(m_dispatcher);", |
| 587 | + " std::error_code getTxsError;", |
| 588 | + "", |
| 589 | + " throwIfStopped();", |
| 590 | + "", |
| 591 | + " m_logger(DEBUGGING) << \"Requesting transactions details\";", |
| 592 | + " System::RemoteContext<void> getTransactionsContext(m_dispatcher, [this, txHashes, &txs, &requestFinished, &getTxsError] () mutable {", |
| 593 | + " m_node.getTransactions(txHashes, txs, [&requestFinished, &getTxsError, this] (std::error_code ec) mutable {", |
| 594 | + " getTxsError = ec;", |
| 595 | + " m_dispatcher.remoteSpawn(std::bind(asyncRequestCompletion, std::ref(requestFinished)));", |
| 596 | + " });", |
| 597 | + " });", |
| 598 | + " getTransactionsContext.get();", |
| 599 | + " requestFinished.wait();", |
| 600 | + "", |
| 601 | + " if (getTxsError) {", |
| 602 | + " m_logger(ERROR, BRIGHT_RED) << \"Failed to get transactions: \" << getTxsError << \", \" << getTxsError.message();", |
| 603 | + " throw std::system_error(getTxsError);", |
| 604 | + " }", |
| 605 | + "", |
| 606 | + " m_logger(DEBUGGING) << \"Transactions details received\";", |
| 607 | + "", |
| 608 | + " return txs;", |
| 609 | + "}", |
| 610 | + "", |
| 611 | + "std::vector<Crypto::PublicKey> WalletGreen::extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const {", |
| 612 | + " std::vector<Crypto::PublicKey> mixin_outputs;", |
| 613 | + " System::Event requestFinished(m_dispatcher);", |
| 614 | + " std::error_code extractKeysError;", |
| 615 | + "", |
| 616 | + " throwIfStopped();", |
| 617 | + "", |
| 618 | + " m_logger(DEBUGGING) << \"Requesting transactions details\";", |
| 619 | + " System::RemoteContext<void> getTransactionsContext(m_dispatcher, [this, amount, absolute_offsets, &mixin_outputs, &requestFinished, &extractKeysError] () mutable {", |
| 620 | + " m_node.extractKeyOutputKeys(amount, absolute_offsets, mixin_outputs, [&requestFinished, &extractKeysError, this] (std::error_code ec) mutable {", |
| 621 | + " extractKeysError = ec;", |
| 622 | + " m_dispatcher.remoteSpawn(std::bind(asyncRequestCompletion, std::ref(requestFinished)));", |
| 623 | + " });", |
| 624 | + " });", |
| 625 | + " getTransactionsContext.get();", |
| 626 | + " requestFinished.wait();", |
| 627 | + "", |
| 628 | + " if (extractKeysError) {", |
| 629 | + " m_logger(ERROR, BRIGHT_RED) << \"Failed to get key output keys: \" << extractKeysError << \", \" << extractKeysError.message();", |
| 630 | + " throw std::system_error(extractKeysError);", |
| 631 | + " }", |
| 632 | + "", |
| 633 | + " m_logger(DEBUGGING) << \"Key output keys received\";", |
| 634 | + "", |
| 635 | + " return mixin_outputs;", |
| 636 | + "}", |
| 637 | + "" |
| 638 | + ] |
| 639 | + } |
| 640 | + }, |
524 | 641 | {
|
525 | 642 | "action": "replace",
|
526 | 643 | "marker": "assert(it->second.amount != 0);",
|
|
657 | 774 | "marker": "std::vector<PaymentService::TransactionsInBlockRpcInfo> convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(",
|
658 | 775 | "parameters": {
|
659 | 776 | "text": [
|
660 |
| - "std::vector<PaymentService::TransactionsInBlockRpcInfo> convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(CryptoNote::INode& node, const std::unordered_set<std::string> addresses," |
| 777 | + "std::vector<PaymentService::TransactionsInBlockRpcInfo> convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(CryptoNote::IWallet& wallet, const std::unordered_set<std::string> addresses," |
661 | 778 | ]
|
662 | 779 | }
|
663 | 780 | },
|
|
666 | 783 | "marker": "PaymentService::TransactionRpcInfo convertTransactionWithTransfersToTransactionRpcInfo(",
|
667 | 784 | "parameters": {
|
668 | 785 | "text": [
|
669 |
| - "PaymentService::TransactionRpcInfo convertTransactionWithTransfersToTransactionRpcInfo(CryptoNote::INode& node, const std::unordered_set<std::string> addresses," |
| 786 | + "PaymentService::TransactionRpcInfo convertTransactionWithTransfersToTransactionRpcInfo(CryptoNote::IWallet& wallet, const std::unordered_set<std::string> addresses," |
670 | 787 | ]
|
671 | 788 | }
|
672 | 789 | },
|
|
684 | 801 | "marker": "return convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(filteredTransactions);",
|
685 | 802 | "parameters": {
|
686 | 803 | "text": [
|
687 |
| - " return convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(node, filter.addresses, filteredTransactions);" |
| 804 | + " return convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(wallet, filter.addresses, filteredTransactions);" |
688 | 805 | ]
|
689 | 806 | }
|
690 | 807 | },
|
|
693 | 810 | "marker": "PaymentService::TransactionRpcInfo transactionInfo = convertTransactionWithTransfersToTransactionRpcInfo(transactionWithTransfers);",
|
694 | 811 | "parameters": {
|
695 | 812 | "text": [
|
696 |
| - " PaymentService::TransactionRpcInfo transactionInfo = convertTransactionWithTransfersToTransactionRpcInfo(node, addresses, transactionWithTransfers, known_outputs_keys);" |
697 |
| - ] |
698 |
| - } |
699 |
| - }, |
700 |
| - |
701 |
| - |
702 |
| - { |
703 |
| - "action": "add_below", |
704 |
| - "marker": "std::vector<PaymentService::TransactionsInBlockRpcInfo> rpcBlocks;", |
705 |
| - "parameters": { |
706 |
| - "text": [ |
707 |
| - " std::cout << \"here\" << std::endl;" |
| 813 | + " PaymentService::TransactionRpcInfo transactionInfo = convertTransactionWithTransfersToTransactionRpcInfo(wallet, addresses, transactionWithTransfers, known_outputs_keys);" |
708 | 814 | ]
|
709 | 815 | }
|
710 | 816 | },
|
|
731 | 837 | "text": [
|
732 | 838 | " std::vector<Crypto::PublicKey> known_outputs_keys;",
|
733 | 839 | " std::unordered_set<std::string> addresses = {};",
|
734 |
| - " transaction = convertTransactionWithTransfersToTransactionRpcInfo(node, addresses, transactionWithTransfers, known_outputs_keys);" |
| 840 | + " transaction = convertTransactionWithTransfersToTransactionRpcInfo(wallet, addresses, transactionWithTransfers, known_outputs_keys);" |
735 | 841 | ]
|
736 | 842 | }
|
737 | 843 | },
|
|
743 | 849 | " std::vector<Crypto::Hash> tx_ids;",
|
744 | 850 | " tx_ids.push_back(transactionWithTransfers.transaction.hash);",
|
745 | 851 | "",
|
746 |
| - " std::vector<CryptoNote::TransactionDetails> txs;", |
747 |
| - |
748 |
| - " CryptoNote::NodeRequest request(", |
749 |
| - " [&](const CryptoNote::INode::Callback& cb) { return node.getTransactions(tx_ids, txs, cb); });", |
750 |
| - " std::error_code ec = request.performBlocking();", |
751 |
| - " if (ec) {", |
752 |
| - "// logger(Logging::ERROR) << \"Can't get transactions by hash: \" << ec.message();", |
753 |
| - " throw std::system_error(ec);", |
754 |
| - " }", |
| 852 | + " std::vector<CryptoNote::TransactionDetails> txs = wallet.getTransactionsDetails(tx_ids);", |
755 | 853 | " CryptoNote::TransactionDetails transaction = txs.front();"
|
756 | 854 | ]
|
757 | 855 | }
|
|
787 | 885 | " if (transfer.amount > 0) {",
|
788 | 886 | " std::unordered_set<std::string>::const_iterator got = addresses.find (transfer.address);",
|
789 | 887 | " if (got != addresses.end()) {",
|
790 |
| - "// if (!transfer.address.empty()) {", |
791 | 888 | " // Populate known_outputs_keys",
|
792 | 889 | " known_outputs_keys.push_back(transaction.extra.publicKey);",
|
793 | 890 | " for (const CryptoNote::TransactionInputDetails& txinput : transaction.inputs) {",
|
|
815 | 912 | " = CryptoNote::relativeOutputOffsetsToAbsolute(txin.input.outputIndexes);",
|
816 | 913 | "",
|
817 | 914 | " // get public keys of outputs used in the mixins that match to the offests",
|
818 |
| - " std::vector<Crypto::PublicKey> mixin_outputs;", |
819 |
| - "", |
820 |
| - "", |
821 |
| - " CryptoNote::NodeRequest request(", |
822 |
| - " [&](const CryptoNote::INode::Callback& cb) { return node.extractKeyOutputKeys(txin.input.amount, absolute_offsets, mixin_outputs, cb); });", |
823 |
| - " std::error_code ec = request.performBlocking();", |
824 |
| - " if (ec) {", |
825 |
| - " // logger(Logging::ERROR) << \"Can't get mixins key images: \" << ec.message();", |
826 |
| - " throw std::system_error(ec);", |
827 |
| - " }", |
| 915 | + " std::vector<Crypto::PublicKey> mixin_outputs = wallet.extractKeyOutputKeys(txin.input.amount, absolute_offsets);", |
828 | 916 | " if (mixin_outputs.empty())",
|
829 | 917 | " {",
|
830 |
| - "// logger(Logging::ERROR) << \"Mixins key images not found\" << endl;", |
831 | 918 | " continue;",
|
832 | 919 | " }",
|
833 | 920 | "",
|
|
843 | 930 | " Crypto::PublicKey output_publicKey = mixin_outputs.at(count);",
|
844 | 931 | " // check here for known keys",
|
845 | 932 | " if (!(std::find(known_outputs_keys.begin(), known_outputs_keys.end(), output_publicKey) != known_outputs_keys.end())) {",
|
846 |
| - "// TODO: this slow is down for some reason", |
847 | 933 | " ++count;",
|
848 | 934 | " continue;",
|
849 | 935 | " }",
|
|
917 | 1003 | "description": "Adding extractKeyOutputKeys to INode",
|
918 | 1004 | "path": "/src/InProcessNode/InProcessNode.cpp",
|
919 | 1005 | "changes": [
|
| 1006 | + { |
| 1007 | + "action": "add_above", |
| 1008 | + "marker": "#include <future>", |
| 1009 | + "parameters": { |
| 1010 | + "text": [ |
| 1011 | + "//remove", |
| 1012 | + "#include <iostream>" |
| 1013 | + ] |
| 1014 | + } |
| 1015 | + }, |
920 | 1016 | {
|
921 | 1017 | "action": "add_above",
|
922 | 1018 | "marker": "void InProcessNode::getTransactions(const std::vector<Crypto::Hash>& transactionHashes,",
|
|
1179 | 1275 | }
|
1180 | 1276 | ]
|
1181 | 1277 | },
|
1182 |
| - |
1183 |
| - |
1184 | 1278 | {
|
1185 | 1279 | "description": "Adding extractKeyOutputKeys to INode",
|
1186 | 1280 | "path": "/tests/UnitTests/ICoreStub.h",
|
|
1271 | 1365 |
|
1272 | 1366 |
|
1273 | 1367 | {
|
1274 |
| - "description": "Adding extractKeyOutputKeys to INode. ", |
| 1368 | + "description": "Adding extractKeyOutputKeys to INode", |
1275 | 1369 | "path": "/src/CryptoNoteCore/IBlockchainCache.h",
|
1276 | 1370 | "changes": [
|
1277 | 1371 | {
|
|
1287 | 1381 | ]
|
1288 | 1382 | },
|
1289 | 1383 | {
|
1290 |
| - "description": "Adding extractKeyOutputKeys to INode. ", |
| 1384 | + "description": "Adding extractKeyOutputKeys to INode", |
1291 | 1385 | "path": "/src/CryptoNoteCore/BlockchainCache.h",
|
1292 | 1386 | "changes": [
|
1293 | 1387 | {
|
|
1303 | 1397 | ]
|
1304 | 1398 | },
|
1305 | 1399 | {
|
1306 |
| - "description": "Adding extractKeyOutputKeys to INode. ", |
| 1400 | + "description": "Adding extractKeyOutputKeys to INode", |
1307 | 1401 | "path": "/src/CryptoNoteCore/DatabaseBlockchainCache.h",
|
1308 | 1402 | "changes": [
|
1309 | 1403 | {
|
|
1322 | 1416 | ]
|
1323 | 1417 | },
|
1324 | 1418 | {
|
1325 |
| - "description": "Adding extractKeyOutputKeys to INode. ", |
| 1419 | + "description": "Adding extractKeyOutputKeys to INode", |
1326 | 1420 | "path": "/src/CryptoNoteCore/BlockchainCache.cpp",
|
1327 | 1421 | "changes": [
|
1328 | 1422 | {
|
|
1359 | 1453 | ]
|
1360 | 1454 | },
|
1361 | 1455 | {
|
1362 |
| - "description": "Adding extractKeyOutputKeys to INode. ", |
| 1456 | + "description": "Adding extractKeyOutputKeys to INode", |
1363 | 1457 | "path": "/src/CryptoNoteCore/DatabaseBlockchainCache.cpp",
|
1364 | 1458 | "changes": [
|
1365 | 1459 | {
|
|
0 commit comments