renew mapping
This commit is contained in:
parent
cf4c3ecbfd
commit
d83126755b
|
@ -359,6 +359,9 @@ export class WalletRPC {
|
|||
params.backup_owner || ""
|
||||
);
|
||||
break;
|
||||
case "lns_renew_mapping":
|
||||
this.lnsRenewMapping(params.password, params.type, params.name);
|
||||
break;
|
||||
case "lns_known_names":
|
||||
console.log("LNS known records case");
|
||||
this.lnsKnownNames();
|
||||
|
@ -1092,6 +1095,81 @@ export class WalletRPC {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Renews an LNS (Lokinet) mapping, since they can expire
|
||||
type can be:
|
||||
lokinet_1y, lokinet_2y, lokinet_5y, lokinet_10y
|
||||
*/
|
||||
lnsRenewMapping(password, type, name) {
|
||||
console.log("Lns renew mapping called with type and name:");
|
||||
console.log(type, name);
|
||||
let _name = name.trim().toLowerCase();
|
||||
|
||||
// the RPC accepts names with the .loki already appeneded only
|
||||
// can be lokinet_1y, lokinet_2y, lokinet_5y, lokinet_10y
|
||||
if (type.startsWith("lokinet")) {
|
||||
_name = _name + ".loki";
|
||||
}
|
||||
|
||||
crypto.pbkdf2(
|
||||
password,
|
||||
this.auth[2],
|
||||
1000,
|
||||
64,
|
||||
"sha512",
|
||||
(err, password_hash) => {
|
||||
if (err) {
|
||||
this.sendGateway("set_lns_status", {
|
||||
code: -1,
|
||||
i18n: "notification.errors.internalError",
|
||||
sending: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.isValidPasswordHash(password_hash)) {
|
||||
this.sendGateway("set_lns_status", {
|
||||
code: -1,
|
||||
i18n: "notification.errors.invalidPassword",
|
||||
sending: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const params = {
|
||||
type,
|
||||
name: _name
|
||||
};
|
||||
|
||||
console.log("lns renew mapping about to be called");
|
||||
this.sendRPC("lns_renew_mapping", params).then(data => {
|
||||
if (data.hasOwnProperty("error")) {
|
||||
console.log("error");
|
||||
console.log(data);
|
||||
let error =
|
||||
data.error.message.charAt(0).toUpperCase() +
|
||||
data.error.message.slice(1);
|
||||
this.sendGateway("set_lns_status", {
|
||||
code: -1,
|
||||
message: error,
|
||||
sending: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.purchasedNames[name.trim()] = type;
|
||||
|
||||
setTimeout(() => this.updateLocalLNSRecords(), 5000);
|
||||
|
||||
this.sendGateway("set_lns_status", {
|
||||
code: 0,
|
||||
i18n: "notification.positive.nameRenewed",
|
||||
sending: false
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Get our LNS record and update our wallet state with decrypted values.
|
||||
This will return `null` if the record is not in our currently stored records.
|
||||
|
|
|
@ -98,6 +98,8 @@ export default {
|
|||
onSubmit(record, oldRecord) {
|
||||
if (this.updating) {
|
||||
this.update(record, oldRecord);
|
||||
} else if (this.renewing) {
|
||||
this.renew(record);
|
||||
} else {
|
||||
this.purchase(record);
|
||||
}
|
||||
|
@ -189,6 +191,38 @@ export default {
|
|||
})
|
||||
.onDismiss(() => {})
|
||||
.onCancel(() => {});
|
||||
},
|
||||
async renew(record) {
|
||||
console.log("renew the record");
|
||||
console.log(record);
|
||||
let passwordDialog = await this.showPasswordConfirmation({
|
||||
title: this.$t("dialog.renew.title"),
|
||||
noPasswordMessage: this.$t("dialog.renew.message"),
|
||||
ok: {
|
||||
label: this.$t("dialog.renew.ok"),
|
||||
color: "primary"
|
||||
},
|
||||
dark: this.theme == "dark",
|
||||
color: this.theme == "dark" ? "white" : "dark"
|
||||
});
|
||||
passwordDialog
|
||||
.onOk(password => {
|
||||
// if no password set
|
||||
password = password || "";
|
||||
this.$store.commit("gateway/set_lns_status", {
|
||||
code: 1,
|
||||
message: "Sending renew mapping transaction",
|
||||
sending: true
|
||||
});
|
||||
const params = {
|
||||
type: record.type,
|
||||
name: record.name,
|
||||
password
|
||||
};
|
||||
this.$gateway.send("wallet", "lns_renew_mapping", params);
|
||||
})
|
||||
.onDismiss(() => {})
|
||||
.onCancel(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -71,7 +71,6 @@ export default {
|
|||
};
|
||||
},
|
||||
mounted() {
|
||||
console.log("lns_known_names kicking off");
|
||||
this.$gateway.send("wallet", "lns_known_names");
|
||||
},
|
||||
computed: mapState({
|
||||
|
@ -147,13 +146,9 @@ export default {
|
|||
return "menuItems.copyAddress";
|
||||
},
|
||||
onUpdate(record) {
|
||||
console.log("update record");
|
||||
console.log(record);
|
||||
this.$emit("onUpdate", record);
|
||||
},
|
||||
onRenew(record) {
|
||||
console.log("renew lns record");
|
||||
console.log(record);
|
||||
this.$emit("onRenew", record);
|
||||
},
|
||||
decrypt() {
|
||||
|
@ -179,10 +174,7 @@ export default {
|
|||
|
||||
const name = this.name.trim();
|
||||
|
||||
console.log("setting gateway once call");
|
||||
this.$gateway.once("decrypt_record_result", data => {
|
||||
console.log("data returned from decrypt result");
|
||||
console.log(data);
|
||||
if (data.decrypted) {
|
||||
this.$q.notify({
|
||||
type: "positive",
|
||||
|
|
|
@ -113,6 +113,11 @@ export default {
|
|||
message: "Do you want to purchase the name?",
|
||||
ok: "PURCHASE"
|
||||
},
|
||||
renew: {
|
||||
title: "Renew name",
|
||||
message: "Do you want to renew the name?",
|
||||
ok: "RENEW"
|
||||
},
|
||||
registerServiceNode: {
|
||||
title: "Register service node",
|
||||
message: "Do you want to register the service node?",
|
||||
|
@ -307,6 +312,7 @@ export default {
|
|||
lnsRecordUpdated: "LNS Record was successfully updated",
|
||||
passwordUpdated: "Password updated",
|
||||
namePurchased: "Name successfully purchased",
|
||||
nameRenewed: "Name successfully renewed",
|
||||
nameCopied: "Name copied to clipboard",
|
||||
ownerCopied: "Owner copied to clipboard",
|
||||
qrCopied: "QR code copied to clipboard",
|
||||
|
|
Loading…
Reference in New Issue