aboutsummaryrefslogtreecommitdiffstats
path: root/tools/names-pay-page-link-test.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-23 09:22:47 -0700
committerAdam Soltys <[email protected]>2026-11-23 09:22:47 -0700
commit2cd42f811d33a74c3ca28094176c009c0388da9b (patch)
treeb2b4127f00cbd7fef990596e7f92511dbf308380 /tools/names-pay-page-link-test.js
parent7711115f1e2a7f8cd73017d548274d4fab9f3d86 (diff)
downloadcoinosv3-2cd42f811d33a74c3ca28094176c009c0388da9b.tar.gz
coinosv3-2cd42f811d33a74c3ca28094176c009c0388da9b.zip
A coinos name has a public pay page: v3.coinos.io/<name>/receive. "The old Coinos I could point this link onto my website give people the ability to Donate/Pay in Bitcoin and Lighting - https://coinos.io/JuryImagePro/receive - I'm not seeing an option to do this thru V3, am I missing something?" (JuryImagePro, relayed by Adam 2026-11-23). v3 had no page a visitor could pay a name from: tapping pay on a profile asks a visitor to sign in. /<name>/receive and /<name>/pay now open a small page of their own (dist/pay/index.html from src/pay-page.js, 39 KB, not the app): the name's face, a LNURL QR any Lightning wallet can pay with an amount picked there, the address to copy, and a form for a set amount and a note that makes an invoice (QR, copy, open in wallet). When coinos' node minted the invoice the page says Paid once it settles (LUD-21 verify, coinosv3-server e40c5eb); when the recipient's own wallet minted it, the page says to pay it from the wallet. ?amount= fills in the amount. Lightning only: a v3 name publishes no on-chain address. Receive → More options → Payment page shows the link with Copy and Open page. nginx on cs routes the two paths to the page; the service worker leaves them alone. New pay-page-test (set amount + note, Paid, no-verify invoice, minimum, unknown name) and names-pay-page-link-test pass; names-invoice-expiry, features-smoke and feature-registry-check pass.HEADmaster
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg
Diffstat (limited to 'tools/names-pay-page-link-test.js')
-rw-r--r--tools/names-pay-page-link-test.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/names-pay-page-link-test.js b/tools/names-pay-page-link-test.js
new file mode 100644
index 0000000..5e18a43
--- /dev/null
+++ b/tools/names-pay-page-link-test.js
@@ -0,0 +1,58 @@
+// Receive → More options → Payment page: the link to the name's public pay
+// page (v3.coinos.io/<name>/receive, see pay-page-test), to copy or open.
+// Run: bun tools/names-pay-page-link-test.js
+import assert from 'node:assert/strict';
+import puppeteer from './puppeteer.js';
+
+const app = await Bun.file('src/app.js').text();
+const domHelper = app.slice(app.indexOf('function h(tag,'), app.indexOf('// ---------------------------------------------------------------- morphing'));
+const entry = `
+import { namesFeature } from './src/features/names.js';
+${domHelper}
+const state = { names: { byDomain: { 'coinos.io': { name: 'alice', domain: 'coinos.io' } } } };
+const ui = { screen: 'wallet', namesMore: 'menu' };
+const wallet = { loadFeatureState: (k, d) => (k in state ? state[k] : d), saveFeatureState: (k, v) => { state[k] = v; }, nostrSign: async (e) => e, nostrPubkey: () => 'aa'.repeat(32), _cacheKey: () => 'w1' };
+const ctx = {
+ h, ui, wallet, render, toast: () => {}, copy: () => {}, copyBtn: (x, l) => h('button', { class: 'btn-sm' }, l), brandHeader: () => null, goBack: () => {}, setAccount: () => {},
+ hook(name, ...a) {
+ if (name === 'arkReady') return true;
+ if (name === 'arkMakeInvoice') return Promise.resolve({ invoice: 'lnbc10u1testinvoice', amountSat: a[0], expiresAt: Date.now() + (window.__life || 3600_000) });
+ return null;
+ },
+};
+const feature = namesFeature(ctx);
+function render() { document.querySelector('#app').replaceChildren(feature.receiveModes()[0].render(h('div', { class: 'seg' }))); }
+window.test = { render };
+render();
+`;
+const bundle = await Bun.build({
+ entrypoints: ['names-page-entry'], target: 'browser',
+ plugins: [{ name: 'names-page', setup(build) {
+ build.onResolve({ filter: /^names-page-entry$/ }, () => ({ path: 'entry', namespace: 'names-page' }));
+ build.onLoad({ filter: /.*/, namespace: 'names-page' }, () => ({ contents: entry, loader: 'js', resolveDir: process.cwd() }));
+ } }],
+});
+assert(bundle.success, bundle.logs.join('\n'));
+const html = `<!doctype html><meta charset="utf-8"><style>${await Bun.file('src/style.css').text()}</style><div id="app"></div><script type="module">${await bundle.outputs[0].text()}</script>`;
+const server = Bun.serve({ port: 0, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) });
+const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: true, args: ['--no-sandbox'] });
+const page = await browser.newPage();
+const errors = [];
+page.on('pageerror', (e) => errors.push(e.message));
+const pause = (ms) => new Promise((r) => setTimeout(r, ms));
+const check = (name, value, detail = '') => { assert(value, name + (detail ? ' — ' + detail : '')); console.log(' ✓ ' + name); };
+const text = () => page.evaluate(() => document.body.innerText.replace(/\s+/g, ' '));
+try {
+ await page.goto(server.url.href);
+ await page.waitForFunction(() => /Payment page/.test(document.body.innerText));
+ check('More options lists the payment page', /A link for your website/.test(await text()));
+ await page.evaluate(() => [...document.querySelectorAll('.item')].find((d) => /Payment page/.test(d.textContent)).click());
+ await pause(50);
+ check('...which shows the link for this name', /https:\/\/v3\.coinos\.io\/alice\/receive/.test(await text()), await text());
+ check('...with Copy and Open page', await page.evaluate(() => ['Copy', 'Open page'].every((l) => [...document.querySelectorAll('button')].some((b) => b.textContent.trim() === l))));
+ check('no page errors', !errors.length, errors.join(' | '));
+ console.log('\n✅ the payment page link is in More options');
+} finally {
+ await browser.close();
+ server.stop(true);
+}