improve ordinal heuristic

and formatting
This commit is contained in:
sneurlax 2023-07-22 22:14:18 -05:00
parent 8e5f2d190d
commit 7da49c7ea0
2 changed files with 46 additions and 9 deletions

View file

@ -136,7 +136,7 @@ class LitecoinWallet extends CoinServiceAPI
_secureStore = secureStore; _secureStore = secureStore;
initCache(walletId, coin); initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride); initWalletDB(mockableOverride: mockableOverride);
initOrdinalsInterface(walletId:walletId, coin: coin, db: db); initOrdinalsInterface(walletId: walletId, coin: coin, db: db);
initCoinControlInterface( initCoinControlInterface(
walletId: walletId, walletId: walletId,
walletName: walletName, walletName: walletName,
@ -1871,14 +1871,6 @@ class LitecoinWallet extends CoinServiceAPI
String? blockReason; String? blockReason;
String? label; String? label;
final utxoAmount = jsonUTXO["value"] as int;
if (utxoAmount <= 10000) {
shouldBlock = true;
blockReason = "May contain ordinal";
label = "Possible ordinal";
}
final vout = jsonUTXO["tx_pos"] as int; final vout = jsonUTXO["tx_pos"] as int;
final outputs = txn["vout"] as List; final outputs = txn["vout"] as List;
@ -1893,6 +1885,25 @@ class LitecoinWallet extends CoinServiceAPI
} }
} }
final utxoAmount = jsonUTXO["value"] as int;
// TODO check the specific output, not just the address in general
// TODO optimize by querying the litescribe API for all addresses at once, instead of one API call per output
if (utxoOwnerAddress != null) {
if (await inscriptionInAddress(utxoOwnerAddress!)) {
shouldBlock = true;
blockReason = "Ordinal";
label = "Ordinal detected at address";
}
} else {
// TODO implement inscriptionInOutput
if (utxoAmount <= 10000) {
shouldBlock = true;
blockReason = "May contain ordinal";
label = "Possible ordinal";
}
}
final utxo = isar_models.UTXO( final utxo = isar_models.UTXO(
walletId: walletId, walletId: walletId,
txid: txn["txid"] as String, txid: txn["txid"] as String,

View file

@ -65,4 +65,30 @@ mixin OrdinalsInterface {
} }
return allInscriptions; return allInscriptions;
} }
// check if an inscription is in a given <UTXO> output
Future<bool> inscriptionInOutput(UTXO output) async {
if (output.address != null) {
var inscriptions =
await litescribeAPI.getInscriptionsByAddress("${output.address}");
if (inscriptions.isNotEmpty) {
return true;
} else {
return false;
}
} else {
throw UnimplementedError(
'TODO look up utxo without address. utxo->txid:output->address');
}
}
// check if an inscription is in a given <UTXO> output
Future<bool> inscriptionInAddress(String address) async {
var inscriptions = await litescribeAPI.getInscriptionsByAddress(address);
if (inscriptions.isNotEmpty) {
return true;
} else {
return false;
}
}
} }