mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
improve ordinal heuristic
and formatting
This commit is contained in:
parent
8e5f2d190d
commit
7da49c7ea0
2 changed files with 46 additions and 9 deletions
|
@ -136,7 +136,7 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
_secureStore = secureStore;
|
||||
initCache(walletId, coin);
|
||||
initWalletDB(mockableOverride: mockableOverride);
|
||||
initOrdinalsInterface(walletId:walletId, coin: coin, db: db);
|
||||
initOrdinalsInterface(walletId: walletId, coin: coin, db: db);
|
||||
initCoinControlInterface(
|
||||
walletId: walletId,
|
||||
walletName: walletName,
|
||||
|
@ -1871,14 +1871,6 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
String? blockReason;
|
||||
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 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(
|
||||
walletId: walletId,
|
||||
txid: txn["txid"] as String,
|
||||
|
|
|
@ -65,4 +65,30 @@ mixin OrdinalsInterface {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue