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';
|
2023-09-25 09:47:39 -04:00
|
|
|
import 'package:cake_wallet/entities/ens_record.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';
|
2022-03-15 10:11:53 +01:00
|
|
|
import 'package:cake_wallet/entities/emoji_string_extension.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';
|
2024-01-27 04:34:38 +02:00
|
|
|
import 'package:cake_wallet/nostr/nostr_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-06-28 18:46:32 +03:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2022-06-13 14:41:46 +03:00
|
|
|
import 'package:cake_wallet/entities/fio_address_provider.dart';
|
2024-01-27 04:34:38 +02:00
|
|
|
import 'package:flutter/cupertino.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-05-30 16:47:46 +03:00
|
|
|
currencies: [CryptoCurrency.xmr, CryptoCurrency.btc],
|
2025-05-30 13:12:02 +03:00
|
|
|
applies: (q) => settingsStore.lookupsTwitter && q.startsWith('@'),
|
|
|
|
// x handle example: @username
|
|
|
|
run: _lookupTwitter,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.zanoAlias,
|
|
|
|
currencies: [CryptoCurrency.zano],
|
|
|
|
applies: (q) => settingsStore.lookupsZanoAlias && q.startsWith('@'),
|
|
|
|
// zano handle example: @username
|
|
|
|
run: _lookupZano,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.mastodon,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
|
|
|
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-02 19:28:40 +03:00
|
|
|
currencies: [CryptoCurrency.nano],
|
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,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
|
|
|
applies: (q) => !q.startsWith('@') && q.contains('@') && !q.contains('.'),
|
|
|
|
// TODO: Add condition for FIO lookups
|
|
|
|
// FIO handle example: username@domain
|
|
|
|
run: _lookupFio,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.yatRecord,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
|
|
|
applies: (q) => settingsStore.lookupsYatService && q.hasOnlyEmojis,
|
|
|
|
// Yat handle example: 🐶🐾
|
|
|
|
run: _lookupYatService,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.thorChain,
|
|
|
|
currencies: [CryptoCurrency.rune],
|
|
|
|
applies: (q) => true,
|
|
|
|
// ThorChain handles can be any string //TODO: Add condition for ThorChain lookups
|
|
|
|
run: _lookupThorChain,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.unstoppableDomains,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
|
|
|
applies: (q) {
|
|
|
|
if (settingsStore.lookupsUnstoppableDomains) return false;
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
currencies: [CryptoCurrency.btc, CryptoCurrency.xmr],
|
|
|
|
applies: (q) => true, //TODO: Add condition for BIP-353 lookups
|
|
|
|
run: _lookupsBip353,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.ens,
|
|
|
|
currencies: [CryptoCurrency.eth],
|
|
|
|
applies: (q) => settingsStore.lookupsENS && q.endsWith('.eth'),
|
|
|
|
// ENS handle example: name.eth
|
|
|
|
run: _lookupEns,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.openAlias,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
|
|
|
applies: (q) {
|
|
|
|
if (settingsStore.lookupsOpenAlias) return false;
|
|
|
|
// OpenAlias handle example:
|
|
|
|
final formattedName = OpenaliasRecord.formatDomainName(q);
|
|
|
|
return formattedName.contains(".");
|
|
|
|
},
|
|
|
|
run: _lookupsOpenAlias,
|
|
|
|
),
|
|
|
|
LookupEntry(
|
|
|
|
source: AddressSource.nostr,
|
|
|
|
currencies: [CryptoCurrency.btc],
|
|
|
|
applies: (q) => isEmailFormat(q),
|
|
|
|
// Nostr handle example: name@domain //TODO: Add condition for Nostr lookups
|
|
|
|
run: _lookupsNostr,
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-01-24 20:24:46 +02:00
|
|
|
static String? extractAddressByType({required String raw, required CryptoCurrency type}) {
|
|
|
|
final addressPattern = AddressValidator.getAddressFromStringPattern(type);
|
|
|
|
|
|
|
|
if (addressPattern == null) {
|
2023-04-21 21:36:47 +03:00
|
|
|
throw Exception('Unexpected token: $type for getAddressFromStringPattern');
|
2023-01-24 20:24:46 +02:00
|
|
|
}
|
|
|
|
|
2024-09-20 14:24:25 +00:00
|
|
|
final match = RegExp(addressPattern, multiLine: true).firstMatch(raw);
|
Bitcoin derivations (#1089)
* - Update and Fix Conflicts with main
* Add Balances for ERC20 tokens
* Fix conflicts with main
* Add erc20 abi json
* Add send erc20 tokens initial function
* add missing getHeightByDate in Haven [skip ci]
* Allow contacts and wallets from the same tag
* Add Shiba Inu icon
* Add send ERC-20 tokens initial flow
* Add missing import in generated file
* Add initial approach for transaction sending for ERC-20 tokens
* Refactor signing/sending transactions
* Add initial flow for transactions subscription
* Refactor signing/sending transactions
* Add home settings icon
* Fix conflicts with main
* Initial flow for home settings
* Add logic flow for adding erc20 tokens
* Fix initial UI
* Finalize UI for Tokens
* Integrate UI with Ethereum flow
* Add "Enable/Disable" feature for ERC20 tokens
* Add initial Erc20 tokens
* Add Sorting and Pin Native Token features
* Fix price sorting
* Sort tokens list as well when Sort criteria changes
* - Improve sorting balances flow
- Add initial add token from search bar flow
* Fix Accounts Popup UI
* Fix Pin native token
* Fix Enabling/Disabling tokens
Fix sorting by fiat once app is opened
Improve token availability mechanism
* Fix deleting token
Fix renaming tokens
* Fix issue with search
* Add more tokens
* - Fix scroll issue
- Add ERC20 tokens placeholder image in picker
* - Separate and organize default erc20 tokens
- Fix scrolling
- Add token placeholder images in picker
- Sort disabled tokens alphabetically
* Change BNB token initial availability [skip ci]
* Fix Conflicts with main
* Fix Conflicts with main
* Add Verse ERC20 token to the initial tokens list
* Add rename wallet to Ethereum
* Integrate EtherScan API for fetching address transactions
Generate Ethereum specific secrets in Ethereum package
* Adjust transactions fiat price for ERC20 tokens
* Free Up GitHub Actions Ubuntu Runner Disk Space
* Free Up GitHub Actions Ubuntu Runner Disk space (trial 2)
* Fix Transaction Fee display
* Save transaction history
* Enhance loading time for erc20 tokens transactions
* Minor Fixes and Enhancements
* Fix sending erc20
fix block explorer issue
* Fix int overflow
* Fix transaction amount conversions
* Minor: `slow` -> `Slow` [skip-ci]
* initial changes
* more base config stuff
* config changes
* successfully builds!
* save
* successfully add nano wallet
* save
* seed generation
* receive screen + node screen working
* tx history working and fiat fixes
* balance working
* derivation updates
* nano-unfinished
* sends working
* remove fees from send screen, send and receive transactions working
* fixes + auto receive incoming txs
* fix for scanning QR codes
* save
* update translations
* fixes
* more fixes
* more strings
* small fix
* fix github actions workflow
* potential fix
* potential fix
* ci/cd fix
* change rep working
* seed generation fixes
* fixes
* save
* change rep screen functional
* save
* banano changes
* fixes, start adding ui for PoW
* pow node changes
* update translations
* fix
* account changing barely working
* save
* disable account generation
* small fix
* save
* UI work
* save
* fixes after merge main
* fixes
* remove monero stuff, work on derivation ui
* lots of fixes + finish up seed derivation
* last minute fixes
* node related fixes
* more fixes
* small fix
* more fixes
* fixes
* pretty big refactor for pow, still some bugs
* finally works!
* get transactions after send
* fix
* merge conflict fixes
* save
* fix pow node showing up twice
* done
* initial changes
* small fix
* more merge fixes
* fixes
* more fixes
* fix
* save
* fix manage pow nodes setting appearing on other wallets
* fix contact bug
* fixes
* fiat fixes
* save
* save
* save
* save
* updates
* cleanup
* restore fix
* fixes
* remove deprecated alert
* fix
* small fix
* remove outdated warning
* electrum restore fixes
* fixes
* fixes
* fix
* derivation fixes
* nano fixes pt.1
* nano fixes pt.2
* bip39 fixes
* pownode refactor
* nodes pages fixes
* observer fix
* ssl fix
* remove old references
* remove unused imports
* code cleanup
* small fix
* small potential fix
* save
* derivation fixes
* deterministic fix
* fix pt.2
* derivation class fixes
* review fixes from nano that also apply here
* formatting
* stuff that should've stayed deleted
* post merge fixes
* remove problematic imports and duplicate changes
* Delete lib/nano/nano.dart
* move wallet restore page proxy code to the view model
* fix dashboard page indicators being the same color
* debatably better refactoring of derivationInfo, migration needed
* additional refactor improvements
* blanket comment some stuff out to narrow down this issue
* refactor fixes
* fix nano exchange
* fix , bug, i.e. replace , with . when making a nano transaction
* fix nano sending, update restore page wording, and other minor fixes
* write migration for existing bitcoin and nano wallets
* merge fixes
* minor fixes
* use default derivation type when restoring from qr code
* fixes for restoring
* fixes
* fixes
* merge fix
* Fix issues with Creating Electrum and Restoring Bip39
* updates & fixes
* Add missing case for no transactions BIP39 wallet restore
* Make the default BIP39 the 84 derivation path
* Add Samourai Deposit
* litecoin mnemonic error fix
* Bip39 passphrase support (#1412)
* save
* passphrase working
* fix for when loading wallets + translation update
* minor fix
* Fix Nano
* minor fix [skip ci]
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
* change error state seed conditions into throwables [skip ci]
* litecoin fixes
* Bip39 minor enhancements (#1416)
* minor enhancements
* rename bitcoin_derivations -> electrum_derivations
* Remove duplicate derivations
handle default case
* minor fix
* Enable passphrase for Litecoin
* obscure text of passphrase
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com>
Co-authored-by: fossephate <fosse@book.local>
2024-04-29 17:49:56 -07:00
|
|
|
return match?.group(0)?.replaceAllMapped(RegExp('[^0-9a-zA-Z]|bitcoincash:|nano_|ban_'),
|
2024-03-04 19:32:10 +02:00
|
|
|
(Match match) {
|
2023-10-17 11:59:41 -04:00
|
|
|
String group = match.group(0)!;
|
Bitcoin derivations (#1089)
* - Update and Fix Conflicts with main
* Add Balances for ERC20 tokens
* Fix conflicts with main
* Add erc20 abi json
* Add send erc20 tokens initial function
* add missing getHeightByDate in Haven [skip ci]
* Allow contacts and wallets from the same tag
* Add Shiba Inu icon
* Add send ERC-20 tokens initial flow
* Add missing import in generated file
* Add initial approach for transaction sending for ERC-20 tokens
* Refactor signing/sending transactions
* Add initial flow for transactions subscription
* Refactor signing/sending transactions
* Add home settings icon
* Fix conflicts with main
* Initial flow for home settings
* Add logic flow for adding erc20 tokens
* Fix initial UI
* Finalize UI for Tokens
* Integrate UI with Ethereum flow
* Add "Enable/Disable" feature for ERC20 tokens
* Add initial Erc20 tokens
* Add Sorting and Pin Native Token features
* Fix price sorting
* Sort tokens list as well when Sort criteria changes
* - Improve sorting balances flow
- Add initial add token from search bar flow
* Fix Accounts Popup UI
* Fix Pin native token
* Fix Enabling/Disabling tokens
Fix sorting by fiat once app is opened
Improve token availability mechanism
* Fix deleting token
Fix renaming tokens
* Fix issue with search
* Add more tokens
* - Fix scroll issue
- Add ERC20 tokens placeholder image in picker
* - Separate and organize default erc20 tokens
- Fix scrolling
- Add token placeholder images in picker
- Sort disabled tokens alphabetically
* Change BNB token initial availability [skip ci]
* Fix Conflicts with main
* Fix Conflicts with main
* Add Verse ERC20 token to the initial tokens list
* Add rename wallet to Ethereum
* Integrate EtherScan API for fetching address transactions
Generate Ethereum specific secrets in Ethereum package
* Adjust transactions fiat price for ERC20 tokens
* Free Up GitHub Actions Ubuntu Runner Disk Space
* Free Up GitHub Actions Ubuntu Runner Disk space (trial 2)
* Fix Transaction Fee display
* Save transaction history
* Enhance loading time for erc20 tokens transactions
* Minor Fixes and Enhancements
* Fix sending erc20
fix block explorer issue
* Fix int overflow
* Fix transaction amount conversions
* Minor: `slow` -> `Slow` [skip-ci]
* initial changes
* more base config stuff
* config changes
* successfully builds!
* save
* successfully add nano wallet
* save
* seed generation
* receive screen + node screen working
* tx history working and fiat fixes
* balance working
* derivation updates
* nano-unfinished
* sends working
* remove fees from send screen, send and receive transactions working
* fixes + auto receive incoming txs
* fix for scanning QR codes
* save
* update translations
* fixes
* more fixes
* more strings
* small fix
* fix github actions workflow
* potential fix
* potential fix
* ci/cd fix
* change rep working
* seed generation fixes
* fixes
* save
* change rep screen functional
* save
* banano changes
* fixes, start adding ui for PoW
* pow node changes
* update translations
* fix
* account changing barely working
* save
* disable account generation
* small fix
* save
* UI work
* save
* fixes after merge main
* fixes
* remove monero stuff, work on derivation ui
* lots of fixes + finish up seed derivation
* last minute fixes
* node related fixes
* more fixes
* small fix
* more fixes
* fixes
* pretty big refactor for pow, still some bugs
* finally works!
* get transactions after send
* fix
* merge conflict fixes
* save
* fix pow node showing up twice
* done
* initial changes
* small fix
* more merge fixes
* fixes
* more fixes
* fix
* save
* fix manage pow nodes setting appearing on other wallets
* fix contact bug
* fixes
* fiat fixes
* save
* save
* save
* save
* updates
* cleanup
* restore fix
* fixes
* remove deprecated alert
* fix
* small fix
* remove outdated warning
* electrum restore fixes
* fixes
* fixes
* fix
* derivation fixes
* nano fixes pt.1
* nano fixes pt.2
* bip39 fixes
* pownode refactor
* nodes pages fixes
* observer fix
* ssl fix
* remove old references
* remove unused imports
* code cleanup
* small fix
* small potential fix
* save
* derivation fixes
* deterministic fix
* fix pt.2
* derivation class fixes
* review fixes from nano that also apply here
* formatting
* stuff that should've stayed deleted
* post merge fixes
* remove problematic imports and duplicate changes
* Delete lib/nano/nano.dart
* move wallet restore page proxy code to the view model
* fix dashboard page indicators being the same color
* debatably better refactoring of derivationInfo, migration needed
* additional refactor improvements
* blanket comment some stuff out to narrow down this issue
* refactor fixes
* fix nano exchange
* fix , bug, i.e. replace , with . when making a nano transaction
* fix nano sending, update restore page wording, and other minor fixes
* write migration for existing bitcoin and nano wallets
* merge fixes
* minor fixes
* use default derivation type when restoring from qr code
* fixes for restoring
* fixes
* fixes
* merge fix
* Fix issues with Creating Electrum and Restoring Bip39
* updates & fixes
* Add missing case for no transactions BIP39 wallet restore
* Make the default BIP39 the 84 derivation path
* Add Samourai Deposit
* litecoin mnemonic error fix
* Bip39 passphrase support (#1412)
* save
* passphrase working
* fix for when loading wallets + translation update
* minor fix
* Fix Nano
* minor fix [skip ci]
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
* change error state seed conditions into throwables [skip ci]
* litecoin fixes
* Bip39 minor enhancements (#1416)
* minor enhancements
* rename bitcoin_derivations -> electrum_derivations
* Remove duplicate derivations
handle default case
* minor fix
* Enable passphrase for Litecoin
* obscure text of passphrase
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
Co-authored-by: Justin Ehrenhofer <justin.ehrenhofer@gmail.com>
Co-authored-by: fossephate <fosse@book.local>
2024-04-29 17:49:56 -07:00
|
|
|
if (group.startsWith('bitcoincash:') ||
|
|
|
|
group.startsWith('nano_') ||
|
|
|
|
group.startsWith('ban_')) {
|
2023-10-17 11:59:41 -04:00
|
|
|
return group;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
});
|
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 {
|
|
|
|
final tasks = <Future<ParsedAddress?>>[];
|
2023-02-13 00:38:12 +02:00
|
|
|
|
2025-05-30 13:12:02 +03:00
|
|
|
for (final entry in _lookupTable) {
|
|
|
|
if (!entry.applies(query)) continue;
|
2023-10-05 15:18:35 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
final coins = currency == null
|
|
|
|
? entry.currencies.toList()
|
2025-05-30 13:12:02 +03:00
|
|
|
: (entry.currencies.contains(currency) ? [currency] : const <CryptoCurrency>[]);
|
2023-10-05 15:18:35 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
print('Running lookup for ${entry.source.label} with query: $query, coins: $coins');
|
|
|
|
|
|
|
|
if (coins.isEmpty) continue;
|
|
|
|
tasks.add(entry.run(query, coins, wallet));
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2025-01-15 17:03:30 -05:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
final results = await Future.wait(tasks);
|
|
|
|
final out = results.whereType<ParsedAddress>().toList();
|
2024-05-06 22:16:25 +03:00
|
|
|
|
2025-06-02 19:28:40 +03:00
|
|
|
if (out.isEmpty)
|
|
|
|
out.add(ParsedAddress(
|
|
|
|
addressByCurrencyMap: {},
|
|
|
|
addressSource: AddressSource.notParsed,
|
|
|
|
handle: query,
|
|
|
|
));
|
2025-05-30 13:12:02 +03:00
|
|
|
return out;
|
|
|
|
}
|
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-02 19:28:40 +03:00
|
|
|
final Map<CryptoCurrency, String> result = {};
|
|
|
|
|
|
|
|
for (final cur in currencies) {
|
|
|
|
final addressFromBio = extractAddressByType(
|
|
|
|
raw: twitterUser.description, type: CryptoCurrency.fromString(cur.title));
|
|
|
|
|
|
|
|
if (addressFromBio != null && addressFromBio.isNotEmpty) {
|
|
|
|
result[cur] = addressFromBio;
|
|
|
|
}
|
2025-05-30 13:12:02 +03:00
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
|
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-02 19:28:40 +03:00
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: {CryptoCurrency.zano: zanoAddress},
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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);
|
|
|
|
if (address.isNotEmpty) {
|
|
|
|
result[cur] = address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
String text, List<CryptoCurrency> currency, WalletBase _) async {
|
|
|
|
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) {
|
|
|
|
final bip353AddressMap = await Bip353Record.fetchUriByCryptoCurrency(text, cur.title);
|
|
|
|
if (bip353AddressMap != null && bip353AddressMap.isNotEmpty) {
|
|
|
|
final address = bip353AddressMap['address'];
|
|
|
|
if (address != null && address.isNotEmpty) {
|
|
|
|
result[cur] = address;
|
|
|
|
}
|
2024-01-27 04:34:38 +02:00
|
|
|
}
|
2021-07-07 16:50:55 +03:00
|
|
|
}
|
2025-06-02 19:28:40 +03:00
|
|
|
if (result.isNotEmpty) {
|
|
|
|
return ParsedAddress(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
addressSource: AddressSource.bip353,
|
|
|
|
handle: text,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// if (bip353AddressMap != null && bip353AddressMap.isNotEmpty) {
|
|
|
|
// final chosenAddress =
|
|
|
|
// await Bip353Record.pickBip353AddressChoice(text, bip353AddressMap); //TODO fix context
|
|
|
|
// if (chosenAddress != null) {
|
|
|
|
// return ParsedAddress.fetchBip353AddressAddress(address: chosenAddress, name: 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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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(
|
|
|
|
addressByCurrencyMap: result,
|
|
|
|
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-02 19:28:40 +03:00
|
|
|
final Future<ParsedAddress?> Function(String query, List<CryptoCurrency> currencies, WalletBase wallet) run;
|
2022-01-14 14:18:03 +01:00
|
|
|
}
|