From 14cb65b8c95ff5d02b43bee6b99f80363bae08b6 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Mon, 22 Jul 2024 16:26:39 -0700 Subject: [PATCH] [skip ci] addressbook updates --- cw_bitcoin/lib/electrum_wallet_addresses.dart | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet_addresses.dart b/cw_bitcoin/lib/electrum_wallet_addresses.dart index 84d28dc19..c90d7a1dd 100644 --- a/cw_bitcoin/lib/electrum_wallet_addresses.dart +++ b/cw_bitcoin/lib/electrum_wallet_addresses.dart @@ -324,7 +324,9 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store { ''; Future getAddressAsync( - {required int index, required bitcoin.HDWallet hd, BitcoinAddressType? addressType}) async => + {required int index, + required bitcoin.HDWallet hd, + BitcoinAddressType? addressType}) async => getAddress(index: index, hd: hd, addressType: addressType); @override @@ -381,6 +383,14 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store { addressesMap[address] = 'Active - P2WSH'; } + final lastMweb = _addresses.firstWhere( + (addressRecord) => _isUnusedReceiveAddressByType(addressRecord, SegwitAddresType.mweb)); + if (lastMweb.address != address) { + addressesMap[lastP2wsh.address] = 'MWEB'; + } else { + addressesMap[address] = 'Active - MWEB'; + } + silentAddresses.forEach((addressRecord) { if (addressRecord.type != SilentPaymentsAddresType.p2sp || addressRecord.isHidden) { return; @@ -546,11 +556,13 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store { void _validateAddresses() { allAddresses.forEach((element) { - if (!element.isHidden && element.address != - getAddress(index: element.index, hd: mainHd, addressType: element.type)) { + if (!element.isHidden && + element.address != + getAddress(index: element.index, hd: mainHd, addressType: element.type)) { element.isHidden = true; - } else if (element.isHidden && element.address != - getAddress(index: element.index, hd: sideHd, addressType: element.type)) { + } else if (element.isHidden && + element.address != + getAddress(index: element.index, hd: sideHd, addressType: element.type)) { element.isHidden = false; } });