aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routes/users.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/routes/users.ts b/routes/users.ts
index 8d67444d..3fe9077a 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -959,7 +959,7 @@ export default {
async updateAccount(req, res) {
const { id } = req.params;
const { id: uid } = req.user;
- const { name, autowithdraw, threshold, reserve, destination, currency } =
+ const { name, autowithdraw, threshold, reserve, destination, currency, fingerprint, pubkey } =
req.body;
const pos = await db.lPos(`${uid}:accounts`, id);
@@ -972,8 +972,25 @@ export default {
if (reserve !== undefined) account.reserve = reserve;
if (destination !== undefined) account.destination = destination.trim();
if (currency !== undefined) account.currency = currency;
+
+ let needsImport = false;
+ if (fingerprint !== undefined && pubkey !== undefined) {
+ account.fingerprint = fingerprint;
+ account.pubkey = pubkey;
+ account.importedAt = null;
+ needsImport = true;
+ }
+
await s(`account:${id}`, account);
+ if (needsImport) {
+ importAccountHistory(account).then(() => {
+ emit(uid, "payment", { aid: id, type: "import" });
+ }).catch((e) =>
+ console.error("importAccountHistory failed:", e.message),
+ );
+ }
+
res.send(account);
},