Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Better ledger dummy #90

Closed
wants to merge 10 commits into from
77 changes: 9 additions & 68 deletions impls/monero.dart/lib/monero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3279,76 +3279,17 @@ int MONERO_Wallet_getBytesSent(wallet ptr) {
return getBytesSent;
}

bool Wallet_getStateIsConnected(wallet ptr) {
debugStart?.call('MONERO_Wallet_getStateIsConnected');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getStateIsConnected(ptr);
debugEnd?.call('MONERO_Wallet_getStateIsConnected');
return ret;
}

Pointer<UnsignedChar> Wallet_getSendToDevice(wallet ptr) {
debugStart?.call('MONERO_Wallet_getSendToDevice');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getSendToDevice(ptr);
debugEnd?.call('MONERO_Wallet_getSendToDevice');
return ret;
}

int Wallet_getSendToDeviceLength(wallet ptr) {
debugStart?.call('MONERO_Wallet_getSendToDeviceLength');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getSendToDeviceLength(ptr);
debugEnd?.call('MONERO_Wallet_getSendToDeviceLength');
return ret;
}

Pointer<UnsignedChar> Wallet_getReceivedFromDevice(wallet ptr) {
debugStart?.call('MONERO_Wallet_getReceivedFromDevice');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getReceivedFromDevice(ptr);
debugEnd?.call('MONERO_Wallet_getReceivedFromDevice');
return ret;
}

int Wallet_getReceivedFromDeviceLength(wallet ptr) {
debugStart?.call('MONERO_Wallet_getReceivedFromDeviceLength');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getReceivedFromDeviceLength(ptr);
debugEnd?.call('MONERO_Wallet_getReceivedFromDeviceLength');
return ret;
}

bool Wallet_getWaitsForDeviceSend(wallet ptr) {
debugStart?.call('MONERO_Wallet_getWaitsForDeviceSend');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getWaitsForDeviceSend(ptr);
debugEnd?.call('MONERO_Wallet_getWaitsForDeviceSend');
return ret;
}

bool Wallet_getWaitsForDeviceReceive(wallet ptr) {
debugStart?.call('MONERO_Wallet_getWaitsForDeviceReceive');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_getWaitsForDeviceReceive(ptr);
debugEnd?.call('MONERO_Wallet_getWaitsForDeviceReceive');
return ret;
}

void Wallet_setDeviceReceivedData(
wallet ptr, Pointer<UnsignedChar> data, int len) {
debugStart?.call('MONERO_Wallet_setDeviceReceivedData');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_setDeviceReceivedData(ptr, data, len);
debugEnd?.call('MONERO_Wallet_setDeviceReceivedData');
return ret;
}
typedef LedgerExchangeFunction = Pointer<
NativeFunction<
Int Function(Pointer<UnsignedChar> command, UnsignedInt cmd_len,
Pointer<UnsignedChar> response, UnsignedInt max_resp_len)>>;

