fix: default to 0 mint index if none saved

This commit is contained in:
julian 2023-05-23 10:43:08 -06:00
parent a77c8c02fd
commit 40dfced949
2 changed files with 6 additions and 5 deletions

View file

@ -2555,7 +2555,7 @@ class FiroWallet extends CoinServiceAPI
var tmpTotal = total;
var index = 1;
var mints = <Map<String, dynamic>>[];
final nextFreeMintIndex = firoGetMintIndex()!;
final nextFreeMintIndex = firoGetMintIndex();
while (tmpTotal > 0) {
final mintValue = min(tmpTotal, MINT_LIMIT);
final mint = await _getMintHex(
@ -2720,7 +2720,7 @@ class FiroWallet extends CoinServiceAPI
amount += utxosToUse[i].value;
}
final index = firoGetMintIndex()!;
final index = firoGetMintIndex();
Logging.instance.log("index of mint $index", level: LogLevel.Info);
for (var mintsElement in mintsMap) {
@ -2987,7 +2987,7 @@ class FiroWallet extends CoinServiceAPI
// if a jmint was made add it to the unspent coin index
LelantusCoin jmint = LelantusCoin(
index!,
index,
transactionInfo['jmintValue'] as int? ?? 0,
transactionInfo['publicCoin'] as String,
transactionInfo['txid'] as String,

View file

@ -35,9 +35,10 @@ mixin FiroHive {
}
// mintIndex
int? firoGetMintIndex() {
int firoGetMintIndex() {
return DB.instance.get<dynamic>(boxName: _walletId, key: "mintIndex")
as int?;
as int? ??
0;
}
Future<void> firoUpdateMintIndex(int mintIndex) async {