ensure only wallet owned p2pkh addresses are passed in

This commit is contained in:
julian 2023-10-09 11:44:17 -06:00
parent bbf0943003
commit 3e2eb2a7c7

View file

@ -80,9 +80,19 @@ mixin FusionWalletInterface {
// set _uiState states
}
/// Returns a list of all addresses in the wallet.
/// Returns a list of all owned p2pkh addresses in the wallet.
Future<List<fusion.Address>> getFusionAddresses() async {
List<Address> _addresses = await _db.getAddresses(_walletId).findAll();
List<Address> _addresses = await _db
.getAddresses(_walletId)
.filter()
.typeEqualTo(AddressType.p2pkh)
.and()
.group((q) => q
.subTypeEqualTo(AddressSubType.receiving)
.or()
.subTypeEqualTo(AddressSubType.change))
.findAll();
return _addresses.map((address) => address.toFusionAddress()).toList();
}