void Wallet_setDeviceSendData(wallet ptr, Pointer<UnsignedChar> data, int len) {
debugStart?.call('MONERO_Wallet_setDeviceSendData');
void Wallet_setLedgerExchange(
wallet ptr, LedgerExchangeFunction sendToLedgerDevice) {
konstantinullrich marked this conversation as resolved.
Show resolved Hide resolved
debugStart?.call('MONERO_Wallet_setLedgerExchange');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.MONERO_Wallet_setDeviceSendData(ptr, data, len);
debugEnd?.call('MONERO_Wallet_setDeviceSendData');
final ret = lib!.MONERO_Wallet_setLedgerExchange(ptr, sendToLedgerDevice);
debugEnd?.call('MONERO_Wallet_setLedgerExchange');
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions impls/monero.dart/lib/src/checksum_monero.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: constant_identifier_names
const String wallet2_api_c_h_sha256 = "198a27486ce4f014b737f52ec2879a90838c3b3ca088de8dc7d55b79a10f4a5b";
const String wallet2_api_c_cpp_sha256 = "22b0c9dd542fb55edfe9e17da67e97ddf5f80bcdd3e126e1bd64cce54234bde1-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const String wallet2_api_c_h_sha256 = "87ec362cdf9b3e6403d899c11e7ae39d932a8098c3ebb360723b537bded2d8de";
const String wallet2_api_c_cpp_sha256 = "32cc5fbbdb89e77f33619b7f3d942cfac4202f3a3838605a396aed3882d668b5-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const String wallet2_api_c_exp_sha256 = "c1f785d62709fd8b849063ecf4fe8854d9e3b05b568b9716de98d33e7bdaf522";
176 changes: 32 additions & 144 deletions impls/monero.dart/lib/src/generated_bindings_monero.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4384,158 +4384,46 @@ class MoneroC {
late final _MONERO_Wallet_getBytesSent = _MONERO_Wallet_getBytesSentPtr
.asFunction<int Function(ffi.Pointer<ffi.Void>)>();

bool MONERO_Wallet_getStateIsConnected(
void MONERO_Wallet_setLedgerExchange(
ffi.Pointer<ffi.Void> wallet_ptr,
ffi.Pointer<
ffi.NativeFunction<
ffi.Int Function(
ffi.Pointer<ffi.UnsignedChar> command,
ffi.UnsignedInt cmd_len,
ffi.Pointer<ffi.UnsignedChar> response,
ffi.UnsignedInt max_resp_len)>>
sendToLedgerDevice,
) {
return _MONERO_Wallet_getStateIsConnected(
return _MONERO_Wallet_setLedgerExchange(
wallet_ptr,
sendToLedgerDevice,
);
}

late final _MONERO_Wallet_getStateIsConnectedPtr =
_lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Void>)>>(
'MONERO_Wallet_getStateIsConnected');
late final _MONERO_Wallet_getStateIsConnected =
_MONERO_Wallet_getStateIsConnectedPtr.asFunction<
bool Function(ffi.Pointer<ffi.Void>)>();

ffi.Pointer<ffi.UnsignedChar> MONERO_Wallet_getSendToDevice(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _MONERO_Wallet_getSendToDevice(
wallet_ptr,
);
}

late final _MONERO_Wallet_getSendToDevicePtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.UnsignedChar> Function(
ffi.Pointer<ffi.Void>)>>('MONERO_Wallet_getSendToDevice');
late final _MONERO_Wallet_getSendToDevice =
_MONERO_Wallet_getSendToDevicePtr.asFunction<
ffi.Pointer<ffi.UnsignedChar> Function(ffi.Pointer<ffi.Void>)>();

int MONERO_Wallet_getSendToDeviceLength(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _MONERO_Wallet_getSendToDeviceLength(
wallet_ptr,
);
}

late final _MONERO_Wallet_getSendToDeviceLengthPtr =
_lookup<ffi.NativeFunction<ffi.Size Function(ffi.Pointer<ffi.Void>)>>(
'MONERO_Wallet_getSendToDeviceLength');
late final _MONERO_Wallet_getSendToDeviceLength =
_MONERO_Wallet_getSendToDeviceLengthPtr.asFunction<
int Function(ffi.Pointer<ffi.Void>)>();

ffi.Pointer<ffi.UnsignedChar> MONERO_Wallet_getReceivedFromDevice(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _MONERO_Wallet_getReceivedFromDevice(
wallet_ptr,
);
}

late final _MONERO_Wallet_getReceivedFromDevicePtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.UnsignedChar> Function(
ffi.Pointer<ffi.Void>)>>('MONERO_Wallet_getReceivedFromDevice');
late final _MONERO_Wallet_getReceivedFromDevice =
_MONERO_Wallet_getReceivedFromDevicePtr.asFunction<
ffi.Pointer<ffi.UnsignedChar> Function(ffi.Pointer<ffi.Void>)>();

int MONERO_Wallet_getReceivedFromDeviceLength(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _MONERO_Wallet_getReceivedFromDeviceLength(
wallet_ptr,
);
}

late final _MONERO_Wallet_getReceivedFromDeviceLengthPtr =
_lookup<ffi.NativeFunction<ffi.Size Function(ffi.Pointer<ffi.Void>)>>(
'MONERO_Wallet_getReceivedFromDeviceLength');
late final _MONERO_Wallet_getReceivedFromDeviceLength =
_MONERO_Wallet_getReceivedFromDeviceLengthPtr.asFunction<
int Function(ffi.Pointer<ffi.Void>)>();

bool MONERO_Wallet_getWaitsForDeviceSend(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _MONERO_Wallet_getWaitsForDeviceSend(
wallet_ptr,
);
}

late final _MONERO_Wallet_getWaitsForDeviceSendPtr =
_lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Void>)>>(
'MONERO_Wallet_getWaitsForDeviceSend');
late final _MONERO_Wallet_getWaitsForDeviceSend =
_MONERO_Wallet_getWaitsForDeviceSendPtr.asFunction<
bool Function(ffi.Pointer<ffi.Void>)>();

bool MONERO_Wallet_getWaitsForDeviceReceive(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _MONERO_Wallet_getWaitsForDeviceReceive(
wallet_ptr,
);
}

late final _MONERO_Wallet_getWaitsForDeviceReceivePtr =
_lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Void>)>>(
'MONERO_Wallet_getWaitsForDeviceReceive');
late final _MONERO_Wallet_getWaitsForDeviceReceive =
_MONERO_Wallet_getWaitsForDeviceReceivePtr.asFunction<
bool Function(ffi.Pointer<ffi.Void>)>();

void MONERO_Wallet_setDeviceReceivedData(
ffi.Pointer<ffi.Void> wallet_ptr,
ffi.Pointer<ffi.UnsignedChar> data,
int len,
) {
return _MONERO_Wallet_setDeviceReceivedData(
wallet_ptr,
data,
len,
);
}

late final _MONERO_Wallet_setDeviceReceivedDataPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Void>,
ffi.Pointer<ffi.UnsignedChar>,
ffi.Size)>>('MONERO_Wallet_setDeviceReceivedData');
late final _MONERO_Wallet_setDeviceReceivedData =
_MONERO_Wallet_setDeviceReceivedDataPtr.asFunction<
late final _MONERO_Wallet_setLedgerExchangePtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Void>,
ffi.Pointer<
ffi.NativeFunction<
ffi.Int Function(
ffi.Pointer<ffi.UnsignedChar> command,
ffi.UnsignedInt cmd_len,
ffi.Pointer<ffi.UnsignedChar> response,
ffi.UnsignedInt max_resp_len)>>)>>(
'MONERO_Wallet_setLedgerExchange');
late final _MONERO_Wallet_setLedgerExchange =
_MONERO_Wallet_setLedgerExchangePtr.asFunction<
void Function(
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.UnsignedChar>, int)>();

