From 90771ebb5987645a35e48a43a8ba89bbddd430e3 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Wed, 31 Aug 2022 04:11:29 +0200 Subject: [PATCH] fix(xmr): fix tx sending to an integrated address --- ci/shell.nix | 4 ++-- core/.changelog.d/2213.fixed.1 | 1 + core/tests/run_tests_device_emu_monero.sh | 4 ++-- core/tests/test_apps.monero.crypto.py | 17 +++++++++++++++++ crypto/monero/base58.c | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 core/.changelog.d/2213.fixed.1 diff --git a/ci/shell.nix b/ci/shell.nix index 6ee6e9584..6f5a3f1d2 100644 --- a/ci/shell.nix +++ b/ci/shell.nix @@ -19,8 +19,8 @@ let sha256 = "02s3qkb6kz3ndyx7rfndjbvp4vlwiqc42fxypn3g6jnc0v5jyz95"; }) { }; moneroTests = nixpkgs.fetchurl { - url = "https://github.com/ph4r05/monero/releases/download/v0.17.3.2-dev-tests-u18.04-03/trezor_tests"; - sha256 = "3280aeef795baf2fc46687c07ac4131e5a18767ecdd3af83cf17823ebb2d1007"; + url = "https://github.com/ph4r05/monero/releases/download/v0.18.1.0-dev-tests-u18.04-01/trezor_tests"; + sha256 = "7a8bab583d5f2f06f092ea297b1417008f20c1c5ca23c74e0eb11660068dead9"; }; moneroTestsPatched = nixpkgs.runCommandCC "monero_trezor_tests" {} '' cp ${moneroTests} $out diff --git a/core/.changelog.d/2213.fixed.1 b/core/.changelog.d/2213.fixed.1 new file mode 100644 index 000000000..34b4ade7e --- /dev/null +++ b/core/.changelog.d/2213.fixed.1 @@ -0,0 +1 @@ +Fix sending XMR transaction to an integrated address diff --git a/core/tests/run_tests_device_emu_monero.sh b/core/tests/run_tests_device_emu_monero.sh index dae62ce0a..c491dfffb 100755 --- a/core/tests/run_tests_device_emu_monero.sh +++ b/core/tests/run_tests_device_emu_monero.sh @@ -23,8 +23,8 @@ fi # When updating URL and sha256sum also update the URL in ci/shell.nix. error=1 -: "${TREZOR_MONERO_TESTS_URL:=https://github.com/ph4r05/monero/releases/download/v0.17.3.2-dev-tests-u18.04-03/trezor_tests}" -: "${TREZOR_MONERO_TESTS_SHA256SUM:=3280aeef795baf2fc46687c07ac4131e5a18767ecdd3af83cf17823ebb2d1007}" +: "${TREZOR_MONERO_TESTS_URL:=https://github.com/ph4r05/monero/releases/download/v0.18.1.0-dev-tests-u18.04-01/trezor_tests}" +: "${TREZOR_MONERO_TESTS_SHA256SUM:=7a8bab583d5f2f06f092ea297b1417008f20c1c5ca23c74e0eb11660068dead9}" : "${TREZOR_MONERO_TESTS_PATH:=$CORE_DIR/tests/trezor_monero_tests}" : "${TREZOR_MONERO_TESTS_LOG:=$CORE_DIR/tests/trezor_monero_tests.log}" : "${TREZOR_MONERO_TESTS_CHAIN:=$CORE_DIR/tests/trezor_monero_tests.chain}" diff --git a/core/tests/test_apps.monero.crypto.py b/core/tests/test_apps.monero.crypto.py index f3eff8aec..e200dc91b 100644 --- a/core/tests/test_apps.monero.crypto.py +++ b/core/tests/test_apps.monero.crypto.py @@ -1,6 +1,7 @@ from common import * if not utils.BITCOIN_ONLY: + from trezor.crypto import monero as tcry from trezor.enums import MoneroNetworkType from apps.monero.xmr import crypto, crypto_helpers, monero from apps.monero.xmr.addresses import encode_addr @@ -153,6 +154,22 @@ class TestMoneroCrypto(unittest.TestCase): b"bcf365a551e6358f3f281a6241d4a25eded60230b60a1d48c67b51a85e33d70e", ) + def test_addr_encode(self): + addr_exp = "4LL9oSLmtpccfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2bYXZKKQePHES9khPK" + addr = tcry.xmr_base58_addr_encode_check( + 19, + unhexlify(b"eda9fe8dfcdd25d5430ea64229d04f6b41b2e5a1587c29cd499a63eb79d117113076a02b73d130fb904c9e91075fcd16f735c6850dfadb125eb826d96a113f098a125052fe6f3877")) + + addr2 = encode_addr( + bytes([19]), + unhexlify(b"eda9fe8dfcdd25d5430ea64229d04f6b41b2e5a1587c29cd499a63eb79d11711"), + unhexlify(b"3076a02b73d130fb904c9e91075fcd16f735c6850dfadb125eb826d96a113f09"), + unhexlify(b"8a125052fe6f3877") + ) + + self.assertEqual(addr, addr_exp) + self.assertEqual(addr2, addr_exp) + def test_wallet_addr(self): addr = encode_addr( net_version(), diff --git a/crypto/monero/base58.c b/crypto/monero/base58.c index 2f33cff58..14ec8279a 100644 --- a/crypto/monero/base58.c +++ b/crypto/monero/base58.c @@ -48,7 +48,7 @@ const size_t encoded_block_sizes[] = { const size_t full_block_size = sizeof(encoded_block_sizes) / sizeof(encoded_block_sizes[0]) - 1; const size_t addr_checksum_size = 4; -const size_t max_bin_data_size = 64; +const size_t max_bin_data_size = 72; const int decoded_block_sizes[] = {0, -1, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8}; #define reverse_alphabet(letter) ((int8_t)b58digits_map[(int)letter])