2021-12-24 12:52:08 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
|
|
|
import 'package:cw_bitcoin/electrum_balance.dart';
|
|
|
|
import 'package:cw_bitcoin/file.dart';
|
|
|
|
import 'package:cw_core/pathForWallet.dart';
|
|
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
|
|
|
|
class ElectrumWallletSnapshot {
|
2022-10-12 17:09:57 +00:00
|
|
|
ElectrumWallletSnapshot({
|
|
|
|
required this.mnemonic,
|
2023-04-03 18:02:11 +00:00
|
|
|
});
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
String mnemonic;
|
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
static Future<ElectrumWallletSnapshot> load(String name, WalletType type, String password) async {
|
|
|
|
final path = await pathForWallet(name: name, type: type);
|
|
|
|
final jsonSource = await read(path: path, password: password);
|
2023-04-03 18:02:11 +00:00
|
|
|
// final data = json.decode(jsonSource) as Map;
|
|
|
|
// final mnemonic = data['mnemonic'] as String;
|
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
return ElectrumWallletSnapshot(
|
2023-04-03 20:04:18 +00:00
|
|
|
mnemonic: jsonSource, //Passing the jsonSource as mnemonic because the json.decode() method throws an exception unterminated string
|
2023-04-03 18:02:11 +00:00
|
|
|
);
|
2021-12-24 12:52:08 +00:00
|
|
|
}
|
2023-04-03 18:02:11 +00:00
|
|
|
}
|