fix: block possible ordinal containing utxos

This commit is contained in:
julian 2023-05-24 13:07:44 -06:00
parent d7aa8134d3
commit 35b631f329

View file

@ -1793,25 +1793,16 @@ class LitecoinWallet extends CoinServiceAPI
coin: coin, coin: coin,
); );
final storedTx = await db.getTransaction(
walletId,
jsonUTXO["tx_hash"] as String,
);
bool shouldBlock = false; bool shouldBlock = false;
String? blockReason; String? blockReason;
String? label; String? label;
if (storedTx?.amountString != null) { final utxoAmount = jsonUTXO["value"] as int;
final amount = Amount.fromSerializedJsonString(
storedTx!.amountString!,
);
if (amount.raw <= BigInt.from(10000)) { if (utxoAmount <= 10000) {
shouldBlock = true; shouldBlock = true;
blockReason = "May contain ordinal"; blockReason = "May contain ordinal";
label = "Possible ordinal"; label = "Possible ordinal";
}
} }
final vout = jsonUTXO["tx_pos"] as int; final vout = jsonUTXO["tx_pos"] as int;
@ -1832,7 +1823,7 @@ class LitecoinWallet extends CoinServiceAPI
walletId: walletId, walletId: walletId,
txid: txn["txid"] as String, txid: txn["txid"] as String,
vout: vout, vout: vout,
value: jsonUTXO["value"] as int, value: utxoAmount,
name: label ?? "", name: label ?? "",
isBlocked: shouldBlock, isBlocked: shouldBlock,
blockedReason: blockReason, blockedReason: blockReason,
@ -1847,16 +1838,20 @@ class LitecoinWallet extends CoinServiceAPI
} }
} }
Logging.instance Logging.instance.log(
.log('Outputs fetched: $outputArray', level: LogLevel.Info); 'Outputs fetched: $outputArray',
level: LogLevel.Info,
);
await db.updateUTXOs(walletId, outputArray); await db.updateUTXOs(walletId, outputArray);
// finally update balance // finally update balance
await _updateBalance(); await _updateBalance();
} catch (e, s) { } catch (e, s) {
Logging.instance Logging.instance.log(
.log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); "Output fetch unsuccessful: $e\n$s",
level: LogLevel.Error,
);
} }
} }