-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathmonero_wallet.dart
More file actions
115 lines (102 loc) · 3.04 KB
/
monero_wallet.dart
File metadata and controls
115 lines (102 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import 'dart:async';
import 'package:compat/compat.dart' as lib_monero_compat;
import '../../../utilities/amount/amount.dart';
import '../../../wl_gen/interfaces/cs_monero_interface.dart';
import '../../../wl_gen/interfaces/cs_salvium_interface.dart'
show WrappedWallet;
import '../../crypto_currency/crypto_currency.dart';
import '../intermediate/lib_monero_wallet.dart';
class MoneroWallet extends LibMoneroWallet {
MoneroWallet(CryptoCurrencyNetwork network)
: super(Monero(network), lib_monero_compat.WalletType.monero);
@override
Future<Amount> estimateFeeFor(Amount amount, BigInt feeRate) async {
if (wallet == null || syncStatus is! lib_monero_compat.SyncedSyncStatus) {
return Amount.zeroWith(fractionDigits: cryptoCurrency.fractionDigits);
}
int approximateFee = 0;
await estimateFeeMutex.protect(() async {
approximateFee = await csMonero.estimateFee(
feeRate.toInt(),
amount.raw,
wallet: wallet!,
);
});
return Amount(
rawValue: BigInt.from(approximateFee),
fractionDigits: cryptoCurrency.fractionDigits,
);
}
@override
bool walletExists(String path) => csMonero.walletExists(path);
@override
Future<WrappedWallet> loadWallet({
required String path,
required String password,
}) => csMonero.loadWallet(walletId, path: path, password: password);
@override
Future<WrappedWallet> getCreatedWallet({
required String path,
required String password,
required int wordCount,
required String seedOffset,
}) => csMonero.getCreatedWallet(
path: path,
password: password,
wordCount: wordCount,
seedOffset: seedOffset,
);
@override
Future<WrappedWallet> getRestoredWallet({
required String path,
required String password,
required String mnemonic,
required String seedOffset,
int height = 0,
}) => csMonero.getRestoredWallet(
path: path,
password: password,
mnemonic: mnemonic,
height: height,
seedOffset: seedOffset,
walletId: walletId,
);
@override
Future<WrappedWallet> getRestoredFromViewKeyWallet({
required String path,
required String password,
required String address,
required String privateViewKey,
int height = 0,
}) => csMonero.getRestoredFromViewKeyWallet(
walletId: walletId,
path: path,
password: password,
address: address,
privateViewKey: privateViewKey,
height: height,
);
@override
Future<WrappedWallet> getRestoredFromKeysWallet({
required String path,
required String password,
required String address,
required String privateViewKey,
required String privateSpendKey,
int height = 0,
}) => csMonero.getRestoredFromKeysWallet(
walletId: walletId,
path: path,
password: password,
address: address,
privateViewKey: privateViewKey,
privateSpendKey: privateSpendKey,
height: height,
);
@override
void invalidSeedLengthCheck(int length) {
if (length != 25 && length != 16) {
throw Exception("Invalid monero mnemonic length found: $length");
}
}
}