mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Revert btc address types
This commit is contained in:
parent
429603118d
commit
a49e57e342
88 changed files with 1317 additions and 1836 deletions
|
@ -1,23 +1,23 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
import 'dart:typed_data';
|
||||||
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
|
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
||||||
|
|
||||||
String addressFromOutputScript(Script script, BasedUtxoNetwork network) {
|
String addressFromOutput(Uint8List script, bitcoin.NetworkType networkType) {
|
||||||
try {
|
try {
|
||||||
switch (script.getAddressType()) {
|
return bitcoin.P2PKH(
|
||||||
case P2pkhAddressType.p2pkh:
|
data: PaymentData(output: script),
|
||||||
return P2pkhAddress.fromScriptPubkey(script: script).toAddress(network);
|
network: networkType)
|
||||||
case P2shAddressType.p2pkInP2sh:
|
.data
|
||||||
return P2shAddress.fromScriptPubkey(script: script).toAddress(network);
|
.address!;
|
||||||
case SegwitAddresType.p2wpkh:
|
|
||||||
return P2wpkhAddress.fromScriptPubkey(script: script).toAddress(network);
|
|
||||||
case P2shAddressType.p2pkhInP2sh:
|
|
||||||
return P2shAddress.fromScriptPubkey(script: script).toAddress(network);
|
|
||||||
case SegwitAddresType.p2wsh:
|
|
||||||
return P2wshAddress.fromScriptPubkey(script: script).toAddress(network);
|
|
||||||
case SegwitAddresType.p2tr:
|
|
||||||
return P2trAddress.fromScriptPubkey(script: script).toAddress(network);
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return bitcoin.P2WPKH(
|
||||||
|
data: PaymentData(output: script),
|
||||||
|
network: networkType)
|
||||||
|
.data
|
||||||
|
.address!;
|
||||||
|
} catch(_) {}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
|
@ -1,9 +1,27 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
|
import 'package:bs58check/bs58check.dart' as bs58check;
|
||||||
|
import 'package:bitcoin_flutter/src/utils/constants/op.dart';
|
||||||
|
import 'package:bitcoin_flutter/src/utils/script.dart' as bscript;
|
||||||
|
import 'package:bitcoin_flutter/src/address.dart';
|
||||||
|
|
||||||
List<int> addressToOutputScript(String address, bitcoin.BasedUtxoNetwork network) {
|
Uint8List p2shAddressToOutputScript(String address) {
|
||||||
|
final decodeBase58 = bs58check.decode(address);
|
||||||
|
final hash = decodeBase58.sublist(1);
|
||||||
|
return bscript.compile(<dynamic>[OPS['OP_HASH160'], hash, OPS['OP_EQUAL']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List addressToOutputScript(
|
||||||
|
String address, bitcoin.NetworkType networkType) {
|
||||||
try {
|
try {
|
||||||
return bitcoin.addressToOutputScript(address: address, network: network);
|
// FIXME: improve validation for p2sh addresses
|
||||||
|
// 3 for bitcoin
|
||||||
|
// m for litecoin
|
||||||
|
if (address.startsWith('3') || address.toLowerCase().startsWith('m')) {
|
||||||
|
return p2shAddressToOutputScript(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Address.addressToOutputScript(address, networkType);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print(err);
|
print(err);
|
||||||
return Uint8List(0);
|
return Uint8List(0);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:bitbox/bitbox.dart' as bitbox;
|
import 'package:bitbox/bitbox.dart' as bitbox;
|
||||||
|
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:cw_bitcoin/script_hash.dart' as sh;
|
|
||||||
|
|
||||||
class BitcoinAddressRecord {
|
class BitcoinAddressRecord {
|
||||||
BitcoinAddressRecord(
|
BitcoinAddressRecord(
|
||||||
this.address, {
|
this.address, {
|
||||||
|
@ -13,41 +10,23 @@ class BitcoinAddressRecord {
|
||||||
int balance = 0,
|
int balance = 0,
|
||||||
String name = '',
|
String name = '',
|
||||||
bool isUsed = false,
|
bool isUsed = false,
|
||||||
required this.type,
|
|
||||||
String? scriptHash,
|
|
||||||
required this.network,
|
|
||||||
}) : _txCount = txCount,
|
}) : _txCount = txCount,
|
||||||
_balance = balance,
|
_balance = balance,
|
||||||
_name = name,
|
_name = name,
|
||||||
_isUsed = isUsed,
|
_isUsed = isUsed;
|
||||||
scriptHash =
|
|
||||||
scriptHash ?? (network != null ? sh.scriptHash(address, network: network) : null);
|
|
||||||
|
|
||||||
factory BitcoinAddressRecord.fromJSON(String jsonSource, BasedUtxoNetwork? network) {
|
factory BitcoinAddressRecord.fromJSON(String jsonSource) {
|
||||||
final decoded = json.decode(jsonSource) as Map;
|
final decoded = json.decode(jsonSource) as Map;
|
||||||
|
|
||||||
return BitcoinAddressRecord(
|
return BitcoinAddressRecord(decoded['address'] as String,
|
||||||
decoded['address'] as String,
|
|
||||||
index: decoded['index'] as int,
|
index: decoded['index'] as int,
|
||||||
isHidden: decoded['isHidden'] as bool? ?? false,
|
isHidden: decoded['isHidden'] as bool? ?? false,
|
||||||
isUsed: decoded['isUsed'] as bool? ?? false,
|
isUsed: decoded['isUsed'] as bool? ?? false,
|
||||||
txCount: decoded['txCount'] as int? ?? 0,
|
txCount: decoded['txCount'] as int? ?? 0,
|
||||||
name: decoded['name'] as String? ?? '',
|
name: decoded['name'] as String? ?? '',
|
||||||
balance: decoded['balance'] as int? ?? 0,
|
balance: decoded['balance'] as int? ?? 0);
|
||||||
type: decoded['type'] != null && decoded['type'] != ''
|
|
||||||
? BitcoinAddressType.values
|
|
||||||
.firstWhere((type) => type.toString() == decoded['type'] as String)
|
|
||||||
: SegwitAddresType.p2wpkh,
|
|
||||||
scriptHash: decoded['scriptHash'] as String?,
|
|
||||||
network: (decoded['network'] as String?) == null
|
|
||||||
? network
|
|
||||||
: BasedUtxoNetwork.fromName(decoded['network'] as String),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object o) => o is BitcoinAddressRecord && address == o.address;
|
|
||||||
|
|
||||||
final String address;
|
final String address;
|
||||||
bool isHidden;
|
bool isHidden;
|
||||||
final int index;
|
final int index;
|
||||||
|
@ -55,8 +34,6 @@ class BitcoinAddressRecord {
|
||||||
int _balance;
|
int _balance;
|
||||||
String _name;
|
String _name;
|
||||||
bool _isUsed;
|
bool _isUsed;
|
||||||
String? scriptHash;
|
|
||||||
BasedUtxoNetwork? network;
|
|
||||||
|
|
||||||
int get txCount => _txCount;
|
int get txCount => _txCount;
|
||||||
|
|
||||||
|
@ -73,28 +50,21 @@ class BitcoinAddressRecord {
|
||||||
void setAsUsed() => _isUsed = true;
|
void setAsUsed() => _isUsed = true;
|
||||||
void setNewName(String label) => _name = label;
|
void setNewName(String label) => _name = label;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object o) => o is BitcoinAddressRecord && address == o.address;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => address.hashCode;
|
int get hashCode => address.hashCode;
|
||||||
|
|
||||||
String get cashAddr => bitbox.Address.toCashAddress(address);
|
String get cashAddr => bitbox.Address.toCashAddress(address);
|
||||||
|
|
||||||
BitcoinAddressType type;
|
|
||||||
|
|
||||||
String updateScriptHash(BasedUtxoNetwork network) {
|
|
||||||
scriptHash = sh.scriptHash(address, network: network);
|
|
||||||
return scriptHash!;
|
|
||||||
}
|
|
||||||
|
|
||||||
String toJSON() => json.encode({
|
String toJSON() => json.encode({
|
||||||
'address': address,
|
'address': address,
|
||||||
'index': index,
|
'index': index,
|
||||||
'isHidden': isHidden,
|
'isHidden': isHidden,
|
||||||
'isUsed': isUsed,
|
|
||||||
'txCount': txCount,
|
'txCount': txCount,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
'isUsed': isUsed,
|
||||||
'balance': balance,
|
'balance': balance,
|
||||||
'type': type.toString(),
|
|
||||||
'scriptHash': scriptHash,
|
|
||||||
'network': network?.value,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
|
||||||
|
|
||||||
class BitcoinReceivePageOption implements ReceivePageOption {
|
|
||||||
static const p2wpkh = BitcoinReceivePageOption._('Segwit (P2WPKH) (Default)');
|
|
||||||
static const p2sh = BitcoinReceivePageOption._('Segwit-Compatible (P2SH)');
|
|
||||||
static const p2tr = BitcoinReceivePageOption._('Taproot (P2TR)');
|
|
||||||
static const p2wsh = BitcoinReceivePageOption._('Segwit (P2WSH)');
|
|
||||||
static const p2pkh = BitcoinReceivePageOption._('Legacy (P2PKH)');
|
|
||||||
|
|
||||||
const BitcoinReceivePageOption._(this.value);
|
|
||||||
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
String toString() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const all = [
|
|
||||||
BitcoinReceivePageOption.p2wpkh,
|
|
||||||
BitcoinReceivePageOption.p2tr,
|
|
||||||
BitcoinReceivePageOption.p2wsh,
|
|
||||||
BitcoinReceivePageOption.p2sh,
|
|
||||||
BitcoinReceivePageOption.p2pkh
|
|
||||||
];
|
|
||||||
|
|
||||||
factory BitcoinReceivePageOption.fromType(BitcoinAddressType type) {
|
|
||||||
switch (type) {
|
|
||||||
case SegwitAddresType.p2tr:
|
|
||||||
return BitcoinReceivePageOption.p2tr;
|
|
||||||
case SegwitAddresType.p2wsh:
|
|
||||||
return BitcoinReceivePageOption.p2wsh;
|
|
||||||
case P2pkhAddressType.p2pkh:
|
|
||||||
return BitcoinReceivePageOption.p2pkh;
|
|
||||||
case P2shAddressType.p2wpkhInP2sh:
|
|
||||||
return BitcoinReceivePageOption.p2sh;
|
|
||||||
case SegwitAddresType.p2wpkh:
|
|
||||||
default:
|
|
||||||
return BitcoinReceivePageOption.p2wpkh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,9 +6,10 @@ class BitcoinUnspent extends Unspent {
|
||||||
: bitcoinAddressRecord = addressRecord,
|
: bitcoinAddressRecord = addressRecord,
|
||||||
super(addressRecord.address, hash, value, vout, null);
|
super(addressRecord.address, hash, value, vout, null);
|
||||||
|
|
||||||
factory BitcoinUnspent.fromJSON(BitcoinAddressRecord address, Map<String, dynamic> json) =>
|
factory BitcoinUnspent.fromJSON(
|
||||||
BitcoinUnspent(
|
BitcoinAddressRecord address, Map<String, dynamic> json) =>
|
||||||
address, json['tx_hash'] as String, json['value'] as int, json['tx_pos'] as int);
|
BitcoinUnspent(address, json['tx_hash'] as String, json['value'] as int,
|
||||||
|
json['tx_pos'] as int);
|
||||||
|
|
||||||
final BitcoinAddressRecord bitcoinAddressRecord;
|
final BitcoinAddressRecord bitcoinAddressRecord;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
import 'package:cw_core/unspent_coins_info.dart';
|
import 'package:cw_core/unspent_coins_info.dart';
|
||||||
|
@ -18,28 +17,22 @@ part 'bitcoin_wallet.g.dart';
|
||||||
class BitcoinWallet = BitcoinWalletBase with _$BitcoinWallet;
|
class BitcoinWallet = BitcoinWalletBase with _$BitcoinWallet;
|
||||||
|
|
||||||
abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
BitcoinWalletBase({
|
BitcoinWalletBase(
|
||||||
required String mnemonic,
|
{required String mnemonic,
|
||||||
required String password,
|
required String password,
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
required Uint8List seedBytes,
|
required Uint8List seedBytes,
|
||||||
String? addressPageType,
|
|
||||||
BasedUtxoNetwork? networkParam,
|
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
}) : super(
|
: super(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
unspentCoinsInfo: unspentCoinsInfo,
|
unspentCoinsInfo: unspentCoinsInfo,
|
||||||
networkType: networkParam == null
|
networkType: bitcoin.bitcoin,
|
||||||
? bitcoin.bitcoin
|
|
||||||
: networkParam == BitcoinNetwork.mainnet
|
|
||||||
? bitcoin.bitcoin
|
|
||||||
: bitcoin.testnet,
|
|
||||||
initialAddresses: initialAddresses,
|
initialAddresses: initialAddresses,
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
seedBytes: seedBytes,
|
seedBytes: seedBytes,
|
||||||
|
@ -51,9 +44,9 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
mainHd: hd,
|
mainHd: hd,
|
||||||
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType).derivePath("m/0'/1"),
|
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType)
|
||||||
network: networkParam ?? network,
|
.derivePath("m/0'/1"),
|
||||||
);
|
networkType: networkType);
|
||||||
autorun((_) {
|
autorun((_) {
|
||||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||||
});
|
});
|
||||||
|
@ -64,12 +57,10 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
required String password,
|
required String password,
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
String? addressPageType,
|
|
||||||
BasedUtxoNetwork? network,
|
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
int initialChangeAddressIndex = 0
|
||||||
}) async {
|
}) async {
|
||||||
return BitcoinWallet(
|
return BitcoinWallet(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
|
@ -80,10 +71,7 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
seedBytes: await mnemonicToSeedBytes(mnemonic),
|
seedBytes: await mnemonicToSeedBytes(mnemonic),
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex);
|
||||||
addressPageType: addressPageType,
|
|
||||||
networkParam: network,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<BitcoinWallet> open({
|
static Future<BitcoinWallet> open({
|
||||||
|
@ -92,9 +80,7 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
required String password,
|
required String password,
|
||||||
}) async {
|
}) async {
|
||||||
final snp = await ElectrumWalletSnapshot.load(name, walletInfo.type, password,
|
final snp = await ElectrumWallletSnapshot.load(name, walletInfo.type, password);
|
||||||
walletInfo.network != null ? BasedUtxoNetwork.fromName(walletInfo.network!) : null);
|
|
||||||
|
|
||||||
return BitcoinWallet(
|
return BitcoinWallet(
|
||||||
mnemonic: snp.mnemonic,
|
mnemonic: snp.mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -104,9 +90,6 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: snp.balance,
|
initialBalance: snp.balance,
|
||||||
seedBytes: await mnemonicToSeedBytes(snp.mnemonic),
|
seedBytes: await mnemonicToSeedBytes(snp.mnemonic),
|
||||||
initialRegularAddressIndex: snp.regularAddressIndex,
|
initialRegularAddressIndex: snp.regularAddressIndex,
|
||||||
initialChangeAddressIndex: snp.changeAddressIndex,
|
initialChangeAddressIndex: snp.changeAddressIndex);
|
||||||
addressPageType: snp.addressPageType,
|
|
||||||
networkParam: snp.network,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||||
|
import 'package:cw_bitcoin/electrum.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
||||||
import 'package:cw_bitcoin/utils.dart';
|
import 'package:cw_bitcoin/utils.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
|
@ -10,31 +11,24 @@ part 'bitcoin_wallet_addresses.g.dart';
|
||||||
class BitcoinWalletAddresses = BitcoinWalletAddressesBase with _$BitcoinWalletAddresses;
|
class BitcoinWalletAddresses = BitcoinWalletAddressesBase with _$BitcoinWalletAddresses;
|
||||||
|
|
||||||
abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
abstract class BitcoinWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
||||||
BitcoinWalletAddressesBase(
|
BitcoinWalletAddressesBase(WalletInfo walletInfo,
|
||||||
WalletInfo walletInfo, {
|
{required bitcoin.HDWallet mainHd,
|
||||||
required super.mainHd,
|
required bitcoin.HDWallet sideHd,
|
||||||
required super.sideHd,
|
required bitcoin.NetworkType networkType,
|
||||||
required super.network,
|
required ElectrumClient electrumClient,
|
||||||
required super.electrumClient,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
super.initialAddresses,
|
int initialRegularAddressIndex = 0,
|
||||||
super.initialRegularAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
super.initialChangeAddressIndex,
|
: super(walletInfo,
|
||||||
}) : super(walletInfo);
|
initialAddresses: initialAddresses,
|
||||||
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
|
mainHd: mainHd,
|
||||||
|
sideHd: sideHd,
|
||||||
|
electrumClient: electrumClient,
|
||||||
|
networkType: networkType);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String getAddress({required int index, required HDWallet hd, BitcoinAddressType? addressType}) {
|
String getAddress({required int index, required bitcoin.HDWallet hd}) =>
|
||||||
if (addressType == P2pkhAddressType.p2pkh)
|
generateP2WPKHAddress(hd: hd, index: index, networkType: networkType);
|
||||||
return generateP2PKHAddress(hd: hd, index: index, network: network);
|
|
||||||
|
|
||||||
if (addressType == SegwitAddresType.p2tr)
|
|
||||||
return generateP2TRAddress(hd: hd, index: index, network: network);
|
|
||||||
|
|
||||||
if (addressType == SegwitAddresType.p2wsh)
|
|
||||||
return generateP2WSHAddress(hd: hd, index: index, network: network);
|
|
||||||
|
|
||||||
if (addressType == P2shAddressType.p2wpkhInP2sh)
|
|
||||||
return generateP2SHAddress(hd: hd, index: index, network: network);
|
|
||||||
|
|
||||||
return generateP2WPKHAddress(hd: hd, index: index, network: network);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||||
import 'package:cw_bitcoin/mnemonic_is_incorrect_exception.dart';
|
import 'package:cw_bitcoin/mnemonic_is_incorrect_exception.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_wallet_creation_credentials.dart';
|
import 'package:cw_bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||||
|
@ -24,17 +23,12 @@ class BitcoinWalletService extends WalletService<BitcoinNewWalletCredentials,
|
||||||
WalletType getType() => WalletType.bitcoin;
|
WalletType getType() => WalletType.bitcoin;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinWallet> create(BitcoinNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<BitcoinWallet> create(BitcoinNewWalletCredentials credentials) async {
|
||||||
final network = isTestnet == true ? BitcoinNetwork.testnet : BitcoinNetwork.mainnet;
|
|
||||||
credentials.walletInfo?.network = network.value;
|
|
||||||
|
|
||||||
final wallet = await BitcoinWalletBase.create(
|
final wallet = await BitcoinWalletBase.create(
|
||||||
mnemonic: await generateMnemonic(),
|
mnemonic: await generateMnemonic(),
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
walletInfo: credentials.walletInfo!,
|
walletInfo: credentials.walletInfo!,
|
||||||
unspentCoinsInfo: unspentCoinsInfoSource,
|
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||||
network: network,
|
|
||||||
);
|
|
||||||
await wallet.save();
|
await wallet.save();
|
||||||
await wallet.init();
|
await wallet.init();
|
||||||
return wallet;
|
return wallet;
|
||||||
|
@ -98,27 +92,20 @@ class BitcoinWalletService extends WalletService<BitcoinNewWalletCredentials,
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinWallet> restoreFromKeys(BitcoinRestoreWalletFromWIFCredentials credentials,
|
Future<BitcoinWallet> restoreFromKeys(BitcoinRestoreWalletFromWIFCredentials credentials) async =>
|
||||||
{bool? isTestnet}) async =>
|
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinWallet> restoreFromSeed(BitcoinRestoreWalletFromSeedCredentials credentials,
|
Future<BitcoinWallet> restoreFromSeed(BitcoinRestoreWalletFromSeedCredentials credentials) async {
|
||||||
{bool? isTestnet}) async {
|
|
||||||
if (!validateMnemonic(credentials.mnemonic)) {
|
if (!validateMnemonic(credentials.mnemonic)) {
|
||||||
throw BitcoinMnemonicIsIncorrectException();
|
throw BitcoinMnemonicIsIncorrectException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final network = isTestnet == true ? BitcoinNetwork.testnet : BitcoinNetwork.mainnet;
|
|
||||||
credentials.walletInfo?.network = network.value;
|
|
||||||
|
|
||||||
final wallet = await BitcoinWalletBase.create(
|
final wallet = await BitcoinWalletBase.create(
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
mnemonic: credentials.mnemonic,
|
mnemonic: credentials.mnemonic,
|
||||||
walletInfo: credentials.walletInfo!,
|
walletInfo: credentials.walletInfo!,
|
||||||
unspentCoinsInfo: unspentCoinsInfoSource,
|
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||||
network: network,
|
|
||||||
);
|
|
||||||
await wallet.save();
|
await wallet.save();
|
||||||
await wallet.init();
|
await wallet.init();
|
||||||
return wallet;
|
return wallet;
|
||||||
|
|
|
@ -2,12 +2,12 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
||||||
import 'package:cw_bitcoin/script_hash.dart';
|
import 'package:cw_bitcoin/script_hash.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
import 'package:rxdart/rxdart.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
String jsonrpcparams(List<Object> params) {
|
String jsonrpcparams(List<Object> params) {
|
||||||
final _params = params?.map((val) => '"${val.toString()}"')?.join(',');
|
final _params = params?.map((val) => '"${val.toString()}"')?.join(',');
|
||||||
|
@ -22,7 +22,10 @@ String jsonrpc(
|
||||||
'{"jsonrpc": "$version", "method": "$method", "id": "$id", "params": ${json.encode(params)}}\n';
|
'{"jsonrpc": "$version", "method": "$method", "id": "$id", "params": ${json.encode(params)}}\n';
|
||||||
|
|
||||||
class SocketTask {
|
class SocketTask {
|
||||||
SocketTask({required this.isSubscription, this.completer, this.subject});
|
SocketTask({
|
||||||
|
required this.isSubscription,
|
||||||
|
this.completer,
|
||||||
|
this.subject});
|
||||||
|
|
||||||
final Completer<dynamic>? completer;
|
final Completer<dynamic>? completer;
|
||||||
final BehaviorSubject<dynamic>? subject;
|
final BehaviorSubject<dynamic>? subject;
|
||||||
|
@ -48,7 +51,8 @@ class ElectrumClient {
|
||||||
Timer? _aliveTimer;
|
Timer? _aliveTimer;
|
||||||
String unterminatedString;
|
String unterminatedString;
|
||||||
|
|
||||||
Future<void> connectToUri(Uri uri) async => await connect(host: uri.host, port: uri.port);
|
Future<void> connectToUri(Uri uri) async =>
|
||||||
|
await connect(host: uri.host, port: uri.port);
|
||||||
|
|
||||||
Future<void> connect({required String host, required int port}) async {
|
Future<void> connect({required String host, required int port}) async {
|
||||||
try {
|
try {
|
||||||
|
@ -100,20 +104,21 @@ class ElectrumClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isJSONStringCorrect(unterminatedString)) {
|
if (isJSONStringCorrect(unterminatedString)) {
|
||||||
final response = json.decode(unterminatedString) as Map<String, dynamic>;
|
final response =
|
||||||
|
json.decode(unterminatedString) as Map<String, dynamic>;
|
||||||
_handleResponse(response);
|
_handleResponse(response);
|
||||||
unterminatedString = '';
|
unterminatedString = '';
|
||||||
}
|
}
|
||||||
} on TypeError catch (e) {
|
} on TypeError catch (e) {
|
||||||
if (!e.toString().contains('Map<String, Object>') &&
|
if (!e.toString().contains('Map<String, Object>') && !e.toString().contains('Map<String, dynamic>')) {
|
||||||
!e.toString().contains('Map<String, dynamic>')) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unterminatedString += message;
|
unterminatedString += message;
|
||||||
|
|
||||||
if (isJSONStringCorrect(unterminatedString)) {
|
if (isJSONStringCorrect(unterminatedString)) {
|
||||||
final response = json.decode(unterminatedString) as Map<String, dynamic>;
|
final response =
|
||||||
|
json.decode(unterminatedString) as Map<String, dynamic>;
|
||||||
_handleResponse(response);
|
_handleResponse(response);
|
||||||
// unterminatedString = null;
|
// unterminatedString = null;
|
||||||
unterminatedString = '';
|
unterminatedString = '';
|
||||||
|
@ -137,7 +142,8 @@ class ElectrumClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> version() => call(method: 'server.version').then((dynamic result) {
|
Future<List<String>> version() =>
|
||||||
|
call(method: 'server.version').then((dynamic result) {
|
||||||
if (result is List) {
|
if (result is List) {
|
||||||
return result.map((dynamic val) => val.toString()).toList();
|
return result.map((dynamic val) => val.toString()).toList();
|
||||||
}
|
}
|
||||||
|
@ -172,10 +178,11 @@ class ElectrumClient {
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getListUnspentWithAddress(
|
Future<List<Map<String, dynamic>>> getListUnspentWithAddress(
|
||||||
String address, BasedUtxoNetwork network) =>
|
String address, NetworkType networkType) =>
|
||||||
call(
|
call(
|
||||||
method: 'blockchain.scripthash.listunspent',
|
method: 'blockchain.scripthash.listunspent',
|
||||||
params: [scriptHash(address, network: network)]).then((dynamic result) {
|
params: [scriptHash(address, networkType: networkType)])
|
||||||
|
.then((dynamic result) {
|
||||||
if (result is List) {
|
if (result is List) {
|
||||||
return result.map((dynamic val) {
|
return result.map((dynamic val) {
|
||||||
if (val is Map<String, dynamic>) {
|
if (val is Map<String, dynamic>) {
|
||||||
|
@ -222,7 +229,8 @@ class ElectrumClient {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getTransactionRaw({required String hash}) async =>
|
Future<Map<String, dynamic>> getTransactionRaw(
|
||||||
|
{required String hash}) async =>
|
||||||
callWithTimeout(method: 'blockchain.transaction.get', params: [hash, true], timeout: 10000)
|
callWithTimeout(method: 'blockchain.transaction.get', params: [hash, true], timeout: 10000)
|
||||||
.then((dynamic result) {
|
.then((dynamic result) {
|
||||||
if (result is Map<String, dynamic>) {
|
if (result is Map<String, dynamic>) {
|
||||||
|
@ -232,7 +240,8 @@ class ElectrumClient {
|
||||||
return <String, dynamic>{};
|
return <String, dynamic>{};
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<String> getTransactionHex({required String hash}) async =>
|
Future<String> getTransactionHex(
|
||||||
|
{required String hash}) async =>
|
||||||
callWithTimeout(method: 'blockchain.transaction.get', params: [hash, false], timeout: 10000)
|
callWithTimeout(method: 'blockchain.transaction.get', params: [hash, false], timeout: 10000)
|
||||||
.then((dynamic result) {
|
.then((dynamic result) {
|
||||||
if (result is String) {
|
if (result is String) {
|
||||||
|
@ -243,22 +252,8 @@ class ElectrumClient {
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<String> broadcastTransaction(
|
Future<String> broadcastTransaction(
|
||||||
{required String transactionRaw, BasedUtxoNetwork? network}) async {
|
{required String transactionRaw}) async =>
|
||||||
if (network == BitcoinNetwork.testnet) {
|
call(method: 'blockchain.transaction.broadcast', params: [transactionRaw])
|
||||||
return http
|
|
||||||
.post(Uri(scheme: 'https', host: 'blockstream.info', path: '/testnet/api/tx'),
|
|
||||||
headers: <String, String>{'Content-Type': 'application/json; charset=utf-8'},
|
|
||||||
body: transactionRaw)
|
|
||||||
.then((http.Response response) {
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw Exception('Failed to broadcast transaction: ${response.body}');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return call(method: 'blockchain.transaction.broadcast', params: [transactionRaw])
|
|
||||||
.then((dynamic result) {
|
.then((dynamic result) {
|
||||||
if (result is String) {
|
if (result is String) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -266,17 +261,20 @@ class ElectrumClient {
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getMerkle({required String hash, required int height}) async =>
|
Future<Map<String, dynamic>> getMerkle(
|
||||||
await call(method: 'blockchain.transaction.get_merkle', params: [hash, height])
|
{required String hash, required int height}) async =>
|
||||||
as Map<String, dynamic>;
|
await call(
|
||||||
|
method: 'blockchain.transaction.get_merkle',
|
||||||
|
params: [hash, height]) as Map<String, dynamic>;
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getHeader({required int height}) async =>
|
Future<Map<String, dynamic>> getHeader({required int height}) async =>
|
||||||
await call(method: 'blockchain.block.get_header', params: [height]) as Map<String, dynamic>;
|
await call(method: 'blockchain.block.get_header', params: [height])
|
||||||
|
as Map<String, dynamic>;
|
||||||
|
|
||||||
Future<double> estimatefee({required int p}) =>
|
Future<double> estimatefee({required int p}) =>
|
||||||
call(method: 'blockchain.estimatefee', params: [p]).then((dynamic result) {
|
call(method: 'blockchain.estimatefee', params: [p])
|
||||||
|
.then((dynamic result) {
|
||||||
if (result is double) {
|
if (result is double) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -316,17 +314,20 @@ class ElectrumClient {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<List<int>> feeRates({BasedUtxoNetwork? network}) async {
|
Future<List<int>> feeRates() async {
|
||||||
if (network == BitcoinNetwork.testnet) {
|
|
||||||
return [1, 1, 1];
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
final topDoubleString = await estimatefee(p: 1);
|
final topDoubleString = await estimatefee(p: 1);
|
||||||
final middleDoubleString = await estimatefee(p: 5);
|
final middleDoubleString = await estimatefee(p: 5);
|
||||||
final bottomDoubleString = await estimatefee(p: 100);
|
final bottomDoubleString = await estimatefee(p: 100);
|
||||||
final top = (stringDoubleToBitcoinAmount(topDoubleString.toString()) / 1000).round();
|
final top =
|
||||||
final middle = (stringDoubleToBitcoinAmount(middleDoubleString.toString()) / 1000).round();
|
(stringDoubleToBitcoinAmount(topDoubleString.toString()) / 1000)
|
||||||
final bottom = (stringDoubleToBitcoinAmount(bottomDoubleString.toString()) / 1000).round();
|
.round();
|
||||||
|
final middle =
|
||||||
|
(stringDoubleToBitcoinAmount(middleDoubleString.toString()) / 1000)
|
||||||
|
.round();
|
||||||
|
final bottom =
|
||||||
|
(stringDoubleToBitcoinAmount(bottomDoubleString.toString()) / 1000)
|
||||||
|
.round();
|
||||||
|
|
||||||
return [bottom, middle, top];
|
return [bottom, middle, top];
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
@ -334,21 +335,6 @@ class ElectrumClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-headers-subscribe
|
|
||||||
// example response:
|
|
||||||
// {
|
|
||||||
// "height": 520481,
|
|
||||||
// "hex": "00000020890208a0ae3a3892aa047c5468725846577cfcd9b512b50000000000000000005dc2b02f2d297a9064ee103036c14d678f9afc7e3d9409cf53fd58b82e938e8ecbeca05a2d2103188ce804c4"
|
|
||||||
// }
|
|
||||||
Future<int?> getCurrentBlockChainTip() =>
|
|
||||||
call(method: 'blockchain.headers.subscribe').then((result) {
|
|
||||||
if (result is Map<String, dynamic>) {
|
|
||||||
return result["height"] as int;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
BehaviorSubject<Object>? scripthashUpdate(String scripthash) {
|
BehaviorSubject<Object>? scripthashUpdate(String scripthash) {
|
||||||
_id += 1;
|
_id += 1;
|
||||||
return subscribe<Object>(
|
return subscribe<Object>(
|
||||||
|
@ -358,14 +344,16 @@ class ElectrumClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
BehaviorSubject<T>? subscribe<T>(
|
BehaviorSubject<T>? subscribe<T>(
|
||||||
{required String id, required String method, List<Object> params = const []}) {
|
{required String id,
|
||||||
|
required String method,
|
||||||
|
List<Object> params = const []}) {
|
||||||
try {
|
try {
|
||||||
final subscription = BehaviorSubject<T>();
|
final subscription = BehaviorSubject<T>();
|
||||||
_regisrySubscription(id, subscription);
|
_regisrySubscription(id, subscription);
|
||||||
socket!.write(jsonrpc(method: method, id: _id, params: params));
|
socket!.write(jsonrpc(method: method, id: _id, params: params));
|
||||||
|
|
||||||
return subscription;
|
return subscription;
|
||||||
} catch (e) {
|
} catch(e) {
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +370,9 @@ class ElectrumClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> callWithTimeout(
|
Future<dynamic> callWithTimeout(
|
||||||
{required String method, List<Object> params = const [], int timeout = 4000}) async {
|
{required String method,
|
||||||
|
List<Object> params = const [],
|
||||||
|
int timeout = 4000}) async {
|
||||||
try {
|
try {
|
||||||
final completer = Completer<dynamic>();
|
final completer = Completer<dynamic>();
|
||||||
_id += 1;
|
_id += 1;
|
||||||
|
@ -396,7 +386,7 @@ class ElectrumClient {
|
||||||
});
|
});
|
||||||
|
|
||||||
return completer.future;
|
return completer.future;
|
||||||
} catch (e) {
|
} catch(e) {
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,8 +397,8 @@ class ElectrumClient {
|
||||||
onConnectionStatusChange = null;
|
onConnectionStatusChange = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registryTask(int id, Completer<dynamic> completer) =>
|
void _registryTask(int id, Completer<dynamic> completer) => _tasks[id.toString()] =
|
||||||
_tasks[id.toString()] = SocketTask(completer: completer, isSubscription: false);
|
SocketTask(completer: completer, isSubscription: false);
|
||||||
|
|
||||||
void _regisrySubscription(String id, BehaviorSubject<dynamic> subject) =>
|
void _regisrySubscription(String id, BehaviorSubject<dynamic> subject) =>
|
||||||
_tasks[id] = SocketTask(subject: subject, isSubscription: true);
|
_tasks[id] = SocketTask(subject: subject, isSubscription: true);
|
||||||
|
@ -429,7 +419,8 @@ class ElectrumClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _methodHandler({required String method, required Map<String, dynamic> request}) {
|
void _methodHandler(
|
||||||
|
{required String method, required Map<String, dynamic> request}) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'blockchain.scripthash.subscribe':
|
case 'blockchain.scripthash.subscribe':
|
||||||
final params = request['params'] as List<dynamic>;
|
final params = request['params'] as List<dynamic>;
|
||||||
|
@ -461,7 +452,7 @@ class ElectrumClient {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null){
|
||||||
_finish(id, result);
|
_finish(id, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
||||||
import 'package:cw_bitcoin/address_from_output.dart';
|
import 'package:cw_bitcoin/address_from_output.dart';
|
||||||
|
@ -11,12 +10,13 @@ import 'package:cw_core/wallet_type.dart';
|
||||||
|
|
||||||
class ElectrumTransactionBundle {
|
class ElectrumTransactionBundle {
|
||||||
ElectrumTransactionBundle(this.originalTransaction,
|
ElectrumTransactionBundle(this.originalTransaction,
|
||||||
{required this.ins, required this.confirmations, this.time, required this.height});
|
{required this.ins,
|
||||||
final BtcTransaction originalTransaction;
|
required this.confirmations,
|
||||||
final List<BtcTransaction> ins;
|
this.time});
|
||||||
|
final bitcoin.Transaction originalTransaction;
|
||||||
|
final List<bitcoin.Transaction> ins;
|
||||||
final int? time;
|
final int? time;
|
||||||
final int confirmations;
|
final int confirmations;
|
||||||
final int height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ElectrumTransactionInfo extends TransactionInfo {
|
class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
|
@ -39,7 +39,8 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
this.confirmations = confirmations;
|
this.confirmations = confirmations;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory ElectrumTransactionInfo.fromElectrumVerbose(Map<String, Object> obj, WalletType type,
|
factory ElectrumTransactionInfo.fromElectrumVerbose(
|
||||||
|
Map<String, Object> obj, WalletType type,
|
||||||
{required List<BitcoinAddressRecord> addresses, required int height}) {
|
{required List<BitcoinAddressRecord> addresses, required int height}) {
|
||||||
final addressesSet = addresses.map((addr) => addr.address).toSet();
|
final addressesSet = addresses.map((addr) => addr.address).toSet();
|
||||||
final id = obj['txid'] as String;
|
final id = obj['txid'] as String;
|
||||||
|
@ -57,8 +58,10 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
for (dynamic vin in vins) {
|
for (dynamic vin in vins) {
|
||||||
final vout = vin['vout'] as int;
|
final vout = vin['vout'] as int;
|
||||||
final out = vin['tx']['vout'][vout] as Map;
|
final out = vin['tx']['vout'][vout] as Map;
|
||||||
final outAddresses = (out['scriptPubKey']['addresses'] as List<Object>?)?.toSet();
|
final outAddresses =
|
||||||
inputsAmount += stringDoubleToBitcoinAmount((out['value'] as double? ?? 0).toString());
|
(out['scriptPubKey']['addresses'] as List<Object>?)?.toSet();
|
||||||
|
inputsAmount +=
|
||||||
|
stringDoubleToBitcoinAmount((out['value'] as double? ?? 0).toString());
|
||||||
|
|
||||||
if (outAddresses?.intersection(addressesSet).isNotEmpty ?? false) {
|
if (outAddresses?.intersection(addressesSet).isNotEmpty ?? false) {
|
||||||
direction = TransactionDirection.outgoing;
|
direction = TransactionDirection.outgoing;
|
||||||
|
@ -66,9 +69,11 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dynamic out in vout) {
|
for (dynamic out in vout) {
|
||||||
final outAddresses = out['scriptPubKey']['addresses'] as List<Object>? ?? [];
|
final outAddresses =
|
||||||
|
out['scriptPubKey']['addresses'] as List<Object>? ?? [];
|
||||||
final ntrs = outAddresses.toSet().intersection(addressesSet);
|
final ntrs = outAddresses.toSet().intersection(addressesSet);
|
||||||
final value = stringDoubleToBitcoinAmount((out['value'] as double? ?? 0.0).toString());
|
final value = stringDoubleToBitcoinAmount(
|
||||||
|
(out['value'] as double? ?? 0.0).toString());
|
||||||
totalOutAmount += value;
|
totalOutAmount += value;
|
||||||
|
|
||||||
if ((direction == TransactionDirection.incoming && ntrs.isNotEmpty) ||
|
if ((direction == TransactionDirection.incoming && ntrs.isNotEmpty) ||
|
||||||
|
@ -91,8 +96,11 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
factory ElectrumTransactionInfo.fromElectrumBundle(
|
factory ElectrumTransactionInfo.fromElectrumBundle(
|
||||||
ElectrumTransactionBundle bundle, WalletType type, BasedUtxoNetwork network,
|
ElectrumTransactionBundle bundle,
|
||||||
{required Set<String> addresses, required int height}) {
|
WalletType type,
|
||||||
|
bitcoin.NetworkType networkType,
|
||||||
|
{required Set<String> addresses,
|
||||||
|
required int height}) {
|
||||||
final date = bundle.time != null
|
final date = bundle.time != null
|
||||||
? DateTime.fromMillisecondsSinceEpoch(bundle.time! * 1000)
|
? DateTime.fromMillisecondsSinceEpoch(bundle.time! * 1000)
|
||||||
: DateTime.now();
|
: DateTime.now();
|
||||||
|
@ -101,40 +109,31 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
var inputAmount = 0;
|
var inputAmount = 0;
|
||||||
var totalOutAmount = 0;
|
var totalOutAmount = 0;
|
||||||
|
|
||||||
for (var i = 0; i < bundle.originalTransaction.inputs.length; i++) {
|
for (var i = 0; i < bundle.originalTransaction.ins.length; i++) {
|
||||||
final input = bundle.originalTransaction.inputs[i];
|
final input = bundle.originalTransaction.ins[i];
|
||||||
final inputTransaction = bundle.ins[i];
|
final inputTransaction = bundle.ins[i];
|
||||||
final outTransaction = inputTransaction.outputs[input.txIndex];
|
final vout = input.index;
|
||||||
inputAmount += outTransaction.amount.toInt();
|
final outTransaction = inputTransaction.outs[vout!];
|
||||||
if (addresses.contains(addressFromOutputScript(outTransaction.scriptPubKey, network))) {
|
final address = addressFromOutput(outTransaction.script!, networkType);
|
||||||
|
inputAmount += outTransaction.value!;
|
||||||
|
if (addresses.contains(address)) {
|
||||||
direction = TransactionDirection.outgoing;
|
direction = TransactionDirection.outgoing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final receivedAmounts = <int>[];
|
for (final out in bundle.originalTransaction.outs) {
|
||||||
for (final out in bundle.originalTransaction.outputs) {
|
totalOutAmount += out.value!;
|
||||||
totalOutAmount += out.amount.toInt();
|
final address = addressFromOutput(out.script!, networkType);
|
||||||
final addressExists = addresses.contains(addressFromOutputScript(out.scriptPubKey, network));
|
final addressExists = addresses.contains(address);
|
||||||
|
|
||||||
if (addressExists) {
|
|
||||||
receivedAmounts.add(out.amount.toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((direction == TransactionDirection.incoming && addressExists) ||
|
if ((direction == TransactionDirection.incoming && addressExists) ||
|
||||||
(direction == TransactionDirection.outgoing && !addressExists)) {
|
(direction == TransactionDirection.outgoing && !addressExists)) {
|
||||||
amount += out.amount.toInt();
|
amount += out.value!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivedAmounts.length == bundle.originalTransaction.outputs.length) {
|
|
||||||
// Self-send
|
|
||||||
direction = TransactionDirection.incoming;
|
|
||||||
amount = receivedAmounts.reduce((a, b) => a + b);
|
|
||||||
}
|
|
||||||
|
|
||||||
final fee = inputAmount - totalOutAmount;
|
final fee = inputAmount - totalOutAmount;
|
||||||
return ElectrumTransactionInfo(type,
|
return ElectrumTransactionInfo(type,
|
||||||
id: bundle.originalTransaction.txId(),
|
id: bundle.originalTransaction.getId(),
|
||||||
height: height,
|
height: height,
|
||||||
isPending: bundle.confirmations == 0,
|
isPending: bundle.confirmations == 0,
|
||||||
fee: fee,
|
fee: fee,
|
||||||
|
@ -153,8 +152,8 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
if (addresses != null) {
|
if (addresses != null) {
|
||||||
tx.outs.forEach((out) {
|
tx.outs.forEach((out) {
|
||||||
try {
|
try {
|
||||||
final p2pkh =
|
final p2pkh = bitcoin.P2PKH(
|
||||||
bitcoin.P2PKH(data: PaymentData(output: out.script), network: bitcoin.bitcoin);
|
data: PaymentData(output: out.script), network: bitcoin.bitcoin);
|
||||||
exist = addresses.contains(p2pkh.data.address);
|
exist = addresses.contains(p2pkh.data.address);
|
||||||
|
|
||||||
if (exist) {
|
if (exist) {
|
||||||
|
@ -164,8 +163,9 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
final date =
|
final date = timestamp != null
|
||||||
timestamp != null ? DateTime.fromMillisecondsSinceEpoch(timestamp * 1000) : DateTime.now();
|
? DateTime.fromMillisecondsSinceEpoch(timestamp * 1000)
|
||||||
|
: DateTime.now();
|
||||||
|
|
||||||
return ElectrumTransactionInfo(type,
|
return ElectrumTransactionInfo(type,
|
||||||
id: tx.getId(),
|
id: tx.getId(),
|
||||||
|
@ -178,7 +178,8 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
confirmations: confirmations);
|
confirmations: confirmations);
|
||||||
}
|
}
|
||||||
|
|
||||||
factory ElectrumTransactionInfo.fromJson(Map<String, dynamic> data, WalletType type) {
|
factory ElectrumTransactionInfo.fromJson(
|
||||||
|
Map<String, dynamic> data, WalletType type) {
|
||||||
return ElectrumTransactionInfo(type,
|
return ElectrumTransactionInfo(type,
|
||||||
id: data['id'] as String,
|
id: data['id'] as String,
|
||||||
height: data['height'] as int,
|
height: data['height'] as int,
|
||||||
|
|
|
@ -3,10 +3,9 @@ import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart' as bitcoin_base;
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:cw_bitcoin/address_to_output_script.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
|
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_transaction_no_inputs_exception.dart';
|
import 'package:cw_bitcoin/bitcoin_transaction_no_inputs_exception.dart';
|
||||||
|
@ -19,7 +18,6 @@ import 'package:cw_bitcoin/electrum_balance.dart';
|
||||||
import 'package:cw_bitcoin/electrum_transaction_history.dart';
|
import 'package:cw_bitcoin/electrum_transaction_history.dart';
|
||||||
import 'package:cw_bitcoin/electrum_transaction_info.dart';
|
import 'package:cw_bitcoin/electrum_transaction_info.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
||||||
import 'package:cw_bitcoin/litecoin_network.dart';
|
|
||||||
import 'package:cw_bitcoin/pending_bitcoin_transaction.dart';
|
import 'package:cw_bitcoin/pending_bitcoin_transaction.dart';
|
||||||
import 'package:cw_bitcoin/script_hash.dart';
|
import 'package:cw_bitcoin/script_hash.dart';
|
||||||
import 'package:cw_bitcoin/utils.dart';
|
import 'package:cw_bitcoin/utils.dart';
|
||||||
|
@ -35,10 +33,10 @@ import 'package:cw_core/utils/file.dart';
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:hex/hex.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:rxdart/subjects.dart';
|
import 'package:rxdart/subjects.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
|
|
||||||
part 'electrum_wallet.g.dart';
|
part 'electrum_wallet.g.dart';
|
||||||
|
|
||||||
|
@ -75,12 +73,6 @@ abstract class ElectrumWalletBase
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
this.unspentCoinsInfo = unspentCoinsInfo,
|
this.unspentCoinsInfo = unspentCoinsInfo,
|
||||||
this.network = networkType == bitcoin.bitcoin
|
|
||||||
? BitcoinNetwork.mainnet
|
|
||||||
: networkType == litecoinNetwork
|
|
||||||
? LitecoinNetwork.mainnet
|
|
||||||
: BitcoinNetwork.testnet,
|
|
||||||
this.isTestnet = networkType == bitcoin.testnet,
|
|
||||||
super(walletInfo) {
|
super(walletInfo) {
|
||||||
this.electrumClient = electrumClient ?? ElectrumClient();
|
this.electrumClient = electrumClient ?? ElectrumClient();
|
||||||
this.walletInfo = walletInfo;
|
this.walletInfo = walletInfo;
|
||||||
|
@ -114,13 +106,13 @@ abstract class ElectrumWalletBase
|
||||||
@observable
|
@observable
|
||||||
SyncStatus syncStatus;
|
SyncStatus syncStatus;
|
||||||
|
|
||||||
List<String> get scriptHashes => walletAddresses.addressesByReceiveType
|
List<String> get scriptHashes => walletAddresses.addresses
|
||||||
.map((addr) => scriptHash(addr.address, network: network))
|
.map((addr) => scriptHash(addr.address, networkType: networkType))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
List<String> get publicScriptHashes => walletAddresses.allAddresses
|
List<String> get publicScriptHashes => walletAddresses.addresses
|
||||||
.where((addr) => !addr.isHidden)
|
.where((addr) => !addr.isHidden)
|
||||||
.map((addr) => scriptHash(addr.address, network: network))
|
.map((addr) => scriptHash(addr.address, networkType: networkType))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
String get xpub => hd.base58!;
|
String get xpub => hd.base58!;
|
||||||
|
@ -129,10 +121,6 @@ abstract class ElectrumWalletBase
|
||||||
String get seed => mnemonic;
|
String get seed => mnemonic;
|
||||||
|
|
||||||
bitcoin.NetworkType networkType;
|
bitcoin.NetworkType networkType;
|
||||||
BasedUtxoNetwork network;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool? isTestnet;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
BitcoinWalletKeys get keys =>
|
BitcoinWalletKeys get keys =>
|
||||||
|
@ -157,11 +145,12 @@ abstract class ElectrumWalletBase
|
||||||
Future<void> startSync() async {
|
Future<void> startSync() async {
|
||||||
try {
|
try {
|
||||||
syncStatus = AttemptingSyncStatus();
|
syncStatus = AttemptingSyncStatus();
|
||||||
|
await walletAddresses.discoverAddresses();
|
||||||
await updateTransactions();
|
await updateTransactions();
|
||||||
_subscribeForUpdates();
|
_subscribeForUpdates();
|
||||||
await updateUnspent();
|
await updateUnspent();
|
||||||
await updateBalance();
|
await updateBalance();
|
||||||
_feeRates = await electrumClient.feeRates(network: network);
|
_feeRates = await electrumClient.feeRates();
|
||||||
|
|
||||||
Timer.periodic(
|
Timer.periodic(
|
||||||
const Duration(minutes: 1), (timer) async => _feeRates = await electrumClient.feeRates());
|
const Duration(minutes: 1), (timer) async => _feeRates = await electrumClient.feeRates());
|
||||||
|
@ -192,206 +181,183 @@ abstract class ElectrumWalletBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<EstimatedTxResult> _estimateTxFeeAndInputsToUse(
|
@override
|
||||||
int credentialsAmount,
|
Future<PendingTransaction> createTransaction(Object credentials) async {
|
||||||
bool sendAll,
|
const minAmount = 546;
|
||||||
List<BitcoinBaseAddress> outputAddresses,
|
final transactionCredentials = credentials as BitcoinTransactionCredentials;
|
||||||
List<BitcoinOutput> outputs,
|
final inputs = <BitcoinUnspent>[];
|
||||||
BitcoinTransactionCredentials transactionCredentials,
|
final outputs = transactionCredentials.outputs;
|
||||||
{int? inputsCount}) async {
|
final hasMultiDestination = outputs.length > 1;
|
||||||
final utxos = <UtxoWithAddress>[];
|
|
||||||
List<ECPrivate> privateKeys = [];
|
|
||||||
|
|
||||||
var leftAmount = credentialsAmount;
|
|
||||||
var allInputsAmount = 0;
|
var allInputsAmount = 0;
|
||||||
|
|
||||||
for (int i = 0; i < unspentCoins.length; i++) {
|
if (unspentCoins.isEmpty) {
|
||||||
final utx = unspentCoins[i];
|
await updateUnspent();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final utx in unspentCoins) {
|
||||||
if (utx.isSending) {
|
if (utx.isSending) {
|
||||||
allInputsAmount += utx.value;
|
allInputsAmount += utx.value;
|
||||||
leftAmount = leftAmount - utx.value;
|
inputs.add(utx);
|
||||||
|
|
||||||
final address = _addressTypeFromStr(utx.address, network);
|
|
||||||
final privkey = generateECPrivate(
|
|
||||||
hd: utx.bitcoinAddressRecord.isHidden ? walletAddresses.sideHd : walletAddresses.mainHd,
|
|
||||||
index: utx.bitcoinAddressRecord.index,
|
|
||||||
network: network);
|
|
||||||
|
|
||||||
privateKeys.add(privkey);
|
|
||||||
|
|
||||||
utxos.add(
|
|
||||||
UtxoWithAddress(
|
|
||||||
utxo: BitcoinUtxo(
|
|
||||||
txHash: utx.hash,
|
|
||||||
value: BigInt.from(utx.value),
|
|
||||||
vout: utx.vout,
|
|
||||||
scriptType: _getScriptType(address),
|
|
||||||
),
|
|
||||||
ownerDetails:
|
|
||||||
UtxoAddressDetails(publicKey: privkey.getPublic().toHex(), address: address),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
bool amountIsAcquired = !sendAll && leftAmount <= 0;
|
|
||||||
if ((inputsCount == null && amountIsAcquired) || inputsCount == i + 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utxos.isEmpty) {
|
if (inputs.isEmpty) {
|
||||||
throw BitcoinTransactionNoInputsException();
|
throw BitcoinTransactionNoInputsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
var changeValue = allInputsAmount - credentialsAmount;
|
final allAmountFee = transactionCredentials.feeRate != null
|
||||||
|
? feeAmountWithFeeRate(transactionCredentials.feeRate!, inputs.length, outputs.length)
|
||||||
|
: feeAmountForPriority(transactionCredentials.priority!, inputs.length, outputs.length);
|
||||||
|
|
||||||
if (!sendAll) {
|
final allAmount = allInputsAmount - allAmountFee;
|
||||||
if (changeValue > 0) {
|
|
||||||
final changeAddress = await walletAddresses.getChangeAddress();
|
var credentialsAmount = 0;
|
||||||
final address = _addressTypeFromStr(changeAddress, network);
|
var amount = 0;
|
||||||
outputAddresses.add(address);
|
var fee = 0;
|
||||||
outputs.add(BitcoinOutput(address: address, value: BigInt.from(changeValue)));
|
|
||||||
}
|
if (hasMultiDestination) {
|
||||||
|
if (outputs.any((item) => item.sendAll || item.formattedCryptoAmount! <= 0)) {
|
||||||
|
throw BitcoinTransactionWrongBalanceException(currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
final estimatedSize = BitcoinTransactionBuilder.estimateTransactionSize(
|
credentialsAmount = outputs.fold(0, (acc, value) => acc + value.formattedCryptoAmount!);
|
||||||
utxos: utxos, outputs: outputs, network: network);
|
|
||||||
|
|
||||||
final fee = transactionCredentials.feeRate != null
|
if (allAmount - credentialsAmount < minAmount) {
|
||||||
? feeAmountWithFeeRate(transactionCredentials.feeRate!, 0, 0, size: estimatedSize)
|
throw BitcoinTransactionWrongBalanceException(currency);
|
||||||
: feeAmountForPriority(transactionCredentials.priority!, 0, 0, size: estimatedSize);
|
}
|
||||||
|
|
||||||
|
amount = credentialsAmount;
|
||||||
|
|
||||||
|
if (transactionCredentials.feeRate != null) {
|
||||||
|
fee = calculateEstimatedFeeWithFeeRate(transactionCredentials.feeRate!, amount,
|
||||||
|
outputsCount: outputs.length + 1);
|
||||||
|
} else {
|
||||||
|
fee = calculateEstimatedFee(transactionCredentials.priority, amount,
|
||||||
|
outputsCount: outputs.length + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
final output = outputs.first;
|
||||||
|
credentialsAmount = !output.sendAll ? output.formattedCryptoAmount! : 0;
|
||||||
|
|
||||||
|
if (credentialsAmount > allAmount) {
|
||||||
|
throw BitcoinTransactionWrongBalanceException(currency);
|
||||||
|
}
|
||||||
|
|
||||||
|
amount = output.sendAll || allAmount - credentialsAmount < minAmount
|
||||||
|
? allAmount
|
||||||
|
: credentialsAmount;
|
||||||
|
|
||||||
|
if (output.sendAll || amount == allAmount) {
|
||||||
|
fee = allAmountFee;
|
||||||
|
} else if (transactionCredentials.feeRate != null) {
|
||||||
|
fee = calculateEstimatedFeeWithFeeRate(transactionCredentials.feeRate!, amount);
|
||||||
|
} else {
|
||||||
|
fee = calculateEstimatedFee(transactionCredentials.priority, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fee == 0) {
|
if (fee == 0) {
|
||||||
throw BitcoinTransactionWrongBalanceException(currency);
|
throw BitcoinTransactionWrongBalanceException(currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
var amount = credentialsAmount;
|
|
||||||
|
|
||||||
final lastOutput = outputs.last;
|
|
||||||
if (!sendAll) {
|
|
||||||
if (changeValue > fee) {
|
|
||||||
// Here, lastOutput is change, deduct the fee from it
|
|
||||||
outputs[outputs.length - 1] =
|
|
||||||
BitcoinOutput(address: lastOutput.address, value: lastOutput.value - BigInt.from(fee));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Here, if sendAll, the output amount equals to the input value - fee to fully spend every input on the transaction and have no amount for change
|
|
||||||
amount = allInputsAmount - fee;
|
|
||||||
outputs[outputs.length - 1] =
|
|
||||||
BitcoinOutput(address: lastOutput.address, value: BigInt.from(amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
final totalAmount = amount + fee;
|
final totalAmount = amount + fee;
|
||||||
|
|
||||||
if (totalAmount > balance[currency]!.confirmed) {
|
if (totalAmount > balance[currency]!.confirmed || totalAmount > allInputsAmount) {
|
||||||
throw BitcoinTransactionWrongBalanceException(currency);
|
throw BitcoinTransactionWrongBalanceException(currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalAmount > allInputsAmount) {
|
final txb = bitcoin.TransactionBuilder(network: networkType);
|
||||||
if (unspentCoins.where((utx) => utx.isSending).length == utxos.length) {
|
final changeAddress = await walletAddresses.getChangeAddress();
|
||||||
throw BitcoinTransactionWrongBalanceException(currency);
|
var leftAmount = totalAmount;
|
||||||
} else {
|
var totalInputAmount = 0;
|
||||||
if (changeValue > fee) {
|
|
||||||
outputAddresses.removeLast();
|
|
||||||
outputs.removeLast();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _estimateTxFeeAndInputsToUse(
|
inputs.clear();
|
||||||
credentialsAmount, sendAll, outputAddresses, outputs, transactionCredentials,
|
|
||||||
inputsCount: utxos.length + 1);
|
for (final utx in unspentCoins) {
|
||||||
|
if (utx.isSending) {
|
||||||
|
leftAmount = leftAmount - utx.value;
|
||||||
|
totalInputAmount += utx.value;
|
||||||
|
inputs.add(utx);
|
||||||
|
|
||||||
|
if (leftAmount <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EstimatedTxResult(utxos: utxos, privateKeys: privateKeys, fee: fee, amount: amount);
|
if (inputs.isEmpty) {
|
||||||
|
throw BitcoinTransactionNoInputsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
if (amount <= 0 || totalInputAmount < totalAmount) {
|
||||||
Future<PendingTransaction> createTransaction(Object credentials) async {
|
|
||||||
try {
|
|
||||||
final outputs = <BitcoinOutput>[];
|
|
||||||
final outputAddresses = <BitcoinBaseAddress>[];
|
|
||||||
final transactionCredentials = credentials as BitcoinTransactionCredentials;
|
|
||||||
final hasMultiDestination = transactionCredentials.outputs.length > 1;
|
|
||||||
final sendAll = !hasMultiDestination && transactionCredentials.outputs.first.sendAll;
|
|
||||||
|
|
||||||
var credentialsAmount = 0;
|
|
||||||
|
|
||||||
for (final out in transactionCredentials.outputs) {
|
|
||||||
final outputAddress = out.isParsedAddress ? out.extractedAddress! : out.address;
|
|
||||||
final address = _addressTypeFromStr(outputAddress, network);
|
|
||||||
|
|
||||||
outputAddresses.add(address);
|
|
||||||
|
|
||||||
if (hasMultiDestination) {
|
|
||||||
if (out.sendAll || out.formattedCryptoAmount! <= 0) {
|
|
||||||
throw BitcoinTransactionWrongBalanceException(currency);
|
throw BitcoinTransactionWrongBalanceException(currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
final outputAmount = out.formattedCryptoAmount!;
|
txb.setVersion(1);
|
||||||
credentialsAmount += outputAmount;
|
inputs.forEach((input) {
|
||||||
|
if (input.isP2wpkh) {
|
||||||
|
final p2wpkh = bitcoin
|
||||||
|
.P2WPKH(
|
||||||
|
data: generatePaymentData(
|
||||||
|
hd: input.bitcoinAddressRecord.isHidden
|
||||||
|
? walletAddresses.sideHd
|
||||||
|
: walletAddresses.mainHd,
|
||||||
|
index: input.bitcoinAddressRecord.index),
|
||||||
|
network: networkType)
|
||||||
|
.data;
|
||||||
|
|
||||||
outputs.add(BitcoinOutput(address: address, value: BigInt.from(outputAmount)));
|
txb.addInput(input.hash, input.vout, null, p2wpkh.output);
|
||||||
} else {
|
} else {
|
||||||
if (!sendAll) {
|
txb.addInput(input.hash, input.vout);
|
||||||
final outputAmount = out.formattedCryptoAmount!;
|
|
||||||
credentialsAmount += outputAmount;
|
|
||||||
outputs.add(BitcoinOutput(address: address, value: BigInt.from(outputAmount)));
|
|
||||||
} else {
|
|
||||||
// The value will be changed after estimating the Tx size and deducting the fee from the total
|
|
||||||
outputs.add(BitcoinOutput(address: address, value: BigInt.from(0)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final estimatedTx = await _estimateTxFeeAndInputsToUse(
|
|
||||||
credentialsAmount, sendAll, outputAddresses, outputs, transactionCredentials);
|
|
||||||
|
|
||||||
final txb = BitcoinTransactionBuilder(
|
|
||||||
utxos: estimatedTx.utxos,
|
|
||||||
outputs: outputs,
|
|
||||||
fee: BigInt.from(estimatedTx.fee),
|
|
||||||
network: network);
|
|
||||||
|
|
||||||
final transaction = txb.buildTransaction((txDigest, utxo, publicKey, sighash) {
|
|
||||||
final key = estimatedTx.privateKeys
|
|
||||||
.firstWhereOrNull((element) => element.getPublic().toHex() == publicKey);
|
|
||||||
|
|
||||||
if (key == null) {
|
|
||||||
throw Exception("Cannot find private key");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utxo.utxo.isP2tr()) {
|
|
||||||
return key.signTapRoot(txDigest, sighash: sighash);
|
|
||||||
} else {
|
|
||||||
return key.signInput(txDigest, sigHash: sighash);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return PendingBitcoinTransaction(transaction, type,
|
outputs.forEach((item) {
|
||||||
electrumClient: electrumClient,
|
final outputAmount = hasMultiDestination ? item.formattedCryptoAmount : amount;
|
||||||
amount: estimatedTx.amount,
|
final outputAddress = item.isParsedAddress ? item.extractedAddress! : item.address;
|
||||||
fee: estimatedTx.fee,
|
txb.addOutput(addressToOutputScript(outputAddress, networkType), outputAmount!);
|
||||||
network: network)
|
});
|
||||||
|
|
||||||
|
final estimatedSize = estimatedTransactionSize(inputs.length, outputs.length + 1);
|
||||||
|
var feeAmount = 0;
|
||||||
|
|
||||||
|
if (transactionCredentials.feeRate != null) {
|
||||||
|
feeAmount = transactionCredentials.feeRate! * estimatedSize;
|
||||||
|
} else {
|
||||||
|
feeAmount = feeRate(transactionCredentials.priority!) * estimatedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
final changeValue = totalInputAmount - amount - feeAmount;
|
||||||
|
|
||||||
|
if (changeValue > minAmount) {
|
||||||
|
txb.addOutput(changeAddress, changeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < inputs.length; i++) {
|
||||||
|
final input = inputs[i];
|
||||||
|
final keyPair = generateKeyPair(
|
||||||
|
hd: input.bitcoinAddressRecord.isHidden ? walletAddresses.sideHd : walletAddresses.mainHd,
|
||||||
|
index: input.bitcoinAddressRecord.index,
|
||||||
|
network: networkType);
|
||||||
|
final witnessValue = input.isP2wpkh ? input.value : null;
|
||||||
|
|
||||||
|
txb.sign(vin: i, keyPair: keyPair, witnessValue: witnessValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PendingBitcoinTransaction(txb.build(), type,
|
||||||
|
electrumClient: electrumClient, amount: amount, fee: fee)
|
||||||
..addListener((transaction) async {
|
..addListener((transaction) async {
|
||||||
transactionHistory.addOne(transaction);
|
transactionHistory.addOne(transaction);
|
||||||
await updateBalance();
|
await updateBalance();
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String toJSON() => json.encode({
|
String toJSON() => json.encode({
|
||||||
'mnemonic': mnemonic,
|
'mnemonic': mnemonic,
|
||||||
'account_index': walletAddresses.currentReceiveAddressIndexByType,
|
'account_index': walletAddresses.currentReceiveAddressIndex.toString(),
|
||||||
'change_address_index': walletAddresses.currentChangeAddressIndexByType,
|
'change_address_index': walletAddresses.currentChangeAddressIndex.toString(),
|
||||||
'addresses': walletAddresses.allAddresses.map((addr) => addr.toJSON()).toList(),
|
'addresses': walletAddresses.addresses.map((addr) => addr.toJSON()).toList(),
|
||||||
'address_page_type': walletInfo.addressPageType == null
|
'balance': balance[currency]?.toJSON()
|
||||||
? SegwitAddresType.p2wpkh.toString()
|
|
||||||
: walletInfo.addressPageType.toString(),
|
|
||||||
'balance': balance[currency]?.toJSON(),
|
|
||||||
'network_type': network == BitcoinNetwork.testnet ? 'testnet' : 'mainnet',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
int feeRate(TransactionPriority priority) {
|
int feeRate(TransactionPriority priority) {
|
||||||
|
@ -406,29 +372,24 @@ abstract class ElectrumWalletBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int feeAmountForPriority(BitcoinTransactionPriority priority, int inputsCount, int outputsCount,
|
int feeAmountForPriority(
|
||||||
{int? size}) =>
|
BitcoinTransactionPriority priority, int inputsCount, int outputsCount) =>
|
||||||
feeRate(priority) * (size ?? estimatedTransactionSize(inputsCount, outputsCount));
|
feeRate(priority) * estimatedTransactionSize(inputsCount, outputsCount);
|
||||||
|
|
||||||
int feeAmountWithFeeRate(int feeRate, int inputsCount, int outputsCount, {int? size}) =>
|
int feeAmountWithFeeRate(int feeRate, int inputsCount, int outputsCount) =>
|
||||||
feeRate * (size ?? estimatedTransactionSize(inputsCount, outputsCount));
|
feeRate * estimatedTransactionSize(inputsCount, outputsCount);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int calculateEstimatedFee(TransactionPriority? priority, int? amount,
|
int calculateEstimatedFee(TransactionPriority? priority, int? amount, {int? outputsCount}) {
|
||||||
{int? outputsCount, int? size}) {
|
|
||||||
if (priority is BitcoinTransactionPriority) {
|
if (priority is BitcoinTransactionPriority) {
|
||||||
return calculateEstimatedFeeWithFeeRate(feeRate(priority), amount,
|
return calculateEstimatedFeeWithFeeRate(feeRate(priority), amount,
|
||||||
outputsCount: outputsCount, size: size);
|
outputsCount: outputsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int calculateEstimatedFeeWithFeeRate(int feeRate, int? amount, {int? outputsCount, int? size}) {
|
int calculateEstimatedFeeWithFeeRate(int feeRate, int? amount, {int? outputsCount}) {
|
||||||
if (size != null) {
|
|
||||||
return feeAmountWithFeeRate(feeRate, 0, 0, size: size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int inputsCount = 0;
|
int inputsCount = 0;
|
||||||
|
|
||||||
if (amount != null) {
|
if (amount != null) {
|
||||||
|
@ -496,6 +457,9 @@ abstract class ElectrumWalletBase
|
||||||
await transactionHistory.changePassword(password);
|
await transactionHistory.changePassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bitcoin.ECPair keyPairFor({required int index}) =>
|
||||||
|
generateKeyPair(hd: hd, index: index, network: networkType);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> rescan({required int height}) async => throw UnimplementedError();
|
Future<void> rescan({required int height}) async => throw UnimplementedError();
|
||||||
|
|
||||||
|
@ -509,23 +473,20 @@ abstract class ElectrumWalletBase
|
||||||
Future<String> makePath() async => pathForWallet(name: walletInfo.name, type: walletInfo.type);
|
Future<String> makePath() async => pathForWallet(name: walletInfo.name, type: walletInfo.type);
|
||||||
|
|
||||||
Future<void> updateUnspent() async {
|
Future<void> updateUnspent() async {
|
||||||
List<BitcoinUnspent> updatedUnspentCoins = [];
|
final unspent = await Future.wait(walletAddresses.addresses.map((address) => electrumClient
|
||||||
|
.getListUnspentWithAddress(address.address, networkType)
|
||||||
final addressesSet = walletAddresses.allAddresses.map((addr) => addr.address).toSet();
|
.then((unspent) => unspent.map((unspent) {
|
||||||
|
|
||||||
await Future.wait(walletAddresses.allAddresses.map((address) => electrumClient
|
|
||||||
.getListUnspentWithAddress(address.address, network)
|
|
||||||
.then((unspent) => Future.forEach<Map<String, dynamic>>(unspent, (unspent) async {
|
|
||||||
try {
|
try {
|
||||||
final coin = BitcoinUnspent.fromJSON(address, unspent);
|
return BitcoinUnspent.fromJSON(address, unspent);
|
||||||
final tx = await fetchTransactionInfo(
|
} catch (_) {
|
||||||
hash: coin.hash, height: 0, myAddresses: addressesSet);
|
return null;
|
||||||
|
}
|
||||||
|
}).whereNotNull())));
|
||||||
|
unspentCoins = unspent.expand((e) => e).toList();
|
||||||
|
unspentCoins.forEach((coin) async {
|
||||||
|
final tx = await fetchTransactionInfo(hash: coin.hash, height: 0);
|
||||||
coin.isChange = tx?.direction == TransactionDirection.outgoing;
|
coin.isChange = tx?.direction == TransactionDirection.outgoing;
|
||||||
updatedUnspentCoins.add(coin);
|
});
|
||||||
} catch (_) {}
|
|
||||||
}))));
|
|
||||||
|
|
||||||
unspentCoins = updatedUnspentCoins;
|
|
||||||
|
|
||||||
if (unspentCoinsInfo.isEmpty) {
|
if (unspentCoinsInfo.isEmpty) {
|
||||||
unspentCoins.forEach((coin) => _addCoinInfo(coin));
|
unspentCoins.forEach((coin) => _addCoinInfo(coin));
|
||||||
|
@ -534,10 +495,8 @@ abstract class ElectrumWalletBase
|
||||||
|
|
||||||
if (unspentCoins.isNotEmpty) {
|
if (unspentCoins.isNotEmpty) {
|
||||||
unspentCoins.forEach((coin) {
|
unspentCoins.forEach((coin) {
|
||||||
final coinInfoList = unspentCoinsInfo.values.where((element) =>
|
final coinInfoList = unspentCoinsInfo.values
|
||||||
element.walletId.contains(id) &&
|
.where((element) => element.walletId.contains(id) && element.hash.contains(coin.hash));
|
||||||
element.hash.contains(coin.hash) &&
|
|
||||||
element.vout == coin.vout);
|
|
||||||
|
|
||||||
if (coinInfoList.isNotEmpty) {
|
if (coinInfoList.isNotEmpty) {
|
||||||
final coinInfo = coinInfoList.first;
|
final coinInfo = coinInfoList.first;
|
||||||
|
@ -578,8 +537,7 @@ abstract class ElectrumWalletBase
|
||||||
|
|
||||||
if (currentWalletUnspentCoins.isNotEmpty) {
|
if (currentWalletUnspentCoins.isNotEmpty) {
|
||||||
currentWalletUnspentCoins.forEach((element) {
|
currentWalletUnspentCoins.forEach((element) {
|
||||||
final existUnspentCoins = unspentCoins
|
final existUnspentCoins = unspentCoins.where((coin) => element.hash.contains(coin.hash));
|
||||||
.where((coin) => element.hash.contains(coin.hash) && element.vout == coin.vout);
|
|
||||||
|
|
||||||
if (existUnspentCoins.isEmpty) {
|
if (existUnspentCoins.isEmpty) {
|
||||||
keys.add(element.key);
|
keys.add(element.key);
|
||||||
|
@ -597,145 +555,92 @@ abstract class ElectrumWalletBase
|
||||||
|
|
||||||
Future<ElectrumTransactionBundle> getTransactionExpanded(
|
Future<ElectrumTransactionBundle> getTransactionExpanded(
|
||||||
{required String hash, required int height}) async {
|
{required String hash, required int height}) async {
|
||||||
String transactionHex;
|
|
||||||
int? time;
|
|
||||||
int confirmations = 0;
|
|
||||||
if (network == BitcoinNetwork.testnet) {
|
|
||||||
// Testnet public electrum server does not support verbose transaction fetching
|
|
||||||
transactionHex = await electrumClient.getTransactionHex(hash: hash);
|
|
||||||
|
|
||||||
final status = json.decode(
|
|
||||||
(await http.get(Uri.parse("https://blockstream.info/testnet/api/tx/$hash/status"))).body);
|
|
||||||
|
|
||||||
time = status["block_time"] as int?;
|
|
||||||
final tip = await electrumClient.getCurrentBlockChainTip() ?? 0;
|
|
||||||
confirmations = tip - (status["block_height"] as int? ?? 0);
|
|
||||||
} else {
|
|
||||||
final verboseTransaction = await electrumClient.getTransactionRaw(hash: hash);
|
final verboseTransaction = await electrumClient.getTransactionRaw(hash: hash);
|
||||||
|
final transactionHex = verboseTransaction['hex'] as String;
|
||||||
|
final original = bitcoin.Transaction.fromHex(transactionHex);
|
||||||
|
final ins = <bitcoin.Transaction>[];
|
||||||
|
final time = verboseTransaction['time'] as int?;
|
||||||
|
final confirmations = verboseTransaction['confirmations'] as int? ?? 0;
|
||||||
|
|
||||||
transactionHex = verboseTransaction['hex'] as String;
|
for (final vin in original.ins) {
|
||||||
time = verboseTransaction['time'] as int?;
|
final id = HEX.encode(vin.hash!.reversed.toList());
|
||||||
confirmations = verboseTransaction['confirmations'] as int? ?? 0;
|
final txHex = await electrumClient.getTransactionHex(hash: id);
|
||||||
}
|
final tx = bitcoin.Transaction.fromHex(txHex);
|
||||||
|
|
||||||
final original = bitcoin_base.BtcTransaction.fromRaw(transactionHex);
|
|
||||||
final ins = <bitcoin_base.BtcTransaction>[];
|
|
||||||
|
|
||||||
for (final vin in original.inputs) {
|
|
||||||
final txHex = await electrumClient.getTransactionHex(hash: vin.txId);
|
|
||||||
final tx = bitcoin_base.BtcTransaction.fromRaw(txHex);
|
|
||||||
ins.add(tx);
|
ins.add(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ElectrumTransactionBundle(original,
|
return ElectrumTransactionBundle(original, ins: ins, time: time, confirmations: confirmations);
|
||||||
ins: ins, time: time, confirmations: confirmations, height: height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ElectrumTransactionInfo?> fetchTransactionInfo(
|
Future<ElectrumTransactionInfo?> fetchTransactionInfo(
|
||||||
{required String hash,
|
{required String hash, required int height}) async {
|
||||||
required int height,
|
|
||||||
required Set<String> myAddresses,
|
|
||||||
bool? retryOnFailure}) async {
|
|
||||||
try {
|
try {
|
||||||
return ElectrumTransactionInfo.fromElectrumBundle(
|
final tx = await getTransactionExpanded(hash: hash, height: height);
|
||||||
await getTransactionExpanded(hash: hash, height: height), walletInfo.type, network,
|
final addresses = walletAddresses.addresses.map((addr) => addr.address).toSet();
|
||||||
addresses: myAddresses, height: height);
|
return ElectrumTransactionInfo.fromElectrumBundle(tx, walletInfo.type, networkType,
|
||||||
} catch (e) {
|
addresses: addresses, height: height);
|
||||||
if (e is FormatException && retryOnFailure == true) {
|
} catch (_) {
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
|
||||||
return fetchTransactionInfo(hash: hash, height: height, myAddresses: myAddresses);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map<String, ElectrumTransactionInfo>> fetchTransactions() async {
|
Future<Map<String, ElectrumTransactionInfo>> fetchTransactions() async {
|
||||||
|
final addressHashes = <String, BitcoinAddressRecord>{};
|
||||||
|
final normalizedHistories = <Map<String, dynamic>>[];
|
||||||
|
final newTxCounts = <String, int>{};
|
||||||
|
|
||||||
|
walletAddresses.addresses.forEach((addressRecord) {
|
||||||
|
final sh = scriptHash(addressRecord.address, networkType: networkType);
|
||||||
|
addressHashes[sh] = addressRecord;
|
||||||
|
newTxCounts[sh] = 0;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Map<String, ElectrumTransactionInfo> historiesWithDetails = {};
|
final histories = addressHashes.keys.map((scriptHash) =>
|
||||||
final addressesSet = walletAddresses.allAddresses.map((addr) => addr.address).toSet();
|
electrumClient.getHistory(scriptHash).then((history) => {scriptHash: history}));
|
||||||
final currentHeight = await electrumClient.getCurrentBlockChainTip() ?? 0;
|
final historyResults = await Future.wait(histories);
|
||||||
|
|
||||||
await Future.wait(ADDRESS_TYPES.map((type) {
|
historyResults.forEach((history) {
|
||||||
final addressesByType = walletAddresses.allAddresses.where((addr) => addr.type == type);
|
history.entries.forEach((historyItem) {
|
||||||
|
if (historyItem.value.isNotEmpty) {
|
||||||
return Future.wait(addressesByType.map((addressRecord) async {
|
final address = addressHashes[historyItem.key];
|
||||||
final history = await _fetchAddressHistory(addressRecord, addressesSet, currentHeight);
|
address?.setAsUsed();
|
||||||
|
newTxCounts[historyItem.key] = historyItem.value.length;
|
||||||
if (history.isNotEmpty) {
|
normalizedHistories.addAll(historyItem.value);
|
||||||
addressRecord.txCount = history.length;
|
|
||||||
historiesWithDetails.addAll(history);
|
|
||||||
|
|
||||||
final matchedAddresses =
|
|
||||||
addressesByType.where((addr) => addr.isHidden == addressRecord.isHidden);
|
|
||||||
|
|
||||||
final isLastUsedAddress =
|
|
||||||
history.isNotEmpty && addressRecord.address == matchedAddresses.last.address;
|
|
||||||
|
|
||||||
if (isLastUsedAddress) {
|
|
||||||
await walletAddresses.discoverAddresses(
|
|
||||||
matchedAddresses.toList(),
|
|
||||||
addressRecord.isHidden,
|
|
||||||
(address, addressesSet) =>
|
|
||||||
_fetchAddressHistory(address, addressesSet, currentHeight)
|
|
||||||
.then((history) => history.isNotEmpty ? address.address : null),
|
|
||||||
type: type);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}));
|
});
|
||||||
}));
|
|
||||||
|
|
||||||
return historiesWithDetails;
|
for (var sh in addressHashes.keys) {
|
||||||
} catch (e) {
|
var balanceData = await electrumClient.getBalance(sh);
|
||||||
print(e.toString());
|
var addressRecord = addressHashes[sh];
|
||||||
return {};
|
if (addressRecord != null) {
|
||||||
|
addressRecord.balance = balanceData['confirmed'] as int? ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, ElectrumTransactionInfo>> _fetchAddressHistory(
|
addressHashes.forEach((sh, addressRecord) {
|
||||||
BitcoinAddressRecord addressRecord, Set<String> addressesSet, int currentHeight) async {
|
addressRecord.txCount = newTxCounts[sh] ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
final historiesWithDetails = await Future.wait(normalizedHistories.map((transaction) {
|
||||||
try {
|
try {
|
||||||
final Map<String, ElectrumTransactionInfo> historiesWithDetails = {};
|
return fetchTransactionInfo(
|
||||||
|
hash: transaction['tx_hash'] as String, height: transaction['height'] as int);
|
||||||
final history = await electrumClient
|
} catch (_) {
|
||||||
.getHistory(addressRecord.scriptHash ?? addressRecord.updateScriptHash(network));
|
|
||||||
|
|
||||||
if (history.isNotEmpty) {
|
|
||||||
addressRecord.setAsUsed();
|
|
||||||
|
|
||||||
await Future.wait(history.map((transaction) async {
|
|
||||||
final txid = transaction['tx_hash'] as String;
|
|
||||||
final height = transaction['height'] as int;
|
|
||||||
final storedTx = transactionHistory.transactions[txid];
|
|
||||||
|
|
||||||
if (storedTx != null) {
|
|
||||||
if (height > 0) {
|
|
||||||
storedTx.height = height;
|
|
||||||
// the tx's block itself is the first confirmation so add 1
|
|
||||||
storedTx.confirmations = currentHeight - height + 1;
|
|
||||||
storedTx.isPending = storedTx.confirmations == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
historiesWithDetails[txid] = storedTx;
|
|
||||||
} else {
|
|
||||||
final tx = await fetchTransactionInfo(
|
|
||||||
hash: txid, height: height, myAddresses: addressesSet, retryOnFailure: true);
|
|
||||||
|
|
||||||
if (tx != null) {
|
|
||||||
historiesWithDetails[txid] = tx;
|
|
||||||
|
|
||||||
// Got a new transaction fetched, add it to the transaction history
|
|
||||||
// instead of waiting all to finish, and next time it will be faster
|
|
||||||
transactionHistory.addOne(tx);
|
|
||||||
await transactionHistory.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Future.value(null);
|
return Future.value(null);
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
return historiesWithDetails;
|
return historiesWithDetails.fold<Map<String, ElectrumTransactionInfo>>(
|
||||||
|
<String, ElectrumTransactionInfo>{}, (acc, tx) {
|
||||||
|
if (tx == null) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
acc[tx.id] = acc[tx.id]?.updated(tx) ?? tx;
|
||||||
|
return acc;
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
return {};
|
return {};
|
||||||
|
@ -749,8 +654,10 @@ abstract class ElectrumWalletBase
|
||||||
}
|
}
|
||||||
|
|
||||||
_isTransactionUpdating = true;
|
_isTransactionUpdating = true;
|
||||||
await fetchTransactions();
|
final transactions = await fetchTransactions();
|
||||||
|
transactionHistory.addMany(transactions);
|
||||||
walletAddresses.updateReceiveAddresses();
|
walletAddresses.updateReceiveAddresses();
|
||||||
|
await transactionHistory.save();
|
||||||
_isTransactionUpdating = false;
|
_isTransactionUpdating = false;
|
||||||
} catch (e, stacktrace) {
|
} catch (e, stacktrace) {
|
||||||
print(stacktrace);
|
print(stacktrace);
|
||||||
|
@ -781,11 +688,11 @@ abstract class ElectrumWalletBase
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ElectrumBalance> _fetchBalances() async {
|
Future<ElectrumBalance> _fetchBalances() async {
|
||||||
final addresses = walletAddresses.allAddresses.toList();
|
final addresses = walletAddresses.addresses.toList();
|
||||||
final balanceFutures = <Future<Map<String, dynamic>>>[];
|
final balanceFutures = <Future<Map<String, dynamic>>>[];
|
||||||
for (var i = 0; i < addresses.length; i++) {
|
for (var i = 0; i < addresses.length; i++) {
|
||||||
final addressRecord = addresses[i];
|
final addressRecord = addresses[i];
|
||||||
final sh = scriptHash(addressRecord.address, network: network);
|
final sh = scriptHash(addressRecord.address, networkType: networkType);
|
||||||
final balanceFuture = electrumClient.getBalance(sh);
|
final balanceFuture = electrumClient.getBalance(sh);
|
||||||
balanceFutures.add(balanceFuture);
|
balanceFutures.add(balanceFuture);
|
||||||
}
|
}
|
||||||
|
@ -794,7 +701,6 @@ abstract class ElectrumWalletBase
|
||||||
unspentCoinsInfo.values.forEach((info) {
|
unspentCoinsInfo.values.forEach((info) {
|
||||||
unspentCoins.forEach((element) {
|
unspentCoins.forEach((element) {
|
||||||
if (element.hash == info.hash &&
|
if (element.hash == info.hash &&
|
||||||
element.vout == info.vout &&
|
|
||||||
info.isFrozen &&
|
info.isFrozen &&
|
||||||
element.bitcoinAddressRecord.address == info.address &&
|
element.bitcoinAddressRecord.address == info.address &&
|
||||||
element.value == info.value) {
|
element.value == info.value) {
|
||||||
|
@ -832,10 +738,10 @@ abstract class ElectrumWalletBase
|
||||||
String getChangeAddress() {
|
String getChangeAddress() {
|
||||||
const minCountOfHiddenAddresses = 5;
|
const minCountOfHiddenAddresses = 5;
|
||||||
final random = Random();
|
final random = Random();
|
||||||
var addresses = walletAddresses.allAddresses.where((addr) => addr.isHidden).toList();
|
var addresses = walletAddresses.addresses.where((addr) => addr.isHidden).toList();
|
||||||
|
|
||||||
if (addresses.length < minCountOfHiddenAddresses) {
|
if (addresses.length < minCountOfHiddenAddresses) {
|
||||||
addresses = walletAddresses.allAddresses.toList();
|
addresses = walletAddresses.addresses.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return addresses[random.nextInt(addresses.length)].address;
|
return addresses[random.nextInt(addresses.length)].address;
|
||||||
|
@ -847,62 +753,9 @@ abstract class ElectrumWalletBase
|
||||||
@override
|
@override
|
||||||
String signMessage(String message, {String? address = null}) {
|
String signMessage(String message, {String? address = null}) {
|
||||||
final index = address != null
|
final index = address != null
|
||||||
? walletAddresses.allAddresses.firstWhere((element) => element.address == address).index
|
? walletAddresses.addresses.firstWhere((element) => element.address == address).index
|
||||||
: null;
|
: null;
|
||||||
final HD = index == null ? hd : hd.derive(index);
|
final HD = index == null ? hd : hd.derive(index);
|
||||||
return base64Encode(HD.signMessage(message));
|
return base64Encode(HD.signMessage(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EstimateTxParams {
|
|
||||||
EstimateTxParams(
|
|
||||||
{required this.amount,
|
|
||||||
required this.feeRate,
|
|
||||||
required this.priority,
|
|
||||||
required this.outputsCount,
|
|
||||||
required this.size});
|
|
||||||
|
|
||||||
final int amount;
|
|
||||||
final int feeRate;
|
|
||||||
final TransactionPriority priority;
|
|
||||||
final int outputsCount;
|
|
||||||
final int size;
|
|
||||||
}
|
|
||||||
|
|
||||||
class EstimatedTxResult {
|
|
||||||
EstimatedTxResult(
|
|
||||||
{required this.utxos, required this.privateKeys, required this.fee, required this.amount});
|
|
||||||
|
|
||||||
final List<UtxoWithAddress> utxos;
|
|
||||||
final List<ECPrivate> privateKeys;
|
|
||||||
final int fee;
|
|
||||||
final int amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
BitcoinBaseAddress _addressTypeFromStr(String address, BasedUtxoNetwork network) {
|
|
||||||
if (P2pkhAddress.regex.hasMatch(address)) {
|
|
||||||
return P2pkhAddress.fromAddress(address: address, network: network);
|
|
||||||
} else if (P2shAddress.regex.hasMatch(address)) {
|
|
||||||
return P2shAddress.fromAddress(address: address, network: network);
|
|
||||||
} else if (P2wshAddress.regex.hasMatch(address)) {
|
|
||||||
return P2wshAddress.fromAddress(address: address, network: network);
|
|
||||||
} else if (P2trAddress.regex.hasMatch(address)) {
|
|
||||||
return P2trAddress.fromAddress(address: address, network: network);
|
|
||||||
} else {
|
|
||||||
return P2wpkhAddress.fromAddress(address: address, network: network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BitcoinAddressType _getScriptType(BitcoinBaseAddress type) {
|
|
||||||
if (type is P2pkhAddress) {
|
|
||||||
return P2pkhAddressType.p2pkh;
|
|
||||||
} else if (type is P2shAddress) {
|
|
||||||
return P2shAddressType.p2wpkhInP2sh;
|
|
||||||
} else if (type is P2wshAddress) {
|
|
||||||
return SegwitAddresType.p2wsh;
|
|
||||||
} else if (type is P2trAddress) {
|
|
||||||
return SegwitAddresType.p2tr;
|
|
||||||
} else {
|
|
||||||
return SegwitAddresType.p2wpkh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
|
||||||
import 'package:bitbox/bitbox.dart' as bitbox;
|
import 'package:bitbox/bitbox.dart' as bitbox;
|
||||||
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||||
import 'package:cw_bitcoin/electrum.dart';
|
import 'package:cw_bitcoin/electrum.dart';
|
||||||
|
import 'package:cw_bitcoin/script_hash.dart';
|
||||||
import 'package:cw_core/wallet_addresses.dart';
|
import 'package:cw_core/wallet_addresses.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
@ -12,41 +12,25 @@ part 'electrum_wallet_addresses.g.dart';
|
||||||
|
|
||||||
class ElectrumWalletAddresses = ElectrumWalletAddressesBase with _$ElectrumWalletAddresses;
|
class ElectrumWalletAddresses = ElectrumWalletAddressesBase with _$ElectrumWalletAddresses;
|
||||||
|
|
||||||
const List<BitcoinAddressType> ADDRESS_TYPES = [
|
|
||||||
SegwitAddresType.p2wpkh,
|
|
||||||
P2pkhAddressType.p2pkh,
|
|
||||||
SegwitAddresType.p2tr,
|
|
||||||
SegwitAddresType.p2wsh,
|
|
||||||
P2shAddressType.p2wpkhInP2sh,
|
|
||||||
];
|
|
||||||
|
|
||||||
abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
ElectrumWalletAddressesBase(
|
ElectrumWalletAddressesBase(WalletInfo walletInfo,
|
||||||
WalletInfo walletInfo, {
|
{required this.mainHd,
|
||||||
required this.mainHd,
|
|
||||||
required this.sideHd,
|
required this.sideHd,
|
||||||
required this.electrumClient,
|
required this.electrumClient,
|
||||||
required this.network,
|
required this.networkType,
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
}) : _addresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? []).toSet()),
|
: addresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? []).toSet()),
|
||||||
addressesByReceiveType =
|
|
||||||
ObservableList<BitcoinAddressRecord>.of((<BitcoinAddressRecord>[]).toSet()),
|
|
||||||
receiveAddresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? [])
|
receiveAddresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? [])
|
||||||
.where((addressRecord) => !addressRecord.isHidden && !addressRecord.isUsed)
|
.where((addressRecord) => !addressRecord.isHidden && !addressRecord.isUsed)
|
||||||
.toSet()),
|
.toSet()),
|
||||||
changeAddresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? [])
|
changeAddresses = ObservableList<BitcoinAddressRecord>.of((initialAddresses ?? [])
|
||||||
.where((addressRecord) => addressRecord.isHidden && !addressRecord.isUsed)
|
.where((addressRecord) => addressRecord.isHidden && !addressRecord.isUsed)
|
||||||
.toSet()),
|
.toSet()),
|
||||||
currentReceiveAddressIndexByType = initialRegularAddressIndex ?? {},
|
currentReceiveAddressIndex = initialRegularAddressIndex,
|
||||||
currentChangeAddressIndexByType = initialChangeAddressIndex ?? {},
|
currentChangeAddressIndex = initialChangeAddressIndex,
|
||||||
_addressPageType = walletInfo.addressPageType != null
|
super(walletInfo);
|
||||||
? BitcoinAddressType.fromValue(walletInfo.addressPageType!)
|
|
||||||
: SegwitAddresType.p2wpkh,
|
|
||||||
super(walletInfo) {
|
|
||||||
updateAddressesByMatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const defaultReceiveAddressesCount = 22;
|
static const defaultReceiveAddressesCount = 22;
|
||||||
static const defaultChangeAddressesCount = 17;
|
static const defaultChangeAddressesCount = 17;
|
||||||
|
@ -56,48 +40,37 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
|
|
||||||
static String toLegacy(String address) => bitbox.Address.toLegacyAddress(address);
|
static String toLegacy(String address) => bitbox.Address.toLegacyAddress(address);
|
||||||
|
|
||||||
final ObservableList<BitcoinAddressRecord> _addresses;
|
final ObservableList<BitcoinAddressRecord> addresses;
|
||||||
// Matched by addressPageType
|
|
||||||
late ObservableList<BitcoinAddressRecord> addressesByReceiveType;
|
|
||||||
final ObservableList<BitcoinAddressRecord> receiveAddresses;
|
final ObservableList<BitcoinAddressRecord> receiveAddresses;
|
||||||
final ObservableList<BitcoinAddressRecord> changeAddresses;
|
final ObservableList<BitcoinAddressRecord> changeAddresses;
|
||||||
final ElectrumClient electrumClient;
|
final ElectrumClient electrumClient;
|
||||||
final BasedUtxoNetwork network;
|
final bitcoin.NetworkType networkType;
|
||||||
final bitcoin.HDWallet mainHd;
|
final bitcoin.HDWallet mainHd;
|
||||||
final bitcoin.HDWallet sideHd;
|
final bitcoin.HDWallet sideHd;
|
||||||
|
|
||||||
@observable
|
|
||||||
BitcoinAddressType _addressPageType = SegwitAddresType.p2wpkh;
|
|
||||||
|
|
||||||
@computed
|
|
||||||
BitcoinAddressType get addressPageType => _addressPageType;
|
|
||||||
|
|
||||||
@computed
|
|
||||||
List<BitcoinAddressRecord> get allAddresses => _addresses;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@computed
|
@computed
|
||||||
String get address {
|
String get address {
|
||||||
String receiveAddress;
|
if (isEnabledAutoGenerateSubaddress) {
|
||||||
|
if (receiveAddresses.isEmpty) {
|
||||||
final typeMatchingReceiveAddresses = receiveAddresses.where(_isAddressPageTypeMatch);
|
final newAddress = generateNewAddress(hd: mainHd).address;
|
||||||
|
return walletInfo.type == WalletType.bitcoinCash ? toCashAddr(newAddress) : newAddress;
|
||||||
if ((isEnabledAutoGenerateSubaddress && receiveAddresses.isEmpty) ||
|
|
||||||
typeMatchingReceiveAddresses.isEmpty) {
|
|
||||||
receiveAddress = generateNewAddress().address;
|
|
||||||
} else {
|
|
||||||
final previousAddressMatchesType =
|
|
||||||
previousAddressRecord != null && previousAddressRecord!.type == addressPageType;
|
|
||||||
|
|
||||||
if (previousAddressMatchesType &&
|
|
||||||
typeMatchingReceiveAddresses.first.address != addressesByReceiveType.first.address) {
|
|
||||||
receiveAddress = previousAddressRecord!.address;
|
|
||||||
} else {
|
|
||||||
receiveAddress = typeMatchingReceiveAddresses.first.address;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
final receiveAddress = receiveAddresses.first.address;
|
||||||
|
|
||||||
return walletInfo.type == WalletType.bitcoinCash ? toCashAddr(receiveAddress) : receiveAddress;
|
return walletInfo.type == WalletType.bitcoinCash
|
||||||
|
? toCashAddr(receiveAddress)
|
||||||
|
: receiveAddress;
|
||||||
|
} else {
|
||||||
|
final receiveAddress = (receiveAddresses.first.address != addresses.first.address &&
|
||||||
|
previousAddressRecord != null)
|
||||||
|
? previousAddressRecord!.address
|
||||||
|
: addresses.first.address;
|
||||||
|
|
||||||
|
return walletInfo.type == WalletType.bitcoinCash
|
||||||
|
? toCashAddr(receiveAddress)
|
||||||
|
: receiveAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
|
@ -108,7 +81,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
if (addr.startsWith('bitcoincash:')) {
|
if (addr.startsWith('bitcoincash:')) {
|
||||||
addr = toLegacy(addr);
|
addr = toLegacy(addr);
|
||||||
}
|
}
|
||||||
final addressRecord = _addresses.firstWhere((addressRecord) => addressRecord.address == addr);
|
final addressRecord = addresses.firstWhere((addressRecord) => addressRecord.address == addr);
|
||||||
|
|
||||||
previousAddressRecord = addressRecord;
|
previousAddressRecord = addressRecord;
|
||||||
receiveAddresses.remove(addressRecord);
|
receiveAddresses.remove(addressRecord);
|
||||||
|
@ -116,29 +89,16 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get primaryAddress => getAddress(index: 0, hd: mainHd, addressType: addressPageType);
|
String get primaryAddress => getAddress(index: 0, hd: mainHd);
|
||||||
|
|
||||||
Map<String, int> currentReceiveAddressIndexByType;
|
int currentReceiveAddressIndex;
|
||||||
|
int currentChangeAddressIndex;
|
||||||
int get currentReceiveAddressIndex =>
|
|
||||||
currentReceiveAddressIndexByType[_addressPageType.toString()] ?? 0;
|
|
||||||
|
|
||||||
void set currentReceiveAddressIndex(int index) =>
|
|
||||||
currentReceiveAddressIndexByType[_addressPageType.toString()] = index;
|
|
||||||
|
|
||||||
Map<String, int> currentChangeAddressIndexByType;
|
|
||||||
|
|
||||||
int get currentChangeAddressIndex =>
|
|
||||||
currentChangeAddressIndexByType[_addressPageType.toString()] ?? 0;
|
|
||||||
|
|
||||||
void set currentChangeAddressIndex(int index) =>
|
|
||||||
currentChangeAddressIndexByType[_addressPageType.toString()] = index;
|
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
BitcoinAddressRecord? previousAddressRecord;
|
BitcoinAddressRecord? previousAddressRecord;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
int get totalCountOfReceiveAddresses => addressesByReceiveType.fold(0, (acc, addressRecord) {
|
int get totalCountOfReceiveAddresses => addresses.fold(0, (acc, addressRecord) {
|
||||||
if (!addressRecord.isHidden) {
|
if (!addressRecord.isHidden) {
|
||||||
return acc + 1;
|
return acc + 1;
|
||||||
}
|
}
|
||||||
|
@ -146,21 +106,22 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
});
|
});
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
int get totalCountOfChangeAddresses => addressesByReceiveType.fold(0, (acc, addressRecord) {
|
int get totalCountOfChangeAddresses => addresses.fold(0, (acc, addressRecord) {
|
||||||
if (addressRecord.isHidden) {
|
if (addressRecord.isHidden) {
|
||||||
return acc + 1;
|
return acc + 1;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Future<void> discoverAddresses() async {
|
||||||
|
await _discoverAddresses(mainHd, false);
|
||||||
|
await _discoverAddresses(sideHd, true);
|
||||||
|
await updateAddressesInBox();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
await _generateInitialAddresses();
|
await _generateInitialAddresses();
|
||||||
await _generateInitialAddresses(type: P2pkhAddressType.p2pkh);
|
|
||||||
await _generateInitialAddresses(type: P2shAddressType.p2wpkhInP2sh);
|
|
||||||
await _generateInitialAddresses(type: SegwitAddresType.p2tr);
|
|
||||||
await _generateInitialAddresses(type: SegwitAddresType.p2wsh);
|
|
||||||
updateAddressesByMatch();
|
|
||||||
updateReceiveAddresses();
|
updateReceiveAddresses();
|
||||||
updateChangeAddresses();
|
updateChangeAddresses();
|
||||||
await updateAddressesInBox();
|
await updateAddressesInBox();
|
||||||
|
@ -180,9 +141,10 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
|
|
||||||
if (changeAddresses.isEmpty) {
|
if (changeAddresses.isEmpty) {
|
||||||
final newAddresses = await _createNewAddresses(gap,
|
final newAddresses = await _createNewAddresses(gap,
|
||||||
|
hd: sideHd,
|
||||||
startIndex: totalCountOfChangeAddresses > 0 ? totalCountOfChangeAddresses - 1 : 0,
|
startIndex: totalCountOfChangeAddresses > 0 ? totalCountOfChangeAddresses - 1 : 0,
|
||||||
isHidden: true);
|
isHidden: true);
|
||||||
addAddresses(newAddresses);
|
_addAddresses(newAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentChangeAddressIndex >= changeAddresses.length) {
|
if (currentChangeAddressIndex >= changeAddresses.length) {
|
||||||
|
@ -195,26 +157,19 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
BitcoinAddressRecord generateNewAddress({String label = ''}) {
|
BitcoinAddressRecord generateNewAddress({bitcoin.HDWallet? hd, String? label}) {
|
||||||
final newAddressIndex = addressesByReceiveType.fold(
|
final isHidden = hd == sideHd;
|
||||||
0, (int acc, addressRecord) => addressRecord.isHidden == false ? acc + 1 : acc);
|
|
||||||
|
|
||||||
final address = BitcoinAddressRecord(
|
final newAddressIndex = addresses.fold(
|
||||||
getAddress(index: newAddressIndex, hd: mainHd, addressType: addressPageType),
|
0, (int acc, addressRecord) => isHidden == addressRecord.isHidden ? acc + 1 : acc);
|
||||||
index: newAddressIndex,
|
|
||||||
isHidden: false,
|
final address = BitcoinAddressRecord(getAddress(index: newAddressIndex, hd: hd ?? sideHd),
|
||||||
name: label,
|
index: newAddressIndex, isHidden: isHidden, name: label ?? '');
|
||||||
type: addressPageType,
|
addresses.add(address);
|
||||||
network: network,
|
|
||||||
);
|
|
||||||
_addresses.add(address);
|
|
||||||
updateAddressesByMatch();
|
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAddress(
|
String getAddress({required int index, required bitcoin.HDWallet hd}) => '';
|
||||||
{required int index, required bitcoin.HDWallet hd, BitcoinAddressType? addressType}) =>
|
|
||||||
'';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> updateAddressesInBox() async {
|
Future<void> updateAddressesInBox() async {
|
||||||
|
@ -232,138 +187,126 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
|
||||||
if (address.startsWith('bitcoincash:')) {
|
if (address.startsWith('bitcoincash:')) {
|
||||||
address = toLegacy(address);
|
address = toLegacy(address);
|
||||||
}
|
}
|
||||||
final addressRecord =
|
final addressRecord = addresses.firstWhere((addressRecord) => addressRecord.address == address);
|
||||||
_addresses.firstWhere((addressRecord) => addressRecord.address == address);
|
|
||||||
addressRecord.setNewName(label);
|
addressRecord.setNewName(label);
|
||||||
final index = _addresses.indexOf(addressRecord);
|
final index = addresses.indexOf(addressRecord);
|
||||||
_addresses.remove(addressRecord);
|
addresses.remove(addressRecord);
|
||||||
_addresses.insert(index, addressRecord);
|
addresses.insert(index, addressRecord);
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
void updateAddressesByMatch() {
|
|
||||||
addressesByReceiveType.clear();
|
|
||||||
addressesByReceiveType.addAll(_addresses.where(_isAddressPageTypeMatch).toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void updateReceiveAddresses() {
|
void updateReceiveAddresses() {
|
||||||
receiveAddresses.removeRange(0, receiveAddresses.length);
|
receiveAddresses.removeRange(0, receiveAddresses.length);
|
||||||
final newAddresses =
|
final newAddresses =
|
||||||
_addresses.where((addressRecord) => !addressRecord.isHidden && !addressRecord.isUsed);
|
addresses.where((addressRecord) => !addressRecord.isHidden && !addressRecord.isUsed);
|
||||||
receiveAddresses.addAll(newAddresses);
|
receiveAddresses.addAll(newAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void updateChangeAddresses() {
|
void updateChangeAddresses() {
|
||||||
changeAddresses.removeRange(0, changeAddresses.length);
|
changeAddresses.removeRange(0, changeAddresses.length);
|
||||||
final newAddresses = _addresses.where((addressRecord) =>
|
final newAddresses =
|
||||||
addressRecord.isHidden &&
|
addresses.where((addressRecord) => addressRecord.isHidden && !addressRecord.isUsed);
|
||||||
!addressRecord.isUsed &&
|
|
||||||
// TODO: feature to change change address type. For now fixed to p2wpkh, the cheapest type
|
|
||||||
addressRecord.type == SegwitAddresType.p2wpkh);
|
|
||||||
changeAddresses.addAll(newAddresses);
|
changeAddresses.addAll(newAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
Future<void> _discoverAddresses(bitcoin.HDWallet hd, bool isHidden) async {
|
||||||
Future<void> discoverAddresses(List<BitcoinAddressRecord> addressList, bool isHidden,
|
var hasAddrUse = true;
|
||||||
Future<String?> Function(BitcoinAddressRecord, Set<String>) getAddressHistory,
|
List<BitcoinAddressRecord> addrs;
|
||||||
{BitcoinAddressType type = SegwitAddresType.p2wpkh}) async {
|
|
||||||
if (!isHidden) {
|
if (addresses.isNotEmpty) {
|
||||||
_validateSideHdAddresses(addressList.toList());
|
|
||||||
|
|
||||||
|
if(!isHidden) {
|
||||||
|
final receiveAddressesList = addresses.where((addr) => !addr.isHidden).toList();
|
||||||
|
validateSideHdAddresses(receiveAddressesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
final newAddresses = await _createNewAddresses(gap,
|
addrs = addresses.where((addr) => addr.isHidden == isHidden).toList();
|
||||||
startIndex: addressList.length, isHidden: isHidden, type: type);
|
} else {
|
||||||
addAddresses(newAddresses);
|
addrs = await _createNewAddresses(
|
||||||
|
isHidden ? defaultChangeAddressesCount : defaultReceiveAddressesCount,
|
||||||
|
startIndex: 0,
|
||||||
|
hd: hd,
|
||||||
|
isHidden: isHidden);
|
||||||
|
}
|
||||||
|
|
||||||
final addressesWithHistory = await Future.wait(newAddresses
|
while (hasAddrUse) {
|
||||||
.map((addr) => getAddressHistory(addr, _addresses.map((e) => e.address).toSet())));
|
final addr = addrs.last.address;
|
||||||
final isLastAddressUsed = addressesWithHistory.last == addressList.last.address;
|
hasAddrUse = await _hasAddressUsed(addr);
|
||||||
|
|
||||||
if (isLastAddressUsed) {
|
if (!hasAddrUse) {
|
||||||
discoverAddresses(addressList, isHidden, getAddressHistory, type: type);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
final start = addrs.length;
|
||||||
|
final count = start + gap;
|
||||||
|
final batch = await _createNewAddresses(count, startIndex: start, hd: hd, isHidden: isHidden);
|
||||||
|
addrs.addAll(batch);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addresses.length < addrs.length) {
|
||||||
|
_addAddresses(addrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _generateInitialAddresses(
|
Future<void> _generateInitialAddresses() async {
|
||||||
{BitcoinAddressType type = SegwitAddresType.p2wpkh}) async {
|
|
||||||
var countOfReceiveAddresses = 0;
|
var countOfReceiveAddresses = 0;
|
||||||
var countOfHiddenAddresses = 0;
|
var countOfHiddenAddresses = 0;
|
||||||
|
|
||||||
_addresses.forEach((addr) {
|
addresses.forEach((addr) {
|
||||||
if (addr.type == type) {
|
|
||||||
if (addr.isHidden) {
|
if (addr.isHidden) {
|
||||||
countOfHiddenAddresses += 1;
|
countOfHiddenAddresses += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
countOfReceiveAddresses += 1;
|
countOfReceiveAddresses += 1;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (countOfReceiveAddresses < defaultReceiveAddressesCount) {
|
if (countOfReceiveAddresses < defaultReceiveAddressesCount) {
|
||||||
final addressesCount = defaultReceiveAddressesCount - countOfReceiveAddresses;
|
final addressesCount = defaultReceiveAddressesCount - countOfReceiveAddresses;
|
||||||
final newAddresses = await _createNewAddresses(addressesCount,
|
final newAddresses = await _createNewAddresses(addressesCount,
|
||||||
startIndex: countOfReceiveAddresses, isHidden: false, type: type);
|
startIndex: countOfReceiveAddresses, hd: mainHd, isHidden: false);
|
||||||
addAddresses(newAddresses);
|
addresses.addAll(newAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countOfHiddenAddresses < defaultChangeAddressesCount) {
|
if (countOfHiddenAddresses < defaultChangeAddressesCount) {
|
||||||
final addressesCount = defaultChangeAddressesCount - countOfHiddenAddresses;
|
final addressesCount = defaultChangeAddressesCount - countOfHiddenAddresses;
|
||||||
final newAddresses = await _createNewAddresses(addressesCount,
|
final newAddresses = await _createNewAddresses(addressesCount,
|
||||||
startIndex: countOfHiddenAddresses, isHidden: true, type: type);
|
startIndex: countOfHiddenAddresses, hd: sideHd, isHidden: true);
|
||||||
addAddresses(newAddresses);
|
addresses.addAll(newAddresses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<BitcoinAddressRecord>> _createNewAddresses(int count,
|
Future<List<BitcoinAddressRecord>> _createNewAddresses(int count,
|
||||||
{int startIndex = 0, bool isHidden = false, BitcoinAddressType? type}) async {
|
{required bitcoin.HDWallet hd, int startIndex = 0, bool isHidden = false}) async {
|
||||||
final list = <BitcoinAddressRecord>[];
|
final list = <BitcoinAddressRecord>[];
|
||||||
|
|
||||||
for (var i = startIndex; i < count + startIndex; i++) {
|
for (var i = startIndex; i < count + startIndex; i++) {
|
||||||
final address = BitcoinAddressRecord(
|
final address =
|
||||||
getAddress(index: i, hd: _getHd(isHidden), addressType: type ?? addressPageType),
|
BitcoinAddressRecord(getAddress(index: i, hd: hd), index: i, isHidden: isHidden);
|
||||||
index: i,
|
|
||||||
isHidden: isHidden,
|
|
||||||
type: type ?? addressPageType,
|
|
||||||
network: network,
|
|
||||||
);
|
|
||||||
list.add(address);
|
list.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
void _addAddresses(Iterable<BitcoinAddressRecord> addresses) {
|
||||||
void addAddresses(Iterable<BitcoinAddressRecord> addresses) {
|
final addressesSet = this.addresses.toSet();
|
||||||
final addressesSet = this._addresses.toSet();
|
|
||||||
addressesSet.addAll(addresses);
|
addressesSet.addAll(addresses);
|
||||||
this._addresses.clear();
|
this.addresses.removeRange(0, this.addresses.length);
|
||||||
this._addresses.addAll(addressesSet);
|
this.addresses.addAll(addressesSet);
|
||||||
updateAddressesByMatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _validateSideHdAddresses(List<BitcoinAddressRecord> addrWithTransactions) {
|
Future<bool> _hasAddressUsed(String address) async {
|
||||||
|
final sh = scriptHash(address, networkType: networkType);
|
||||||
|
final transactionHistory = await electrumClient.getHistory(sh);
|
||||||
|
return transactionHistory.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
void validateSideHdAddresses(List<BitcoinAddressRecord> addrWithTransactions) {
|
||||||
addrWithTransactions.forEach((element) {
|
addrWithTransactions.forEach((element) {
|
||||||
if (element.address !=
|
if (element.address != getAddress(index: element.index, hd: mainHd)) element.isHidden = true;
|
||||||
getAddress(index: element.index, hd: mainHd, addressType: element.type))
|
|
||||||
element.isHidden = true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
Future<void> setAddressType(BitcoinAddressType type) async {
|
|
||||||
_addressPageType = type;
|
|
||||||
updateAddressesByMatch();
|
|
||||||
walletInfo.addressPageType = addressPageType.toString();
|
|
||||||
await walletInfo.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _isAddressPageTypeMatch(BitcoinAddressRecord addressRecord) {
|
|
||||||
return _isAddressByType(addressRecord, addressPageType);
|
|
||||||
}
|
|
||||||
|
|
||||||
bitcoin.HDWallet _getHd(bool isHidden) => isHidden ? sideHd : mainHd;
|
|
||||||
bool _isAddressByType(BitcoinAddressRecord addr, BitcoinAddressType type) => addr.type == type;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||||
import 'package:cw_bitcoin/electrum_balance.dart';
|
import 'package:cw_bitcoin/electrum_balance.dart';
|
||||||
import 'package:cw_core/pathForWallet.dart';
|
import 'package:cw_core/pathForWallet.dart';
|
||||||
import 'package:cw_core/utils/file.dart';
|
import 'package:cw_core/utils/file.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
|
||||||
class ElectrumWalletSnapshot {
|
class ElectrumWallletSnapshot {
|
||||||
ElectrumWalletSnapshot({
|
ElectrumWallletSnapshot({
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.type,
|
required this.type,
|
||||||
required this.password,
|
required this.password,
|
||||||
|
@ -15,24 +14,19 @@ class ElectrumWalletSnapshot {
|
||||||
required this.addresses,
|
required this.addresses,
|
||||||
required this.balance,
|
required this.balance,
|
||||||
required this.regularAddressIndex,
|
required this.regularAddressIndex,
|
||||||
required this.changeAddressIndex,
|
required this.changeAddressIndex});
|
||||||
required this.addressPageType,
|
|
||||||
required this.network,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final String password;
|
final String password;
|
||||||
final WalletType type;
|
final WalletType type;
|
||||||
final String addressPageType;
|
|
||||||
final BasedUtxoNetwork network;
|
|
||||||
|
|
||||||
String mnemonic;
|
String mnemonic;
|
||||||
List<BitcoinAddressRecord> addresses;
|
List<BitcoinAddressRecord> addresses;
|
||||||
ElectrumBalance balance;
|
ElectrumBalance balance;
|
||||||
Map<String, int> regularAddressIndex;
|
int regularAddressIndex;
|
||||||
Map<String, int> changeAddressIndex;
|
int changeAddressIndex;
|
||||||
|
|
||||||
static Future<ElectrumWalletSnapshot> load(String name, WalletType type, String password, BasedUtxoNetwork? network) async {
|
static Future<ElectrumWallletSnapshot> load(String name, WalletType type, String password) async {
|
||||||
final path = await pathForWallet(name: name, type: type);
|
final path = await pathForWallet(name: name, type: type);
|
||||||
final jsonSource = await read(path: path, password: password);
|
final jsonSource = await read(path: path, password: password);
|
||||||
final data = json.decode(jsonSource) as Map;
|
final data = json.decode(jsonSource) as Map;
|
||||||
|
@ -40,39 +34,26 @@ class ElectrumWalletSnapshot {
|
||||||
final mnemonic = data['mnemonic'] as String;
|
final mnemonic = data['mnemonic'] as String;
|
||||||
final addresses = addressesTmp
|
final addresses = addressesTmp
|
||||||
.whereType<String>()
|
.whereType<String>()
|
||||||
.map((addr) => BitcoinAddressRecord.fromJSON(addr, network))
|
.map((addr) => BitcoinAddressRecord.fromJSON(addr))
|
||||||
.toList();
|
.toList();
|
||||||
final balance = ElectrumBalance.fromJSON(data['balance'] as String) ??
|
final balance = ElectrumBalance.fromJSON(data['balance'] as String) ??
|
||||||
ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
||||||
var regularAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
|
var regularAddressIndex = 0;
|
||||||
var changeAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0};
|
var changeAddressIndex = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
regularAddressIndexByType = {
|
regularAddressIndex = int.parse(data['account_index'] as String? ?? '0');
|
||||||
SegwitAddresType.p2wpkh.toString(): int.parse(data['account_index'] as String? ?? '0')
|
changeAddressIndex = int.parse(data['change_address_index'] as String? ?? '0');
|
||||||
};
|
|
||||||
changeAddressIndexByType = {
|
|
||||||
SegwitAddresType.p2wpkh.toString():
|
|
||||||
int.parse(data['change_address_index'] as String? ?? '0')
|
|
||||||
};
|
|
||||||
} catch (_) {
|
|
||||||
try {
|
|
||||||
regularAddressIndexByType = data["account_index"] as Map<String, int>? ?? {};
|
|
||||||
changeAddressIndexByType = data["change_address_index"] as Map<String, int>? ?? {};
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
|
||||||
|
|
||||||
return ElectrumWalletSnapshot(
|
return ElectrumWallletSnapshot(
|
||||||
name: name,
|
name: name,
|
||||||
type: type,
|
type: type,
|
||||||
password: password,
|
password: password,
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
addresses: addresses,
|
addresses: addresses,
|
||||||
balance: balance,
|
balance: balance,
|
||||||
regularAddressIndex: regularAddressIndexByType,
|
regularAddressIndex: regularAddressIndex,
|
||||||
changeAddressIndex: changeAddressIndexByType,
|
changeAddressIndex: changeAddressIndex);
|
||||||
addressPageType: data['address_page_type'] as String? ?? SegwitAddresType.p2wpkh.toString(),
|
|
||||||
network: data['network_type'] == 'testnet' ? BitcoinNetwork.testnet : BitcoinNetwork.mainnet,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_transaction_priority.dart';
|
import 'package:cw_bitcoin/bitcoin_transaction_priority.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
|
@ -21,18 +20,17 @@ part 'litecoin_wallet.g.dart';
|
||||||
class LitecoinWallet = LitecoinWalletBase with _$LitecoinWallet;
|
class LitecoinWallet = LitecoinWalletBase with _$LitecoinWallet;
|
||||||
|
|
||||||
abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
LitecoinWalletBase({
|
LitecoinWalletBase(
|
||||||
required String mnemonic,
|
{required String mnemonic,
|
||||||
required String password,
|
required String password,
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
required Uint8List seedBytes,
|
required Uint8List seedBytes,
|
||||||
String? addressPageType,
|
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
}) : super(
|
: super(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
|
@ -49,24 +47,25 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
mainHd: hd,
|
mainHd: hd,
|
||||||
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType).derivePath("m/0'/1"),
|
sideHd: bitcoin.HDWallet
|
||||||
network: network,
|
.fromSeed(seedBytes, network: networkType)
|
||||||
);
|
.derivePath("m/0'/1"),
|
||||||
|
networkType: networkType,);
|
||||||
autorun((_) {
|
autorun((_) {
|
||||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<LitecoinWallet> create(
|
static Future<LitecoinWallet> create({
|
||||||
{required String mnemonic,
|
required String mnemonic,
|
||||||
required String password,
|
required String password,
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
String? addressPageType,
|
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex}) async {
|
int initialChangeAddressIndex = 0
|
||||||
|
}) async {
|
||||||
return LitecoinWallet(
|
return LitecoinWallet(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -76,9 +75,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
seedBytes: await mnemonicToSeedBytes(mnemonic),
|
seedBytes: await mnemonicToSeedBytes(mnemonic),
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex);
|
||||||
addressPageType: addressPageType,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<LitecoinWallet> open({
|
static Future<LitecoinWallet> open({
|
||||||
|
@ -87,8 +84,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
required String password,
|
required String password,
|
||||||
}) async {
|
}) async {
|
||||||
final snp =
|
final snp = await ElectrumWallletSnapshot.load (name, walletInfo.type, password);
|
||||||
await ElectrumWalletSnapshot.load(name, walletInfo.type, password, LitecoinNetwork.mainnet);
|
|
||||||
return LitecoinWallet(
|
return LitecoinWallet(
|
||||||
mnemonic: snp.mnemonic,
|
mnemonic: snp.mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -98,9 +94,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: snp.balance,
|
initialBalance: snp.balance,
|
||||||
seedBytes: await mnemonicToSeedBytes(snp.mnemonic),
|
seedBytes: await mnemonicToSeedBytes(snp.mnemonic),
|
||||||
initialRegularAddressIndex: snp.regularAddressIndex,
|
initialRegularAddressIndex: snp.regularAddressIndex,
|
||||||
initialChangeAddressIndex: snp.changeAddressIndex,
|
initialChangeAddressIndex: snp.changeAddressIndex);
|
||||||
addressPageType: snp.addressPageType,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -1,28 +1,39 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
|
import 'package:cw_bitcoin/electrum.dart';
|
||||||
import 'package:cw_bitcoin/utils.dart';
|
import 'package:cw_bitcoin/utils.dart';
|
||||||
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
part 'litecoin_wallet_addresses.g.dart';
|
part 'litecoin_wallet_addresses.g.dart';
|
||||||
|
|
||||||
class LitecoinWalletAddresses = LitecoinWalletAddressesBase with _$LitecoinWalletAddresses;
|
class LitecoinWalletAddresses = LitecoinWalletAddressesBase
|
||||||
|
with _$LitecoinWalletAddresses;
|
||||||
|
|
||||||
abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses
|
||||||
|
with Store {
|
||||||
LitecoinWalletAddressesBase(
|
LitecoinWalletAddressesBase(
|
||||||
WalletInfo walletInfo, {
|
WalletInfo walletInfo,
|
||||||
required super.mainHd,
|
{required bitcoin.HDWallet mainHd,
|
||||||
required super.sideHd,
|
required bitcoin.HDWallet sideHd,
|
||||||
required super.network,
|
required bitcoin.NetworkType networkType,
|
||||||
required super.electrumClient,
|
required ElectrumClient electrumClient,
|
||||||
super.initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
super.initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
super.initialChangeAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
}) : super(walletInfo);
|
: super(
|
||||||
|
walletInfo,
|
||||||
|
initialAddresses: initialAddresses,
|
||||||
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
|
mainHd: mainHd,
|
||||||
|
sideHd: sideHd,
|
||||||
|
electrumClient: electrumClient,
|
||||||
|
networkType: networkType);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String getAddress(
|
String getAddress({required int index, required bitcoin.HDWallet hd}) =>
|
||||||
{required int index, required bitcoin.HDWallet hd, BitcoinAddressType? addressType}) =>
|
generateP2WPKHAddress(hd: hd, index: index, networkType: networkType);
|
||||||
generateP2WPKHAddress(hd: hd, index: index, network: network);
|
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ class LitecoinWalletService extends WalletService<
|
||||||
WalletType getType() => WalletType.litecoin;
|
WalletType getType() => WalletType.litecoin;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LitecoinWallet> create(BitcoinNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<LitecoinWallet> create(BitcoinNewWalletCredentials credentials) async {
|
||||||
final wallet = await LitecoinWalletBase.create(
|
final wallet = await LitecoinWalletBase.create(
|
||||||
mnemonic: await generateMnemonic(),
|
mnemonic: await generateMnemonic(),
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
|
@ -94,12 +94,12 @@ class LitecoinWalletService extends WalletService<
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LitecoinWallet> restoreFromKeys(
|
Future<LitecoinWallet> restoreFromKeys(
|
||||||
BitcoinRestoreWalletFromWIFCredentials credentials, {bool? isTestnet}) async =>
|
BitcoinRestoreWalletFromWIFCredentials credentials) async =>
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LitecoinWallet> restoreFromSeed(
|
Future<LitecoinWallet> restoreFromSeed(
|
||||||
BitcoinRestoreWalletFromSeedCredentials credentials, {bool? isTestnet}) async {
|
BitcoinRestoreWalletFromSeedCredentials credentials) async {
|
||||||
if (!validateMnemonic(credentials.mnemonic)) {
|
if (!validateMnemonic(credentials.mnemonic)) {
|
||||||
throw LitecoinMnemonicIsIncorrectException();
|
throw LitecoinMnemonicIsIncorrectException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:cw_bitcoin/bitcoin_commit_transaction_exception.dart';
|
import 'package:cw_bitcoin/bitcoin_commit_transaction_exception.dart';
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:cw_core/pending_transaction.dart';
|
import 'package:cw_core/pending_transaction.dart';
|
||||||
import 'package:cw_bitcoin/electrum.dart';
|
import 'package:cw_bitcoin/electrum.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
|
||||||
|
@ -9,21 +9,22 @@ import 'package:cw_core/wallet_type.dart';
|
||||||
|
|
||||||
class PendingBitcoinTransaction with PendingTransaction {
|
class PendingBitcoinTransaction with PendingTransaction {
|
||||||
PendingBitcoinTransaction(this._tx, this.type,
|
PendingBitcoinTransaction(this._tx, this.type,
|
||||||
{required this.electrumClient, required this.amount, required this.fee, this.network})
|
{required this.electrumClient,
|
||||||
|
required this.amount,
|
||||||
|
required this.fee})
|
||||||
: _listeners = <void Function(ElectrumTransactionInfo transaction)>[];
|
: _listeners = <void Function(ElectrumTransactionInfo transaction)>[];
|
||||||
|
|
||||||
final WalletType type;
|
final WalletType type;
|
||||||
final BtcTransaction _tx;
|
final bitcoin.Transaction _tx;
|
||||||
final ElectrumClient electrumClient;
|
final ElectrumClient electrumClient;
|
||||||
final int amount;
|
final int amount;
|
||||||
final int fee;
|
final int fee;
|
||||||
final BasedUtxoNetwork? network;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get id => _tx.txId();
|
String get id => _tx.getId();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get hex => _tx.serialize();
|
String get hex => _tx.toHex();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get amountFormatted => bitcoinAmountToString(amount: amount);
|
String get amountFormatted => bitcoinAmountToString(amount: amount);
|
||||||
|
@ -35,16 +36,18 @@ class PendingBitcoinTransaction with PendingTransaction {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> commit() async {
|
Future<void> commit() async {
|
||||||
final result = await electrumClient.broadcastTransaction(transactionRaw: hex, network: network);
|
final result =
|
||||||
|
await electrumClient.broadcastTransaction(transactionRaw: _tx.toHex());
|
||||||
|
|
||||||
if (result.isEmpty) {
|
if (result.isEmpty) {
|
||||||
throw BitcoinCommitTransactionException();
|
throw BitcoinCommitTransactionException();
|
||||||
}
|
}
|
||||||
|
|
||||||
_listeners.forEach((listener) => listener(transactionInfo()));
|
_listeners?.forEach((listener) => listener(transactionInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addListener(void Function(ElectrumTransactionInfo transaction) listener) =>
|
void addListener(
|
||||||
|
void Function(ElectrumTransactionInfo transaction) listener) =>
|
||||||
_listeners.add(listener);
|
_listeners.add(listener);
|
||||||
|
|
||||||
ElectrumTransactionInfo transactionInfo() => ElectrumTransactionInfo(type,
|
ElectrumTransactionInfo transactionInfo() => ElectrumTransactionInfo(type,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
|
|
||||||
String scriptHash(String address, {required BasedUtxoNetwork network}) {
|
String scriptHash(String address, {required bitcoin.NetworkType networkType}) {
|
||||||
final outputScript = addressToOutputScript(address: address, network: network);
|
final outputScript =
|
||||||
|
bitcoin.Address.addressToOutputScript(address, networkType);
|
||||||
final parts = sha256.convert(outputScript).toString().split('');
|
final parts = sha256.convert(outputScript).toString().split('');
|
||||||
var res = '';
|
var res = '';
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,55 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
||||||
import 'package:hex/hex.dart';
|
import 'package:hex/hex.dart';
|
||||||
|
|
||||||
bitcoin.PaymentData generatePaymentData({required bitcoin.HDWallet hd, required int index}) =>
|
bitcoin.PaymentData generatePaymentData(
|
||||||
PaymentData(pubkey: Uint8List.fromList(HEX.decode(hd.derive(index).pubKey!)));
|
{required bitcoin.HDWallet hd, required int index}) =>
|
||||||
|
PaymentData(
|
||||||
|
pubkey: Uint8List.fromList(HEX.decode(hd.derive(index).pubKey!)));
|
||||||
|
|
||||||
ECPrivate generateECPrivate(
|
bitcoin.ECPair generateKeyPair(
|
||||||
{required bitcoin.HDWallet hd, required int index, required BasedUtxoNetwork network}) =>
|
{required bitcoin.HDWallet hd,
|
||||||
ECPrivate.fromWif(hd.derive(index).wif!, netVersion: network.wifNetVer);
|
required int index,
|
||||||
|
required bitcoin.NetworkType network}) =>
|
||||||
|
bitcoin.ECPair.fromWIF(hd.derive(index).wif!, network: network);
|
||||||
|
|
||||||
String generateP2WPKHAddress(
|
String generateP2WPKHAddress(
|
||||||
{required bitcoin.HDWallet hd, required int index, required BasedUtxoNetwork network}) =>
|
{required bitcoin.HDWallet hd,
|
||||||
ECPublic.fromHex(hd.derive(index).pubKey!).toP2wpkhAddress().toAddress(network);
|
required int index,
|
||||||
|
required bitcoin.NetworkType networkType}) =>
|
||||||
|
bitcoin
|
||||||
|
.P2WPKH(
|
||||||
|
data: PaymentData(
|
||||||
|
pubkey:
|
||||||
|
Uint8List.fromList(HEX.decode(hd.derive(index).pubKey!))),
|
||||||
|
network: networkType)
|
||||||
|
.data
|
||||||
|
.address!;
|
||||||
|
|
||||||
String generateP2SHAddress(
|
String generateP2WPKHAddressByPath(
|
||||||
{required bitcoin.HDWallet hd, required int index, required BasedUtxoNetwork network}) =>
|
{required bitcoin.HDWallet hd,
|
||||||
ECPublic.fromHex(hd.derive(index).pubKey!).toP2wpkhInP2sh().toAddress(network);
|
required String path,
|
||||||
|
required bitcoin.NetworkType networkType}) =>
|
||||||
String generateP2WSHAddress(
|
bitcoin
|
||||||
{required bitcoin.HDWallet hd, required int index, required BasedUtxoNetwork network}) =>
|
.P2WPKH(
|
||||||
ECPublic.fromHex(hd.derive(index).pubKey!).toP2wshAddress().toAddress(network);
|
data: PaymentData(
|
||||||
|
pubkey:
|
||||||
|
Uint8List.fromList(HEX.decode(hd.derivePath(path).pubKey!))),
|
||||||
|
network: networkType)
|
||||||
|
.data
|
||||||
|
.address!;
|
||||||
|
|
||||||
String generateP2PKHAddress(
|
String generateP2PKHAddress(
|
||||||
{required bitcoin.HDWallet hd, required int index, required BasedUtxoNetwork network}) =>
|
{required bitcoin.HDWallet hd,
|
||||||
ECPublic.fromHex(hd.derive(index).pubKey!).toP2pkhAddress().toAddress(network);
|
required int index,
|
||||||
|
required bitcoin.NetworkType networkType}) =>
|
||||||
String generateP2TRAddress(
|
bitcoin
|
||||||
{required bitcoin.HDWallet hd, required int index, required BasedUtxoNetwork network}) =>
|
.P2PKH(
|
||||||
ECPublic.fromHex(hd.derive(index).pubKey!).toTaprootAddress().toAddress(network);
|
data: PaymentData(
|
||||||
|
pubkey:
|
||||||
|
Uint8List.fromList(HEX.decode(hd.derive(index).pubKey!))),
|
||||||
|
network: networkType)
|
||||||
|
.data
|
||||||
|
.address!;
|
||||||
|
|
|
@ -21,18 +21,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: args
|
name: args
|
||||||
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.3.2"
|
||||||
asn1lib:
|
asn1lib:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: asn1lib
|
name: asn1lib
|
||||||
sha256: c9c85fedbe2188b95133cbe960e16f5f448860f7133330e272edbbca5893ddc6
|
sha256: ab96a1cb3beeccf8145c52e449233fe68364c9641623acd3adad66f8184f1039
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.2"
|
version: "1.4.0"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -75,15 +75,6 @@ packages:
|
||||||
url: "https://github.com/cake-tech/bitbox-flutter.git"
|
url: "https://github.com/cake-tech/bitbox-flutter.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
bitcoin_base:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
path: "."
|
|
||||||
ref: cake-update-v1
|
|
||||||
resolved-ref: "9611e9db77e92a8434e918cdfb620068f6fcb1aa"
|
|
||||||
url: "https://github.com/cake-tech/bitcoin_base.git"
|
|
||||||
source: git
|
|
||||||
version: "4.0.0"
|
|
||||||
bitcoin_flutter:
|
bitcoin_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -93,14 +84,6 @@ packages:
|
||||||
url: "https://github.com/cake-tech/bitcoin_flutter.git"
|
url: "https://github.com/cake-tech/bitcoin_flutter.git"
|
||||||
source: git
|
source: git
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
blockchain_utils:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: blockchain_utils
|
|
||||||
sha256: "9701dfaa74caad4daae1785f1ec4445cf7fb94e45620bc3a4aca1b9b281dc6c9"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.6.0"
|
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -121,10 +104,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build
|
name: build
|
||||||
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
|
sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
version: "2.3.1"
|
||||||
build_config:
|
build_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -137,10 +120,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_daemon
|
name: build_daemon
|
||||||
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
|
sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.1"
|
version: "3.1.0"
|
||||||
build_resolvers:
|
build_resolvers:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
@ -153,18 +136,18 @@ packages:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_runner
|
name: build_runner
|
||||||
sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21"
|
sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.8"
|
version: "2.3.3"
|
||||||
build_runner_core:
|
build_runner_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_runner_core
|
name: build_runner_core
|
||||||
sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41"
|
sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.2.10"
|
version: "7.2.7"
|
||||||
built_collection:
|
built_collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -177,10 +160,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: built_value
|
name: built_value
|
||||||
sha256: a3ec2e0f967bc47f69f95009bb93db936288d61d5343b9436e378b28a2f830c6
|
sha256: "169565c8ad06adb760c3645bf71f00bff161b00002cace266cad42c5d22a7725"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.9.0"
|
version: "8.4.3"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -193,10 +176,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: checked_yaml
|
name: checked_yaml
|
||||||
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
|
sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.2"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -209,10 +192,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: code_builder
|
name: code_builder
|
||||||
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
|
sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.10.0"
|
version: "4.4.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -233,18 +216,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: crypto
|
name: crypto
|
||||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.3"
|
version: "3.0.2"
|
||||||
cryptography:
|
cryptography:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cryptography
|
name: cryptography
|
||||||
sha256: df156c5109286340817d21fa7b62f9140f17915077127dd70f8bd7a2a0997a35
|
sha256: e0e37f79665cd5c86e8897f9abe1accfe813c0cc5299dab22256e22fddc1fef8
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.0.5"
|
||||||
cw_core:
|
cw_core:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -264,10 +247,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: encrypt
|
name: encrypt
|
||||||
sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2"
|
sha256: "4fd4e4fdc21b9d7d4141823e1e6515cd94e7b8d84749504c232999fba25d9bbb"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.3"
|
version: "5.0.1"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -280,10 +263,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.0.1"
|
||||||
file:
|
file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -309,10 +292,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_mobx
|
name: flutter_mobx
|
||||||
sha256: "4a5d062ff85ed3759f4aac6410ff0ffae32e324b2e71ca722ae1b37b32e865f4"
|
sha256: "0da4add0016387a7bf309a0d0c41d36c6b3ae25ed7a176409267f166509e723e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0+2"
|
version: "2.0.6+5"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -330,18 +313,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: glob
|
name: glob
|
||||||
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: graphs
|
name: graphs
|
||||||
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.1"
|
version: "2.2.0"
|
||||||
hex:
|
hex:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -418,18 +401,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: json_annotation
|
name: json_annotation
|
||||||
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.8.1"
|
version: "4.8.0"
|
||||||
logging:
|
logging:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: logging
|
name: logging
|
||||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.1.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -466,26 +449,18 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: mobx
|
name: mobx
|
||||||
sha256: "74ee54012dc7c1b3276eaa960a600a7418ef5f9997565deb8fca1fd88fb36b78"
|
sha256: f1862bd92c6a903fab67338f27e2f731117c3cb9ea37cee1a487f9e4e0de314a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0+1"
|
version: "2.1.3+1"
|
||||||
mobx_codegen:
|
mobx_codegen:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: mobx_codegen
|
name: mobx_codegen
|
||||||
sha256: d4beb9cea4b7b014321235f8fdc7c2193ee0fe1d1198e9da7403f8bc85c4407c
|
sha256: "86122e410d8ea24dda0c69adb5c2a6ccadd5ce02ad46e144764e0d0184a06181"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.1.1"
|
||||||
nested:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: nested
|
|
||||||
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.0"
|
|
||||||
package_config:
|
package_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -506,26 +481,26 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider
|
name: path_provider
|
||||||
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
path_provider_android:
|
path_provider_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.2"
|
version: "2.2.1"
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_foundation
|
name: path_provider_foundation
|
||||||
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.2"
|
version: "2.3.1"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -538,10 +513,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_platform_interface
|
name: path_provider_platform_interface
|
||||||
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
path_provider_windows:
|
path_provider_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -554,26 +529,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: platform
|
name: platform
|
||||||
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.4"
|
version: "3.1.0"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.3"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pointycastle
|
name: pointycastle
|
||||||
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
|
sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.7.4"
|
version: "3.6.2"
|
||||||
pool:
|
pool:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -582,30 +557,30 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.1"
|
version: "1.5.1"
|
||||||
provider:
|
process:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: provider
|
name: process
|
||||||
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
|
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "4.2.4"
|
||||||
pub_semver:
|
pub_semver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pub_semver
|
name: pub_semver
|
||||||
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.3"
|
||||||
pubspec_parse:
|
pubspec_parse:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pubspec_parse
|
name: pubspec_parse
|
||||||
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
|
sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.3"
|
version: "1.2.1"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -618,18 +593,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shelf
|
name: shelf
|
||||||
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
|
sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.1"
|
version: "1.4.0"
|
||||||
shelf_web_socket:
|
shelf_web_socket:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shelf_web_socket
|
name: shelf_web_socket
|
||||||
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.3"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -727,10 +702,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "1.3.1"
|
||||||
unorm_dart:
|
unorm_dart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -751,42 +726,42 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: watcher
|
name: watcher
|
||||||
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.0.2"
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web_socket_channel
|
name: web_socket_channel
|
||||||
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
|
sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.3.0"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3"
|
sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.9"
|
version: "3.1.3"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: xdg_directories
|
name: xdg_directories
|
||||||
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
|
sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "0.2.0+3"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: yaml
|
name: yaml
|
||||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.0.0 <4.0.0"
|
dart: ">=3.0.0 <4.0.0"
|
||||||
flutter: ">=3.10.0"
|
flutter: ">=3.7.0"
|
||||||
|
|
|
@ -30,11 +30,6 @@ dependencies:
|
||||||
rxdart: ^0.27.5
|
rxdart: ^0.27.5
|
||||||
unorm_dart: ^0.2.0
|
unorm_dart: ^0.2.0
|
||||||
cryptography: ^2.0.5
|
cryptography: ^2.0.5
|
||||||
bitcoin_base:
|
|
||||||
git:
|
|
||||||
url: https://github.com/cake-tech/bitcoin_base.git
|
|
||||||
ref: cake-update-v1
|
|
||||||
blockchain_utils: ^1.6.0
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -28,18 +28,17 @@ part 'bitcoin_cash_wallet.g.dart';
|
||||||
class BitcoinCashWallet = BitcoinCashWalletBase with _$BitcoinCashWallet;
|
class BitcoinCashWallet = BitcoinCashWalletBase with _$BitcoinCashWallet;
|
||||||
|
|
||||||
abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
BitcoinCashWalletBase({
|
BitcoinCashWalletBase(
|
||||||
required String mnemonic,
|
{required String mnemonic,
|
||||||
required String password,
|
required String password,
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
required Uint8List seedBytes,
|
required Uint8List seedBytes,
|
||||||
String? addressPageType,
|
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
}) : super(
|
: super(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
walletInfo: walletInfo,
|
walletInfo: walletInfo,
|
||||||
|
@ -49,31 +48,30 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
seedBytes: seedBytes,
|
seedBytes: seedBytes,
|
||||||
currency: CryptoCurrency.bch) {
|
currency: CryptoCurrency.bch) {
|
||||||
walletAddresses = BitcoinCashWalletAddresses(
|
walletAddresses = BitcoinCashWalletAddresses(walletInfo,
|
||||||
walletInfo,
|
|
||||||
electrumClient: electrumClient,
|
electrumClient: electrumClient,
|
||||||
initialAddresses: initialAddresses,
|
initialAddresses: initialAddresses,
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
mainHd: hd,
|
mainHd: hd,
|
||||||
sideHd: bitcoin.HDWallet.fromSeed(seedBytes).derivePath("m/44'/145'/0'/1"),
|
sideHd: bitcoin.HDWallet.fromSeed(seedBytes)
|
||||||
network: network,
|
.derivePath("m/44'/145'/0'/1"),
|
||||||
);
|
networkType: networkType);
|
||||||
autorun((_) {
|
autorun((_) {
|
||||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Future<BitcoinCashWallet> create(
|
static Future<BitcoinCashWallet> create(
|
||||||
{required String mnemonic,
|
{required String mnemonic,
|
||||||
required String password,
|
required String password,
|
||||||
required WalletInfo walletInfo,
|
required WalletInfo walletInfo,
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
String? addressPageType,
|
|
||||||
List<BitcoinAddressRecord>? initialAddresses,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
ElectrumBalance? initialBalance,
|
ElectrumBalance? initialBalance,
|
||||||
Map<String, int>? initialRegularAddressIndex,
|
int initialRegularAddressIndex = 0,
|
||||||
Map<String, int>? initialChangeAddressIndex}) async {
|
int initialChangeAddressIndex = 0}) async {
|
||||||
return BitcoinCashWallet(
|
return BitcoinCashWallet(
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -83,9 +81,7 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: initialBalance,
|
initialBalance: initialBalance,
|
||||||
seedBytes: await Mnemonic.toSeed(mnemonic),
|
seedBytes: await Mnemonic.toSeed(mnemonic),
|
||||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
initialChangeAddressIndex: initialChangeAddressIndex);
|
||||||
addressPageType: addressPageType,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<BitcoinCashWallet> open({
|
static Future<BitcoinCashWallet> open({
|
||||||
|
@ -94,8 +90,7 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||||
required String password,
|
required String password,
|
||||||
}) async {
|
}) async {
|
||||||
final snp = await ElectrumWalletSnapshot.load(
|
final snp = await ElectrumWallletSnapshot.load(name, walletInfo.type, password);
|
||||||
name, walletInfo.type, password, BitcoinCashNetwork.mainnet);
|
|
||||||
return BitcoinCashWallet(
|
return BitcoinCashWallet(
|
||||||
mnemonic: snp.mnemonic,
|
mnemonic: snp.mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -105,9 +100,7 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
initialBalance: snp.balance,
|
initialBalance: snp.balance,
|
||||||
seedBytes: await Mnemonic.toSeed(snp.mnemonic),
|
seedBytes: await Mnemonic.toSeed(snp.mnemonic),
|
||||||
initialRegularAddressIndex: snp.regularAddressIndex,
|
initialRegularAddressIndex: snp.regularAddressIndex,
|
||||||
initialChangeAddressIndex: snp.changeAddressIndex,
|
initialChangeAddressIndex: snp.changeAddressIndex);
|
||||||
addressPageType: snp.addressPageType,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -277,18 +270,20 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
electrumClient: electrumClient, amount: amount, fee: fee);
|
electrumClient: electrumClient, amount: amount, fee: fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
bitbox.ECPair generateKeyPair({required bitcoin.HDWallet hd, required int index}) =>
|
bitbox.ECPair generateKeyPair(
|
||||||
|
{required bitcoin.HDWallet hd,
|
||||||
|
required int index}) =>
|
||||||
bitbox.ECPair.fromWIF(hd.derive(index).wif!);
|
bitbox.ECPair.fromWIF(hd.derive(index).wif!);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int feeAmountForPriority(BitcoinTransactionPriority priority, int inputsCount, int outputsCount,
|
int feeAmountForPriority(
|
||||||
{int? size}) =>
|
BitcoinTransactionPriority priority, int inputsCount, int outputsCount) =>
|
||||||
feeRate(priority) * bitbox.BitcoinCash.getByteCount(inputsCount, outputsCount);
|
feeRate(priority) * bitbox.BitcoinCash.getByteCount(inputsCount, outputsCount);
|
||||||
|
|
||||||
int feeAmountWithFeeRate(int feeRate, int inputsCount, int outputsCount, {int? size}) =>
|
int feeAmountWithFeeRate(int feeRate, int inputsCount, int outputsCount) =>
|
||||||
feeRate * bitbox.BitcoinCash.getByteCount(inputsCount, outputsCount);
|
feeRate * bitbox.BitcoinCash.getByteCount(inputsCount, outputsCount);
|
||||||
|
|
||||||
int calculateEstimatedFeeWithFeeRate(int feeRate, int? amount, {int? outputsCount, int? size}) {
|
int calculateEstimatedFeeWithFeeRate(int feeRate, int? amount, {int? outputsCount}) {
|
||||||
int inputsCount = 0;
|
int inputsCount = 0;
|
||||||
int totalValue = 0;
|
int totalValue = 0;
|
||||||
|
|
||||||
|
@ -328,10 +323,9 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
@override
|
@override
|
||||||
String signMessage(String message, {String? address = null}) {
|
String signMessage(String message, {String? address = null}) {
|
||||||
final index = address != null
|
final index = address != null
|
||||||
? walletAddresses.allAddresses
|
? walletAddresses.addresses
|
||||||
.firstWhere((element) => element.address == AddressUtils.toLegacyAddress(address))
|
.firstWhere((element) => element.address == AddressUtils.toLegacyAddress(address))
|
||||||
.index
|
.index : null;
|
||||||
: null;
|
|
||||||
final HD = index == null ? hd : hd.derive(index);
|
final HD = index == null ? hd : hd.derive(index);
|
||||||
return base64Encode(HD.signMessage(message));
|
return base64Encode(HD.signMessage(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
|
||||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
|
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||||
|
import 'package:cw_bitcoin/electrum.dart';
|
||||||
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
import 'package:cw_bitcoin/electrum_wallet_addresses.dart';
|
||||||
import 'package:cw_bitcoin/utils.dart';
|
import 'package:cw_bitcoin/utils.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
|
@ -10,19 +11,24 @@ part 'bitcoin_cash_wallet_addresses.g.dart';
|
||||||
class BitcoinCashWalletAddresses = BitcoinCashWalletAddressesBase with _$BitcoinCashWalletAddresses;
|
class BitcoinCashWalletAddresses = BitcoinCashWalletAddressesBase with _$BitcoinCashWalletAddresses;
|
||||||
|
|
||||||
abstract class BitcoinCashWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
abstract class BitcoinCashWalletAddressesBase extends ElectrumWalletAddresses with Store {
|
||||||
BitcoinCashWalletAddressesBase(
|
BitcoinCashWalletAddressesBase(WalletInfo walletInfo,
|
||||||
WalletInfo walletInfo, {
|
{required bitcoin.HDWallet mainHd,
|
||||||
required super.mainHd,
|
required bitcoin.HDWallet sideHd,
|
||||||
required super.sideHd,
|
required bitcoin.NetworkType networkType,
|
||||||
required super.network,
|
required ElectrumClient electrumClient,
|
||||||
required super.electrumClient,
|
List<BitcoinAddressRecord>? initialAddresses,
|
||||||
super.initialAddresses,
|
int initialRegularAddressIndex = 0,
|
||||||
super.initialRegularAddressIndex,
|
int initialChangeAddressIndex = 0})
|
||||||
super.initialChangeAddressIndex,
|
: super(walletInfo,
|
||||||
}) : super(walletInfo);
|
initialAddresses: initialAddresses,
|
||||||
|
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||||
|
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||||
|
mainHd: mainHd,
|
||||||
|
sideHd: sideHd,
|
||||||
|
electrumClient: electrumClient,
|
||||||
|
networkType: networkType);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String getAddress(
|
String getAddress({required int index, required bitcoin.HDWallet hd}) =>
|
||||||
{required int index, required bitcoin.HDWallet hd, BitcoinAddressType? addressType}) =>
|
generateP2PKHAddress(hd: hd, index: index, networkType: networkType);
|
||||||
generateP2PKHAddress(hd: hd, index: index, network: network);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:bip39/bip39.dart';
|
import 'package:bip39/bip39.dart';
|
||||||
import 'package:cw_bitcoin_cash/cw_bitcoin_cash.dart';
|
import 'package:cw_bitcoin_cash/cw_bitcoin_cash.dart';
|
||||||
|
import 'package:cw_core/balance.dart';
|
||||||
import 'package:cw_core/pathForWallet.dart';
|
import 'package:cw_core/pathForWallet.dart';
|
||||||
|
import 'package:cw_core/transaction_history.dart';
|
||||||
|
import 'package:cw_core/transaction_info.dart';
|
||||||
import 'package:cw_core/unspent_coins_info.dart';
|
import 'package:cw_core/unspent_coins_info.dart';
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
|
@ -12,7 +15,8 @@ import 'package:collection/collection.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
|
||||||
class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredentials,
|
class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredentials,
|
||||||
BitcoinCashRestoreWalletFromSeedCredentials, BitcoinCashRestoreWalletFromWIFCredentials> {
|
BitcoinCashRestoreWalletFromSeedCredentials,
|
||||||
|
BitcoinCashRestoreWalletFromWIFCredentials> {
|
||||||
BitcoinCashWalletService(this.walletInfoSource, this.unspentCoinsInfoSource);
|
BitcoinCashWalletService(this.walletInfoSource, this.unspentCoinsInfoSource);
|
||||||
|
|
||||||
final Box<WalletInfo> walletInfoSource;
|
final Box<WalletInfo> walletInfoSource;
|
||||||
|
@ -26,9 +30,13 @@ class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredent
|
||||||
File(await pathForWallet(name: name, type: getType())).existsSync();
|
File(await pathForWallet(name: name, type: getType())).existsSync();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinCashWallet> create(credentials, {bool? isTestnet}) async {
|
Future<BitcoinCashWallet> create(
|
||||||
final strength = credentials.seedPhraseLength == 24 ? 256 : 128;
|
credentials) async {
|
||||||
|
final strength = (credentials.seedPhraseLength == 12)
|
||||||
|
? 128
|
||||||
|
: (credentials.seedPhraseLength == 24)
|
||||||
|
? 256
|
||||||
|
: 128;
|
||||||
final wallet = await BitcoinCashWalletBase.create(
|
final wallet = await BitcoinCashWalletBase.create(
|
||||||
mnemonic: await Mnemonic.generate(strength: strength),
|
mnemonic: await Mnemonic.generate(strength: strength),
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
|
@ -41,24 +49,20 @@ class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredent
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinCashWallet> openWallet(String name, String password) async {
|
Future<BitcoinCashWallet> openWallet(String name, String password) async {
|
||||||
final walletInfo = walletInfoSource.values
|
final walletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||||
.firstWhereOrNull((info) => info.id == WalletBase.idFor(name, getType()))!;
|
(info) => info.id == WalletBase.idFor(name, getType()))!;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final wallet = await BitcoinCashWalletBase.open(
|
final wallet = await BitcoinCashWalletBase.open(
|
||||||
password: password,
|
password: password, name: name, walletInfo: walletInfo,
|
||||||
name: name,
|
|
||||||
walletInfo: walletInfo,
|
|
||||||
unspentCoinsInfo: unspentCoinsInfoSource);
|
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||||
await wallet.init();
|
await wallet.init();
|
||||||
saveBackup(name);
|
saveBackup(name);
|
||||||
return wallet;
|
return wallet;
|
||||||
} catch (_) {
|
} catch(_) {
|
||||||
await restoreWalletFilesFromBackup(name);
|
await restoreWalletFilesFromBackup(name);
|
||||||
final wallet = await BitcoinCashWalletBase.open(
|
final wallet = await BitcoinCashWalletBase.open(
|
||||||
password: password,
|
password: password, name: name, walletInfo: walletInfo,
|
||||||
name: name,
|
|
||||||
walletInfo: walletInfo,
|
|
||||||
unspentCoinsInfo: unspentCoinsInfoSource);
|
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||||
await wallet.init();
|
await wallet.init();
|
||||||
return wallet;
|
return wallet;
|
||||||
|
@ -67,16 +71,17 @@ class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredent
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> remove(String wallet) async {
|
Future<void> remove(String wallet) async {
|
||||||
File(await pathForWalletDir(name: wallet, type: getType())).delete(recursive: true);
|
File(await pathForWalletDir(name: wallet, type: getType()))
|
||||||
final walletInfo = walletInfoSource.values
|
.delete(recursive: true);
|
||||||
.firstWhereOrNull((info) => info.id == WalletBase.idFor(wallet, getType()))!;
|
final walletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||||
|
(info) => info.id == WalletBase.idFor(wallet, getType()))!;
|
||||||
await walletInfoSource.delete(walletInfo.key);
|
await walletInfoSource.delete(walletInfo.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> rename(String currentName, String password, String newName) async {
|
Future<void> rename(String currentName, String password, String newName) async {
|
||||||
final currentWalletInfo = walletInfoSource.values
|
final currentWalletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||||
.firstWhereOrNull((info) => info.id == WalletBase.idFor(currentName, getType()))!;
|
(info) => info.id == WalletBase.idFor(currentName, getType()))!;
|
||||||
final currentWallet = await BitcoinCashWalletBase.open(
|
final currentWallet = await BitcoinCashWalletBase.open(
|
||||||
password: password,
|
password: password,
|
||||||
name: currentName,
|
name: currentName,
|
||||||
|
@ -94,14 +99,15 @@ class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredent
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinCashWallet> restoreFromKeys(credentials, {bool? isTestnet}) {
|
Future<BitcoinCashWallet>
|
||||||
|
restoreFromKeys(credentials) {
|
||||||
// TODO: implement restoreFromKeys
|
// TODO: implement restoreFromKeys
|
||||||
throw UnimplementedError('restoreFromKeys() is not implemented');
|
throw UnimplementedError('restoreFromKeys() is not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<BitcoinCashWallet> restoreFromSeed(BitcoinCashRestoreWalletFromSeedCredentials credentials,
|
Future<BitcoinCashWallet> restoreFromSeed(
|
||||||
{bool? isTestnet}) async {
|
BitcoinCashRestoreWalletFromSeedCredentials credentials) async {
|
||||||
if (!validateMnemonic(credentials.mnemonic)) {
|
if (!validateMnemonic(credentials.mnemonic)) {
|
||||||
throw BitcoinCashMnemonicIsIncorrectException();
|
throw BitcoinCashMnemonicIsIncorrectException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/cake-tech/bitbox-flutter.git
|
url: https://github.com/cake-tech/bitbox-flutter.git
|
||||||
ref: master
|
ref: master
|
||||||
bitcoin_base:
|
bitcoin_base: ^3.0.1
|
||||||
git:
|
|
||||||
url: https://github.com/cake-tech/bitcoin_base.git
|
|
||||||
ref: cake-update-v1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
abstract class Enumerate {
|
|
||||||
String get value;
|
|
||||||
|
|
||||||
@override
|
|
||||||
operator ==(other) {
|
|
||||||
if (identical(other, this)) return true;
|
|
||||||
if (other is! Enumerate) return false;
|
|
||||||
return other.runtimeType == runtimeType && value == other.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => value.hashCode;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import 'package:cw_core/enumerate.dart';
|
|
||||||
|
|
||||||
class ReceivePageOption implements Enumerate {
|
|
||||||
static const mainnet = ReceivePageOption._('mainnet');
|
|
||||||
static const anonPayInvoice = ReceivePageOption._('anonPayInvoice');
|
|
||||||
static const anonPayDonationLink = ReceivePageOption._('anonPayDonationLink');
|
|
||||||
|
|
||||||
const ReceivePageOption._(this.value);
|
|
||||||
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
String toString() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ReceivePageOptions = [
|
|
||||||
ReceivePageOption.mainnet,
|
|
||||||
ReceivePageOption.anonPayInvoice,
|
|
||||||
ReceivePageOption.anonPayDonationLink
|
|
||||||
];
|
|
|
@ -88,6 +88,4 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
|
||||||
Future<void> renameWalletFiles(String newWalletName);
|
Future<void> renameWalletFiles(String newWalletName);
|
||||||
|
|
||||||
String signMessage(String message, {String? address = null}) => throw UnimplementedError();
|
String signMessage(String message, {String? address = null}) => throw UnimplementedError();
|
||||||
|
|
||||||
bool? isTestnet;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,12 +148,6 @@ class WalletInfo extends HiveObject {
|
||||||
@HiveField(17)
|
@HiveField(17)
|
||||||
String? derivationPath;
|
String? derivationPath;
|
||||||
|
|
||||||
@HiveField(18)
|
|
||||||
String? addressPageType;
|
|
||||||
|
|
||||||
@HiveField(19)
|
|
||||||
String? network;
|
|
||||||
|
|
||||||
String get yatLastUsedAddress => yatLastUsedAddressRaw ?? '';
|
String get yatLastUsedAddress => yatLastUsedAddressRaw ?? '';
|
||||||
|
|
||||||
set yatLastUsedAddress(String address) {
|
set yatLastUsedAddress(String address) {
|
||||||
|
|
|
@ -9,11 +9,11 @@ abstract class WalletService<N extends WalletCredentials, RFS extends WalletCred
|
||||||
RFK extends WalletCredentials> {
|
RFK extends WalletCredentials> {
|
||||||
WalletType getType();
|
WalletType getType();
|
||||||
|
|
||||||
Future<WalletBase> create(N credentials, {bool? isTestnet});
|
Future<WalletBase> create(N credentials);
|
||||||
|
|
||||||
Future<WalletBase> restoreFromSeed(RFS credentials, {bool? isTestnet});
|
Future<WalletBase> restoreFromSeed(RFS credentials);
|
||||||
|
|
||||||
Future<WalletBase> restoreFromKeys(RFK credentials, {bool? isTestnet});
|
Future<WalletBase> restoreFromKeys(RFK credentials);
|
||||||
|
|
||||||
Future<WalletBase> openWallet(String name, String password);
|
Future<WalletBase> openWallet(String name, String password);
|
||||||
|
|
||||||
|
|
|
@ -5,34 +5,34 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
|
sha256: "4897882604d919befd350648c7f91926a9d5de99e67b455bf0917cc2362f4bb8"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "64.0.0"
|
version: "47.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
|
sha256: "690e335554a8385bc9d787117d9eb52c0c03ee207a607e593de3c9d71b1cfe80"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.2.0"
|
version: "4.7.0"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: args
|
name: args
|
||||||
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.3.2"
|
||||||
asn1lib:
|
asn1lib:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: asn1lib
|
name: asn1lib
|
||||||
sha256: "21afe4333076c02877d14f4a89df111e658a6d466cbfc802eb705eb91bd5adfd"
|
sha256: ab96a1cb3beeccf8145c52e449233fe68364c9641623acd3adad66f8184f1039
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.0"
|
version: "1.4.0"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -53,10 +53,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build
|
name: build
|
||||||
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
|
sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
version: "2.3.1"
|
||||||
build_config:
|
build_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -69,34 +69,34 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_daemon
|
name: build_daemon
|
||||||
sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1"
|
sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.1"
|
version: "3.1.0"
|
||||||
build_resolvers:
|
build_resolvers:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_resolvers
|
name: build_resolvers
|
||||||
sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a"
|
sha256: "687cf90a3951affac1bd5f9ecb5e3e90b60487f3d9cdc359bb310f8876bb02a6"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.0.10"
|
||||||
build_runner:
|
build_runner:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_runner
|
name: build_runner
|
||||||
sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21"
|
sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.8"
|
version: "2.3.3"
|
||||||
build_runner_core:
|
build_runner_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_runner_core
|
name: build_runner_core
|
||||||
sha256: c9e32d21dd6626b5c163d48b037ce906bbe428bc23ab77bcd77bb21e593b6185
|
sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.2.11"
|
version: "7.2.7"
|
||||||
built_collection:
|
built_collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -109,10 +109,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: built_value
|
name: built_value
|
||||||
sha256: c9aabae0718ec394e5bc3c7272e6bb0dc0b32201a08fe185ec1d8401d3e39309
|
sha256: "169565c8ad06adb760c3645bf71f00bff161b00002cace266cad42c5d22a7725"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.8.1"
|
version: "8.4.3"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -125,10 +125,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: checked_yaml
|
name: checked_yaml
|
||||||
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
|
sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.2"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -141,10 +141,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: code_builder
|
name: code_builder
|
||||||
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
|
sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.10.0"
|
version: "4.4.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -165,26 +165,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: crypto
|
name: crypto
|
||||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.3"
|
version: "3.0.2"
|
||||||
dart_style:
|
dart_style:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dart_style
|
name: dart_style
|
||||||
sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
|
sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.4"
|
version: "2.2.4"
|
||||||
encrypt:
|
encrypt:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: encrypt
|
name: encrypt
|
||||||
sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2"
|
sha256: "4fd4e4fdc21b9d7d4141823e1e6515cd94e7b8d84749504c232999fba25d9bbb"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.3"
|
version: "5.0.1"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -197,10 +197,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.0.1"
|
||||||
file:
|
file:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -226,10 +226,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_mobx
|
name: flutter_mobx
|
||||||
sha256: "4a5d062ff85ed3759f4aac6410ff0ffae32e324b2e71ca722ae1b37b32e865f4"
|
sha256: "0da4add0016387a7bf309a0d0c41d36c6b3ae25ed7a176409267f166509e723e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0+2"
|
version: "2.0.6+5"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -247,18 +247,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: glob
|
name: glob
|
||||||
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: graphs
|
name: graphs
|
||||||
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.1"
|
version: "2.2.0"
|
||||||
hive:
|
hive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -327,18 +327,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: json_annotation
|
name: json_annotation
|
||||||
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.8.1"
|
version: "4.8.0"
|
||||||
logging:
|
logging:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: logging
|
name: logging
|
||||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.1.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -375,26 +375,18 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: mobx
|
name: mobx
|
||||||
sha256: "74ee54012dc7c1b3276eaa960a600a7418ef5f9997565deb8fca1fd88fb36b78"
|
sha256: f1862bd92c6a903fab67338f27e2f731117c3cb9ea37cee1a487f9e4e0de314a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0+1"
|
version: "2.1.3+1"
|
||||||
mobx_codegen:
|
mobx_codegen:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: mobx_codegen
|
name: mobx_codegen
|
||||||
sha256: b26c7f9c20b38f0ea572c1ed3f29d8e027cb265538bbd1aed3ec198642cfca42
|
sha256: "86122e410d8ea24dda0c69adb5c2a6ccadd5ce02ad46e144764e0d0184a06181"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.6.0+1"
|
version: "2.1.1"
|
||||||
nested:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: nested
|
|
||||||
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.0"
|
|
||||||
package_config:
|
package_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -415,26 +407,26 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider
|
name: path_provider
|
||||||
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
path_provider_android:
|
path_provider_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.2"
|
version: "2.2.1"
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_foundation
|
name: path_provider_foundation
|
||||||
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.2"
|
version: "2.3.1"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -447,10 +439,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_platform_interface
|
name: path_provider_platform_interface
|
||||||
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
path_provider_windows:
|
path_provider_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -463,26 +455,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: platform
|
name: platform
|
||||||
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.4"
|
version: "3.1.0"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.3"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pointycastle
|
name: pointycastle
|
||||||
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
|
sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.7.4"
|
version: "3.6.2"
|
||||||
pool:
|
pool:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -491,46 +483,46 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.1"
|
version: "1.5.1"
|
||||||
provider:
|
process:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: provider
|
name: process
|
||||||
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
|
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "4.2.4"
|
||||||
pub_semver:
|
pub_semver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pub_semver
|
name: pub_semver
|
||||||
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.3"
|
||||||
pubspec_parse:
|
pubspec_parse:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pubspec_parse
|
name: pubspec_parse
|
||||||
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
|
sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.3"
|
version: "1.2.1"
|
||||||
shelf:
|
shelf:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shelf
|
name: shelf
|
||||||
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
|
sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.1"
|
version: "1.4.0"
|
||||||
shelf_web_socket:
|
shelf_web_socket:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shelf_web_socket
|
name: shelf_web_socket
|
||||||
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.3"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -548,18 +540,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_gen
|
name: source_gen
|
||||||
sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
|
sha256: "2d79738b6bbf38a43920e2b8d189e9a3ce6cc201f4b8fc76be5e4fe377b1c38d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.0"
|
version: "1.2.6"
|
||||||
source_helper:
|
source_helper:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_helper
|
name: source_helper
|
||||||
sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd"
|
sha256: "3b67aade1d52416149c633ba1bb36df44d97c6b51830c2198e934e3fca87ca1f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.4"
|
version: "1.3.3"
|
||||||
source_span:
|
source_span:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -628,10 +620,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.2"
|
version: "1.3.1"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -644,42 +636,42 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: watcher
|
name: watcher
|
||||||
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.0.2"
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web_socket_channel
|
name: web_socket_channel
|
||||||
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
|
sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.3.0"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3"
|
sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.9"
|
version: "3.1.3"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: xdg_directories
|
name: xdg_directories
|
||||||
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
|
sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "0.2.0+3"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: yaml
|
name: yaml
|
||||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.0.0 <4.0.0"
|
dart: ">=3.0.0 <4.0.0"
|
||||||
flutter: ">=3.10.0"
|
flutter: ">=3.7.0"
|
||||||
|
|
|
@ -16,7 +16,7 @@ class EthereumWalletService extends EVMChainWalletService<EthereumWallet> {
|
||||||
WalletType getType() => WalletType.ethereum;
|
WalletType getType() => WalletType.ethereum;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<EthereumWallet> create(EVMChainNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<EthereumWallet> create(EVMChainNewWalletCredentials credentials) async {
|
||||||
final strength = credentials.seedPhraseLength == 24 ? 256 : 128;
|
final strength = credentials.seedPhraseLength == 24 ? 256 : 128;
|
||||||
|
|
||||||
final mnemonic = bip39.generateMnemonic(strength: strength);
|
final mnemonic = bip39.generateMnemonic(strength: strength);
|
||||||
|
@ -52,6 +52,7 @@ class EthereumWalletService extends EVMChainWalletService<EthereumWallet> {
|
||||||
saveBackup(name);
|
saveBackup(name);
|
||||||
return wallet;
|
return wallet;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
||||||
await restoreWalletFilesFromBackup(name);
|
await restoreWalletFilesFromBackup(name);
|
||||||
|
|
||||||
final wallet = await EthereumWallet.open(
|
final wallet = await EthereumWallet.open(
|
||||||
|
@ -83,8 +84,7 @@ class EthereumWalletService extends EVMChainWalletService<EthereumWallet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<EthereumWallet> restoreFromKeys(EVMChainRestoreWalletFromPrivateKey credentials,
|
Future<EthereumWallet> restoreFromKeys(EVMChainRestoreWalletFromPrivateKey credentials) async {
|
||||||
{bool? isTestnet}) async {
|
|
||||||
final wallet = EthereumWallet(
|
final wallet = EthereumWallet(
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
privateKey: credentials.privateKey,
|
privateKey: credentials.privateKey,
|
||||||
|
@ -100,8 +100,8 @@ class EthereumWalletService extends EVMChainWalletService<EthereumWallet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<EthereumWallet> restoreFromSeed(EVMChainRestoreWalletFromSeedCredentials credentials,
|
Future<EthereumWallet> restoreFromSeed(
|
||||||
{bool? isTestnet}) async {
|
EVMChainRestoreWalletFromSeedCredentials credentials) async {
|
||||||
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
||||||
throw EthereumMnemonicIsIncorrectException();
|
throw EthereumMnemonicIsIncorrectException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ abstract class EVMChainWalletService<T extends EVMChainWallet> extends WalletSer
|
||||||
WalletType getType();
|
WalletType getType();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<T> create(EVMChainNewWalletCredentials credentials, {bool? isTestnet});
|
Future<T> create(EVMChainNewWalletCredentials credentials);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<T> openWallet(String name, String password);
|
Future<T> openWallet(String name, String password);
|
||||||
|
@ -31,10 +31,10 @@ abstract class EVMChainWalletService<T extends EVMChainWallet> extends WalletSer
|
||||||
Future<void> rename(String currentName, String password, String newName);
|
Future<void> rename(String currentName, String password, String newName);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<T> restoreFromKeys(EVMChainRestoreWalletFromPrivateKey credentials, {bool? isTestnet});
|
Future<T> restoreFromKeys(EVMChainRestoreWalletFromPrivateKey credentials);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<T> restoreFromSeed(EVMChainRestoreWalletFromSeedCredentials credentials, {bool? isTestnet});
|
Future<T> restoreFromSeed(EVMChainRestoreWalletFromSeedCredentials credentials);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> isWalletExit(String name) async =>
|
Future<bool> isWalletExit(String name) async =>
|
||||||
|
|
|
@ -68,7 +68,7 @@ class HavenWalletService extends WalletService<
|
||||||
WalletType getType() => WalletType.haven;
|
WalletType getType() => WalletType.haven;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<HavenWallet> create(HavenNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<HavenWallet> create(HavenNewWalletCredentials credentials) async {
|
||||||
try {
|
try {
|
||||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||||
await haven_wallet_manager.createWallet(
|
await haven_wallet_manager.createWallet(
|
||||||
|
@ -174,7 +174,7 @@ class HavenWalletService extends WalletService<
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<HavenWallet> restoreFromKeys(
|
Future<HavenWallet> restoreFromKeys(
|
||||||
HavenRestoreWalletFromKeysCredentials credentials, {bool? isTestnet}) async {
|
HavenRestoreWalletFromKeysCredentials credentials) async {
|
||||||
try {
|
try {
|
||||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||||
await haven_wallet_manager.restoreFromKeys(
|
await haven_wallet_manager.restoreFromKeys(
|
||||||
|
@ -198,7 +198,7 @@ class HavenWalletService extends WalletService<
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<HavenWallet> restoreFromSeed(
|
Future<HavenWallet> restoreFromSeed(
|
||||||
HavenRestoreWalletFromSeedCredentials credentials, {bool? isTestnet}) async {
|
HavenRestoreWalletFromSeedCredentials credentials) async {
|
||||||
try {
|
try {
|
||||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||||
await haven_wallet_manager.restoreFromSeed(
|
await haven_wallet_manager.restoreFromSeed(
|
||||||
|
|
|
@ -68,7 +68,7 @@ class MoneroWalletService extends WalletService<MoneroNewWalletCredentials,
|
||||||
WalletType getType() => WalletType.monero;
|
WalletType getType() => WalletType.monero;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MoneroWallet> create(MoneroNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<MoneroWallet> create(MoneroNewWalletCredentials credentials) async {
|
||||||
try {
|
try {
|
||||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||||
|
|
||||||
|
@ -203,8 +203,7 @@ class MoneroWalletService extends WalletService<MoneroNewWalletCredentials,
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MoneroWallet> restoreFromKeys(MoneroRestoreWalletFromKeysCredentials credentials,
|
Future<MoneroWallet> restoreFromKeys(MoneroRestoreWalletFromKeysCredentials credentials) async {
|
||||||
{bool? isTestnet}) async {
|
|
||||||
try {
|
try {
|
||||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||||
await monero_wallet_manager.restoreFromKeys(
|
await monero_wallet_manager.restoreFromKeys(
|
||||||
|
@ -228,8 +227,7 @@ class MoneroWalletService extends WalletService<MoneroNewWalletCredentials,
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MoneroWallet> restoreFromSeed(MoneroRestoreWalletFromSeedCredentials credentials,
|
Future<MoneroWallet> restoreFromSeed(MoneroRestoreWalletFromSeedCredentials credentials) async {
|
||||||
{bool? isTestnet}) async {
|
|
||||||
// Restore from Polyseed
|
// Restore from Polyseed
|
||||||
if (Polyseed.isValidSeed(credentials.mnemonic)) {
|
if (Polyseed.isValidSeed(credentials.mnemonic)) {
|
||||||
return restoreFromPolyseed(credentials);
|
return restoreFromPolyseed(credentials);
|
||||||
|
|
|
@ -26,7 +26,7 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
||||||
WalletType getType() => WalletType.nano;
|
WalletType getType() => WalletType.nano;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<WalletBase> create(NanoNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<WalletBase> create(NanoNewWalletCredentials credentials) async {
|
||||||
// nano standard:
|
// nano standard:
|
||||||
DerivationType derivationType = DerivationType.nano;
|
DerivationType derivationType = DerivationType.nano;
|
||||||
String seedKey = NanoSeeds.generateSeed();
|
String seedKey = NanoSeeds.generateSeed();
|
||||||
|
@ -79,7 +79,7 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<NanoWallet> restoreFromKeys(NanoRestoreWalletFromKeysCredentials credentials, {bool? isTestnet}) async {
|
Future<NanoWallet> restoreFromKeys(NanoRestoreWalletFromKeysCredentials credentials) async {
|
||||||
if (credentials.seedKey.contains(' ')) {
|
if (credentials.seedKey.contains(' ')) {
|
||||||
throw Exception("Invalid key!");
|
throw Exception("Invalid key!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,7 +113,7 @@ class NanoWalletService extends WalletService<NanoNewWalletCredentials,
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<NanoWallet> restoreFromSeed(NanoRestoreWalletFromSeedCredentials credentials, {bool? isTestnet}) async {
|
Future<NanoWallet> restoreFromSeed(NanoRestoreWalletFromSeedCredentials credentials) async {
|
||||||
if (credentials.mnemonic.contains(' ')) {
|
if (credentials.mnemonic.contains(' ')) {
|
||||||
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
||||||
throw nm.NanoMnemonicIsIncorrectException();
|
throw nm.NanoMnemonicIsIncorrectException();
|
||||||
|
|
|
@ -19,7 +19,7 @@ class PolygonWalletService extends EVMChainWalletService<PolygonWallet> {
|
||||||
WalletType getType() => WalletType.polygon;
|
WalletType getType() => WalletType.polygon;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PolygonWallet> create(EVMChainNewWalletCredentials credentials, {bool? isTestnet}) async {
|
Future<PolygonWallet> create(EVMChainNewWalletCredentials credentials) async {
|
||||||
final strength = credentials.seedPhraseLength == 24 ? 256 : 128;
|
final strength = credentials.seedPhraseLength == 24 ? 256 : 128;
|
||||||
|
|
||||||
final mnemonic = bip39.generateMnemonic(strength: strength);
|
final mnemonic = bip39.generateMnemonic(strength: strength);
|
||||||
|
@ -70,8 +70,8 @@ class PolygonWalletService extends EVMChainWalletService<PolygonWallet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PolygonWallet> restoreFromKeys(EVMChainRestoreWalletFromPrivateKey credentials,
|
Future<PolygonWallet> restoreFromKeys(EVMChainRestoreWalletFromPrivateKey credentials) async {
|
||||||
{bool? isTestnet}) async {
|
|
||||||
final wallet = PolygonWallet(
|
final wallet = PolygonWallet(
|
||||||
password: credentials.password!,
|
password: credentials.password!,
|
||||||
privateKey: credentials.privateKey,
|
privateKey: credentials.privateKey,
|
||||||
|
@ -87,8 +87,8 @@ class PolygonWalletService extends EVMChainWalletService<PolygonWallet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PolygonWallet> restoreFromSeed(EVMChainRestoreWalletFromSeedCredentials credentials,
|
Future<PolygonWallet> restoreFromSeed(
|
||||||
{bool? isTestnet}) async {
|
EVMChainRestoreWalletFromSeedCredentials credentials) async {
|
||||||
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
if (!bip39.validateMnemonic(credentials.mnemonic)) {
|
||||||
throw PolygonMnemonicIsIncorrectException();
|
throw PolygonMnemonicIsIncorrectException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,23 +5,25 @@ class CWBitcoin extends Bitcoin {
|
||||||
TransactionPriority getMediumTransactionPriority() => BitcoinTransactionPriority.medium;
|
TransactionPriority getMediumTransactionPriority() => BitcoinTransactionPriority.medium;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials(
|
WalletCredentials createBitcoinRestoreWalletFromSeedCredentials({
|
||||||
{required String name, required String mnemonic, required String password}) =>
|
required String name,
|
||||||
BitcoinRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password);
|
required String mnemonic,
|
||||||
|
required String password})
|
||||||
|
=> BitcoinRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
WalletCredentials createBitcoinRestoreWalletFromWIFCredentials(
|
WalletCredentials createBitcoinRestoreWalletFromWIFCredentials({
|
||||||
{required String name,
|
required String name,
|
||||||
required String password,
|
required String password,
|
||||||
required String wif,
|
required String wif,
|
||||||
WalletInfo? walletInfo}) =>
|
WalletInfo? walletInfo})
|
||||||
BitcoinRestoreWalletFromWIFCredentials(
|
=> BitcoinRestoreWalletFromWIFCredentials(name: name, password: password, wif: wif, walletInfo: walletInfo);
|
||||||
name: name, password: password, wif: wif, walletInfo: walletInfo);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
WalletCredentials createBitcoinNewWalletCredentials(
|
WalletCredentials createBitcoinNewWalletCredentials({
|
||||||
{required String name, WalletInfo? walletInfo}) =>
|
required String name,
|
||||||
BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
WalletInfo? walletInfo})
|
||||||
|
=> BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<String> getWordList() => wordlist;
|
List<String> getWordList() => wordlist;
|
||||||
|
@ -39,18 +41,20 @@ class CWBitcoin extends Bitcoin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<TransactionPriority> getTransactionPriorities() => BitcoinTransactionPriority.all;
|
List<TransactionPriority> getTransactionPriorities()
|
||||||
|
=> BitcoinTransactionPriority.all;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<TransactionPriority> getLitecoinTransactionPriorities() => LitecoinTransactionPriority.all;
|
List<TransactionPriority> getLitecoinTransactionPriorities()
|
||||||
|
=> LitecoinTransactionPriority.all;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority deserializeBitcoinTransactionPriority(int raw) =>
|
TransactionPriority deserializeBitcoinTransactionPriority(int raw)
|
||||||
BitcoinTransactionPriority.deserialize(raw: raw);
|
=> BitcoinTransactionPriority.deserialize(raw: raw);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority deserializeLitecoinTransactionPriority(int raw) =>
|
TransactionPriority deserializeLitecoinTransactionPriority(int raw)
|
||||||
LitecoinTransactionPriority.deserialize(raw: raw);
|
=> LitecoinTransactionPriority.deserialize(raw: raw);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int getFeeRate(Object wallet, TransactionPriority priority) {
|
int getFeeRate(Object wallet, TransactionPriority priority) {
|
||||||
|
@ -61,23 +65,21 @@ class CWBitcoin extends Bitcoin {
|
||||||
@override
|
@override
|
||||||
Future<void> generateNewAddress(Object wallet, String label) async {
|
Future<void> generateNewAddress(Object wallet, String label) async {
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
final bitcoinWallet = wallet as ElectrumWallet;
|
||||||
await bitcoinWallet.walletAddresses.generateNewAddress(label: label);
|
await bitcoinWallet.walletAddresses.generateNewAddress(label: label, hd: bitcoinWallet.hd);
|
||||||
await wallet.save();
|
await wallet.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> updateAddress(Object wallet, String address, String label) async {
|
Future<void> updateAddress(Object wallet,String address, String label) async {
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
final bitcoinWallet = wallet as ElectrumWallet;
|
||||||
bitcoinWallet.walletAddresses.updateAddress(address, label);
|
bitcoinWallet.walletAddresses.updateAddress(address, label);
|
||||||
await wallet.save();
|
await wallet.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Object createBitcoinTransactionCredentials(List<Output> outputs,
|
Object createBitcoinTransactionCredentials(List<Output> outputs, {required TransactionPriority priority, int? feeRate})
|
||||||
{required TransactionPriority priority, int? feeRate}) =>
|
=> BitcoinTransactionCredentials(
|
||||||
BitcoinTransactionCredentials(
|
outputs.map((out) => OutputInfo(
|
||||||
outputs
|
|
||||||
.map((out) => OutputInfo(
|
|
||||||
fiatAmount: out.fiatAmount,
|
fiatAmount: out.fiatAmount,
|
||||||
cryptoAmount: out.cryptoAmount,
|
cryptoAmount: out.cryptoAmount,
|
||||||
address: out.address,
|
address: out.address,
|
||||||
|
@ -91,16 +93,16 @@ class CWBitcoin extends Bitcoin {
|
||||||
feeRate: feeRate);
|
feeRate: feeRate);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Object createBitcoinTransactionCredentialsRaw(List<OutputInfo> outputs,
|
Object createBitcoinTransactionCredentialsRaw(List<OutputInfo> outputs, {TransactionPriority? priority, required int feeRate})
|
||||||
{TransactionPriority? priority, required int feeRate}) =>
|
=> BitcoinTransactionCredentials(
|
||||||
BitcoinTransactionCredentials(outputs,
|
outputs,
|
||||||
priority: priority != null ? priority as BitcoinTransactionPriority : null,
|
priority: priority != null ? priority as BitcoinTransactionPriority : null,
|
||||||
feeRate: feeRate);
|
feeRate: feeRate);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<String> getAddresses(Object wallet) {
|
List<String> getAddresses(Object wallet) {
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
final bitcoinWallet = wallet as ElectrumWallet;
|
||||||
return bitcoinWallet.walletAddresses.addressesByReceiveType
|
return bitcoinWallet.walletAddresses.addresses
|
||||||
.map((BitcoinAddressRecord addr) => addr.address)
|
.map((BitcoinAddressRecord addr) => addr.address)
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +111,7 @@ class CWBitcoin extends Bitcoin {
|
||||||
@computed
|
@computed
|
||||||
List<ElectrumSubAddress> getSubAddresses(Object wallet) {
|
List<ElectrumSubAddress> getSubAddresses(Object wallet) {
|
||||||
final electrumWallet = wallet as ElectrumWallet;
|
final electrumWallet = wallet as ElectrumWallet;
|
||||||
return electrumWallet.walletAddresses.addressesByReceiveType
|
return electrumWallet.walletAddresses.addresses
|
||||||
.map((BitcoinAddressRecord addr) => ElectrumSubAddress(
|
.map((BitcoinAddressRecord addr) => ElectrumSubAddress(
|
||||||
id: addr.index,
|
id: addr.index,
|
||||||
name: addr.name,
|
name: addr.name,
|
||||||
|
@ -127,19 +129,20 @@ class CWBitcoin extends Bitcoin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String formatterBitcoinAmountToString({required int amount}) =>
|
String formatterBitcoinAmountToString({required int amount})
|
||||||
bitcoinAmountToString(amount: amount);
|
=> bitcoinAmountToString(amount: amount);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double formatterBitcoinAmountToDouble({required int amount}) =>
|
double formatterBitcoinAmountToDouble({required int amount})
|
||||||
bitcoinAmountToDouble(amount: amount);
|
=> bitcoinAmountToDouble(amount: amount);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int formatterStringDoubleToBitcoinAmount(String amount) => stringDoubleToBitcoinAmount(amount);
|
int formatterStringDoubleToBitcoinAmount(String amount)
|
||||||
|
=> stringDoubleToBitcoinAmount(amount);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate) =>
|
String bitcoinTransactionPriorityWithLabel(TransactionPriority priority, int rate)
|
||||||
(priority as BitcoinTransactionPriority).labelWithRate(rate);
|
=> (priority as BitcoinTransactionPriority).labelWithRate(rate);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<BitcoinUnspent> getUnspents(Object wallet) {
|
List<BitcoinUnspent> getUnspents(Object wallet) {
|
||||||
|
@ -152,57 +155,27 @@ class CWBitcoin extends Bitcoin {
|
||||||
await bitcoinWallet.updateUnspent();
|
await bitcoinWallet.updateUnspent();
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletService createBitcoinWalletService(
|
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
|
||||||
Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
|
|
||||||
return BitcoinWalletService(walletInfoSource, unspentCoinSource);
|
return BitcoinWalletService(walletInfoSource, unspentCoinSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletService createLitecoinWalletService(
|
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
|
||||||
Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
|
|
||||||
return LitecoinWalletService(walletInfoSource, unspentCoinSource);
|
return LitecoinWalletService(walletInfoSource, unspentCoinSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority getBitcoinTransactionPriorityMedium() => BitcoinTransactionPriority.medium;
|
TransactionPriority getBitcoinTransactionPriorityMedium()
|
||||||
|
=> BitcoinTransactionPriority.medium;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority getLitecoinTransactionPriorityMedium() => LitecoinTransactionPriority.medium;
|
TransactionPriority getLitecoinTransactionPriorityMedium()
|
||||||
|
=> LitecoinTransactionPriority.medium;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority getBitcoinTransactionPrioritySlow() => BitcoinTransactionPriority.slow;
|
TransactionPriority getBitcoinTransactionPrioritySlow()
|
||||||
|
=> BitcoinTransactionPriority.slow;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TransactionPriority getLitecoinTransactionPrioritySlow() => LitecoinTransactionPriority.slow;
|
TransactionPriority getLitecoinTransactionPrioritySlow()
|
||||||
|
=> LitecoinTransactionPriority.slow;
|
||||||
@override
|
|
||||||
Future<void> setAddressType(Object wallet, dynamic option) async {
|
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
|
||||||
await bitcoinWallet.walletAddresses.setAddressType(option as BitcoinAddressType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
ReceivePageOption getSelectedAddressType(Object wallet) {
|
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
|
||||||
return BitcoinReceivePageOption.fromType(bitcoinWallet.walletAddresses.addressPageType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<ReceivePageOption> getBitcoinReceivePageOptions() => BitcoinReceivePageOption.all;
|
|
||||||
|
|
||||||
@override
|
|
||||||
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option) {
|
|
||||||
switch (option) {
|
|
||||||
case BitcoinReceivePageOption.p2pkh:
|
|
||||||
return P2pkhAddressType.p2pkh;
|
|
||||||
case BitcoinReceivePageOption.p2sh:
|
|
||||||
return P2shAddressType.p2wpkhInP2sh;
|
|
||||||
case BitcoinReceivePageOption.p2tr:
|
|
||||||
return SegwitAddresType.p2tr;
|
|
||||||
case BitcoinReceivePageOption.p2wsh:
|
|
||||||
return SegwitAddresType.p2wsh;
|
|
||||||
case BitcoinReceivePageOption.p2wpkh:
|
|
||||||
default:
|
|
||||||
return SegwitAddresType.p2wpkh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/core/validator.dart';
|
import 'package:cake_wallet/core/validator.dart';
|
||||||
import 'package:cake_wallet/solana/solana.dart';
|
import 'package:cake_wallet/solana/solana.dart';
|
||||||
|
@ -9,9 +9,7 @@ class AddressValidator extends TextValidator {
|
||||||
AddressValidator({required CryptoCurrency type})
|
AddressValidator({required CryptoCurrency type})
|
||||||
: super(
|
: super(
|
||||||
errorMessage: S.current.error_text_address,
|
errorMessage: S.current.error_text_address,
|
||||||
useAdditionalValidation: type == CryptoCurrency.btc
|
useAdditionalValidation: type == CryptoCurrency.btc ? bitcoin.Address.validateAddress : null,
|
||||||
? (String txt) => validateAddress(address: txt, network: BitcoinNetwork.mainnet)
|
|
||||||
: null,
|
|
||||||
pattern: getPattern(type),
|
pattern: getPattern(type),
|
||||||
length: getLength(type));
|
length: getLength(type));
|
||||||
|
|
||||||
|
@ -26,7 +24,7 @@ class AddressValidator extends TextValidator {
|
||||||
return '^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{104}\$'
|
return '^[0-9a-zA-Z]{59}\$|^[0-9a-zA-Z]{92}\$|^[0-9a-zA-Z]{104}\$'
|
||||||
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
|
'|^[0-9a-zA-Z]{105}\$|^addr1[0-9a-zA-Z]{98}\$';
|
||||||
case CryptoCurrency.btc:
|
case CryptoCurrency.btc:
|
||||||
return '^${P2pkhAddress.regex.pattern}\$|^${P2shAddress.regex.pattern}\$|^${P2wpkhAddress.regex.pattern}\$|${P2trAddress.regex.pattern}\$|^${P2wshAddress.regex.pattern}\$';
|
return '^3[0-9a-zA-Z]{32}\$|^3[0-9a-zA-Z]{33}\$|^bc1[0-9a-zA-Z]{59}\$';
|
||||||
case CryptoCurrency.nano:
|
case CryptoCurrency.nano:
|
||||||
return '[0-9a-zA-Z_]';
|
return '[0-9a-zA-Z_]';
|
||||||
case CryptoCurrency.banano:
|
case CryptoCurrency.banano:
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:cake_wallet/di.dart';
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
@ -54,7 +55,7 @@ class WalletCreationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<WalletBase> create(WalletCredentials credentials, {bool? isTestnet}) async {
|
Future<WalletBase> create(WalletCredentials credentials) async {
|
||||||
checkIfExists(credentials.name);
|
checkIfExists(credentials.name);
|
||||||
final password = generateWalletPassword();
|
final password = generateWalletPassword();
|
||||||
credentials.password = password;
|
credentials.password = password;
|
||||||
|
@ -62,7 +63,7 @@ class WalletCreationService {
|
||||||
credentials.seedPhraseLength = settingsStore.seedPhraseLength.value;
|
credentials.seedPhraseLength = settingsStore.seedPhraseLength.value;
|
||||||
}
|
}
|
||||||
await keyService.saveWalletPassword(password: password, walletName: credentials.name);
|
await keyService.saveWalletPassword(password: password, walletName: credentials.name);
|
||||||
final wallet = await _service!.create(credentials, isTestnet: isTestnet);
|
final wallet = await _service!.create(credentials);
|
||||||
|
|
||||||
if (wallet.type == WalletType.monero) {
|
if (wallet.type == WalletType.monero) {
|
||||||
await sharedPreferences.setBool(
|
await sharedPreferences.setBool(
|
||||||
|
@ -72,12 +73,12 @@ class WalletCreationService {
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<WalletBase> restoreFromKeys(WalletCredentials credentials, {bool? isTestnet}) async {
|
Future<WalletBase> restoreFromKeys(WalletCredentials credentials) async {
|
||||||
checkIfExists(credentials.name);
|
checkIfExists(credentials.name);
|
||||||
final password = generateWalletPassword();
|
final password = generateWalletPassword();
|
||||||
credentials.password = password;
|
credentials.password = password;
|
||||||
await keyService.saveWalletPassword(password: password, walletName: credentials.name);
|
await keyService.saveWalletPassword(password: password, walletName: credentials.name);
|
||||||
final wallet = await _service!.restoreFromKeys(credentials, isTestnet: isTestnet);
|
final wallet = await _service!.restoreFromKeys(credentials);
|
||||||
|
|
||||||
if (wallet.type == WalletType.monero) {
|
if (wallet.type == WalletType.monero) {
|
||||||
await sharedPreferences.setBool(
|
await sharedPreferences.setBool(
|
||||||
|
@ -87,12 +88,12 @@ class WalletCreationService {
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<WalletBase> restoreFromSeed(WalletCredentials credentials, {bool? isTestnet}) async {
|
Future<WalletBase> restoreFromSeed(WalletCredentials credentials) async {
|
||||||
checkIfExists(credentials.name);
|
checkIfExists(credentials.name);
|
||||||
final password = generateWalletPassword();
|
final password = generateWalletPassword();
|
||||||
credentials.password = password;
|
credentials.password = password;
|
||||||
await keyService.saveWalletPassword(password: password, walletName: credentials.name);
|
await keyService.saveWalletPassword(password: password, walletName: credentials.name);
|
||||||
final wallet = await _service!.restoreFromSeed(credentials, isTestnet: isTestnet);
|
final wallet = await _service!.restoreFromSeed(credentials);
|
||||||
|
|
||||||
if (wallet.type == WalletType.monero) {
|
if (wallet.type == WalletType.monero) {
|
||||||
await sharedPreferences.setBool(
|
await sharedPreferences.setBool(
|
||||||
|
|
|
@ -13,7 +13,7 @@ import 'package:cake_wallet/core/yat_service.dart';
|
||||||
import 'package:cake_wallet/entities/background_tasks.dart';
|
import 'package:cake_wallet/entities/background_tasks.dart';
|
||||||
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||||
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
import 'package:cake_wallet/entities/receive_page_option.dart';
|
||||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||||
import 'package:cake_wallet/nano/nano.dart';
|
import 'package:cake_wallet/nano/nano.dart';
|
||||||
import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
||||||
|
|
|
@ -23,10 +23,6 @@ import 'package:collection/collection.dart';
|
||||||
|
|
||||||
const newCakeWalletMoneroUri = 'xmr-node.cakewallet.com:18081';
|
const newCakeWalletMoneroUri = 'xmr-node.cakewallet.com:18081';
|
||||||
const cakeWalletBitcoinElectrumUri = 'electrum.cakewallet.com:50002';
|
const cakeWalletBitcoinElectrumUri = 'electrum.cakewallet.com:50002';
|
||||||
const publicBitcoinTestnetElectrumAddress = 'electrum.blockstream.info';
|
|
||||||
const publicBitcoinTestnetElectrumPort = '60002';
|
|
||||||
const publicBitcoinTestnetElectrumUri =
|
|
||||||
'$publicBitcoinTestnetElectrumAddress:$publicBitcoinTestnetElectrumPort';
|
|
||||||
const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002';
|
const cakeWalletLitecoinElectrumUri = 'ltc-electrum.cakewallet.com:50002';
|
||||||
const havenDefaultNodeUri = 'nodes.havenprotocol.org:443';
|
const havenDefaultNodeUri = 'nodes.havenprotocol.org:443';
|
||||||
const ethereumDefaultNodeUri = 'ethereum.publicnode.com';
|
const ethereumDefaultNodeUri = 'ethereum.publicnode.com';
|
||||||
|
@ -338,12 +334,6 @@ Node? getBitcoinDefaultElectrumServer({required Box<Node> nodes}) {
|
||||||
nodes.values.firstWhereOrNull((node) => node.type == WalletType.bitcoin);
|
nodes.values.firstWhereOrNull((node) => node.type == WalletType.bitcoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node? getBitcoinTestnetDefaultElectrumServer({required Box<Node> nodes}) {
|
|
||||||
return nodes.values
|
|
||||||
.firstWhereOrNull((Node node) => node.uriRaw == publicBitcoinTestnetElectrumUri) ??
|
|
||||||
nodes.values.firstWhereOrNull((node) => node.type == WalletType.bitcoin);
|
|
||||||
}
|
|
||||||
|
|
||||||
Node? getLitecoinDefaultElectrumServer({required Box<Node> nodes}) {
|
Node? getLitecoinDefaultElectrumServer({required Box<Node> nodes}) {
|
||||||
return nodes.values
|
return nodes.values
|
||||||
.firstWhereOrNull((Node node) => node.uriRaw == cakeWalletLitecoinElectrumUri) ??
|
.firstWhereOrNull((Node node) => node.uriRaw == cakeWalletLitecoinElectrumUri) ??
|
||||||
|
@ -513,15 +503,8 @@ Future<void> rewriteSecureStoragePin({required FlutterSecureStorage secureStorag
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changeBitcoinCurrentElectrumServerToDefault(
|
Future<void> changeBitcoinCurrentElectrumServerToDefault(
|
||||||
{required SharedPreferences sharedPreferences,
|
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
|
||||||
required Box<Node> nodes,
|
final server = getBitcoinDefaultElectrumServer(nodes: nodes);
|
||||||
bool? isTestnet}) async {
|
|
||||||
Node? server;
|
|
||||||
if (isTestnet == true) {
|
|
||||||
server = getBitcoinTestnetDefaultElectrumServer(nodes: nodes);
|
|
||||||
} else {
|
|
||||||
server = getBitcoinDefaultElectrumServer(nodes: nodes);
|
|
||||||
}
|
|
||||||
final serverId = server?.key as int? ?? 0;
|
final serverId = server?.key as int? ?? 0;
|
||||||
|
|
||||||
await sharedPreferences.setInt(PreferencesKey.currentBitcoinElectrumSererIdKey, serverId);
|
await sharedPreferences.setInt(PreferencesKey.currentBitcoinElectrumSererIdKey, serverId);
|
||||||
|
|
23
lib/entities/receive_page_option.dart
Normal file
23
lib/entities/receive_page_option.dart
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
enum ReceivePageOption {
|
||||||
|
mainnet,
|
||||||
|
anonPayInvoice,
|
||||||
|
anonPayDonationLink;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
String label = '';
|
||||||
|
switch (this) {
|
||||||
|
case ReceivePageOption.mainnet:
|
||||||
|
label = 'Mainnet';
|
||||||
|
break;
|
||||||
|
case ReceivePageOption.anonPayInvoice:
|
||||||
|
label = 'Trocador AnonPay Invoice';
|
||||||
|
break;
|
||||||
|
case ReceivePageOption.anonPayDonationLink:
|
||||||
|
label = 'Trocador AnonPay Donation Link';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
|
@ -532,19 +532,13 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
builder: (_) => getIt.get<WebViewPage>(param1: title, param2: url));
|
builder: (_) => getIt.get<WebViewPage>(param1: title, param2: url));
|
||||||
|
|
||||||
case Routes.advancedPrivacySettings:
|
case Routes.advancedPrivacySettings:
|
||||||
final args = settings.arguments as Map<String, dynamic>;
|
final type = settings.arguments as WalletType;
|
||||||
final type = args['type'] as WalletType;
|
|
||||||
final useTestnet = args['useTestnet'] as bool;
|
|
||||||
final toggleTestnet = args['toggleTestnet'] as Function(bool? val);
|
|
||||||
|
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
builder: (_) => AdvancedPrivacySettingsPage(
|
builder: (_) => AdvancedPrivacySettingsPage(
|
||||||
useTestnet,
|
|
||||||
toggleTestnet,
|
|
||||||
getIt.get<AdvancedPrivacySettingsViewModel>(param1: type),
|
getIt.get<AdvancedPrivacySettingsViewModel>(param1: type),
|
||||||
getIt.get<NodeCreateOrEditViewModel>(param1: type, param2: false),
|
getIt.get<NodeCreateOrEditViewModel>(param1: type, param2: false),
|
||||||
getIt.get<SeedTypeViewModel>(),
|
getIt.get<SeedTypeViewModel>()));
|
||||||
));
|
|
||||||
|
|
||||||
case Routes.anonPayInvoicePage:
|
case Routes.anonPayInvoicePage:
|
||||||
final args = settings.arguments as List;
|
final args = settings.arguments as List;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart';
|
import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
||||||
import 'package:cake_wallet/di.dart';
|
import 'package:cake_wallet/di.dart';
|
||||||
|
@ -6,7 +5,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
|
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
|
||||||
import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart';
|
import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart';
|
||||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
import 'package:cake_wallet/entities/receive_page_option.dart';
|
||||||
import 'package:cake_wallet/src/screens/dashboard/widgets/present_receive_option_picker.dart';
|
import 'package:cake_wallet/src/screens/dashboard/widgets/present_receive_option_picker.dart';
|
||||||
import 'package:cake_wallet/src/widgets/gradient_background.dart';
|
import 'package:cake_wallet/src/widgets/gradient_background.dart';
|
||||||
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
||||||
|
@ -167,7 +166,8 @@ class AddressPage extends BasePage {
|
||||||
(WalletType.monero == addressListViewModel.wallet.type ||
|
(WalletType.monero == addressListViewModel.wallet.type ||
|
||||||
WalletType.haven == addressListViewModel.wallet.type)
|
WalletType.haven == addressListViewModel.wallet.type)
|
||||||
? await showPopUp<void>(
|
? await showPopUp<void>(
|
||||||
context: context, builder: (_) => getIt.get<MoneroAccountListPage>())
|
context: context,
|
||||||
|
builder: (_) => getIt.get<MoneroAccountListPage>())
|
||||||
: Navigator.of(context).pushNamed(Routes.receive),
|
: Navigator.of(context).pushNamed(Routes.receive),
|
||||||
textColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
textColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
||||||
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
||||||
|
@ -230,9 +230,6 @@ class AddressPage extends BasePage {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (addressListViewModel.type == WalletType.bitcoin) {
|
|
||||||
addressListViewModel.setAddressType(bitcoin!.getBitcoinAddressType(option));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:cake_wallet/entities/default_settings_migration.dart';
|
|
||||||
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||||
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
||||||
import 'package:cake_wallet/entities/seed_phrase_length.dart';
|
import 'package:cake_wallet/entities/seed_phrase_length.dart';
|
||||||
|
@ -12,7 +11,6 @@ import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.
|
||||||
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
|
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
|
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
|
@ -21,7 +19,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||||
|
|
||||||
class AdvancedPrivacySettingsPage extends BasePage {
|
class AdvancedPrivacySettingsPage extends BasePage {
|
||||||
AdvancedPrivacySettingsPage(this.useTestnet, this.toggleUseTestnet,
|
AdvancedPrivacySettingsPage(
|
||||||
this.advancedPrivacySettingsViewModel, this.nodeViewModel, this.seedTypeViewModel);
|
this.advancedPrivacySettingsViewModel, this.nodeViewModel, this.seedTypeViewModel);
|
||||||
|
|
||||||
final AdvancedPrivacySettingsViewModel advancedPrivacySettingsViewModel;
|
final AdvancedPrivacySettingsViewModel advancedPrivacySettingsViewModel;
|
||||||
|
@ -31,16 +29,13 @@ class AdvancedPrivacySettingsPage extends BasePage {
|
||||||
@override
|
@override
|
||||||
String get title => S.current.privacy_settings;
|
String get title => S.current.privacy_settings;
|
||||||
|
|
||||||
final bool useTestnet;
|
|
||||||
final Function(bool? val) toggleUseTestnet;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) => AdvancedPrivacySettingsBody(useTestnet, toggleUseTestnet,
|
Widget body(BuildContext context) => AdvancedPrivacySettingsBody(
|
||||||
advancedPrivacySettingsViewModel, nodeViewModel, seedTypeViewModel);
|
advancedPrivacySettingsViewModel, nodeViewModel, seedTypeViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdvancedPrivacySettingsBody extends StatefulWidget {
|
class AdvancedPrivacySettingsBody extends StatefulWidget {
|
||||||
const AdvancedPrivacySettingsBody(this.useTestnet, this.toggleUseTestnet,
|
const AdvancedPrivacySettingsBody(
|
||||||
this.privacySettingsViewModel, this.nodeViewModel, this.seedTypeViewModel,
|
this.privacySettingsViewModel, this.nodeViewModel, this.seedTypeViewModel,
|
||||||
{Key? key})
|
{Key? key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
@ -49,9 +44,6 @@ class AdvancedPrivacySettingsBody extends StatefulWidget {
|
||||||
final NodeCreateOrEditViewModel nodeViewModel;
|
final NodeCreateOrEditViewModel nodeViewModel;
|
||||||
final SeedTypeViewModel seedTypeViewModel;
|
final SeedTypeViewModel seedTypeViewModel;
|
||||||
|
|
||||||
final bool useTestnet;
|
|
||||||
final Function(bool? val) toggleUseTestnet;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AdvancedPrivacySettingsBodyState createState() => _AdvancedPrivacySettingsBodyState();
|
_AdvancedPrivacySettingsBodyState createState() => _AdvancedPrivacySettingsBodyState();
|
||||||
}
|
}
|
||||||
|
@ -60,14 +52,9 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
|
||||||
_AdvancedPrivacySettingsBodyState();
|
_AdvancedPrivacySettingsBodyState();
|
||||||
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
bool? testnetValue;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (testnetValue == null && widget.useTestnet != null) {
|
|
||||||
testnetValue = widget.useTestnet;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: 24),
|
padding: EdgeInsets.only(top: 24),
|
||||||
child: ScrollableWithBottomSection(
|
child: ScrollableWithBottomSection(
|
||||||
|
@ -138,19 +125,6 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
if (widget.privacySettingsViewModel.type == WalletType.bitcoin)
|
|
||||||
Builder(builder: (_) {
|
|
||||||
final val = testnetValue!;
|
|
||||||
return SettingsSwitcherCell(
|
|
||||||
title: S.current.use_testnet,
|
|
||||||
value: val,
|
|
||||||
onValueChange: (_, __) {
|
|
||||||
setState(() {
|
|
||||||
testnetValue = !val;
|
|
||||||
});
|
|
||||||
widget.toggleUseTestnet!.call(testnetValue);
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomSectionPadding: EdgeInsets.all(24),
|
bottomSectionPadding: EdgeInsets.all(24),
|
||||||
|
@ -163,13 +137,6 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.nodeViewModel.save();
|
|
||||||
} else if (testnetValue == true) {
|
|
||||||
// TODO: add type (mainnet/testnet) to Node class so when switching wallets the node can be switched to a matching type
|
|
||||||
// Currently this is so you can create a working testnet wallet but you need to keep switching back the node if you use multiple wallets at once
|
|
||||||
widget.nodeViewModel.address = publicBitcoinTestnetElectrumAddress;
|
|
||||||
widget.nodeViewModel.port = publicBitcoinTestnetElectrumPort;
|
|
||||||
|
|
||||||
widget.nodeViewModel.save();
|
widget.nodeViewModel.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,7 @@ class NewWalletPage extends BasePage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) => WalletNameForm(
|
Widget body(BuildContext context) => WalletNameForm(
|
||||||
_walletNewVM,
|
_walletNewVM, currentTheme.type == ThemeType.dark ? walletNameImage : walletNameLightImage, _seedTypeViewModel);
|
||||||
currentTheme.type == ThemeType.dark ? walletNameImage : walletNameLightImage,
|
|
||||||
_seedTypeViewModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class WalletNameForm extends StatefulWidget {
|
class WalletNameForm extends StatefulWidget {
|
||||||
|
@ -189,6 +187,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (_walletNewVM.hasLanguageSelector) ...[
|
if (_walletNewVM.hasLanguageSelector) ...[
|
||||||
if (_walletNewVM.hasSeedType) ...[
|
if (_walletNewVM.hasSeedType) ...[
|
||||||
Observer(
|
Observer(
|
||||||
|
@ -223,7 +222,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -246,11 +245,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.advancedPrivacySettings, arguments: {
|
Navigator.of(context)
|
||||||
"type": _walletNewVM.type,
|
.pushNamed(Routes.advancedPrivacySettings, arguments: _walletNewVM.type);
|
||||||
"useTestnet": _walletNewVM.useTestnet,
|
|
||||||
"toggleTestnet": _walletNewVM.toggleUseTestnet
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
child: Text(S.of(context).advanced_settings),
|
child: Text(S.of(context).advanced_settings),
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart';
|
||||||
import 'package:cake_wallet/core/execution_state.dart';
|
import 'package:cake_wallet/core/execution_state.dart';
|
||||||
import 'package:cake_wallet/di.dart';
|
import 'package:cake_wallet/di.dart';
|
||||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
import 'package:cake_wallet/entities/receive_page_option.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/src/screens/dashboard/widgets/present_receive_option_picker.dart';
|
import 'package:cake_wallet/src/screens/dashboard/widgets/present_receive_option_picker.dart';
|
||||||
import 'package:cake_wallet/src/screens/receive/widgets/anonpay_input_form.dart';
|
import 'package:cake_wallet/src/screens/receive/widgets/anonpay_input_form.dart';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:cake_wallet/anonpay/anonpay_info_base.dart';
|
import 'package:cake_wallet/anonpay/anonpay_info_base.dart';
|
||||||
import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
|
import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
|
||||||
import 'package:cake_wallet/entities/qr_view_data.dart';
|
import 'package:cake_wallet/entities/qr_view_data.dart';
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
import 'package:cake_wallet/entities/receive_page_option.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
|
|
|
@ -210,12 +210,8 @@ class WalletRestorePage extends BasePage {
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context)
|
Navigator.of(context).pushNamed(Routes.advancedPrivacySettings,
|
||||||
.pushNamed(Routes.advancedPrivacySettings, arguments: {
|
arguments: walletRestoreViewModel.type);
|
||||||
'type': walletRestoreViewModel.type,
|
|
||||||
'useTestnet': walletRestoreViewModel.useTestnet,
|
|
||||||
'toggleTestnet': walletRestoreViewModel.toggleUseTestnet
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
child: Text(S.of(context).advanced_settings),
|
child: Text(S.of(context).advanced_settings),
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import 'package:cake_wallet/anonpay/anonpay_request.dart';
|
||||||
import 'package:cake_wallet/core/execution_state.dart';
|
import 'package:cake_wallet/core/execution_state.dart';
|
||||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
import 'package:cake_wallet/entities/receive_page_option.dart';
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
import 'package:cw_core/currency.dart';
|
import 'package:cw_core/currency.dart';
|
||||||
|
|
|
@ -148,18 +148,14 @@ abstract class DashboardViewModelBase with Store {
|
||||||
monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id)
|
monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
final sortedTransactions = [..._accountTransactions];
|
transactions = ObservableList.of(_accountTransactions.map((transaction) =>
|
||||||
sortedTransactions.sort((a, b) => a.date.compareTo(b.date));
|
TransactionListItem(
|
||||||
|
|
||||||
transactions = ObservableList.of(sortedTransactions.map((transaction) => TransactionListItem(
|
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore)));
|
settingsStore: appStore.settingsStore)));
|
||||||
} else {
|
} else {
|
||||||
final sortedTransactions = [...wallet.transactionHistory.transactions.values];
|
transactions = ObservableList.of(wallet.transactionHistory.transactions.values.map(
|
||||||
sortedTransactions.sort((a, b) => a.date.compareTo(b.date));
|
(transaction) => TransactionListItem(
|
||||||
|
|
||||||
transactions = ObservableList.of(sortedTransactions.map((transaction) => TransactionListItem(
|
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore)));
|
settingsStore: appStore.settingsStore)));
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
import 'package:cake_wallet/entities/receive_page_option.dart';
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
@ -10,20 +9,11 @@ class ReceiveOptionViewModel = ReceiveOptionViewModelBase with _$ReceiveOptionVi
|
||||||
|
|
||||||
abstract class ReceiveOptionViewModelBase with Store {
|
abstract class ReceiveOptionViewModelBase with Store {
|
||||||
ReceiveOptionViewModelBase(this._wallet, this.initialPageOption)
|
ReceiveOptionViewModelBase(this._wallet, this.initialPageOption)
|
||||||
: selectedReceiveOption = initialPageOption ??
|
: selectedReceiveOption = initialPageOption ?? ReceivePageOption.mainnet,
|
||||||
(_wallet.type == WalletType.bitcoin
|
|
||||||
? bitcoin!.getSelectedAddressType(_wallet)
|
|
||||||
: ReceivePageOption.mainnet),
|
|
||||||
_options = [] {
|
_options = [] {
|
||||||
final walletType = _wallet.type;
|
final walletType = _wallet.type;
|
||||||
_options = walletType == WalletType.haven
|
_options =
|
||||||
? [ReceivePageOption.mainnet]
|
walletType == WalletType.haven ? [ReceivePageOption.mainnet] : ReceivePageOption.values;
|
||||||
: walletType == WalletType.bitcoin
|
|
||||||
? [
|
|
||||||
...bitcoin!.getBitcoinReceivePageOptions(),
|
|
||||||
...ReceivePageOptions.where((element) => element != ReceivePageOption.mainnet)
|
|
||||||
]
|
|
||||||
: ReceivePageOptions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final WalletBase _wallet;
|
final WalletBase _wallet;
|
||||||
|
|
|
@ -65,8 +65,6 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
bool get hasAuthCredentials =>
|
bool get hasAuthCredentials =>
|
||||||
_walletType == WalletType.monero || _walletType == WalletType.haven;
|
_walletType == WalletType.monero || _walletType == WalletType.haven;
|
||||||
|
|
||||||
bool get hasTestnetSupport => _walletType == WalletType.bitcoin;
|
|
||||||
|
|
||||||
String get uri {
|
String get uri {
|
||||||
var uri = address;
|
var uri = address;
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,7 @@ abstract class NodeListViewModelBase with Store {
|
||||||
|
|
||||||
switch (_appStore.wallet!.type) {
|
switch (_appStore.wallet!.type) {
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
if (_appStore.wallet!.isTestnet == true) {
|
|
||||||
node = getBitcoinTestnetDefaultElectrumServer(nodes: _nodeSource)!;
|
|
||||||
} else {
|
|
||||||
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!;
|
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WalletType.monero:
|
case WalletType.monero:
|
||||||
node = getMoneroDefaultNode(nodes: _nodeSource);
|
node = getMoneroDefaultNode(nodes: _nodeSource);
|
||||||
|
|
|
@ -119,7 +119,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
case WalletType.monero:
|
case WalletType.monero:
|
||||||
return 'https://monero.com/tx/${txId}';
|
return 'https://monero.com/tx/${txId}';
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
return 'https://mempool.space/${wallet.isTestnet == true ? "testnet/" : ""}tx/${txId}';
|
return 'https://mempool.space/tx/${txId}';
|
||||||
case WalletType.litecoin:
|
case WalletType.litecoin:
|
||||||
return 'https://blockchair.com/litecoin/transaction/${txId}';
|
return 'https://blockchair.com/litecoin/transaction/${txId}';
|
||||||
case WalletType.bitcoinCash:
|
case WalletType.bitcoinCash:
|
||||||
|
|
|
@ -388,6 +388,9 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||||
wallet.type == WalletType.bitcoin ||
|
wallet.type == WalletType.bitcoin ||
|
||||||
wallet.type == WalletType.litecoin;
|
wallet.type == WalletType.litecoin;
|
||||||
|
|
||||||
|
// wallet.type == WalletType.nano ||
|
||||||
|
// wallet.type == WalletType.banano; TODO: nano accounts are disabled for now
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get isElectrumWallet =>
|
bool get isElectrumWallet =>
|
||||||
wallet.type == WalletType.bitcoin ||
|
wallet.type == WalletType.bitcoin ||
|
||||||
|
@ -406,17 +409,16 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||||
void setAddress(WalletAddressListItem address) =>
|
void setAddress(WalletAddressListItem address) =>
|
||||||
wallet.walletAddresses.address = address.address;
|
wallet.walletAddresses.address = address.address;
|
||||||
|
|
||||||
@action
|
|
||||||
Future<void> setAddressType(dynamic option) async {
|
|
||||||
if (wallet.type == WalletType.bitcoin) {
|
|
||||||
await bitcoin!.setAddressType(wallet, option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _init() {
|
void _init() {
|
||||||
_baseItems = [];
|
_baseItems = [];
|
||||||
|
|
||||||
if (wallet.type == WalletType.monero || wallet.type == WalletType.haven) {
|
if (wallet.type == WalletType.monero ||
|
||||||
|
wallet.type ==
|
||||||
|
WalletType
|
||||||
|
.haven /*||
|
||||||
|
wallet.type == WalletType.nano ||
|
||||||
|
wallet.type == WalletType.banano*/
|
||||||
|
) {
|
||||||
_baseItems.add(WalletAccountListHeader());
|
_baseItems.add(WalletAccountListHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,6 @@ abstract class WalletCreationVMBase with Store {
|
||||||
: state = InitialExecutionState(),
|
: state = InitialExecutionState(),
|
||||||
name = '';
|
name = '';
|
||||||
|
|
||||||
@observable
|
|
||||||
bool _useTestnet = false;
|
|
||||||
|
|
||||||
@computed
|
|
||||||
bool get useTestnet => _useTestnet;
|
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
@ -100,9 +94,4 @@ abstract class WalletCreationVMBase with Store {
|
||||||
Future<WalletBase> processFromRestoredWallet(
|
Future<WalletBase> processFromRestoredWallet(
|
||||||
WalletCredentials credentials, RestoredWallet restoreWallet) =>
|
WalletCredentials credentials, RestoredWallet restoreWallet) =>
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
|
|
||||||
@action
|
|
||||||
void toggleUseTestnet(bool? value) {
|
|
||||||
_useTestnet = value ?? !_useTestnet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,6 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||||
@override
|
@override
|
||||||
Future<WalletBase> process(WalletCredentials credentials) async {
|
Future<WalletBase> process(WalletCredentials credentials) async {
|
||||||
walletCreationService.changeWalletType(type: type);
|
walletCreationService.changeWalletType(type: type);
|
||||||
return walletCreationService.create(credentials, isTestnet: useTestnet);
|
return walletCreationService.create(credentials);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,9 +207,9 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||||
@override
|
@override
|
||||||
Future<WalletBase> process(WalletCredentials credentials) async {
|
Future<WalletBase> process(WalletCredentials credentials) async {
|
||||||
if (mode == WalletRestoreMode.keys) {
|
if (mode == WalletRestoreMode.keys) {
|
||||||
return walletCreationService.restoreFromKeys(credentials, isTestnet: useTestnet);
|
return walletCreationService.restoreFromKeys(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
return walletCreationService.restoreFromSeed(credentials, isTestnet: useTestnet);
|
return walletCreationService.restoreFromSeed(credentials);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "يتم تحويل الأموال إلى الدولار الأمريكي عند الاحتفاظ بها في الحساب المدفوع مسبقًا ، وليس بالعملات الرقمية.",
|
"use_card_info_two": "يتم تحويل الأموال إلى الدولار الأمريكي عند الاحتفاظ بها في الحساب المدفوع مسبقًا ، وليس بالعملات الرقمية.",
|
||||||
"use_ssl": "استخدم SSL",
|
"use_ssl": "استخدم SSL",
|
||||||
"use_suggested": "استخدام المقترح",
|
"use_suggested": "استخدام المقترح",
|
||||||
"use_testnet": "استخدم testnet",
|
|
||||||
"variable_pair_not_supported": "هذا الزوج المتغير غير مدعوم في التبادلات المحددة",
|
"variable_pair_not_supported": "هذا الزوج المتغير غير مدعوم في التبادلات المحددة",
|
||||||
"verification": "تَحَقّق",
|
"verification": "تَحَقّق",
|
||||||
"verify_with_2fa": "تحقق مع Cake 2FA",
|
"verify_with_2fa": "تحقق مع Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Средствата се обръщат в USD, когато биват запазени в предплатената карта, а не в дигитална валута.",
|
"use_card_info_two": "Средствата се обръщат в USD, когато биват запазени в предплатената карта, а не в дигитална валута.",
|
||||||
"use_ssl": "Използване на SSL",
|
"use_ssl": "Използване на SSL",
|
||||||
"use_suggested": "Използване на предложеното",
|
"use_suggested": "Използване на предложеното",
|
||||||
"use_testnet": "Използвайте TestNet",
|
|
||||||
"variable_pair_not_supported": "Този variable pair не се поддържа от избраната борса",
|
"variable_pair_not_supported": "Този variable pair не се поддържа от избраната борса",
|
||||||
"verification": "Потвърждаване",
|
"verification": "Потвърждаване",
|
||||||
"verify_with_2fa": "Проверете с Cake 2FA",
|
"verify_with_2fa": "Проверете с Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Prostředky jsou převedeny na USD, když jsou drženy na předplaceném účtu, nikoliv na digitální měnu.",
|
"use_card_info_two": "Prostředky jsou převedeny na USD, když jsou drženy na předplaceném účtu, nikoliv na digitální měnu.",
|
||||||
"use_ssl": "Použít SSL",
|
"use_ssl": "Použít SSL",
|
||||||
"use_suggested": "Použít doporučený",
|
"use_suggested": "Použít doporučený",
|
||||||
"use_testnet": "Použijte testNet",
|
|
||||||
"variable_pair_not_supported": "Tento pár s tržním kurzem není ve zvolené směnárně podporován",
|
"variable_pair_not_supported": "Tento pár s tržním kurzem není ve zvolené směnárně podporován",
|
||||||
"verification": "Ověření",
|
"verification": "Ověření",
|
||||||
"verify_with_2fa": "Ověřte pomocí Cake 2FA",
|
"verify_with_2fa": "Ověřte pomocí Cake 2FA",
|
||||||
|
|
|
@ -725,7 +725,6 @@
|
||||||
"use_card_info_two": "Guthaben werden auf dem Prepaid-Konto in USD umgerechnet, nicht in digitale Währung.",
|
"use_card_info_two": "Guthaben werden auf dem Prepaid-Konto in USD umgerechnet, nicht in digitale Währung.",
|
||||||
"use_ssl": "SSL verwenden",
|
"use_ssl": "SSL verwenden",
|
||||||
"use_suggested": "Vorgeschlagen verwenden",
|
"use_suggested": "Vorgeschlagen verwenden",
|
||||||
"use_testnet": "TESTNET verwenden",
|
|
||||||
"variable_pair_not_supported": "Dieses Variablenpaar wird von den ausgewählten Börsen nicht unterstützt",
|
"variable_pair_not_supported": "Dieses Variablenpaar wird von den ausgewählten Börsen nicht unterstützt",
|
||||||
"verification": "Verifizierung",
|
"verification": "Verifizierung",
|
||||||
"verify_with_2fa": "Verifizieren Sie mit Cake 2FA",
|
"verify_with_2fa": "Verifizieren Sie mit Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Funds are converted to USD when they're held in the prepaid account, not in digital currencies.",
|
"use_card_info_two": "Funds are converted to USD when they're held in the prepaid account, not in digital currencies.",
|
||||||
"use_ssl": "Use SSL",
|
"use_ssl": "Use SSL",
|
||||||
"use_suggested": "Use Suggested",
|
"use_suggested": "Use Suggested",
|
||||||
"use_testnet": "Use Testnet",
|
|
||||||
"variable_pair_not_supported": "This variable pair is not supported with the selected exchanges",
|
"variable_pair_not_supported": "This variable pair is not supported with the selected exchanges",
|
||||||
"verification": "Verification",
|
"verification": "Verification",
|
||||||
"verify_with_2fa": "Verify with Cake 2FA",
|
"verify_with_2fa": "Verify with Cake 2FA",
|
||||||
|
|
|
@ -724,7 +724,6 @@
|
||||||
"use_card_info_two": "Los fondos se convierten a USD cuando se mantienen en la cuenta prepaga, no en monedas digitales.",
|
"use_card_info_two": "Los fondos se convierten a USD cuando se mantienen en la cuenta prepaga, no en monedas digitales.",
|
||||||
"use_ssl": "Utilice SSL",
|
"use_ssl": "Utilice SSL",
|
||||||
"use_suggested": "Usar sugerido",
|
"use_suggested": "Usar sugerido",
|
||||||
"use_testnet": "Use TestNet",
|
|
||||||
"variable_pair_not_supported": "Este par de variables no es compatible con los intercambios seleccionados",
|
"variable_pair_not_supported": "Este par de variables no es compatible con los intercambios seleccionados",
|
||||||
"verification": "Verificación",
|
"verification": "Verificación",
|
||||||
"verify_with_2fa": "Verificar con Cake 2FA",
|
"verify_with_2fa": "Verificar con Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Les fonds sont convertis en USD lorsqu'ils sont détenus sur le compte prépayé, et non en devises numériques.",
|
"use_card_info_two": "Les fonds sont convertis en USD lorsqu'ils sont détenus sur le compte prépayé, et non en devises numériques.",
|
||||||
"use_ssl": "Utiliser SSL",
|
"use_ssl": "Utiliser SSL",
|
||||||
"use_suggested": "Suivre la suggestion",
|
"use_suggested": "Suivre la suggestion",
|
||||||
"use_testnet": "Utiliser TestNet",
|
|
||||||
"variable_pair_not_supported": "Cette paire variable n'est pas prise en charge avec les échanges sélectionnés",
|
"variable_pair_not_supported": "Cette paire variable n'est pas prise en charge avec les échanges sélectionnés",
|
||||||
"verification": "Vérification",
|
"verification": "Vérification",
|
||||||
"verify_with_2fa": "Vérifier avec Cake 2FA",
|
"verify_with_2fa": "Vérifier avec Cake 2FA",
|
||||||
|
|
|
@ -725,7 +725,6 @@
|
||||||
"use_card_info_two": "Ana canza kuɗi zuwa dalar Amurka lokacin da ake riƙe su a cikin asusun da aka riga aka biya, ba cikin agogon dijital ba.",
|
"use_card_info_two": "Ana canza kuɗi zuwa dalar Amurka lokacin da ake riƙe su a cikin asusun da aka riga aka biya, ba cikin agogon dijital ba.",
|
||||||
"use_ssl": "Yi amfani da SSL",
|
"use_ssl": "Yi amfani da SSL",
|
||||||
"use_suggested": "Amfani da Shawarwari",
|
"use_suggested": "Amfani da Shawarwari",
|
||||||
"use_testnet": "Amfani da gwaji",
|
|
||||||
"variable_pair_not_supported": "Ba a samun goyan bayan wannan m biyu tare da zaɓaɓɓun musayar",
|
"variable_pair_not_supported": "Ba a samun goyan bayan wannan m biyu tare da zaɓaɓɓun musayar",
|
||||||
"verification": "tabbatar",
|
"verification": "tabbatar",
|
||||||
"verify_with_2fa": "Tabbatar da Cake 2FA",
|
"verify_with_2fa": "Tabbatar da Cake 2FA",
|
||||||
|
|
|
@ -725,7 +725,6 @@
|
||||||
"use_card_info_two": "डिजिटल मुद्राओं में नहीं, प्रीपेड खाते में रखे जाने पर निधियों को यूएसडी में बदल दिया जाता है।",
|
"use_card_info_two": "डिजिटल मुद्राओं में नहीं, प्रीपेड खाते में रखे जाने पर निधियों को यूएसडी में बदल दिया जाता है।",
|
||||||
"use_ssl": "उपयोग SSL",
|
"use_ssl": "उपयोग SSL",
|
||||||
"use_suggested": "सुझाए गए का प्रयोग करें",
|
"use_suggested": "सुझाए गए का प्रयोग करें",
|
||||||
"use_testnet": "टेस्टनेट का उपयोग करें",
|
|
||||||
"variable_pair_not_supported": "यह परिवर्तनीय जोड़ी चयनित एक्सचेंजों के साथ समर्थित नहीं है",
|
"variable_pair_not_supported": "यह परिवर्तनीय जोड़ी चयनित एक्सचेंजों के साथ समर्थित नहीं है",
|
||||||
"verification": "सत्यापन",
|
"verification": "सत्यापन",
|
||||||
"verify_with_2fa": "केक 2FA के साथ सत्यापित करें",
|
"verify_with_2fa": "केक 2FA के साथ सत्यापित करें",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Sredstva se pretvaraju u USD kada se drže na prepaid računu, a ne u digitalnim valutama.",
|
"use_card_info_two": "Sredstva se pretvaraju u USD kada se drže na prepaid računu, a ne u digitalnim valutama.",
|
||||||
"use_ssl": "Koristi SSL",
|
"use_ssl": "Koristi SSL",
|
||||||
"use_suggested": "Koristite predloženo",
|
"use_suggested": "Koristite predloženo",
|
||||||
"use_testnet": "Koristite TestNet",
|
|
||||||
"variable_pair_not_supported": "Ovaj par varijabli nije podržan s odabranim burzama",
|
"variable_pair_not_supported": "Ovaj par varijabli nije podržan s odabranim burzama",
|
||||||
"verification": "Potvrda",
|
"verification": "Potvrda",
|
||||||
"verify_with_2fa": "Provjerite s Cake 2FA",
|
"verify_with_2fa": "Provjerite s Cake 2FA",
|
||||||
|
|
|
@ -726,7 +726,6 @@
|
||||||
"use_card_info_two": "Dana dikonversi ke USD ketika disimpan dalam akun pra-bayar, bukan dalam mata uang digital.",
|
"use_card_info_two": "Dana dikonversi ke USD ketika disimpan dalam akun pra-bayar, bukan dalam mata uang digital.",
|
||||||
"use_ssl": "Gunakan SSL",
|
"use_ssl": "Gunakan SSL",
|
||||||
"use_suggested": "Gunakan yang Disarankan",
|
"use_suggested": "Gunakan yang Disarankan",
|
||||||
"use_testnet": "Gunakan TestNet",
|
|
||||||
"variable_pair_not_supported": "Pasangan variabel ini tidak didukung dengan bursa yang dipilih",
|
"variable_pair_not_supported": "Pasangan variabel ini tidak didukung dengan bursa yang dipilih",
|
||||||
"verification": "Verifikasi",
|
"verification": "Verifikasi",
|
||||||
"verify_with_2fa": "Verifikasi dengan Cake 2FA",
|
"verify_with_2fa": "Verifikasi dengan Cake 2FA",
|
||||||
|
|
|
@ -725,7 +725,6 @@
|
||||||
"use_card_info_two": "I fondi vengono convertiti in USD quando sono detenuti nel conto prepagato, non in valute digitali.",
|
"use_card_info_two": "I fondi vengono convertiti in USD quando sono detenuti nel conto prepagato, non in valute digitali.",
|
||||||
"use_ssl": "Usa SSL",
|
"use_ssl": "Usa SSL",
|
||||||
"use_suggested": "Usa suggerito",
|
"use_suggested": "Usa suggerito",
|
||||||
"use_testnet": "Usa TestNet",
|
|
||||||
"variable_pair_not_supported": "Questa coppia di variabili non è supportata con gli scambi selezionati",
|
"variable_pair_not_supported": "Questa coppia di variabili non è supportata con gli scambi selezionati",
|
||||||
"verification": "Verifica",
|
"verification": "Verifica",
|
||||||
"verify_with_2fa": "Verifica con Cake 2FA",
|
"verify_with_2fa": "Verifica con Cake 2FA",
|
||||||
|
|
|
@ -724,7 +724,6 @@
|
||||||
"use_card_info_two": "デジタル通貨ではなく、プリペイドアカウントで保持されている場合、資金は米ドルに変換されます。",
|
"use_card_info_two": "デジタル通貨ではなく、プリペイドアカウントで保持されている場合、資金は米ドルに変換されます。",
|
||||||
"use_ssl": "SSLを使用する",
|
"use_ssl": "SSLを使用する",
|
||||||
"use_suggested": "推奨を使用",
|
"use_suggested": "推奨を使用",
|
||||||
"use_testnet": "テストネットを使用します",
|
|
||||||
"variable_pair_not_supported": "この変数ペアは、選択した取引所ではサポートされていません",
|
"variable_pair_not_supported": "この変数ペアは、選択した取引所ではサポートされていません",
|
||||||
"verification": "検証",
|
"verification": "検証",
|
||||||
"verify_with_2fa": "Cake 2FA で検証する",
|
"verify_with_2fa": "Cake 2FA で検証する",
|
||||||
|
|
|
@ -724,7 +724,6 @@
|
||||||
"use_card_info_two": "디지털 화폐가 아닌 선불 계정에 보유하면 자금이 USD로 변환됩니다.",
|
"use_card_info_two": "디지털 화폐가 아닌 선불 계정에 보유하면 자금이 USD로 변환됩니다.",
|
||||||
"use_ssl": "SSL 사용",
|
"use_ssl": "SSL 사용",
|
||||||
"use_suggested": "추천 사용",
|
"use_suggested": "추천 사용",
|
||||||
"use_testnet": "TestNet을 사용하십시오",
|
|
||||||
"variable_pair_not_supported": "이 변수 쌍은 선택한 교환에서 지원되지 않습니다.",
|
"variable_pair_not_supported": "이 변수 쌍은 선택한 교환에서 지원되지 않습니다.",
|
||||||
"verification": "검증",
|
"verification": "검증",
|
||||||
"verify_with_2fa": "케이크 2FA로 확인",
|
"verify_with_2fa": "케이크 2FA로 확인",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "ဒစ်ဂျစ်တယ်ငွေကြေးများဖြင့်မဟုတ်ဘဲ ကြိုတင်ငွေပေးချေသည့်အကောင့်တွင် သိမ်းထားသည့်အခါ ရန်ပုံငွေများကို USD သို့ ပြောင်းလဲပါသည်။",
|
"use_card_info_two": "ဒစ်ဂျစ်တယ်ငွေကြေးများဖြင့်မဟုတ်ဘဲ ကြိုတင်ငွေပေးချေသည့်အကောင့်တွင် သိမ်းထားသည့်အခါ ရန်ပုံငွေများကို USD သို့ ပြောင်းလဲပါသည်။",
|
||||||
"use_ssl": "SSL ကိုသုံးပါ။",
|
"use_ssl": "SSL ကိုသုံးပါ။",
|
||||||
"use_suggested": "အကြံပြုထားသည်ကို အသုံးပြုပါ။",
|
"use_suggested": "အကြံပြုထားသည်ကို အသုံးပြုပါ။",
|
||||||
"use_testnet": "testnet ကိုသုံးပါ",
|
|
||||||
"variable_pair_not_supported": "ရွေးချယ်ထားသော ဖလှယ်မှုများဖြင့် ဤပြောင်းလဲနိုင်သောအတွဲကို ပံ့ပိုးမထားပါ။",
|
"variable_pair_not_supported": "ရွေးချယ်ထားသော ဖလှယ်မှုများဖြင့် ဤပြောင်းလဲနိုင်သောအတွဲကို ပံ့ပိုးမထားပါ။",
|
||||||
"verification": "စိစစ်ခြင်း။",
|
"verification": "စိစစ်ခြင်း။",
|
||||||
"verify_with_2fa": "Cake 2FA ဖြင့် စစ်ဆေးပါ။",
|
"verify_with_2fa": "Cake 2FA ဖြင့် စစ်ဆေးပါ။",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Tegoeden worden omgezet naar USD wanneer ze op de prepaid-rekening staan, niet in digitale valuta.",
|
"use_card_info_two": "Tegoeden worden omgezet naar USD wanneer ze op de prepaid-rekening staan, niet in digitale valuta.",
|
||||||
"use_ssl": "Gebruik SSL",
|
"use_ssl": "Gebruik SSL",
|
||||||
"use_suggested": "Gebruik aanbevolen",
|
"use_suggested": "Gebruik aanbevolen",
|
||||||
"use_testnet": "Gebruik testnet",
|
|
||||||
"variable_pair_not_supported": "Dit variabelenpaar wordt niet ondersteund met de geselecteerde uitwisselingen",
|
"variable_pair_not_supported": "Dit variabelenpaar wordt niet ondersteund met de geselecteerde uitwisselingen",
|
||||||
"verification": "Verificatie",
|
"verification": "Verificatie",
|
||||||
"verify_with_2fa": "Controleer met Cake 2FA",
|
"verify_with_2fa": "Controleer met Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Środki są przeliczane na USD, gdy są przechowywane na koncie przedpłaconym, a nie w walutach cyfrowych.",
|
"use_card_info_two": "Środki są przeliczane na USD, gdy są przechowywane na koncie przedpłaconym, a nie w walutach cyfrowych.",
|
||||||
"use_ssl": "Użyj SSL",
|
"use_ssl": "Użyj SSL",
|
||||||
"use_suggested": "Użyj sugerowane",
|
"use_suggested": "Użyj sugerowane",
|
||||||
"use_testnet": "Użyj testne",
|
|
||||||
"variable_pair_not_supported": "Ta para zmiennych nie jest obsługiwana na wybranych giełdach",
|
"variable_pair_not_supported": "Ta para zmiennych nie jest obsługiwana na wybranych giełdach",
|
||||||
"verification": "Weryfikacja",
|
"verification": "Weryfikacja",
|
||||||
"verify_with_2fa": "Sprawdź za pomocą Cake 2FA",
|
"verify_with_2fa": "Sprawdź za pomocą Cake 2FA",
|
||||||
|
|
|
@ -725,7 +725,6 @@
|
||||||
"use_card_info_two": "Os fundos são convertidos para USD quando mantidos na conta pré-paga, não em moedas digitais.",
|
"use_card_info_two": "Os fundos são convertidos para USD quando mantidos na conta pré-paga, não em moedas digitais.",
|
||||||
"use_ssl": "Use SSL",
|
"use_ssl": "Use SSL",
|
||||||
"use_suggested": "Uso sugerido",
|
"use_suggested": "Uso sugerido",
|
||||||
"use_testnet": "Use testNet",
|
|
||||||
"variable_pair_not_supported": "Este par de variáveis não é compatível com as trocas selecionadas",
|
"variable_pair_not_supported": "Este par de variáveis não é compatível com as trocas selecionadas",
|
||||||
"verification": "Verificação",
|
"verification": "Verificação",
|
||||||
"verify_with_2fa": "Verificar com Cake 2FA",
|
"verify_with_2fa": "Verificar com Cake 2FA",
|
||||||
|
|
|
@ -724,7 +724,6 @@
|
||||||
"use_card_info_two": "Средства конвертируются в доллары США, когда они хранятся на предоплаченном счете, а не в цифровых валютах.",
|
"use_card_info_two": "Средства конвертируются в доллары США, когда они хранятся на предоплаченном счете, а не в цифровых валютах.",
|
||||||
"use_ssl": "Использовать SSL",
|
"use_ssl": "Использовать SSL",
|
||||||
"use_suggested": "Использовать предложенный",
|
"use_suggested": "Использовать предложенный",
|
||||||
"use_testnet": "Используйте Testnet",
|
|
||||||
"variable_pair_not_supported": "Эта пара переменных не поддерживается выбранными биржами.",
|
"variable_pair_not_supported": "Эта пара переменных не поддерживается выбранными биржами.",
|
||||||
"verification": "Проверка",
|
"verification": "Проверка",
|
||||||
"verify_with_2fa": "Подтвердить с помощью Cake 2FA",
|
"verify_with_2fa": "Подтвердить с помощью Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "เงินจะถูกแปลงค่าเป็นดอลลาร์สหรัฐเมื่อถือไว้ในบัญชีสำรองเงิน ไม่ใช่สกุลเงินดิจิตอล",
|
"use_card_info_two": "เงินจะถูกแปลงค่าเป็นดอลลาร์สหรัฐเมื่อถือไว้ในบัญชีสำรองเงิน ไม่ใช่สกุลเงินดิจิตอล",
|
||||||
"use_ssl": "ใช้ SSL",
|
"use_ssl": "ใช้ SSL",
|
||||||
"use_suggested": "ใช้ที่แนะนำ",
|
"use_suggested": "ใช้ที่แนะนำ",
|
||||||
"use_testnet": "ใช้ testnet",
|
|
||||||
"variable_pair_not_supported": "คู่ความสัมพันธ์ที่เปลี่ยนแปลงได้นี้ไม่สนับสนุนกับหุ้นที่เลือก",
|
"variable_pair_not_supported": "คู่ความสัมพันธ์ที่เปลี่ยนแปลงได้นี้ไม่สนับสนุนกับหุ้นที่เลือก",
|
||||||
"verification": "การตรวจสอบ",
|
"verification": "การตรวจสอบ",
|
||||||
"verify_with_2fa": "ตรวจสอบกับ Cake 2FA",
|
"verify_with_2fa": "ตรวจสอบกับ Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Ang mga pondo ay na -convert sa USD kapag gaganapin sila sa prepaid account, hindi sa mga digital na pera.",
|
"use_card_info_two": "Ang mga pondo ay na -convert sa USD kapag gaganapin sila sa prepaid account, hindi sa mga digital na pera.",
|
||||||
"use_ssl": "Gumamit ng SSL",
|
"use_ssl": "Gumamit ng SSL",
|
||||||
"use_suggested": "Gumamit ng iminungkahing",
|
"use_suggested": "Gumamit ng iminungkahing",
|
||||||
"use_testnet": "Gumamit ng testnet",
|
|
||||||
"variable_pair_not_supported": "Ang variable na pares na ito ay hindi suportado sa mga napiling palitan",
|
"variable_pair_not_supported": "Ang variable na pares na ito ay hindi suportado sa mga napiling palitan",
|
||||||
"verification": "Pag -verify",
|
"verification": "Pag -verify",
|
||||||
"verify_with_2fa": "Mag -verify sa cake 2FA",
|
"verify_with_2fa": "Mag -verify sa cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "Paralar, dijital para birimlerinde değil, ön ödemeli hesapta tutulduğunda USD'ye dönüştürülür.",
|
"use_card_info_two": "Paralar, dijital para birimlerinde değil, ön ödemeli hesapta tutulduğunda USD'ye dönüştürülür.",
|
||||||
"use_ssl": "SSL kullan",
|
"use_ssl": "SSL kullan",
|
||||||
"use_suggested": "Önerileni Kullan",
|
"use_suggested": "Önerileni Kullan",
|
||||||
"use_testnet": "TestNet kullanın",
|
|
||||||
"variable_pair_not_supported": "Bu değişken paritesi seçilen borsalarda desteklenmemekte",
|
"variable_pair_not_supported": "Bu değişken paritesi seçilen borsalarda desteklenmemekte",
|
||||||
"verification": "Doğrulama",
|
"verification": "Doğrulama",
|
||||||
"verify_with_2fa": "Cake 2FA ile Doğrulayın",
|
"verify_with_2fa": "Cake 2FA ile Doğrulayın",
|
||||||
|
|
|
@ -724,7 +724,6 @@
|
||||||
"use_card_info_two": "Кошти конвертуються в долари США, якщо вони зберігаються на передплаченому рахунку, а не в цифрових валютах.",
|
"use_card_info_two": "Кошти конвертуються в долари США, якщо вони зберігаються на передплаченому рахунку, а не в цифрових валютах.",
|
||||||
"use_ssl": "Використати SSL",
|
"use_ssl": "Використати SSL",
|
||||||
"use_suggested": "Використати запропоноване",
|
"use_suggested": "Використати запропоноване",
|
||||||
"use_testnet": "Використовуйте тестову мережу",
|
|
||||||
"variable_pair_not_supported": "Ця пара змінних не підтримується вибраними біржами",
|
"variable_pair_not_supported": "Ця пара змінних не підтримується вибраними біржами",
|
||||||
"verification": "Перевірка",
|
"verification": "Перевірка",
|
||||||
"verify_with_2fa": "Перевірте за допомогою Cake 2FA",
|
"verify_with_2fa": "Перевірте за допомогою Cake 2FA",
|
||||||
|
|
|
@ -725,7 +725,6 @@
|
||||||
"use_card_info_two": "رقوم کو امریکی ڈالر میں تبدیل کیا جاتا ہے جب پری پیڈ اکاؤنٹ میں رکھا جاتا ہے، ڈیجیٹل کرنسیوں میں نہیں۔",
|
"use_card_info_two": "رقوم کو امریکی ڈالر میں تبدیل کیا جاتا ہے جب پری پیڈ اکاؤنٹ میں رکھا جاتا ہے، ڈیجیٹل کرنسیوں میں نہیں۔",
|
||||||
"use_ssl": "SSL استعمال کریں۔",
|
"use_ssl": "SSL استعمال کریں۔",
|
||||||
"use_suggested": "تجویز کردہ استعمال کریں۔",
|
"use_suggested": "تجویز کردہ استعمال کریں۔",
|
||||||
"use_testnet": "ٹیسٹ نیٹ استعمال کریں",
|
|
||||||
"variable_pair_not_supported": "یہ متغیر جوڑا منتخب ایکسچینجز کے ساتھ تعاون یافتہ نہیں ہے۔",
|
"variable_pair_not_supported": "یہ متغیر جوڑا منتخب ایکسچینجز کے ساتھ تعاون یافتہ نہیں ہے۔",
|
||||||
"verification": "تصدیق",
|
"verification": "تصدیق",
|
||||||
"verify_with_2fa": "کیک 2FA سے تصدیق کریں۔",
|
"verify_with_2fa": "کیک 2FA سے تصدیق کریں۔",
|
||||||
|
|
|
@ -724,7 +724,6 @@
|
||||||
"use_card_info_two": "A pààrọ̀ owó sí owó Amẹ́ríkà tó bá wà nínú àkanti t'á ti fikún tẹ́lẹ̀tẹ́lẹ̀. A kò kó owó náà nínú owó ayélujára.",
|
"use_card_info_two": "A pààrọ̀ owó sí owó Amẹ́ríkà tó bá wà nínú àkanti t'á ti fikún tẹ́lẹ̀tẹ́lẹ̀. A kò kó owó náà nínú owó ayélujára.",
|
||||||
"use_ssl": "Lo SSL",
|
"use_ssl": "Lo SSL",
|
||||||
"use_suggested": "Lo àbá",
|
"use_suggested": "Lo àbá",
|
||||||
"use_testnet": "Lo tele",
|
|
||||||
"variable_pair_not_supported": "A kì í ṣe k'á fi àwọn ilé pàṣípààrọ̀ yìí ṣe pàṣípààrọ̀ irú owó méji yìí",
|
"variable_pair_not_supported": "A kì í ṣe k'á fi àwọn ilé pàṣípààrọ̀ yìí ṣe pàṣípààrọ̀ irú owó méji yìí",
|
||||||
"verification": "Ìjẹ́rìísí",
|
"verification": "Ìjẹ́rìísí",
|
||||||
"verify_with_2fa": "Ṣeẹda pẹlu Cake 2FA",
|
"verify_with_2fa": "Ṣeẹda pẹlu Cake 2FA",
|
||||||
|
|
|
@ -723,7 +723,6 @@
|
||||||
"use_card_info_two": "预付账户中的资金转换为美元,不是数字货币。",
|
"use_card_info_two": "预付账户中的资金转换为美元,不是数字货币。",
|
||||||
"use_ssl": "使用SSL",
|
"use_ssl": "使用SSL",
|
||||||
"use_suggested": "使用建议",
|
"use_suggested": "使用建议",
|
||||||
"use_testnet": "使用TestNet",
|
|
||||||
"variable_pair_not_supported": "所选交易所不支持此变量对",
|
"variable_pair_not_supported": "所选交易所不支持此变量对",
|
||||||
"verification": "验证",
|
"verification": "验证",
|
||||||
"verify_with_2fa": "用 Cake 2FA 验证",
|
"verify_with_2fa": "用 Cake 2FA 验证",
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
|
|
||||||
pkgs.mkShell {
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.curl
|
|
||||||
pkgs.unzip
|
|
||||||
pkgs.automake
|
|
||||||
pkgs.file
|
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.git
|
|
||||||
pkgs.libtool
|
|
||||||
pkgs.ncurses5
|
|
||||||
pkgs.openjdk8
|
|
||||||
pkgs.clang
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -61,7 +61,6 @@ Future<void> main(List<String> args) async {
|
||||||
Future<void> generateBitcoin(bool hasImplementation) async {
|
Future<void> generateBitcoin(bool hasImplementation) async {
|
||||||
final outputFile = File(bitcoinOutputPath);
|
final outputFile = File(bitcoinOutputPath);
|
||||||
const bitcoinCommonHeaders = """
|
const bitcoinCommonHeaders = """
|
||||||
import 'package:cw_core/receive_page_option.dart';
|
|
||||||
import 'package:cw_core/unspent_transaction_output.dart';
|
import 'package:cw_core/unspent_transaction_output.dart';
|
||||||
import 'package:cw_core/wallet_credentials.dart';
|
import 'package:cw_core/wallet_credentials.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
|
@ -71,10 +70,8 @@ import 'package:cw_core/unspent_coins_info.dart';
|
||||||
import 'package:cw_core/wallet_service.dart';
|
import 'package:cw_core/wallet_service.dart';
|
||||||
import 'package:cake_wallet/view_model/send/output.dart';
|
import 'package:cake_wallet/view_model/send/output.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';""";
|
||||||
import 'package:bitcoin_base/bitcoin_base.dart';""";
|
|
||||||
const bitcoinCWHeaders = """
|
const bitcoinCWHeaders = """
|
||||||
import 'package:cw_bitcoin/bitcoin_receive_page_option.dart';
|
|
||||||
import 'package:cw_bitcoin/electrum_wallet.dart';
|
import 'package:cw_bitcoin/electrum_wallet.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_unspent.dart';
|
import 'package:cw_bitcoin/bitcoin_unspent.dart';
|
||||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||||
|
@ -142,11 +139,6 @@ abstract class Bitcoin {
|
||||||
TransactionPriority getLitecoinTransactionPriorityMedium();
|
TransactionPriority getLitecoinTransactionPriorityMedium();
|
||||||
TransactionPriority getBitcoinTransactionPrioritySlow();
|
TransactionPriority getBitcoinTransactionPrioritySlow();
|
||||||
TransactionPriority getLitecoinTransactionPrioritySlow();
|
TransactionPriority getLitecoinTransactionPrioritySlow();
|
||||||
|
|
||||||
Future<void> setAddressType(Object wallet, dynamic option);
|
|
||||||
ReceivePageOption getSelectedAddressType(Object wallet);
|
|
||||||
List<ReceivePageOption> getBitcoinReceivePageOptions();
|
|
||||||
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option);
|
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue