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.
This commit is contained in:
sneurlax 2024-02-05 11:31:07 -06:00
parent 2be13a89c5
commit 9b93dc78d2

View file

@ -128,7 +128,12 @@ mixin ElectrumXInterface<T extends Bip39HDCurrency> on Bip39HDWallet<T> {
// 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}",