aboutsummaryrefslogtreecommitdiffstats
path: root/names
diff options
context:
space:
mode:
Diffstat (limited to 'names')
-rw-r--r--names/ownership.js10
-rw-r--r--names/server.js6
2 files changed, 12 insertions, 4 deletions
diff --git a/names/ownership.js b/names/ownership.js
new file mode 100644
index 0000000..19ae4ef
--- /dev/null
+++ b/names/ownership.js
@@ -0,0 +1,10 @@
+// A migration grant names the identity that owns the address. Its manager
+// may submit the registration without becoming that identity.
+export function registrationIdentity({ existing, signer, manager, grant, granted }) {
+ const pubkey = existing?.pubkey || (granted ? grant.pubkey : signer);
+ const nominated = /^[0-9a-f]{64}$/.test(manager || '') && manager !== pubkey;
+ return {
+ pubkey,
+ manager: nominated ? manager : existing?.manager || (granted ? grant.manager : undefined),
+ };
+}
diff --git a/names/server.js b/names/server.js
index ed44ad3..97ac662 100644
--- a/names/server.js
+++ b/names/server.js
@@ -31,6 +31,7 @@ import { decodeAddress } from '../src/ark/proto.js';
import { decodeNoffer } from '../src/noffer.js';
import { decodeBolt11 } from '../src/ark/lightning.js';
import { decodeOffer } from '../src/bolt12.js';
+import { registrationIdentity } from './ownership.js';
const CFG = JSON.parse(readFileSync(process.env.NAMES_CONFIG
|| join(import.meta.dir, 'config.json'), 'utf8'));
@@ -1624,10 +1625,7 @@ Bun.serve({
const recordId = await cfWrite(name, domain, published, existing?.recordId);
state.names[key] = {
- pubkey: existing?.pubkey || auth.pubkey,
- // the owner may nominate a key that manages the record from here on
- manager: (claim.manager && /^[0-9a-f]{64}$/.test(claim.manager) && auth.pubkey !== claim.manager)
- ? claim.manager : existing?.manager,
+ ...registrationIdentity({ existing, signer: auth.pubkey, manager: claim.manager, grant, granted }),
uri: published, recordId, updated: Date.now(), domain,
// the wallet's CLINK offer key, so LNURL can ask it for invoices
offerPk: (claim.offerPk && /^[0-9a-f]{64}$/.test(claim.offerPk)) ? claim.offerPk : existing?.offerPk,