added ledger functions; added serialize_cache_to_JSON() functionality

This commit is contained in:
Some Random Crypto Guy
2025-09-30 09:54:09 +01:00
parent 78c6768b51
commit df059e02b6
5 changed files with 82 additions and 0 deletions

View File

@@ -3358,6 +3358,25 @@ void Wallet_setDeviceSendData(wallet ptr, Pointer<UnsignedChar> data, int len) {
return ret;
}
@Deprecated("TODO")
void Wallet_setLedgerCallback(Pointer<NativeFunction<Void Function(Pointer<UnsignedChar>, UnsignedInt)>> callback) {
debugStart?.call('SALVIUM_Wallet_setLedgerCallback');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.SALVIUM_Wallet_setLedgerCallback(callback);
debugEnd?.call('SALVIUM_Wallet_setLedgerCallback');
return ret;
}
String Wallet_serializeCacheToJson(wallet ptr) {
debugStart?.call('SALVIUM_Wallet_serializeCacheToJson');
lib ??= MoneroC(DynamicLibrary.open(libPath));
final ret = lib!.SALVIUM_Wallet_serializeCacheToJson(ptr);
final str = ret.cast<Utf8>().toDartString();
MONERO_free(ret.cast());
debugEnd?.call('SALVIUM_Wallet_serializeCacheToJson');
return str;
}
// WalletManager
typedef WalletManager = Pointer<Void>;

View File

@@ -4550,6 +4550,51 @@ class SalviumC {
void Function(
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.UnsignedChar>, int)>();
void MONERO_Wallet_setLedgerCallback(
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(ffi.Pointer<ffi.UnsignedChar> command,
ffi.UnsignedInt cmd_len)>>
sendToLedgerDevice,
) {
return _MONERO_Wallet_setLedgerCallback(
sendToLedgerDevice,
);
}
late final _SALVIUM_Wallet_setLedgerCallbackPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.UnsignedChar> command,
ffi.UnsignedInt cmd_len)>>)>>(
'SALVIUM_Wallet_setLedgerCallback');
late final _SALVIUM_Wallet_setLedgerCallback =
_SALVIUM_Wallet_setLedgerCallbackPtr.asFunction<
void Function(
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(ffi.Pointer<ffi.UnsignedChar> command,
ffi.UnsignedInt cmd_len)>>)>();
ffi.Pointer<ffi.Char> SALVIUM_Wallet_serializeCacheToJson(
ffi.Pointer<ffi.Void> wallet_ptr,
) {
return _SALVIUM_Wallet_serializeCacheToJson(
wallet_ptr,
);
}
late final _SALVIUM_Wallet_serializeCacheToJsonPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.Char> Function(
ffi.Pointer<ffi.Void>)>>('SALVIUM_Wallet_serializeCacheToJson');
late final _SALVIUM_Wallet_serializeCacheToJson =
_SALVIUM_Wallet_serializeCacheToJsonPtr.asFunction<
ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Void>)>();
ffi.Pointer<ffi.Void> SALVIUM_WalletManager_createWallet(
ffi.Pointer<ffi.Void> wm_ptr,
ffi.Pointer<ffi.Char> path,

View File

@@ -126,6 +126,8 @@ _SALVIUM_MultisigState_total
_SALVIUM_DeviceProgress_progress
_SALVIUM_DeviceProgress_indeterminate
_SALVIUM_Wallet_seed
_SALVIUM_Wallet_setLedgerCallback
_SALVIUM_Wallet_serializeCacheToJson
_SALVIUM_Wallet_getSeedLanguage
_SALVIUM_Wallet_setSeedLanguage
_SALVIUM_Wallet_status

View File

@@ -2211,6 +2211,20 @@ void SALVIUM_Wallet_setDeviceSendData(void* wallet_ptr, unsigned char* data, siz
DEBUG_END()
}
void SALVIUM_Wallet_setLedgerCallback(void (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len)) {
DEBUG_START()
Monero::Wallet::setLedgerCallback(sendToLedgerDevice);
DEBUG_END()
}
const char* SALVIUM_Wallet_serializeCacheToJson(void* wallet_ptr) {
DEBUG_START()
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
std::string result = wallet->serializeCacheToJson();
return strdup(result.c_str());
DEBUG_END()
}
void* SALVIUM_WalletManager_createWallet(void* wm_ptr, const char* path, const char* password, const char* language, int networkType) {
DEBUG_START()
Monero::WalletManager *wm = reinterpret_cast<Monero::WalletManager*>(wm_ptr);

View File

@@ -854,6 +854,8 @@ extern ADDAPI bool SALVIUM_Wallet_getWaitsForDeviceSend(void* wallet_ptr);
extern ADDAPI bool SALVIUM_Wallet_getWaitsForDeviceReceive(void* wallet_ptr);
extern ADDAPI void SALVIUM_Wallet_setDeviceReceivedData(void* wallet_ptr, unsigned char* data, size_t len);
extern ADDAPI void SALVIUM_Wallet_setDeviceSendData(void* wallet_ptr, unsigned char* data, size_t len);
extern ADDAPI void SALVIUM_Wallet_setLedgerCallback(void (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len));
extern ADDAPI const char* SALVIUM_Wallet_serializeCacheToJson(void* wallet_ptr);
// };
// struct WalletManager