SP Enhancments (#1483)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

* fixes and minor enhancements for SP flow

* fix build

* change dfx text

* minor fixes

* pass use electrs to setListeners

* comment out connecting on failure for now
This commit is contained in:
Omar Hatem 2024-06-10 09:30:58 +02:00 committed by GitHub
parent 1dd2c7da56
commit 5a6502a35a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 86 additions and 68 deletions

View file

@ -96,13 +96,17 @@ abstract class ElectrumWalletBase
this.walletInfo = walletInfo;
transactionHistory = ElectrumTransactionHistory(walletInfo: walletInfo, password: password);
reaction((_) => syncStatus, (SyncStatus syncStatus) {
if (syncStatus is! AttemptingSyncStatus && syncStatus is! SyncedTipSyncStatus)
reaction((_) => syncStatus, (SyncStatus syncStatus) async {
if (syncStatus is! AttemptingSyncStatus && syncStatus is! SyncedTipSyncStatus) {
silentPaymentsScanningActive = syncStatus is SyncingSyncStatus;
}
if (syncStatus is NotConnectedSyncStatus) {
// Needs to re-subscribe to all scripthashes when reconnected
_scripthashesUpdateSubject = {};
// TODO: double check this and make sure it doesn't cause any un-necessary calls
// await this.electrumClient.connectToUri(node!.uri, useSSL: node!.useSSL);
}
// Message is shown on the UI for 3 seconds, revert to synced
@ -219,13 +223,13 @@ abstract class ElectrumWalletBase
} else {
alwaysScan = false;
(await _isolate)?.kill(priority: Isolate.immediate);
_isolate?.then((value) => value.kill(priority: Isolate.immediate));
if (electrumClient.isConnected) {
syncStatus = SyncedSyncStatus();
} else {
if (electrumClient.uri != null) {
await electrumClient.connectToUri(electrumClient.uri!);
await electrumClient.connectToUri(electrumClient.uri!, useSSL: electrumClient.useSSL);
startSync();
}
}
@ -463,17 +467,7 @@ abstract class ElectrumWalletBase
await electrumClient.close();
electrumClient.onConnectionStatusChange = (bool? isConnected) async {
if (syncStatus is SyncingSyncStatus) return;
if (isConnected == true && syncStatus is! SyncedSyncStatus) {
syncStatus = ConnectedSyncStatus();
} else if (isConnected == false) {
syncStatus = LostConnectionSyncStatus();
} else if (!(isConnected ?? false) && syncStatus is! ConnectingSyncStatus) {
syncStatus = NotConnectedSyncStatus();
}
};
electrumClient.onConnectionStatusChange = _onConnectionStatusChange;
await electrumClient.connectToUri(node.uri, useSSL: node.useSSL);
} catch (e) {
@ -1139,7 +1133,7 @@ abstract class ElectrumWalletBase
bool? usingElectrs,
}) async {
silentPaymentsScanningActive = true;
_setListeners(height, doSingleScan: doSingleScan);
_setListeners(height, doSingleScan: doSingleScan, usingElectrs: usingElectrs);
}
@override
@ -1657,6 +1651,7 @@ abstract class ElectrumWalletBase
if (_isTransactionUpdating) {
return;
}
await getCurrentChainTip();
transactionHistory.transactions.values.forEach((tx) async {
if (tx.unspents != null && tx.unspents!.isNotEmpty && tx.height > 0) {
@ -1821,6 +1816,19 @@ abstract class ElectrumWalletBase
static String _hardenedDerivationPath(String derivationPath) =>
derivationPath.substring(0, derivationPath.lastIndexOf("'") + 1);
@action
void _onConnectionStatusChange(bool? isConnected) {
if (syncStatus is SyncingSyncStatus) return;
if (isConnected == true && syncStatus is! SyncedSyncStatus) {
syncStatus = ConnectedSyncStatus();
} else if (isConnected == false) {
syncStatus = LostConnectionSyncStatus();
} else if (isConnected != true && syncStatus is! ConnectingSyncStatus) {
syncStatus = NotConnectedSyncStatus();
}
}
}
class ScanNode {

View file

@ -306,7 +306,7 @@ class CWBitcoin extends Bitcoin {
}
final electrumClient = ElectrumClient();
await electrumClient.connectToUri(node.uri);
await electrumClient.connectToUri(node.uri, useSSL: node.useSSL);
late BasedUtxoNetwork network;
btc.NetworkType networkType;
@ -560,10 +560,16 @@ class CWBitcoin extends Bitcoin {
}
final bitcoinWallet = wallet as ElectrumWallet;
final tweaksResponse = await bitcoinWallet.electrumClient.getTweaks(height: 0);
try {
final tweaksResponse = await bitcoinWallet.electrumClient.getTweaks(height: 0);
if (tweaksResponse != null) {
return true;
if (tweaksResponse != null) {
return true;
}
} on RequestFailedTimeoutException {
return false;
} catch (_) {
rethrow;
}
return false;

View file

@ -136,9 +136,11 @@ class RootState extends State<Root> with WidgetsBindingObserver {
break;
case AppLifecycleState.resumed:
widget.authService.requireAuth().then((value) {
setState(() {
_requestAuth = value;
});
if (mounted) {
setState(() {
_requestAuth = value;
});
}
});
break;
default:

View file

@ -118,25 +118,27 @@ class ExceptionHandler {
WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) async {
await showPopUp<void>(
context: navigatorKey.currentContext!,
builder: (context) {
return AlertWithTwoActions(
isDividerExist: true,
alertTitle: S.of(context).error,
alertContent: S.of(context).error_dialog_content,
rightButtonText: S.of(context).send,
leftButtonText: S.of(context).do_not_send,
actionRightButton: () {
Navigator.of(context).pop();
_sendExceptionFile();
},
actionLeftButton: () {
Navigator.of(context).pop();
},
);
},
);
if (navigatorKey.currentContext != null) {
await showPopUp<void>(
context: navigatorKey.currentContext!,
builder: (context) {
return AlertWithTwoActions(
isDividerExist: true,
alertTitle: S.of(context).error,
alertContent: S.of(context).error_dialog_content,
rightButtonText: S.of(context).send,
leftButtonText: S.of(context).do_not_send,
actionRightButton: () {
Navigator.of(context).pop();
_sendExceptionFile();
},
actionLeftButton: () {
Navigator.of(context).pop();
},
);
},
);
}
_hasError = false;
},

View file

@ -197,7 +197,7 @@
"descending": "النزول",
"description": "ﻒﺻﻭ",
"destination_tag": "علامة الوجهة:",
"dfx_option_description": "ﺎﺑﻭﺭﻭﺃ ﻲﻓ ﺕﺎﻛﺮﺸﻟﺍﻭ ﺔﺋﺰﺠﺘﻟﺍ ءﻼﻤﻌﻟ .ﻲﻓﺎﺿﺇ KYC ﻥﻭﺪﺑ ﻭﺭﻮﻳ 990 ﻰﻟﺇ ﻞﺼﻳ ﺎﻣ .ﻱﺮﺴﻳﻮﺴﻟﺍ",
"dfx_option_description": "شراء التشفير مع EUR & CHF. لعملاء البيع بالتجزئة والشركات في أوروبا",
"didnt_get_code": "لم تحصل على رمز؟",
"digit_pin": "-رقم PIN",
"digital_and_physical_card": " بطاقة ائتمان رقمية ومادية مسبقة الدفع",

View file

@ -197,7 +197,7 @@
"descending": "Низходящ",
"description": "Описание",
"destination_tag": "Destination tag:",
"dfx_option_description": "Купете крипто с EUR и CHF. До 990 € без допълнителен KYC. За клиенти на дребно и корпоративни клиенти в Европа",
"dfx_option_description": "Купете криптовалута с Eur & CHF. За търговски и корпоративни клиенти в Европа",
"didnt_get_code": "Не получихте код?",
"digit_pin": "-цифрен PIN",
"digital_and_physical_card": " дигитална или физическа предплатена дебитна карта",

View file

@ -197,7 +197,7 @@
"descending": "Klesající",
"description": "Popis",
"destination_tag": "Destination Tag:",
"dfx_option_description": "Nakupujte kryptoměny za EUR a CHF. Až 990 € bez dalších KYC. Pro maloobchodní a firemní zákazníky v Evropě",
"dfx_option_description": "Koupit krypto s EUR & CHF. Pro maloobchodní a firemní zákazníky v Evropě",
"didnt_get_code": "Nepřišel Vám kód?",
"digit_pin": "-číselný PIN",
"digital_and_physical_card": " digitální a fyzické předplacené debetní karty,",

View file

@ -197,7 +197,7 @@
"descending": "Absteigend",
"description": "Beschreibung",
"destination_tag": "Ziel-Tag:",
"dfx_option_description": "Krypto mit EUR und CHF kaufen. Bis zu 990€ ohne zusätzliches KYC. Für Privat- und Firmenkunden in Europa",
"dfx_option_description": "Kaufen Sie Krypto mit EUR & CHF. Für Einzelhandel und Unternehmenskunden in Europa",
"didnt_get_code": "Kein Code?",
"digit_pin": "-stellige PIN",
"digital_and_physical_card": "digitale und physische Prepaid-Debitkarte",

View file

@ -197,7 +197,7 @@
"descending": "Descending",
"description": "Description",
"destination_tag": "Destination tag:",
"dfx_option_description": "Buy crypto with EUR & CHF. Up to 990€ without additional KYC. For retail and corporate customers in Europe",
"dfx_option_description": "Buy crypto with EUR & CHF. For retail and corporate customers in Europe",
"didnt_get_code": "Didn't get code?",
"digit_pin": "-digit PIN",
"digital_and_physical_card": " digital and physical prepaid debit card",

View file

@ -197,7 +197,7 @@
"descending": "Descendente",
"description": "Descripción",
"destination_tag": "Etiqueta de destino:",
"dfx_option_description": "Compre criptomonedas con EUR y CHF. Hasta 990€ sin KYC adicional. Para clientes minoristas y corporativos en Europa",
"dfx_option_description": "Compre criptografía con EUR y CHF. Para clientes minoristas y corporativos en Europa",
"didnt_get_code": "¿No recibiste el código?",
"digit_pin": "-dígito PIN",
"digital_and_physical_card": " tarjeta de débito prepago digital y física",

View file

@ -197,7 +197,7 @@
"descending": "Descendant",
"description": "Description",
"destination_tag": "Tag de destination :",
"dfx_option_description": "Achetez des crypto-monnaies avec EUR et CHF. Jusqu'à 990€ sans KYC supplémentaire. Pour les clients particuliers et entreprises en Europe",
"dfx_option_description": "Achetez de la crypto avec EUR & CHF. Pour les clients de la vente au détail et des entreprises en Europe",
"didnt_get_code": "Vous n'avez pas reçu le code ?",
"digit_pin": " chiffres",
"digital_and_physical_card": "carte de débit prépayée numérique et physique",

View file

@ -197,7 +197,7 @@
"descending": "Saukowa",
"description": "Bayani",
"destination_tag": "Tambarin makoma:",
"dfx_option_description": "Sayi crypto tare da EUR & CHF. Har zuwa € 990 ba tare da ƙarin KYC ba. Don 'yan kasuwa da abokan ciniki na kamfanoni a Turai",
"dfx_option_description": "Buy crypto tare da Eur & Chf. Don Retail da abokan ciniki na kamfanoni a Turai",
"didnt_get_code": "Ba a samun code?",
"digit_pin": "-lambar PIN",
"digital_and_physical_card": "katin zare kudi na dijital da na zahiri",

View file

@ -197,7 +197,7 @@
"descending": "अवरोही",
"description": "विवरण",
"destination_tag": "गंतव्य टैग:",
"dfx_option_description": "EUR और CHF के साथ क्रिप्टो खरीदें। अतिरिक्त केवाईसी के बिना 990€ तक। यूरोप में खुदरा और कॉर्पोरेट ग्राहकों के लिए",
"dfx_option_description": "EUR और CHF के साथ क्रिप्टो खरीदें। यूरोप में खुदरा और कॉर्पोरेट ग्राहकों के लिए",
"didnt_get_code": "कोड नहीं मिला?",
"digit_pin": "-अंक पिन",
"digital_and_physical_card": "डिजिटल और भौतिक प्रीपेड डेबिट कार्ड",

View file

@ -197,7 +197,7 @@
"descending": "Silazni",
"description": "Opis",
"destination_tag": "Odredišna oznaka:",
"dfx_option_description": "Kupujte kripto s EUR i CHF. Do 990 € bez dodatnog KYC-a. Za maloprodajne i poslovne korisnike u Europi",
"dfx_option_description": "Kupite kriptovalute s Eur & CHF. Za maloprodajne i korporativne kupce u Europi",
"didnt_get_code": "Ne dobivate kod?",
"digit_pin": "-znamenkasti PIN",
"digital_and_physical_card": "digitalna i fizička unaprijed plaćena debitna kartica",

View file

@ -197,7 +197,7 @@
"descending": "Menurun",
"description": "Keterangan",
"destination_tag": "Tag tujuan:",
"dfx_option_description": "Beli kripto dengan EUR & CHF. Hingga 990€ tanpa KYC tambahan. Untuk pelanggan ritel dan korporat di Eropa",
"dfx_option_description": "Beli crypto dengan EUR & CHF. Untuk pelanggan ritel dan perusahaan di Eropa",
"didnt_get_code": "Tidak mendapatkan kode?",
"digit_pin": "-digit PIN",
"digital_and_physical_card": " kartu debit pra-bayar digital dan fisik",

View file

@ -198,7 +198,7 @@
"descending": "Discendente",
"description": "Descrizione",
"destination_tag": "Tag destinazione:",
"dfx_option_description": "Acquista criptovalute con EUR e CHF. Fino a 990€ senza KYC aggiuntivi. Per clienti al dettaglio e aziendali in Europa",
"dfx_option_description": "Acquista Crypto con EUR & CHF. Per i clienti al dettaglio e aziendali in Europa",
"didnt_get_code": "Non ricevi il codice?",
"digit_pin": "-cifre PIN",
"digital_and_physical_card": "carta di debito prepagata digitale e fisica",

View file

@ -197,7 +197,7 @@
"descending": "下降",
"description": "説明",
"destination_tag": "宛先タグ:",
"dfx_option_description": "EUR と CHF で暗号通貨を購入します。追加のKYCなしで最大990ユーロ。ヨーロッパの小売および法人顧客向け",
"dfx_option_description": "EURCHFで暗号を購入します。ヨーロッパの小売および企業の顧客向け",
"didnt_get_code": "コードを取得しませんか?",
"digit_pin": "桁ピン",
"digital_and_physical_card": "デジタルおよび物理プリペイドデビットカード",

View file

@ -197,7 +197,7 @@
"descending": "내림차순",
"description": "설명",
"destination_tag": "목적지 태그:",
"dfx_option_description": "EUR 및 CHF로 암호화폐를 구매하세요. 추가 KYC 없이 최대 990€. 유럽의 소매 및 기업 고객용",
"dfx_option_description": "EUR & CHF로 암호화를 구입하십시오. 유럽의 소매 및 기업 고객을 위해",
"didnt_get_code": "코드를 받지 못하셨습니까?",
"digit_pin": "숫자 PIN",
"digital_and_physical_card": " 디지털 및 실제 선불 직불 카드",

View file

@ -197,7 +197,7 @@
"descending": "ဆင်း",
"description": "ဖော်ပြချက်",
"destination_tag": "ခရီးဆုံးအမှတ်-",
"dfx_option_description": "EUR & CHF ဖြင့် crypto ကိုဝယ်ပါ။ အပို KYC မပါဘဲ 990€ အထိ။ ဥရောပရှိ လက်လီရောင်းချသူများနှင့် ကော်ပိုရိတ်ဖောက်သည်များအတွက်",
"dfx_option_description": "Crypto ကို EUR & CHF ဖြင့် 0 ယ်ပါ။ လက်လီရောင်းဝယ်မှုနှင့်ဥရောပရှိကော်ပိုရိတ်ဖောက်သည်များအတွက်",
"didnt_get_code": "ကုဒ်ကို မရဘူးလား?",
"digit_pin": "-ဂဏန်း PIN",
"digital_and_physical_card": " ဒစ်ဂျစ်တယ်နှင့် ရုပ်ပိုင်းဆိုင်ရာ ကြိုတင်ငွေပေးချေသော ဒက်ဘစ်ကတ်",

View file

@ -197,7 +197,7 @@
"descending": "Aflopend",
"description": "Beschrijving",
"destination_tag": "Bestemmingstag:",
"dfx_option_description": "Koop crypto met EUR & CHF. Tot 990€ zonder extra KYC. Voor particuliere en zakelijke klanten in Europa",
"dfx_option_description": "Koop crypto met EUR & CHF. Voor retail- en zakelijke klanten in Europa",
"didnt_get_code": "Geen code?",
"digit_pin": "-cijferige PIN",
"digital_and_physical_card": "digitale en fysieke prepaid debetkaart",

View file

@ -197,7 +197,7 @@
"descending": "Schodzenie",
"description": "Opis",
"destination_tag": "Tag docelowy:",
"dfx_option_description": "Kupuj kryptowaluty za EUR i CHF. Do 990 € bez dodatkowego KYC. Dla klientów detalicznych i korporacyjnych w Europie",
"dfx_option_description": "Kup krypto z EUR & CHF. Dla klientów detalicznych i korporacyjnych w Europie",
"didnt_get_code": "Nie dostałeś kodu?",
"digit_pin": "-znakowy PIN",
"digital_and_physical_card": " cyfrowa i fizyczna przedpłacona karta debetowa",

View file

@ -197,7 +197,7 @@
"descending": "descendente",
"description": "Descrição",
"destination_tag": "Tag de destino:",
"dfx_option_description": "Compre criptografia com EUR e CHF. Até 990€ sem KYC adicional. Para clientes de varejo e corporativos na Europa",
"dfx_option_description": "Compre criptografia com EUR & CHF. Para clientes de varejo e corporativo na Europa",
"didnt_get_code": "Não recebeu o código?",
"digit_pin": "dígitos",
"digital_and_physical_card": "cartão de débito pré-pago digital e físico",

View file

@ -197,7 +197,7 @@
"descending": "Нисходящий",
"description": "Описание",
"destination_tag": "Целевой тег:",
"dfx_option_description": "Покупайте криптовалюту за EUR и CHF. До 990€ без дополнительного KYC. Для розничных и корпоративных клиентов в Европе",
"dfx_option_description": "Купить крипто с Eur & CHF. Для розничных и корпоративных клиентов в Европе",
"didnt_get_code": "Не получить код?",
"digit_pin": "-значный PIN",
"digital_and_physical_card": "цифровая и физическая предоплаченная дебетовая карта",

View file

@ -197,7 +197,7 @@
"descending": "ลงมา",
"description": "คำอธิบาย",
"destination_tag": "แท็กปลายทาง:",
"dfx_option_description": "ซื้อ crypto ด้วย EUR และ CHF สูงถึง 990€ โดยไม่มี KYC เพิ่มเติม สำหรับลูกค้ารายย่อยและลูกค้าองค์กรในยุโรป",
"dfx_option_description": "ซื้อ crypto ด้วย Eur & CHF สำหรับลูกค้ารายย่อยและลูกค้าในยุโรป",
"didnt_get_code": "ไม่ได้รับรหัส?",
"digit_pin": "-หลัก PIN",
"digital_and_physical_card": "บัตรเดบิตดิจิตอลและบัตรพื้นฐาน",

View file

@ -197,7 +197,7 @@
"descending": "Pababang",
"description": "Paglalarawan",
"destination_tag": "Tag ng patutunguhan:",
"dfx_option_description": "Bumili ng crypto gamit ang EUR at CHF. Hanggang 990€ nang walang karagdagang KYC. Para sa retail at corporate na mga customer sa Europe",
"dfx_option_description": "Bumili ng crypto kasama ang EUR & CHF. Para sa mga customer at corporate customer sa Europa",
"didnt_get_code": "Hindi nakuha ang code?",
"digit_pin": "-digit pin",
"digital_and_physical_card": "Digital at Physical Prepaid Debit Card",

View file

@ -197,7 +197,7 @@
"descending": "Azalan",
"description": "Tanım",
"destination_tag": "Hedef Etiketi:",
"dfx_option_description": "EUR ve CHF ile kripto satın alın. Ek KYC olmadan 990 €'ya kadar. Avrupa'daki perakende ve kurumsal müşteriler için",
"dfx_option_description": "Eur & chf ile kripto satın alın. Avrupa'daki perakende ve kurumsal müşteriler için",
"didnt_get_code": "Kod gelmedi mi?",
"digit_pin": " haneli PIN",
"digital_and_physical_card": " Dijital para birimleri ile para yükleyebileceğiniz ve ek bilgiye gerek olmayan",

View file

@ -197,7 +197,7 @@
"descending": "Низхідний",
"description": "опис",
"destination_tag": "Тег призначення:",
"dfx_option_description": "Купуйте криптовалюту за EUR і CHF. До 990 євро без додаткового KYC. Для роздрібних і корпоративних клієнтів у Європі",
"dfx_option_description": "Купуйте криптовалюту з EUR & CHF. Для роздрібних та корпоративних клієнтів у Європі",
"didnt_get_code": "Не отримуєте код?",
"digit_pin": "-значний PIN",
"digital_and_physical_card": " цифрова та фізична передплачена дебетова картка",

View file

@ -197,7 +197,7 @@
"descending": "اترتے ہوئے",
"description": "ﻞﯿﺼﻔﺗ",
"destination_tag": "منزل کا ٹیگ:",
"dfx_option_description": "EUR ﺭﻭﺍ CHF ﯽﻓﺎﺿﺍ ۔ﮟﯾﺪﯾﺮﺧ ﻮﭩﭘﺮﮐ ﮫﺗﺎﺳ ﮯﮐ KYC ﮯﯿﻟ ﮯﮐ ﻦﯿﻓﺭﺎﺻ ﭧﯾﺭﻮﭘﺭﺎﮐ ﺭﻭﺍ ﮦﺩﺭﻮﺧ ﮟ",
"dfx_option_description": "یورو اور سی ایچ ایف کے ساتھ کرپٹو خریدیں۔ یورپ میں خوردہ اور کارپوریٹ صارفین کے لئے",
"didnt_get_code": "کوڈ نہیں ملتا؟",
"digit_pin": "-ہندسوں کا پن",
"digital_and_physical_card": " ڈیجیٹل اور فزیکل پری پیڈ ڈیبٹ کارڈ",

View file

@ -197,7 +197,7 @@
"descending": "Sọkalẹ",
"description": "Apejuwe",
"destination_tag": "Orúkọ tí ìbí tó a ránṣẹ́ sí:",
"dfx_option_description": "Ra crypto pẹlu EUR & CHF. Titi di 990 € laisi afikun KYC. Fun soobu ati awọn onibara ile-iṣẹ ni Yuroopu",
"dfx_option_description": "Ra Crypto pẹlu EUR & CHF. Fun soobu ati awọn alabara ile-iṣẹ ni Yuroopu",
"didnt_get_code": "Ko gba koodu?",
"digit_pin": "-díjíìtì òǹkà ìdánimọ̀ àdáni",
"digital_and_physical_card": " káàdì ìrajà t'ara àti ti ayélujára",

View file

@ -197,7 +197,7 @@
"descending": "下降",
"description": "描述",
"destination_tag": "目标Tag:",
"dfx_option_description": "用欧元和瑞士法郎购买加密货币。高达 990 欧元,无需额外 KYC。对于欧洲的零售和企业客户",
"dfx_option_description": "用EurChf购买加密货币。对于欧洲的零售和企业客户",
"didnt_get_code": "没有获取代码?",
"digit_pin": "位 PIN",
"digital_and_physical_card": "数字和物理预付借记卡",