2023-01-24 20:24:46 +02:00
|
|
|
import 'package:cake_wallet/core/address_validator.dart';
|
2022-03-15 10:11:53 +01:00
|
|
|
import 'package:cake_wallet/core/yat_service.dart';
|
2025-06-13 15:45:14 +03:00
|
|
|
import 'package:cake_wallet/entities/emoji_string_extension.dart';
|
2023-09-25 09:47:39 -04:00
|
|
|
import 'package:cake_wallet/entities/ens_record.dart';
|
2025-06-13 15:45:14 +03:00
|
|
|
import 'package:cake_wallet/entities/fio_address_provider.dart';
|
2021-07-07 16:50:55 +03:00
|
|
|
import 'package:cake_wallet/entities/openalias_record.dart';
|
2021-07-07 17:31:16 +03:00
|
|
|
import 'package:cake_wallet/entities/parsed_address.dart';
|
2021-07-07 16:50:55 +03:00
|
|
|
import 'package:cake_wallet/entities/unstoppable_domain_address.dart';
|
2025-01-15 17:03:30 -05:00
|
|
|
import 'package:cake_wallet/entities/wellknown_record.dart';
|
Zano with passphrase (#1971)
* CW-685 Add passphrase restore for xmr/wow (#1552)
* CW-685 Add passphrase restore for xmr/wow
* add support for polyseed passphrase
* disable 14 word seed passphrase (not supported in wownero-seed)
fix: Getting grayed screen on latest passphrase build after having restored a 14-word wownero seed (+passphrase) and attempting to restore a XMR seed, legacy or otherwise.
* fix pointer when restoring depracated wownero seed
* Fix polyseed encryption
* changes from review
* remove unused code
* add passphrase back to the screen
add passphrase to qr code backup export
* fix settings leaking through currencies on seed restore
* fix monero.com builds, make passphrase a getter on WalletBase
* add support for weird polyseed
* store passphrase for weird polyseed
* show encrypted seed only when passphrase is not empty
* force set restore height
* fix build issues
* fix build errors
* fix configure script
* print -> printV
* Update lib/view_model/wallet_keys_view_model.dart [skip ci]
* Update lib/view_model/wallet_keys_view_model.dart [skip ci]
* Update tool/configure.dart [skip ci]
* Update lib/view_model/wallet_new_vm.dart
* reuse existing passphrase field
* remove unused passphrase field
* make workflow run on pullrequests only [skip ci] [skip slack]
---------
Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
* Zano (#1793)
* my experiments
* Inital code for Zano integration
* Added missing android log lib
* added dummy wallet & some zano implementation
* fixing api for zano
* fixed zano build script
* attempt tp fix namespace problem
* added copy script for Zano files
* changes for zano wallet
* last updates
* zano.dart test app
* wallet recovery
* added pending transfer, some cleanup of unused
* some cleanup
* send + receive qr code
* last upd
* updated build_zano.sh
* updated zano ApiCalls, removed dummy
* updated zano ApiCalls, removed dummy
* added logging for get status/get info
* restored old wallet.dart
* restoring original versions of files
* restoring original versions of files
* restored get_height_by_date.dart, removed unnecessary calls for zano get height
* restoring original versions
* added multiple destinations, send all flag; some refactoring
* logging
* removed the duplicate
* fixed syncing sync status, decimal division, safe null json parsing
* some fixes after merge
* added multibalance/asset support for zano (ui)
* adding/removing from whitelist
* transfers in different assets
* transfers for multiple destinations and send all, some refactoring
* whitelists, some refactoring
* added different digits (decimal points) for formatters, some refactoring
* open, create, restore wallet refactoring; whitelists
* whitelists
* getting and updating transaction list; restoring a wallet from QR code
* several attempts to close wallet
* some refactoring
* added seed phrase
* changed fields to BigInt, some fixes
* modified build scripts for android
* build scripts
* restored accidently removed cw_haven.dart
* inital ios integration(zano libs built)
* update in script
* latest changes
* Applied a patch for iOS build (Boost and Zano scripts)
* Removed zano.dart (script-generated) and some unnecessary files
* Revert "Removed zano.dart (script-generated) and some unnecessary files"
This reverts commit 367c86398ef2616006a2cbd2339ef2f30ed2800e.
* Removed zano.dart (generated by scripts), some files restored to initial versions
* added timer library
* changed paths in build_zano.sh
* build_zano.sh
* edit_token_page.dart - removed flag skipZanoAddressValidation
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
* lib/core/address_validator.dart - updated zano address regex
lib/src/screens/dashboard/edit_token_page.dart - using AddressValidator().call
* fix zano build issues on android
* remove contrib/depends to save space
* move async call to a synchronouse one
* call sync call in isolate to make it async
generate framework for iOS as well
fix UR issues
* zano changes from monero_c repo
* update monero_c hash
* fix invalid zano imports, add support for linux, speed up CI builds
* update monero_c hash
* bump monero_c commit (yes, again, I know)
* fix wallet resttore, fix hardcoded IP
* fix regex, don't throw error when opening wallet, fix tx history, fix async calls, move stuff to isolate
* fix api calls in async transaction creation
* update build scripts
* fix some build issues
* update dependencies
* fix dependencies
* update ci scripts
* Improve multithread use of zano api
* Fix build issue
* fix zano node selection, move other zano calls to separate isolate
* update moneroc hash
WIP fixes for zano
* update monero_c
* fix monero.com builds
* sync wallet after connecting
* update monero_c
* Fix windows builds
* update monero_c
* update monero_c
* unshallow submodule
* cherry pick CW-867 Wownero fixes (#1881)
* fix wownero syntax error
* remove print statements in zano
* update zano node URL
* [PATCH] Apply new CI script (https://github.com/cake-tech/cake_wallet/pull/1948)
* drop env -i to fix cmake build errors on newer system
* [skip ci] Revert "[PATCH] Apply new CI script (https://github.com/cake-tech/cake_wallet/pull/1948)"
This reverts commit 5acb5bfe57c4b2aeb7aa40bd684a3319a68f98bc.
* [run tests] [skip slack] Fix env in build
* Dynamically detect number of cores used to build monero_c, since it appears that zano requires more memory to link (and it reliably fails for first couple builds due to OOM on CI/VM with memory constrains).
Drop unshallowing of all modules
[run tests]
* Changes from review [run tests]
* drop zano on linux (missing symbols)
fix wownero on linux
add aarch64-linux-gnu
[run tests]
* - remove duplicate entry in addToken()
- use walletPassword in createZanoNewWalletCredentials
- remove createZanoRestoreWalletFromKeysCredentials
[run tests]
* [skip ci] update dockerfile
* fix parameter issue
---------
Co-authored-by: leo <leonid.ivanov@gmail.com>
Co-authored-by: cr.zoidberg <crypto.zoidberg@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
* - Add Zano Aliases
- Enable simpleswap [skip ci]
- Fix settings migration versions
* push missing file [skip ci]
* Zano pr with CW-685 passphrase (#1969)
* my experiments
* Inital code for Zano integration
* Added missing android log lib
* added dummy wallet & some zano implementation
* fixing api for zano
* fixed zano build script
* attempt tp fix namespace problem
* added copy script for Zano files
* changes for zano wallet
* last updates
* zano.dart test app
* wallet recovery
* added pending transfer, some cleanup of unused
* some cleanup
* send + receive qr code
* last upd
* updated build_zano.sh
* updated zano ApiCalls, removed dummy
* updated zano ApiCalls, removed dummy
* added logging for get status/get info
* restored old wallet.dart
* restoring original versions of files
* restoring original versions of files
* restored get_height_by_date.dart, removed unnecessary calls for zano get height
* restoring original versions
* added multiple destinations, send all flag; some refactoring
* logging
* removed the duplicate
* fixed syncing sync status, decimal division, safe null json parsing
* some fixes after merge
* added multibalance/asset support for zano (ui)
* adding/removing from whitelist
* transfers in different assets
* transfers for multiple destinations and send all, some refactoring
* whitelists, some refactoring
* added different digits (decimal points) for formatters, some refactoring
* open, create, restore wallet refactoring; whitelists
* whitelists
* getting and updating transaction list; restoring a wallet from QR code
* several attempts to close wallet
* some refactoring
* added seed phrase
* CW-685 Add passphrase restore for xmr/wow
* add support for polyseed passphrase
* disable 14 word seed passphrase (not supported in wownero-seed)
fix: Getting grayed screen on latest passphrase build after having restored a 14-word wownero seed (+passphrase) and attempting to restore a XMR seed, legacy or otherwise.
* fix pointer when restoring depracated wownero seed
* Fix polyseed encryption
* changed fields to BigInt, some fixes
* modified build scripts for android
* build scripts
* restored accidently removed cw_haven.dart
* inital ios integration(zano libs built)
* update in script
* latest changes
* changes from review
* remove unused code
* add passphrase back to the screen
add passphrase to qr code backup export
* fix settings leaking through currencies on seed restore
* fix monero.com builds, make passphrase a getter on WalletBase
* add support for weird polyseed
* store passphrase for weird polyseed
* show encrypted seed only when passphrase is not empty
* force set restore height
* Applied a patch for iOS build (Boost and Zano scripts)
* Removed zano.dart (script-generated) and some unnecessary files
* Revert "Removed zano.dart (script-generated) and some unnecessary files"
This reverts commit 367c86398ef2616006a2cbd2339ef2f30ed2800e.
* Removed zano.dart (generated by scripts), some files restored to initial versions
* fix build issues
* fix build errors
* added timer library
* changed paths in build_zano.sh
* build_zano.sh
* edit_token_page.dart - removed flag skipZanoAddressValidation
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
* lib/core/address_validator.dart - updated zano address regex
lib/src/screens/dashboard/edit_token_page.dart - using AddressValidator().call
* fix zano build issues on android
* remove contrib/depends to save space
* move async call to a synchronouse one
* call sync call in isolate to make it async
generate framework for iOS as well
fix UR issues
* zano changes from monero_c repo
* update monero_c hash
* fix invalid zano imports, add support for linux, speed up CI builds
* update monero_c hash
* bump monero_c commit (yes, again, I know)
* fix wallet resttore, fix hardcoded IP
* fix regex, don't throw error when opening wallet, fix tx history, fix async calls, move stuff to isolate
* fix api calls in async transaction creation
* fix configure script
* update build scripts
* fix some build issues
* update dependencies
* fix dependencies
* update ci scripts
* Improve multithread use of zano api
* Fix build issue
* fix zano node selection, move other zano calls to separate isolate
* update moneroc hash
WIP fixes for zano
* update monero_c
* fix monero.com builds
* sync wallet after connecting
* update monero_c
* Fix windows builds
* update monero_c
* print -> printV
* update monero_c
* unshallow submodule
* cherry pick CW-867 Wownero fixes (#1881)
* fix wownero syntax error
* remove print statements in zano
* update zano node URL
* [PATCH] Apply new CI script (https://github.com/cake-tech/cake_wallet/pull/1948)
* drop env -i to fix cmake build errors on newer system
* Update lib/view_model/wallet_keys_view_model.dart [skip ci]
* Update lib/view_model/wallet_keys_view_model.dart [skip ci]
* Update tool/configure.dart [skip ci]
* Update lib/view_model/wallet_new_vm.dart
* [skip ci] Revert "[PATCH] Apply new CI script (https://github.com/cake-tech/cake_wallet/pull/1948)"
This reverts commit 5acb5bfe57c4b2aeb7aa40bd684a3319a68f98bc.
* [run tests] [skip slack] Fix env in build
* Dynamically detect number of cores used to build monero_c, since it appears that zano requires more memory to link (and it reliably fails for first couple builds due to OOM on CI/VM with memory constrains).
Drop unshallowing of all modules
[run tests]
* Changes from review [run tests]
* drop zano on linux (missing symbols)
fix wownero on linux
add aarch64-linux-gnu
[run tests]
* - remove duplicate entry in addToken()
- use walletPassword in createZanoNewWalletCredentials
- remove createZanoRestoreWalletFromKeysCredentials
[run tests]
* [skip ci] update dockerfile
* reuse existing passphrase field
* add passphrase support for zano
* Drop aarch64-linux-gnu for now.
* fix passphrase display, fix gray screen
* catch errors in polyseed encryption, encrypt only polyseed, fix coin in wownero
* update monero_c
update wownero to 0.11.3.0
* Show passphrase only when non-empty, fix passphrase being displayed as view key private.
* fix NanoAccountListPage showing up instead of MoneroAccountListPage for wownero
* build zano dependencies on android
* fix parameter issue
* minor merge leftover [skip ci]
* minor cleanup [skip ci]
* fix zano alias
update eth url for ens lookup
change $MAKE_JOB_COUNT to $NPROC
* minor cleanup [skip ci]
* fix zano alias
* Disable passphrase for creation of xmr/wow/zano
minor fixes
* fix zano on iOS
* - Fix get token data
- Enable unavailable balance
- Enable confirmations count
- Adjust explorer link
---------
Co-authored-by: leo <leonid.ivanov@gmail.com>
Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
Co-authored-by: cr.zoidberg <crypto.zoidberg@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
---------
Co-authored-by: cyan <cyjan@mrcyjanek.net>
Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
Co-authored-by: leo <leonid.ivanov@gmail.com>
Co-authored-by: cr.zoidberg <crypto.zoidberg@gmail.com>
2025-01-24 20:33:24 +02:00
|
|
|
import 'package:cake_wallet/entities/zano_alias.dart';
|
2024-05-06 22:16:25 +03:00
|
|
|
import 'package:cake_wallet/exchange/provider/thorchain_exchange.provider.dart';
|
2023-10-05 15:18:35 +03:00
|
|
|
import 'package:cake_wallet/mastodon/mastodon_api.dart';
|
2023-11-03 21:23:11 +02:00
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
2023-01-24 20:24:46 +02:00
|
|
|
import 'package:cake_wallet/twitter/twitter_api.dart';
|
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2024-12-09 12:23:59 -06:00
|
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
2023-10-03 10:55:38 -04:00
|
|
|
import 'package:cw_core/wallet_base.dart';
|
2022-03-15 10:11:53 +01:00
|
|
|
|
2025-02-17 23:05:44 +02:00
|
|
|
import 'bip_353_record.dart';
|
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
class AddressResolverService {
|
|
|
|
AddressResolverService({required this.yatService, required this.settingsStore}) {
|
|
|
|
_buildLookupTable();
|
|
|
|
}
|
2023-01-31 21:39:08 +02:00
|
|
|
|
2022-03-15 10:11:53 +01:00
|
|
|
final YatService yatService;
|
2023-11-03 21:23:11 +02:00
|
|
|
final SettingsStore settingsStore;
|
2023-01-24 20:24:46 +02:00
|
|
|
|
2022-03-15 10:11:53 +01:00
|
|
|
static const unstoppableDomains = [
|
2024-11-25 18:26:41 +02:00
|
|
|
"888",
|
2025-02-28 19:55:22 +02:00
|
|
|
"academy",
|
|
|
|
"agency",
|
2024-11-25 18:26:41 +02:00
|
|
|
"altimist",
|
|
|
|
"anime",
|
|
|
|
"austin",
|
|
|
|
"bald",
|
2025-02-28 19:55:22 +02:00
|
|
|
"bay",
|
2024-11-25 18:26:41 +02:00
|
|
|
"benji",
|
|
|
|
"bet",
|
|
|
|
"binanceus",
|
|
|
|
"bitcoin",
|
|
|
|
"bitget",
|
2025-02-28 19:55:22 +02:00
|
|
|
"bitscrunch",
|
2024-11-25 18:26:41 +02:00
|
|
|
"blockchain",
|
2025-02-28 19:55:22 +02:00
|
|
|
"boomer",
|
|
|
|
"boston",
|
2024-11-25 18:26:41 +02:00
|
|
|
"ca",
|
2025-02-28 19:55:22 +02:00
|
|
|
"caw",
|
|
|
|
"cc",
|
|
|
|
"chat",
|
2024-11-25 18:26:41 +02:00
|
|
|
"chomp",
|
|
|
|
"clay",
|
2025-02-28 19:55:22 +02:00
|
|
|
"club",
|
2024-11-25 18:26:41 +02:00
|
|
|
"co",
|
|
|
|
"com",
|
2025-02-28 19:55:22 +02:00
|
|
|
"company",
|
2024-11-25 18:26:41 +02:00
|
|
|
"crypto",
|
|
|
|
"dao",
|
2025-02-28 19:55:22 +02:00
|
|
|
"design",
|
2024-11-25 18:26:41 +02:00
|
|
|
"dfz",
|
|
|
|
"digital",
|
2025-02-28 19:55:22 +02:00
|
|
|
"doga",
|
|
|
|
"donut",
|
2024-11-25 18:26:41 +02:00
|
|
|
"dream",
|
2025-02-28 19:55:22 +02:00
|
|
|
"email",
|
|
|
|
"emir",
|
2024-11-25 18:26:41 +02:00
|
|
|
"eth",
|
|
|
|
"ethermail",
|
2025-02-28 19:55:22 +02:00
|
|
|
"family",
|
2024-11-25 18:26:41 +02:00
|
|
|
"farms",
|
2025-02-28 19:55:22 +02:00
|
|
|
"finance",
|
2024-11-25 18:26:41 +02:00
|
|
|
"fun",
|
2025-02-28 19:55:22 +02:00
|
|
|
"fyi",
|
|
|
|
"games",
|
|
|
|
"global",
|
2024-11-25 18:26:41 +02:00
|
|
|
"go",
|
|
|
|
"group",
|
2025-02-28 19:55:22 +02:00
|
|
|
"guru",
|
2024-11-25 18:26:41 +02:00
|
|
|
"hi",
|
2025-02-28 19:55:22 +02:00
|
|
|
"hockey",
|
2024-11-25 18:26:41 +02:00
|
|
|
"host",
|
|
|
|
"info",
|
|
|
|
"io",
|
|
|
|
"klever",
|
|
|
|
"kresus",
|
|
|
|
"kryptic",
|
|
|
|
"lfg",
|
|
|
|
"life",
|
|
|
|
"live",
|
2025-02-28 19:55:22 +02:00
|
|
|
"llc",
|
|
|
|
"ltc",
|
2024-11-25 18:26:41 +02:00
|
|
|
"ltd",
|
|
|
|
"manga",
|
2025-02-28 19:55:22 +02:00
|
|
|
"me",
|
|
|
|
"media",
|
2024-11-25 18:26:41 +02:00
|
|
|
"metropolis",
|
2025-02-28 19:55:22 +02:00
|
|
|
"miami",
|
|
|
|
"miku",
|
|
|
|
"money",
|
2024-11-25 18:26:41 +02:00
|
|
|
"moon",
|
|
|
|
"mumu",
|
|
|
|
"net",
|
2025-02-28 19:55:22 +02:00
|
|
|
"network",
|
|
|
|
"news",
|
2024-11-25 18:26:41 +02:00
|
|
|
"nft",
|
2025-02-28 19:55:22 +02:00
|
|
|
"npc",
|
|
|
|
"onchain",
|
2024-11-25 18:26:41 +02:00
|
|
|
"online",
|
|
|
|
"org",
|
2025-02-28 19:55:22 +02:00
|
|
|
"podcast",
|
2024-11-25 18:26:41 +02:00
|
|
|
"pog",
|
|
|
|
"polygon",
|
|
|
|
"press",
|
2025-02-28 19:55:22 +02:00
|
|
|
"privacy",
|
2024-11-25 18:26:41 +02:00
|
|
|
"pro",
|
|
|
|
"propykeys",
|
|
|
|
"pudgy",
|
|
|
|
"pw",
|
2025-02-28 19:55:22 +02:00
|
|
|
"quantum",
|
|
|
|
"rad",
|
2024-11-25 18:26:41 +02:00
|
|
|
"raiin",
|
2025-02-28 19:55:22 +02:00
|
|
|
"retardio",
|
|
|
|
"rip",
|
|
|
|
"rocks",
|
2024-11-25 18:26:41 +02:00
|
|
|
"secret",
|
2025-02-28 19:55:22 +02:00
|
|
|
"services",
|
2024-11-25 18:26:41 +02:00
|
|
|
"site",
|
|
|
|
"smobler",
|
2025-02-28 19:55:22 +02:00
|
|
|
"social",
|
|
|
|
"solutions",
|
2024-11-25 18:26:41 +02:00
|
|
|
"space",
|
|
|
|
"stepn",
|
|
|
|
"store",
|
2025-02-28 19:55:22 +02:00
|
|
|
"studio",
|
|
|
|
"systems",
|
2024-11-25 18:26:41 +02:00
|
|
|
"tball",
|
2025-02-28 19:55:22 +02:00
|
|
|
"tea",
|
|
|
|
"team",
|
2024-11-25 18:26:41 +02:00
|
|
|
"tech",
|
2025-02-28 19:55:22 +02:00
|
|
|
"technology",
|
|
|
|
"today",
|
|
|
|
"tribe",
|
|
|
|
"u",
|
2024-11-25 18:26:41 +02:00
|
|
|
"ubu",
|
|
|
|
"uno",
|
|
|
|
"unstoppable",
|
2025-02-28 19:55:22 +02:00
|
|
|
"vip",
|
2024-11-25 18:26:41 +02:00
|
|
|
"wallet",
|
|
|
|
"website",
|
2025-02-28 19:55:22 +02:00
|
|
|
"wif",
|
2024-11-25 18:26:41 +02:00
|
|
|
"wifi",
|
|
|
|
"witg",
|
2025-02-28 19:55:22 +02:00
|
|
|
"work",
|
|
|
|
"world",
|
2024-11-25 18:26:41 +02:00
|
|
|
"wrkx",
|
2025-02-28 19:55:22 +02:00
|
|
|
"wtf",
|
2024-11-25 18:26:41 +02:00
|
|
|
"x",
|
|
|
|
"xmr",
|
|
|
|
"xyz",
|
|
|
|
"zil",
|
2025-02-28 19:55:22 +02:00
|
|
|
"zone"
|
2023-01-31 21:39:08 +02:00
|
|
|
];
|
2021-07-07 16:50:55 +03:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
late final List<LookupEntry> _lookupTable;
|
|
|
|
|
|
|
|
void _buildLookupTable() {
|
|
|
|
_lookupTable = [
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.twitter,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.twitter.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) => settingsStore.lookupsTwitter && q.startsWith('@'),
|
|
|
|
// x handle example: @username
|
|
|
|
run: _lookupTwitter,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.zanoAlias,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.zanoAlias.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) => settingsStore.lookupsZanoAlias && q.startsWith('@'),
|
|
|
|
// zano handle example: @username
|
|
|
|
run: _lookupZano,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.mastodon,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.mastodon.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) =>
|
|
|
|
settingsStore.lookupsMastodon &&
|
|
|
|
q.startsWith('@') &&
|
|
|
|
q.contains('@', 1) &&
|
|
|
|
q.contains('.', 1),
|
|
|
|
// Mastodon handle example: @username@hostname.xxx
|
|
|
|
run: _lookupMastodon,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.wellKnown,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.wellKnown.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) => settingsStore.lookupsWellKnown && q.contains('.') && q.contains('@'),
|
|
|
|
// .well-known handle example:
|
|
|
|
run: _lookupWellKnown,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.fio,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.fio.supportedCurrencies,
|
2025-06-24 17:22:53 +03:00
|
|
|
applies: (q) =>
|
|
|
|
settingsStore.lookupsFio && !q.startsWith('@') && q.contains('@') && !q.contains('.'),
|
2025-05-30 13:12:02 +03:00
|
|
|
// FIO handle example: username@domain
|
|
|
|
run: _lookupFio,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.yatRecord,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.yatRecord.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) => settingsStore.lookupsYatService && q.hasOnlyEmojis,
|
|
|
|
// Yat handle example: 🐶🐾
|
|
|
|
run: _lookupYatService,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.thorChain,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.thorChain.supportedCurrencies,
|
2025-06-23 14:07:23 +03:00
|
|
|
applies: (q) => settingsStore.lookupsThorChain && q.isNotEmpty,
|
2025-05-30 13:12:02 +03:00
|
|
|
run: _lookupThorChain,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.unstoppableDomains,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.unstoppableDomains.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) {
|
2025-06-13 15:45:14 +03:00
|
|
|
if (!settingsStore.lookupsUnstoppableDomains) return false;
|
2025-05-30 13:12:02 +03:00
|
|
|
// Unstoppable Domains handle example: name.crypto
|
|
|
|
final formattedName = OpenaliasRecord.formatDomainName(q);
|
|
|
|
final domainParts = formattedName.split('.');
|
|
|
|
final name = domainParts.last;
|
|
|
|
return domainParts.length > 1 &&
|
|
|
|
domainParts.first.isNotEmpty &&
|
|
|
|
name.isNotEmpty &&
|
|
|
|
unstoppableDomains.any((domain) => name.trim() == domain);
|
|
|
|
},
|
|
|
|
run: _lookupsUnstoppableDomains,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.bip353,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.bip353.supportedCurrencies,
|
2025-06-24 17:22:53 +03:00
|
|
|
applies: (q) => settingsStore.lookupsBip353 && q.contains('@') && q.contains('.'),
|
2025-05-30 13:12:02 +03:00
|
|
|
run: _lookupsBip353,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.ens,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.ens.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) => settingsStore.lookupsENS && q.endsWith('.eth'),
|
|
|
|
// ENS handle example: name.eth
|
|
|
|
run: _lookupEns,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.openAlias,
|
2025-06-13 15:45:14 +03:00
|
|
|
currencies: AddressSource.openAlias.supportedCurrencies,
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) {
|
2025-06-13 15:45:14 +03:00
|
|
|
if (!settingsStore.lookupsOpenAlias) return false;
|
2025-05-30 13:12:02 +03:00
|
|
|
// OpenAlias handle example:
|
|
|
|
final formattedName = OpenaliasRecord.formatDomainName(q);
|
|
|
|
return formattedName.contains(".");
|
|
|
|
},
|
|
|
|
run: _lookupsOpenAlias,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.nostr,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
2025-06-23 14:07:23 +03:00
|
|
|
applies: (q) => settingsStore.lookupsNostr && isEmailFormat(q),
|
|
|
|
// Nostr handle example: name@domain
|
2025-05-30 13:12:02 +03:00
|
|
|
run: _lookupsNostr,
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2025-06-24 17:22:53 +03:00
|
|
|
static String _cleanInput(String raw) =>
|
|
|
|
raw.replaceAll(RegExp(r'[\u2028\u2029]'), '\n').replaceAll(RegExp(r'<[^>]+>'), ' ');
|
2025-06-13 15:45:14 +03:00
|
|
|
|
|
|
|
static String? extractAddressByType({
|
|
|
|
required String raw,
|
|
|
|
required CryptoCurrency type,
|
|
|
|
}) {
|
|
|
|
final pat = AddressValidator.getAddressFromStringPattern(type);
|
|
|
|
if (pat == null) {
|
2025-06-24 17:22:53 +03:00
|
|
|
printV('Unknown pattern for $type');
|
|
|
|
return null;
|
2023-01-24 20:24:46 +02:00
|
|
|
}
|
|
|
|
|
2025-06-13 15:45:14 +03:00
|
|
|
final text = _cleanInput(raw);
|
|
|
|
|
2025-06-24 17:22:53 +03:00
|
|
|
final regex =
|
|
|
|
RegExp(r'(?:^|[^0-9A-Za-z])(' + pat + r')', multiLine: true, caseSensitive: false);
|
2025-06-13 15:45:14 +03:00
|
|
|
|
|
|
|
final m = regex.firstMatch(text);
|
|
|
|
if (m == null) return null;
|
|
|
|
|
|
|
|
// 3. Strip BCH / NANO prefixes and punctuation just like before
|
2025-06-24 17:22:53 +03:00
|
|
|
final cleaned =
|
|
|
|
m.group(1)!.replaceAllMapped(RegExp(r'[^0-9a-zA-Z]|bitcoincash:|nano_|ban_'), (m) {
|
2025-06-13 15:45:14 +03:00
|
|
|
final g = m.group(0)!;
|
|
|
|
return (g.startsWith('bitcoincash:') || g.startsWith('nano_') || g.startsWith('ban_'))
|
|
|
|
? g
|
|
|
|
: '';
|
2023-10-17 11:59:41 -04:00
|
|
|
});
|
2025-06-13 15:45:14 +03:00
|
|
|
|
|
|
|
return cleaned;
|
2023-01-24 20:24:46 +02:00
|
|
|
}
|
|
|
|
|
2024-01-27 04:34:38 +02:00
|
|
|
bool isEmailFormat(String address) {
|
|
|
|
final RegExp emailRegex = RegExp(
|
|
|
|
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
|
|
|
|
caseSensitive: false,
|
|
|
|
);
|
|
|
|
return emailRegex.hasMatch(address);
|
|
|
|
}
|
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<List<ParsedAddress>> resolve({
|
|
|
|
required String query,
|
|
|
|
required WalletBase wallet,
|
|
|
|
CryptoCurrency? currency,
|
|
|
|
}) async {
|
2025-06-13 15:45:14 +03:00
|
|
|
try {
|
|
|
|
final tasks = <Future<ParsedAddress?>>[];
|
2023-02-13 00:38:12 +02:00
|
|
|
|
2025-06-13 15:45:14 +03:00
|
|
|
for (final entry in _lookupTable) {
|
|
|
|
if (!supportedSources.contains(entry.source)) continue;
|
|
|
|
if (!entry.applies(query)) continue;
|
2023-10-05 15:18:35 +03:00
|
|
|
|
2025-06-13 15:45:14 +03:00
|
|
|
final coins = currency == null
|
|
|
|
? entry.currencies.toList()
|
|
|
|
: (entry.currencies.contains(currency) ? [currency] : const <CryptoCurrency>[]);
|
2023-10-05 15:18:35 +03:00
|
|
|
|
2025-06-13 15:45:14 +03:00
|
|
|
if (coins.isEmpty) continue;
|
|
|
|
tasks.add(entry.run(query, coins, wallet));
|
|
|
|
}
|
2025-01-15 17:03:30 -05:00
|
|
|
|
2025-06-13 15:45:14 +03:00
|
|
|
final results = await Future.wait(tasks);
|
2024-05-06 22:16:25 +03:00
|
|
|
|
2025-06-13 15:45:14 +03:00
|
|
|
return results.whereType<ParsedAddress>().toList();
|
|
|
|
} catch (e) {
|
|
|
|
printV('Error resolving address: $e');
|
|
|
|
return [];
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2024-05-06 22:16:25 +03:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
Future<ParsedAddress?> _lookupTwitter(
|
2025-06-02 19:28:40 +03:00
|
|
|
String text, List<CryptoCurrency> currencies, WalletBase wallet) async {
|
2025-05-30 13:12:02 +03:00
|
|
|
final formattedName = text.substring(1);
|
|
|
|
final twitterUser = await TwitterApi.lookupUserByName(userName: formattedName);
|
2025-06-13 15:45:14 +03:00
|
|
|
|
|
|
|
if (twitterUser == null) return null;
|
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
2025-06-24 17:22:53 +03:00
|
|
|
try {
|
2025-06-02 19:28:40 +03:00
|
|
|
for (final cur in currencies) {
|
|
|
|
final addressFromBio = extractAddressByType(
|
|
|
|
raw: twitterUser.description, type: CryptoCurrency.fromString(cur.title));
|
2025-06-24 17:22:53 +03:00
|
|
|
print('Address from bio: $addressFromBio');
|
2025-06-02 19:28:40 +03:00
|
|
|
|
|
|
|
if (addressFromBio != null && addressFromBio.isNotEmpty) {
|
|
|
|
result[cur] = addressFromBio;
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2025-06-24 17:22:53 +03:00
|
|
|
} catch (e) {
|
|
|
|
printV('Error extracting address from Twitter bio: $e');
|
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
|
2025-06-24 17:22:53 +03:00
|
|
|
try {
|
2025-05-30 13:12:02 +03:00
|
|
|
final pinnedTweet = twitterUser.pinnedTweet?.text;
|
|
|
|
if (pinnedTweet != null) {
|
2025-06-02 19:28:40 +03:00
|
|
|
for (final cur in currencies) {
|
|
|
|
final addressFromPinnedTweet =
|
|
|
|
extractAddressByType(raw: pinnedTweet, type: CryptoCurrency.fromString(cur.title));
|
|
|
|
if (addressFromPinnedTweet != null && addressFromPinnedTweet.isNotEmpty) {
|
|
|
|
result[cur] = addressFromPinnedTweet;
|
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2025-06-24 17:22:53 +03:00
|
|
|
} catch (e) {
|
|
|
|
printV('Error extracting address from Twitter pinned tweet: $e');
|
|
|
|
}
|
2025-06-02 19:28:40 +03:00
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.twitter,
|
|
|
|
handle: text,
|
|
|
|
profileImageUrl: twitterUser.profileImageUrl,
|
|
|
|
profileName: twitterUser.name,
|
|
|
|
);
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
return null;
|
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<ParsedAddress?> _lookupZano(
|
|
|
|
String text, List<CryptoCurrency> currencies, WalletBase _) async {
|
2025-05-30 13:12:02 +03:00
|
|
|
final formattedName = text.substring(1);
|
2025-06-02 19:28:40 +03:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
final zanoAddress = await ZanoAlias.fetchZanoAliasAddress(formattedName);
|
|
|
|
if (zanoAddress != null && zanoAddress.isNotEmpty) {
|
2025-06-02 19:28:40 +03:00
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: {CryptoCurrency.zano: zanoAddress},
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.zanoAlias,
|
|
|
|
handle: text,
|
2025-05-30 13:12:02 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<ParsedAddress?> _lookupMastodon(
|
|
|
|
String text, List<CryptoCurrency> currencies, WalletBase _) async {
|
2025-05-30 13:12:02 +03:00
|
|
|
final subText = text.substring(1);
|
|
|
|
final hostNameIndex = subText.indexOf('@');
|
|
|
|
final hostName = subText.substring(hostNameIndex + 1);
|
|
|
|
final userName = subText.substring(0, hostNameIndex);
|
2025-02-17 23:05:44 +02:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
final mastodonUser =
|
|
|
|
await MastodonAPI.lookupUserByUserName(userName: userName, apiHost: hostName);
|
2025-02-17 23:05:44 +02:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
if (mastodonUser != null) {
|
2025-06-02 19:28:40 +03:00
|
|
|
for (final cur in currencies) {
|
|
|
|
String? addressFromBio = extractAddressByType(raw: mastodonUser.note, type: cur);
|
|
|
|
if (addressFromBio != null && addressFromBio.isNotEmpty) {
|
|
|
|
result[cur] = addressFromBio;
|
|
|
|
}
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
final pinnedPosts =
|
|
|
|
await MastodonAPI.getPinnedPosts(userId: mastodonUser.id, apiHost: hostName);
|
2025-05-30 13:12:02 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
if (pinnedPosts.isNotEmpty) {
|
|
|
|
final userPinnedPostsText = pinnedPosts.map((item) => item.content).join('\n');
|
|
|
|
|
|
|
|
for (final cur in currencies) {
|
|
|
|
String? addressFromPinnedPost = extractAddressByType(raw: userPinnedPostsText, type: cur);
|
2025-05-30 13:12:02 +03:00
|
|
|
if (addressFromPinnedPost != null && addressFromPinnedPost.isNotEmpty) {
|
2025-06-02 19:28:40 +03:00
|
|
|
result[cur] = addressFromPinnedPost;
|
2023-11-03 21:23:11 +02:00
|
|
|
}
|
2023-09-25 09:47:39 -04:00
|
|
|
}
|
|
|
|
}
|
2025-06-02 19:28:40 +03:00
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.mastodon,
|
|
|
|
handle: text,
|
|
|
|
profileImageUrl: mastodonUser.profileImageUrl,
|
|
|
|
profileName: mastodonUser.username,
|
|
|
|
);
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2023-09-25 09:47:39 -04:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
Future<ParsedAddress?> _lookupWellKnown(
|
2025-06-02 19:28:40 +03:00
|
|
|
String text, List<CryptoCurrency> currencies, WalletBase _) async {
|
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
|
|
|
for (final cur in currencies) {
|
|
|
|
final record = await WellKnownRecord.fetchAddressAndName(formattedName: text, currency: cur);
|
|
|
|
if (record != null) {
|
|
|
|
result[cur] = record.address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.wellKnown,
|
|
|
|
handle: text,
|
|
|
|
);
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2024-12-30 20:58:58 +02:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<ParsedAddress?> _lookupFio(
|
|
|
|
String text, List<CryptoCurrency> currencies, WalletBase _) async {
|
|
|
|
final Map<CryptoCurrency, String> result = {};
|
2025-05-30 13:12:02 +03:00
|
|
|
final bool isFioRegistered = await FioAddressProvider.checkAvail(text);
|
2025-06-02 19:28:40 +03:00
|
|
|
if (!isFioRegistered) return null;
|
|
|
|
|
|
|
|
for (final cur in currencies) {
|
|
|
|
final address = await FioAddressProvider.getPubAddress(text, cur.title);
|
2025-06-24 17:22:53 +03:00
|
|
|
if (address != null && address.isNotEmpty) {
|
2025-06-02 19:28:40 +03:00
|
|
|
result[cur] = address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.fio,
|
|
|
|
handle: text,
|
|
|
|
);
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<ParsedAddress?> _lookupYatService(
|
2025-06-02 19:28:40 +03:00
|
|
|
String text, List<CryptoCurrency> currency, WalletBase _) async {
|
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
|
|
|
for (final cur in currency) {
|
|
|
|
final addresses = await yatService.fetchYatAddress(text, cur.title);
|
|
|
|
if (addresses.isNotEmpty) {
|
|
|
|
result[cur] = addresses.first.address; //TODO: Handle multiple addresses
|
|
|
|
}
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.yatRecord,
|
|
|
|
handle: text,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<ParsedAddress?> _lookupThorChain(
|
2025-06-02 19:28:40 +03:00
|
|
|
String text, List<CryptoCurrency> currency, WalletBase _) async {
|
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
final thorChainAddress = await ThorChainExchangeProvider.lookupAddressByName(text);
|
|
|
|
if (thorChainAddress != null && thorChainAddress.isNotEmpty) {
|
2025-06-02 19:28:40 +03:00
|
|
|
for (final cur in currency) {
|
|
|
|
String? address =
|
|
|
|
thorChainAddress[cur.title] ?? (cur.title == 'RUNE' ? thorChainAddress['THOR'] : null);
|
|
|
|
if (address != null && address.isNotEmpty) {
|
|
|
|
result[cur] = address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.thorChain,
|
|
|
|
handle: text,
|
|
|
|
);
|
2023-01-31 21:39:08 +02:00
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<ParsedAddress?> _lookupsUnstoppableDomains(
|
2025-06-02 19:28:40 +03:00
|
|
|
String text, List<CryptoCurrency> currency, WalletBase _) async {
|
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
for (final cur in currency) {
|
|
|
|
final address = await fetchUnstoppableDomainAddress(text, cur.title);
|
|
|
|
if (address.isNotEmpty) {
|
|
|
|
result[cur] = address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
|
|
|
profileImageUrl: 'assets/images/profile.png',
|
|
|
|
profileName: text,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.unstoppableDomains,
|
|
|
|
handle: text,
|
|
|
|
);
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2025-06-02 19:28:40 +03:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<ParsedAddress?> _lookupsBip353(
|
2025-06-24 17:22:53 +03:00
|
|
|
String text, List<CryptoCurrency> currencies, WalletBase _) async {
|
2025-06-02 19:28:40 +03:00
|
|
|
final Map<CryptoCurrency, String> result = {};
|
2025-05-30 13:12:02 +03:00
|
|
|
|
2025-06-24 17:22:53 +03:00
|
|
|
for (final cur in currencies) {
|
2025-06-02 19:28:40 +03:00
|
|
|
final bip353AddressMap = await Bip353Record.fetchUriByCryptoCurrency(text, cur.title);
|
2025-06-24 17:22:53 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
if (bip353AddressMap != null && bip353AddressMap.isNotEmpty) {
|
2025-06-24 17:22:53 +03:00
|
|
|
if (cur == CryptoCurrency.btc) {
|
|
|
|
bip353AddressMap.forEach((key, value) {
|
|
|
|
final address = bip353AddressMap['sp'] ?? bip353AddressMap['address'];
|
|
|
|
if (address != null && address.isNotEmpty) {
|
|
|
|
result[cur] = address;
|
|
|
|
}
|
|
|
|
});
|
2025-06-02 19:28:40 +03:00
|
|
|
}
|
2024-01-27 04:34:38 +02:00
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
}
|
2025-06-24 17:22:53 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.bip353,
|
|
|
|
handle: text,
|
|
|
|
);
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
return null;
|
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<ParsedAddress?> _lookupEns(
|
|
|
|
String text, List<CryptoCurrency> currency, WalletBase wallet) async {
|
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
|
|
|
for (final cur in currency) {
|
|
|
|
final address = await EnsRecord.fetchEnsAddress(text, wallet: wallet);
|
|
|
|
if (address.isNotEmpty && address != "0x0000000000000000000000000000000000000000") {
|
|
|
|
result[cur] = address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.ens,
|
|
|
|
handle: text,
|
|
|
|
);
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
|
|
|
return null;
|
2021-07-07 16:50:55 +03:00
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
|
|
|
|
Future<ParsedAddress?> _lookupsOpenAlias(
|
2025-06-02 19:28:40 +03:00
|
|
|
String text, List<CryptoCurrency> currency, WalletBase _) async {
|
2025-05-30 13:12:02 +03:00
|
|
|
final formattedName = OpenaliasRecord.formatDomainName(text);
|
|
|
|
final txtRecord = await OpenaliasRecord.lookupOpenAliasRecord(formattedName);
|
2025-06-02 19:28:40 +03:00
|
|
|
final Map<CryptoCurrency, String> result = {};
|
2025-05-30 13:12:02 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
for (final cur in currency) {
|
|
|
|
if (txtRecord == null) continue;
|
2025-05-30 13:12:02 +03:00
|
|
|
final record = await OpenaliasRecord.fetchAddressAndName(
|
2025-06-02 19:28:40 +03:00
|
|
|
formattedName: formattedName, ticker: cur.title.toLowerCase(), txtRecord: txtRecord);
|
|
|
|
if (record.address.isNotEmpty) {
|
|
|
|
result[cur] = record.address;
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2025-06-02 19:28:40 +03:00
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
2025-06-13 15:45:14 +03:00
|
|
|
parsedAddressByCurrencyMap: result,
|
2025-06-02 19:28:40 +03:00
|
|
|
addressSource: AddressSource.openAlias,
|
|
|
|
handle: text,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
Future<ParsedAddress?> _lookupsNostr(
|
|
|
|
String text, List<CryptoCurrency> currency, WalletBase _) async {
|
2025-05-30 13:12:02 +03:00
|
|
|
//TODO implement Nostr lookup logic
|
|
|
|
// final nostrProfile = await NostrProfileHandler.queryProfile(context, text);
|
|
|
|
// if (nostrProfile?.relays != null) {
|
|
|
|
// final nostrUserData =
|
|
|
|
// await NostrProfileHandler.processRelays(context, nostrProfile!, text);
|
|
|
|
//
|
|
|
|
// if (nostrUserData != null) {
|
|
|
|
// String? addressFromBio = extractAddressByType(raw: nostrUserData.about, type: currency);
|
|
|
|
// if (addressFromBio != null && addressFromBio.isNotEmpty) {
|
|
|
|
// return ParsedAddress.nostrAddress(
|
|
|
|
// address: addressFromBio,
|
|
|
|
// name: text,
|
|
|
|
// profileImageUrl: nostrUserData.picture,
|
|
|
|
// profileName: nostrUserData.name);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LookupEntry {
|
|
|
|
const LookupEntry({
|
|
|
|
required this.source,
|
|
|
|
required this.currencies,
|
|
|
|
required this.applies,
|
|
|
|
required this.run,
|
|
|
|
});
|
|
|
|
|
|
|
|
final AddressSource source;
|
|
|
|
final List<CryptoCurrency> currencies;
|
|
|
|
final bool Function(String query) applies;
|
2025-06-13 15:45:14 +03:00
|
|
|
final Future<ParsedAddress?> Function(
|
|
|
|
String query, List<CryptoCurrency> currencies, WalletBase wallet) run;
|
2022-01-14 14:18:03 +01:00
|
|
|
}
|