void MONERO_Wallet_setDeviceSendData(
ffi.Pointer<ffi.Void> wallet_ptr,
ffi.Pointer<ffi.UnsignedChar> data,
int len,
) {
return _MONERO_Wallet_setDeviceSendData(
wallet_ptr,
data,
len,
);
}

late final _MONERO_Wallet_setDeviceSendDataPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Void>,
ffi.Pointer<ffi.UnsignedChar>,
ffi.Size)>>('MONERO_Wallet_setDeviceSendData');
late final _MONERO_Wallet_setDeviceSendData =
_MONERO_Wallet_setDeviceSendDataPtr.asFunction<
void Function(
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.UnsignedChar>, int)>();
ffi.Pointer<
ffi.NativeFunction<
ffi.Int Function(
ffi.Pointer<ffi.UnsignedChar> command,
ffi.UnsignedInt cmd_len,
ffi.Pointer<ffi.UnsignedChar> response,
ffi.UnsignedInt max_resp_len)>>)>();

ffi.Pointer<ffi.Void> MONERO_WalletManager_createWallet(
ffi.Pointer<ffi.Void> wm_ptr,
Expand Down
4 changes: 2 additions & 2 deletions impls/monero.ts/checksum_monero.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const moneroChecksum = {
wallet2_api_c_h_sha256: "198a27486ce4f014b737f52ec2879a90838c3b3ca088de8dc7d55b79a10f4a5b",
wallet2_api_c_cpp_sha256: "22b0c9dd542fb55edfe9e17da67e97ddf5f80bcdd3e126e1bd64cce54234bde1-b089f9ee69924882c5d14dd1a6991deb05d9d1cd",
wallet2_api_c_h_sha256: "87ec362cdf9b3e6403d899c11e7ae39d932a8098c3ebb360723b537bded2d8de",
wallet2_api_c_cpp_sha256: "32cc5fbbdb89e77f33619b7f3d942cfac4202f3a3838605a396aed3882d668b5-b089f9ee69924882c5d14dd1a6991deb05d9d1cd",
wallet2_api_c_exp_sha256: "c1f785d62709fd8b849063ecf4fe8854d9e3b05b568b9716de98d33e7bdaf522",
}
4 changes: 2 additions & 2 deletions monero_libwallet2_api_c/src/main/cpp/monero_checksum.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef MONEROC_CHECKSUMS
#define MONEROC_CHECKSUMS
const char * MONERO_wallet2_api_c_h_sha256 = "198a27486ce4f014b737f52ec2879a90838c3b3ca088de8dc7d55b79a10f4a5b";
const char * MONERO_wallet2_api_c_cpp_sha256 = "22b0c9dd542fb55edfe9e17da67e97ddf5f80bcdd3e126e1bd64cce54234bde1-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const char * MONERO_wallet2_api_c_h_sha256 = "87ec362cdf9b3e6403d899c11e7ae39d932a8098c3ebb360723b537bded2d8de";
const char * MONERO_wallet2_api_c_cpp_sha256 = "32cc5fbbdb89e77f33619b7f3d942cfac4202f3a3838605a396aed3882d668b5-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const char * MONERO_wallet2_api_c_exp_sha256 = "c1f785d62709fd8b849063ecf4fe8854d9e3b05b568b9716de98d33e7bdaf522";
#endif
44 changes: 2 additions & 42 deletions monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,49 +1607,9 @@ uint64_t MONERO_Wallet_getBytesSent(void* wallet_ptr) {
return wallet->getBytesSent();
}

bool MONERO_Wallet_getStateIsConnected(void* wallet_ptr) {
void MONERO_Wallet_setLedgerExchange(void* wallet_ptr, int (*sendToLedgerDevice) (unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len)) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getStateIsConnected();
}

unsigned char* MONERO_Wallet_getSendToDevice(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getSendToDevice();
}

size_t MONERO_Wallet_getSendToDeviceLength(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getSendToDeviceLength();
}

unsigned char* MONERO_Wallet_getReceivedFromDevice(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getReceivedFromDevice();
}

size_t MONERO_Wallet_getReceivedFromDeviceLength(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getReceivedFromDeviceLength();
}

bool MONERO_Wallet_getWaitsForDeviceSend(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getWaitsForDeviceSend();
}

bool MONERO_Wallet_getWaitsForDeviceReceive(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->getWaitsForDeviceReceive();
}

void MONERO_Wallet_setDeviceReceivedData(void* wallet_ptr, unsigned char* data, size_t len) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->setDeviceReceivedData(data, len);
}

