summaryrefslogtreecommitdiff
path: root/impls/monero.dart/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'impls/monero.dart/lib/src')
-rw-r--r--impls/monero.dart/lib/src/generated_bindings_monero.g.dart34
-rw-r--r--impls/monero.dart/lib/src/monero.dart42
2 files changed, 76 insertions, 0 deletions
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 b757806..0cd6bb5 100644
--- a/impls/monero.dart/lib/src/generated_bindings_monero.g.dart
+++ b/impls/monero.dart/lib/src/generated_bindings_monero.g.dart
@@ -4504,6 +4504,40 @@ class MoneroC {
_MONERO_Wallet_serializeCacheToJsonPtr.asFunction<
ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Void>)>();
+ ffi.Pointer<ffi.Char> MONERO_Wallet_exportTrezorTdis(
+ ffi.Pointer<ffi.Void> wallet_ptr,
+ ) {
+ return _MONERO_Wallet_exportTrezorTdis(
+ wallet_ptr,
+ );
+ }
+
+ late final _MONERO_Wallet_exportTrezorTdisPtr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer<ffi.Char> Function(
+ ffi.Pointer<ffi.Void>)>>('MONERO_Wallet_exportTrezorTdis');
+ late final _MONERO_Wallet_exportTrezorTdis =
+ _MONERO_Wallet_exportTrezorTdisPtr.asFunction<
+ ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Void>)>();
+
+ bool MONERO_Wallet_importTrezorEncryptedKeyImagesJson(
+ ffi.Pointer<ffi.Void> wallet_ptr,
+ ffi.Pointer<ffi.Char> json,
+ ) {
+ return _MONERO_Wallet_importTrezorEncryptedKeyImagesJson(
+ wallet_ptr,
+ json,
+ );
+ }
+
+ late final _MONERO_Wallet_importTrezorEncryptedKeyImagesJsonPtr = _lookup<
+ ffi.NativeFunction<
+ ffi.Bool Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>)>>(
+ 'MONERO_Wallet_importTrezorEncryptedKeyImagesJson');
+ late final _MONERO_Wallet_importTrezorEncryptedKeyImagesJson =
+ _MONERO_Wallet_importTrezorEncryptedKeyImagesJsonPtr.asFunction<
+ bool Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>)>();
+
ffi.Pointer<ffi.Void> MONERO_WalletManager_createWallet(
ffi.Pointer<ffi.Void> wm_ptr,
ffi.Pointer<ffi.Char> path,
diff --git a/impls/monero.dart/lib/src/monero.dart b/impls/monero.dart/lib/src/monero.dart
index e142d6b..abecee0 100644
--- a/impls/monero.dart/lib/src/monero.dart
+++ b/impls/monero.dart/lib/src/monero.dart
@@ -1,5 +1,6 @@
// ignore_for_file: deprecated_member_use_from_same_package
+import 'dart:convert';
import 'dart:ffi';
import 'package:monero/monero.dart' as monero;
@@ -1517,10 +1518,51 @@ class MoneroWallet implements Wallet2Wallet {
return monero.Wallet_watchOnly(walletPtr);
}
+ List<TrezorTdi> exportTrezorTdis() {
+ final res = monero.Wallet_exportTrezorTdis(walletPtr);
+ final l = parseTrezorTdis(res);
+ return l;
+ }
+
@override
int ffiAddress() => walletPtr.address;
}
+class TrezorTdi {
+ TrezorTdi({
+ required this.outKey,
+ required this.txPubKey,
+ this.additionalTxPubKeys,
+ required this.internalOutputIndex,
+ required this.subAddrMajor,
+ required this.subAddrMinor,
+ });
+
+ final String outKey;
+ final String txPubKey;
+ final List<String>? additionalTxPubKeys;
+ final int internalOutputIndex;
+ final int subAddrMajor;
+ final int subAddrMinor;
+
+ factory TrezorTdi.fromJson(Map<String, dynamic> j) => TrezorTdi(
+ outKey: j['out_key'] as String,
+ txPubKey: j['tx_pub_key'] as String,
+ additionalTxPubKeys: (j['additional_tx_pub_keys'] as List?)
+ ?.cast<String>(),
+ internalOutputIndex: (j['internal_output_index'] as num).toInt(),
+ subAddrMajor: (j['sub_addr_major'] as num).toInt(),
+ subAddrMinor: (j['sub_addr_minor'] as num).toInt(),
+ );
+}
+
+List<TrezorTdi> parseTrezorTdis(String json) {
+ final root = jsonDecode(json) as Map<String, dynamic>;
+ return (root['tdis'] as List)
+ .map((e) => TrezorTdi.fromJson(e as Map<String, dynamic>))
+ .toList();
+}
+
class MoneroWalletManager implements Wallet2WalletManager {
MoneroWalletManager(this.wmPtr);