mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-25 21:19:37 +00:00
fd9018bcc4
* fix: address book addresses, bch builder, exchange all fee estimation, bch coin control * feat: new error framework for Electrum messages * build: cw_bitcoin.dart * feat: error improvements, localization, fix exchange amount mismatch * chore: misc comment & print [skip ci] * feat: refactor & simplify sendAll vs regular tx estimation and creation - Since there were so many conditions inside a single function to alter its behavior if sendAll or not, it is easier and more readable to have separate sendAll and estimateTx functions that behave separately * fix: wrong LTC dust * feat: fee rate confirmation * fix: wrong createTrade value when isSendAll is enabled * fix bitcoin cash address parsing [skip ci] * fix: form no amount validator, address book with multiple entries, exchange all below min error * fix: improve string, fix sending with dust inputs at the top * fix: two change outputs when re-estimating * fix: sendAll with a little dust adds fees * chore: sanity check [skip ci] * fix: if the fee is higher than estimated * Minor enhancement [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
45 lines
1 KiB
Dart
45 lines
1 KiB
Dart
import 'package:cw_core/address_info.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
|
|
abstract class WalletAddresses {
|
|
WalletAddresses(this.walletInfo)
|
|
: addressesMap = {},
|
|
allAddressesMap = {},
|
|
addressInfos = {};
|
|
|
|
final WalletInfo walletInfo;
|
|
|
|
String get address;
|
|
|
|
String? get primaryAddress => null;
|
|
|
|
set address(String address);
|
|
|
|
Map<String, String> addressesMap;
|
|
Map<String, String> allAddressesMap;
|
|
|
|
Map<int, List<AddressInfo>> addressInfos;
|
|
|
|
Set<String> usedAddresses = {};
|
|
|
|
Future<void> init();
|
|
|
|
Future<void> updateAddressesInBox();
|
|
|
|
Future<void> saveAddressesInBox() async {
|
|
try {
|
|
walletInfo.address = address;
|
|
walletInfo.addresses = addressesMap;
|
|
walletInfo.addressInfos = addressInfos;
|
|
walletInfo.usedAddresses = usedAddresses.toList();
|
|
|
|
if (walletInfo.isInBox) {
|
|
await walletInfo.save();
|
|
}
|
|
} catch (e) {
|
|
print(e.toString());
|
|
}
|
|
}
|
|
|
|
bool containsAddress(String address) => allAddressesMap.containsKey(address);
|
|
}
|