mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-17 09:46:39 +01:00
CWA-69 | created formatDomainName() and fetchXmrAddress() in the openalias.dart. Added openalias to send page
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user