From 9b93dc78d202b87941c88c959997d567cba702ef Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 5 Feb 2024 11:31:07 -0600 Subject: [PATCH] resolve null check operator used on a null value issue because unconfirmed txs have a null blockTime. we could also use currentChainHeight+1, which may be more appropriate. --- .../wallet_mixin_interfaces/electrumx_interface.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index 502ec57ae..71c822702 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -128,7 +128,12 @@ mixin ElectrumXInterface on Bip39HDWallet { // don't care about sorting if using all utxos if (!coinControl) { // sort spendable by age (oldest first) - spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); + spendableOutputs.sort((a, b) => (b.blockTime ?? currentChainHeight) + .compareTo((a.blockTime ?? currentChainHeight))); + // Null check operator changed to null assignment in order to resolve a + // `Null check operator used on a null value` error. currentChainHeight + // used in order to sort these unconfirmed outputs as the youngest, but we + // could just as well use currentChainHeight + 1. } Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}",