From 5578a5da437b3575b3cb0fc49a46a9d0505aa642 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Tue, 13 May 2025 12:43:02 +0200 Subject: int -> void use sendToLedgerDeviceCallback only when needed --- impls/monero.dart/lib/src/checksum_monero.dart | 4 +- .../lib/src/generated_bindings_monero.g.dart | 6 +-- impls/monero.ts/checksum_monero.ts | 4 +- .../src/main/cpp/monero_checksum.h | 4 +- .../src/main/cpp/wallet2_api_c.cpp | 2 +- .../src/main/cpp/wallet2_api_c.h | 2 +- .../monero/0006-add-dummy-device-for-ledger.patch | 50 +++++++++++----------- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/impls/monero.dart/lib/src/checksum_monero.dart b/impls/monero.dart/lib/src/checksum_monero.dart index b907f7c..fdbfbaa 100644 --- a/impls/monero.dart/lib/src/checksum_monero.dart +++ b/impls/monero.dart/lib/src/checksum_monero.dart @@ -1,4 +1,4 @@ // ignore_for_file: constant_identifier_names -const String wallet2_api_c_h_sha256 = "9e80c4b59a0509aa02fbf01e8df2881b89f82225d1765bfa7856cbdbaf7af116"; -const String wallet2_api_c_cpp_sha256 = "d229507db508e574bd2badf4819a38dbead8c16a84311ad32c22c887a6003439-0232839913b13cf0ab0bb7ad25fff0c05f37d2fe"; +const String wallet2_api_c_h_sha256 = "91218f60e937753a606b1db899ee2ed66a1b02144eb2d79b950ce59804397f84"; +const String wallet2_api_c_cpp_sha256 = "282128494f3419c128dff7ed67daadd9c2ad0600d10557e829df03d9bc1ad891-0232839913b13cf0ab0bb7ad25fff0c05f37d2fe"; const String wallet2_api_c_exp_sha256 = "d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d"; diff --git a/impls/monero.dart/lib/src/generated_bindings_monero.g.dart b/impls/monero.dart/lib/src/generated_bindings_monero.g.dart index 5f5657c..81649b1 100644 --- a/impls/monero.dart/lib/src/generated_bindings_monero.g.dart +++ b/impls/monero.dart/lib/src/generated_bindings_monero.g.dart @@ -4462,7 +4462,7 @@ class MoneroC { void MONERO_Wallet_setLedgerCallback( ffi.Pointer< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer command, + ffi.Void Function(ffi.Pointer command, ffi.UnsignedInt cmd_len)>> sendToLedgerDevice, ) { @@ -4476,7 +4476,7 @@ class MoneroC { ffi.Void Function( ffi.Pointer< ffi.NativeFunction< - ffi.Int Function( + ffi.Void Function( ffi.Pointer command, ffi.UnsignedInt cmd_len)>>)>>( 'MONERO_Wallet_setLedgerCallback'); @@ -4485,7 +4485,7 @@ class MoneroC { void Function( ffi.Pointer< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer command, + ffi.Void Function(ffi.Pointer command, ffi.UnsignedInt cmd_len)>>)>(); ffi.Pointer MONERO_WalletManager_createWallet( diff --git a/impls/monero.ts/checksum_monero.ts b/impls/monero.ts/checksum_monero.ts index 0972f78..7ed01a3 100644 --- a/impls/monero.ts/checksum_monero.ts +++ b/impls/monero.ts/checksum_monero.ts @@ -1,5 +1,5 @@ export const moneroChecksum = { - wallet2_api_c_h_sha256: "9e80c4b59a0509aa02fbf01e8df2881b89f82225d1765bfa7856cbdbaf7af116", - wallet2_api_c_cpp_sha256: "d229507db508e574bd2badf4819a38dbead8c16a84311ad32c22c887a6003439-0232839913b13cf0ab0bb7ad25fff0c05f37d2fe", + wallet2_api_c_h_sha256: "91218f60e937753a606b1db899ee2ed66a1b02144eb2d79b950ce59804397f84", + wallet2_api_c_cpp_sha256: "282128494f3419c128dff7ed67daadd9c2ad0600d10557e829df03d9bc1ad891-0232839913b13cf0ab0bb7ad25fff0c05f37d2fe", wallet2_api_c_exp_sha256: "d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d", } diff --git a/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h b/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h index 4e0fb1c..d3d7414 100644 --- a/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h +++ b/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h @@ -1,6 +1,6 @@ #ifndef MONEROC_CHECKSUMS #define MONEROC_CHECKSUMS -const char * MONERO_wallet2_api_c_h_sha256 = "9e80c4b59a0509aa02fbf01e8df2881b89f82225d1765bfa7856cbdbaf7af116"; -const char * MONERO_wallet2_api_c_cpp_sha256 = "d229507db508e574bd2badf4819a38dbead8c16a84311ad32c22c887a6003439-0232839913b13cf0ab0bb7ad25fff0c05f37d2fe"; +const char * MONERO_wallet2_api_c_h_sha256 = "91218f60e937753a606b1db899ee2ed66a1b02144eb2d79b950ce59804397f84"; +const char * MONERO_wallet2_api_c_cpp_sha256 = "282128494f3419c128dff7ed67daadd9c2ad0600d10557e829df03d9bc1ad891-0232839913b13cf0ab0bb7ad25fff0c05f37d2fe"; const char * MONERO_wallet2_api_c_exp_sha256 = "d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d"; #endif diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp index aa08270..fce37c4 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp +++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp @@ -2156,7 +2156,7 @@ void MONERO_Wallet_setDeviceSendData(unsigned char* data, size_t len) { DEBUG_END() } -void MONERO_Wallet_setLedgerCallback(int (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len)) { +void MONERO_Wallet_setLedgerCallback(void (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len)) { DEBUG_START() Monero::Wallet::setLedgerCallback(sendToLedgerDevice); DEBUG_END() diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h index f5fc460..580e746 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h +++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h @@ -841,7 +841,7 @@ extern ADDAPI bool MONERO_Wallet_getWaitsForDeviceSend(); extern ADDAPI bool MONERO_Wallet_getWaitsForDeviceReceive(); extern ADDAPI void MONERO_Wallet_setDeviceReceivedData(unsigned char* data, size_t len); extern ADDAPI void MONERO_Wallet_setDeviceSendData(unsigned char* data, size_t len); -extern ADDAPI void MONERO_Wallet_setLedgerCallback(int (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len)); +extern ADDAPI void MONERO_Wallet_setLedgerCallback(void (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len)); // }; // struct WalletManager diff --git a/patches/monero/0006-add-dummy-device-for-ledger.patch b/patches/monero/0006-add-dummy-device-for-ledger.patch index 42bfd76..6a332c6 100644 --- a/patches/monero/0006-add-dummy-device-for-ledger.patch +++ b/patches/monero/0006-add-dummy-device-for-ledger.patch @@ -197,7 +197,7 @@ index 000000000..01e6fc7b7 +size_t hw::io::device_io_dummy::receivedFromDeviceLength = 0; +bool hw::io::device_io_dummy::waitsForDeviceSend = false; +bool hw::io::device_io_dummy::waitsForDeviceReceive = false; -+int (*hw::io::device_io_dummy::sendToLedgerDeviceCallback)(unsigned char *command, unsigned int cmd_len) = nullptr; ++void (*hw::io::device_io_dummy::sendToLedgerDeviceCallback)(unsigned char *command, unsigned int cmd_len) = nullptr; +std::mutex hw::io::device_io_dummy::mutex; +std::condition_variable hw::io::device_io_dummy::cv_send; +std::condition_variable hw::io::device_io_dummy::cv_receive; @@ -249,25 +249,25 @@ index 000000000..01e6fc7b7 + if (sendToLedgerDeviceCallback != nullptr) { + MDEBUG("exchange(): calling sendToLedgerDeviceCallback"); + sendToLedgerDeviceCallback(command, cmd_len); -+ } -+ -+ MDEBUG("exchange(): waitsForDeviceSend"); -+ // Wait for the send flag to be cleared by external code -+ while (waitsForDeviceSend) { -+ cv_send.wait(lock); -+ MDEBUG("exchange(): waitsForDeviceSend notified"); -+ } -+ -+ MDEBUG("exchange(): waitsForDeviceReceive"); -+ // Wait for the receive flag to be cleared by external code -+ while (waitsForDeviceReceive) { -+ cv_receive.wait(lock); -+ MDEBUG("exchange(): waitsForDeviceReceive notified"); -+ } -+ -+ if (receivedFromDeviceLength > max_resp_len) { -+ MDEBUG("exchange(): receivedFromDeviceLength ("< max_resp_len) { ++ MDEBUG("exchange(): receivedFromDeviceLength ("<