void MONERO_Wallet_setDeviceSendData(void* wallet_ptr, unsigned char* data, size_t len) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->setDeviceSendData(data, len);
return wallet->setLedgerExchange(sendToLedgerDevice);
}

void* MONERO_WalletManager_createWallet(void* wm_ptr, const char* path, const char* password, const char* language, int networkType) {
Expand Down
10 changes: 1 addition & 9 deletions monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,7 @@ extern ADDAPI uint64_t MONERO_Wallet_getBytesReceived(void* wallet_ptr);
// virtual uint64_t getBytesSent() = 0;
extern ADDAPI uint64_t MONERO_Wallet_getBytesSent(void* wallet_ptr);
// HIDAPI_DUMMY
extern ADDAPI bool MONERO_Wallet_getStateIsConnected(void* wallet_ptr);
extern ADDAPI unsigned char* MONERO_Wallet_getSendToDevice(void* wallet_ptr);
extern ADDAPI size_t MONERO_Wallet_getSendToDeviceLength(void* wallet_ptr);
extern ADDAPI unsigned char* MONERO_Wallet_getReceivedFromDevice(void* wallet_ptr);
extern ADDAPI size_t MONERO_Wallet_getReceivedFromDeviceLength(void* wallet_ptr);
extern ADDAPI bool MONERO_Wallet_getWaitsForDeviceSend(void* wallet_ptr);
extern ADDAPI bool MONERO_Wallet_getWaitsForDeviceReceive(void* wallet_ptr);
extern ADDAPI void MONERO_Wallet_setDeviceReceivedData(void* wallet_ptr, unsigned char* data, size_t len);
extern ADDAPI void MONERO_Wallet_setDeviceSendData(void* wallet_ptr, unsigned char* data, size_t len);
extern ADDAPI void MONERO_Wallet_setLedgerExchange(void* wallet_ptr, int (*sendToLedgerDevice) (unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len));
// };

// struct WalletManager
Expand Down
Loading
Loading