forked from jl777/SuperNET
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement TX history V2 for UTXO coins activated with a Hardware wallet
#964 (#1467) * Refactor `BchAndSlpTxHistory` making it generic over `Coin` type * Add `UtxoTxHistoryOps`, implement it for `BchCoin` * Remove `UtxoStandardOps` implementation for `BchCoin` * TODO implement `WaitForHistoryUpdateTrigger` state * Implement `UtxoTxHistoryOps` and `CoinWithTxHistoryV2` for `UtxoStandardCoin` * Add `taget: MyTxHistoryTarget` field to `my_tx_history` request * Add `utxo_common/utxo_tx_history_common.rs` for TX history related common impl * Add `HDWalletCoinOps::derive_known_addresses` * Refactor `GetTxHistoryFilters` by requiring to set `from_addresses` * Fix `tx_history_v2_tests` * Start history background fetching on UTXO/QTUM coin initialization * Implement `UtxoTxHistoryOps` and `CoinWithTxHistoryV2` for `QtumCoin` * Implement * Implement `WaitForHistoryUpdateTrigger` state * Add `ElectrumClient::scripthash_get_history_batch` * Implement `UtxoTxHistoryOps::request_tx_history` according to `DerivationMethod` * Add `CoinBalanceReportOps` trait * Don't spawn legacy tx_history loop on `init_utxo`, `init_qtum` RPCs * Rename `EnableCoinBalance` to `CoinBalanceReport` * Add `UtxoTxHistoryV2::my_addresses` to optimize `tx_details_by_hash` * Rename `utxo_tx_history_common.rs` to `utxo_tx_history_v2_common.rs` * Implement `UtxoTxHistoryOps::tx_details_by_hash` optimized for TX history V2 * Add `UtxoTxHistoryOps::tx_from_storage_or_rpc` * Fix `CoinWithTxHistoryV2::get_tx_history_filters`, `UtxoTxHistoryOps::request_tx_history` * Add `UtxoTxHistoryError` * Test `UtxoTxHistoryOps::tx_details_by_hash` along with `UtxoStandardOps::tx_details_by_hash` * Final refactoring * Add `UtxoMyAddressesHistoryError` for `UtxoTxHistoryOps::my_addresses` * Optimize `UtxoTxHistoryOps::request_tx_history` by passing `my_addresses` argument * Fix fmt * Fix `test_bch_and_slp_testnet_history` test * Fix compile error * Refactor BCH to fix `test_bch_and_slp_testnet_history` * Use `utxo_common::request_tx_history` for `BchCoin` instead of `utxo_tx_history_v2_common`'s * Fix PR issues * Optimize TX history states by specifying `FetchingTxHashes::fetch_for_addresses` * Rename `UtxoTxHistoryOps::get_addresses_balances` to `my_addresses_balances` * Add `UtxoTxHistoryOps::address_from_str` to parse addresses within `UtxoTxHistoryOps::my_addresses_balances` result * Add `AddrFromStrError` * Add `for_addresses` argument to the `unique_tx_hashes_num_in_history` function * Add `SqlQuery::count_distinct` * Add `for_addresses` argument to the `history_contains_unconfirmed_txes` and `get_unconfirmed_txes_from_history` functions * Minor changes * Add `test_hd_utxo_tx_history` native and WASM test * Fix `SqlTxHistoryStorage` to repeat the same ordering as in `compare_transaction_details` * Fix tests * Use `utxo_common::utxo_tx_history_v2_common::request_tx_history` within for BCH coin * Move `utxo_coin_fields_for_test` to `utxo_common_tests.rs` * Add `test_bch_and_slp_testnet_history` in WASM * Add `T_BCH_ELECTRUMS` listening on WSS port * Ignore `solana_prerequisites` test * Skip serializing of `ElectrumRpcRequest::protocol` if it's None * Add timeout to `wait_till_history_has_records` helper * Fix ETH tests * Fix `test_convert_segwit_address` and `test_validateaddress_segwit`
- Loading branch information
1 parent
f305594
commit 36392fd
Showing
47 changed files
with
2,906 additions
and
1,028 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
mm2src/coins/for_tests/MORTY_HD_tx_history_fixtures.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
[ | ||
{ | ||
"tx_hex": "0400008085202f890189cb3d4e9d36a7c2c6bb1b76dcfc1ee7c9d3d83b364c50a3f3a791c5efb6f392030000006b483045022100a0b910ecbf5ed1c473507c3e1a5a06ad612c982d3204d2dc066bfbbeb39c5e400220559a82d151cbcdcb097786127f499863e0864662519a9caf758c929f1659bc34012102d09f2cb1693be9c0ea73bb48d45ce61805edd1c43590681b02f877206078a5b3ffffffff0400e1f505000000001976a914ab19b1f2bd2337a58c1b5d198468951ac42d796788ac00c2eb0b000000001976a914ab19b1f2bd2337a58c1b5d198468951ac42d796788aca01f791c000000001976a914ab19b1f2bd2337a58c1b5d198468951ac42d796788ac3091cce2e80000001976a91490a0d8ba62c339ade97a14e81b6f531de03fdbb288ac00000000000000000000000000000000000000", | ||
"tx_hash": "6ca27dd058b939c98a33625b9f68eaeebca5a3058aec062647ca6fd7634bb339", | ||
"from": [ | ||
"RNTv4xTLLm26p3SvsQCBy9qNK7s1RgGYSB" | ||
], | ||
"to": [ | ||
"RNTv4xTLLm26p3SvsQCBy9qNK7s1RgGYSB", | ||
"RQstQeTUEZLh6c3YWJDkeVTTQoZUsfvNCr" | ||
], | ||
"total_amount": "10010.1518", | ||
"spent_by_me": "0", | ||
"received_by_me": "7.777", | ||
"my_balance_change": "7.777", | ||
"block_height": 1629306, | ||
"timestamp": 1663619097, | ||
"fee_details": { | ||
"type": "Utxo", | ||
"coin": "MORTY", | ||
"amount": "0.0001" | ||
}, | ||
"coin": "MORTY", | ||
"internal_id": "6ca27dd058b939c98a33625b9f68eaeebca5a3058aec062647ca6fd7634bb339", | ||
"transaction_type": "StandardTransfer", | ||
"confirmations": 4 | ||
}, | ||
{ | ||
"tx_hex": "0400008085202f89011b8746195a7e80172d948e1eb7f2d6710bd2ecbe7750e653bb8d345b940da55b030000006a4730440220482c7a7762977ed3a8afcf751b7413d5ef978f604e550eb4fd35199e1f4d52400220486fb4f3831a7f512dba1271a4f793e7050ea123bcb4922e3848bb18c7cac4c4012102d09f2cb1693be9c0ea73bb48d45ce61805edd1c43590681b02f877206078a5b3ffffffff0400e1f505000000001976a914bd658bdd369c8bb98ac837071639819e5f8dd3cb88ac00c2eb0b000000001976a914bd658bdd369c8bb98ac837071639819e5f8dd3cb88aca01f791c000000001976a914bd658bdd369c8bb98ac837071639819e5f8dd3cb88acf037389ce90000001976a91490a0d8ba62c339ade97a14e81b6f531de03fdbb288ac00000000000000000000000000000000000000", | ||
"tx_hash": "70c62f42d65f9d71a8fb7f4560057b80dc2ecd9e4990621323faf1de9a53ca97", | ||
"from": [ | ||
"RNTv4xTLLm26p3SvsQCBy9qNK7s1RgGYSB" | ||
], | ||
"to": [ | ||
"RNTv4xTLLm26p3SvsQCBy9qNK7s1RgGYSB", | ||
"RSYdSLRYWuzBson2GDbWBa632q2PmFnCaH" | ||
], | ||
"total_amount": "10041.2602", | ||
"spent_by_me": "0", | ||
"received_by_me": "7.777", | ||
"my_balance_change": "7.777", | ||
"block_height": 1617702, | ||
"timestamp": 1662914954, | ||
"fee_details": { | ||
"type": "Utxo", | ||
"coin": "MORTY", | ||
"amount": "0.0001" | ||
}, | ||
"coin": "MORTY", | ||
"internal_id": "70c62f42d65f9d71a8fb7f4560057b80dc2ecd9e4990621323faf1de9a53ca97", | ||
"transaction_type": "StandardTransfer", | ||
"confirmations": 11603 | ||
}, | ||
{ | ||
"tx_hex": "0400008085202f890175fb4250e95dc0c89cd89a9487324aa8dd7a2f8fd8581fc90881567ca6be02bf000000006b483045022100be3e58c5d4dbe5ea35ab831d610b42bb1ae01fc0df1786f11cbe6969d8d45c6302207b8747b4012a6c4aefecf670eaf8d787445909ebd7775b85c77d723e9d6445a8012103f7f831c6fbe62b987e4b2f455e5b7f27375cf59b57eb3ffa9e122b2c9b395f6bffffffff0200e1f505000000001976a914c23136f831b15dd4522eb1c6eb4c5cd3abbfbe3b88aca8b66428000000001976a914bd658bdd369c8bb98ac837071639819e5f8dd3cb88ac00000000000000000000000000000000000000", | ||
"tx_hash": "bd031dc681cdc63491fd71902c5960985127b04eb02211a1049bff0d0c8ebce3", | ||
"from": [ | ||
"RPj9JXUVnewWwVpxZDeqGB25qVqz5qJzwP" | ||
], | ||
"to": [ | ||
"RSYdSLRYWuzBson2GDbWBa632q2PmFnCaH", | ||
"RSyz8EJaTzhkT6uZinAtHhFu5bfsvqcLqg" | ||
], | ||
"total_amount": "7.77699", | ||
"spent_by_me": "7.77699", | ||
"received_by_me": "6.77689", | ||
"my_balance_change": "-1.00010", | ||
"block_height": 1499070, | ||
"timestamp": 1655738171, | ||
"fee_details": { | ||
"type": "Utxo", | ||
"coin": "MORTY", | ||
"amount": "0.0001" | ||
}, | ||
"coin": "MORTY", | ||
"internal_id": "bd031dc681cdc63491fd71902c5960985127b04eb02211a1049bff0d0c8ebce3", | ||
"transaction_type": "StandardTransfer", | ||
"confirmations": 130235 | ||
}, | ||
{ | ||
"tx_hex": "0400008085202f89038dea273bcc9194a80b19ea1a8ca076d3d00c590b4571808f10f3eee5aa38c07d000000006b483045022100ff31b7c36145dc9fa06346fe38b75b81273b41b7d236b900322154ba136799bb02204ddd253eb93e95c9d24f8e36a8a5a42022c63d6edd81c453f24cbb5db785037d012102d6a78b71b10459bd0757a614ca1eef62f4a65514225d10e95df31ee9cb23ffd5ffffffff8dea273bcc9194a80b19ea1a8ca076d3d00c590b4571808f10f3eee5aa38c07d010000006a47304402202d3e0fd3ce7b4753725adc0175a050c919f93b564682ffd8d65974c15996b3560220211b8120acb3ad80dbdd9160f639884f0e15c0c5703c86c069b3abe85cb6c4fd012102d6a78b71b10459bd0757a614ca1eef62f4a65514225d10e95df31ee9cb23ffd5ffffffff8dea273bcc9194a80b19ea1a8ca076d3d00c590b4571808f10f3eee5aa38c07d020000006b483045022100c788b064db34e961479393bad19d8c5f7d437b02c64c3172381fbe2b7d104efd022027167b2e5a6f29a7567e43b39a3d5b8f50c20767162ec29328067a6fcbd87409012102d6a78b71b10459bd0757a614ca1eef62f4a65514225d10e95df31ee9cb23ffd5ffffffff01b8be5a2e000000001976a9149e7a424abb2f341d655ce6af1143409edef4d55588acbdb1d661000000000000000000000000000000", | ||
"tx_hash": "bf02bea67c568108c91f58d88f2f7adda84a3287949ad89cc8c05de95042fb75", | ||
"from": [ | ||
"RYM6yDMn8vdqtkYKLzY5dNe7p3T6YmMWvq" | ||
], | ||
"to": [ | ||
"RPj9JXUVnewWwVpxZDeqGB25qVqz5qJzwP" | ||
], | ||
"total_amount": "7.777", | ||
"spent_by_me": "7.777", | ||
"received_by_me": "7.77699", | ||
"my_balance_change": "-0.00001", | ||
"block_height": 1263905, | ||
"timestamp": 1641460263, | ||
"fee_details": { | ||
"type": "Utxo", | ||
"coin": "MORTY", | ||
"amount": "0.00001" | ||
}, | ||
"coin": "MORTY", | ||
"internal_id": "bf02bea67c568108c91f58d88f2f7adda84a3287949ad89cc8c05de95042fb75", | ||
"transaction_type": "StandardTransfer", | ||
"confirmations": 365400 | ||
}, | ||
{ | ||
"tx_hex": "0400008085202f8901fe0ccc272929c811b20ab910f5478a99229a5304480b5897cf9507149a044c63030000006b483045022100c5b24fbd1ce11736760ebc0edccad6bde2dcbbff090528db4602a485a5ec645f02201340e5f818b9d7ab75e39abaacaa5d94c03fdb8e41698182eeff389a45c5ad15012102d09f2cb1693be9c0ea73bb48d45ce61805edd1c43590681b02f877206078a5b3ffffffff0400e1f505000000001976a914fd084ad97ae0313bba5717acedfba629b8bd426988ac00c2eb0b000000001976a914fd084ad97ae0313bba5717acedfba629b8bd426988aca01f791c000000001976a914fd084ad97ae0313bba5717acedfba629b8bd426988ac40053045260100001976a91490a0d8ba62c339ade97a14e81b6f531de03fdbb288ac00000000000000000000000000000000000000", | ||
"tx_hash": "7dc038aae5eef3108f8071450b590cd0d376a08c1aea190ba89491cc3b27ea8d", | ||
"from": [ | ||
"RNTv4xTLLm26p3SvsQCBy9qNK7s1RgGYSB" | ||
], | ||
"to": [ | ||
"RNTv4xTLLm26p3SvsQCBy9qNK7s1RgGYSB", | ||
"RYM6yDMn8vdqtkYKLzY5dNe7p3T6YmMWvq" | ||
], | ||
"total_amount": "12646.5887", | ||
"spent_by_me": "0", | ||
"received_by_me": "7.777", | ||
"my_balance_change": "7.777", | ||
"block_height": 1263875, | ||
"timestamp": 1641458818, | ||
"fee_details": { | ||
"type": "Utxo", | ||
"coin": "MORTY", | ||
"amount": "0.0001" | ||
}, | ||
"coin": "MORTY", | ||
"internal_id": "7dc038aae5eef3108f8071450b590cd0d376a08c1aea190ba89491cc3b27ea8d", | ||
"transaction_type": "StandardTransfer", | ||
"confirmations": 365430 | ||
} | ||
] |
Oops, something went wrong.