mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 19:26:27 +00:00
CWA-69 | created formatDomainName() and fetchXmrAddress() in the openalias.dart. Added openalias to send page
This commit is contained in:
parent
fb10f17622
commit
df9418c799
5 changed files with 48 additions and 4 deletions
33
lib/src/domain/common/openalias.dart
Normal file
33
lib/src/domain/common/openalias.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
import 'package:basic_utils/basic_utils.dart';
|
||||
|
||||
String formatDomainName(String name) {
|
||||
if (!name.contains(".")) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return name.replaceAll("@", ".");
|
||||
}
|
||||
|
||||
Future<String> fetchXmrAddress(String name) async {
|
||||
String xmrAddress = "";
|
||||
|
||||
await DnsUtils.lookupRecord(name, RRecordType.TXT, dnssec: true).then((txtRecord) {
|
||||
if (txtRecord != null) {
|
||||
String record;
|
||||
|
||||
for (int i = 0; i < txtRecord.length; i++) {
|
||||
record = txtRecord[i].data;
|
||||
|
||||
if (record.contains("oa1:xmr") && record.contains("recipient_address")) {
|
||||
record = record.replaceAll('\"', "");
|
||||
xmrAddress = record.split(" ").where((item) => (item.contains("recipient_address")))
|
||||
.toString().replaceAll("recipient_address=", "").replaceAll("\;", "")
|
||||
.replaceAll("(", "").replaceAll(")", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return xmrAddress;
|
||||
}
|
|
@ -22,6 +22,7 @@ import 'package:cake_wallet/src/domain/common/calculate_estimated_fee.dart';
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/openalias.dart';
|
||||
|
||||
class SendPage extends BasePage {
|
||||
@override
|
||||
|
@ -358,6 +359,12 @@ class SendFormState extends State<SendForm> {
|
|||
// Hack. Don't ask me.
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
|
||||
final domainName = formatDomainName(_addressController.text);
|
||||
|
||||
if (domainName != "") {
|
||||
await fetchXmrAddress(domainName).then((address) => _addressController.text = address);
|
||||
}
|
||||
|
||||
if (_formKey.currentState.validate()) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
|
|
|
@ -43,6 +43,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
basic_utils:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: basic_utils
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -53,6 +53,7 @@ dependencies:
|
|||
cupertino_icons: ^0.1.2
|
||||
encrypt: ^4.0.0
|
||||
password: ^1.0.0
|
||||
basic_utils: ^1.0.8
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -342,9 +342,5 @@
|
|||
"incorrect_seed" : "입력하신 텍스트가 유효하지 않습니다.",
|
||||
|
||||
"biometric_auth_reason" : "지문을 스캔하여 인증",
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> 4848485be8cbc34cbec847abbb76dabd075841ae
|
||||
"version" : "버전 ${currentVersion}"
|
||||
}
|
Loading…
Reference in a new issue