mirror of
https://github.com/tompro/sattle.git
synced 2026-08-27 07:15:59 +00:00
fix: discover a mint's signing key from the mint-address endpoint, not the payRequest
This commit is contained in:
@@ -8,9 +8,11 @@ import { createFreshWallet } from '../helpers/wallet';
|
|||||||
// registry accepts
|
// registry accepts
|
||||||
const MINT_PUBKEY = `02${'ab'.repeat(32)}`;
|
const MINT_PUBKEY = `02${'ab'.repeat(32)}`;
|
||||||
|
|
||||||
// the payRequest discovery behind a one-tap suggestion: the app resolves
|
// the discovery behind a one-tap suggestion: the app resolves
|
||||||
// "@mint.600.wtf" to https://mint.600.wtf/.well-known/lnurlp/mint and reads
|
// "@mint.600.wtf" to https://mint.600.wtf/.well-known/lnurlp/mint, derives
|
||||||
// the mint's signing key out of the response
|
// the mint-address endpoint (/.well-known/lnurlw/mint) and reads the
|
||||||
|
// signing key there - the payRequest deliberately does NOT carry
|
||||||
|
// mintPubkey (LUD-25 advertises it on the withdraw side only)
|
||||||
const mockSuggestionMint = async (page: Page): Promise<void> => {
|
const mockSuggestionMint = async (page: Page): Promise<void> => {
|
||||||
const fulfill = async (route: import('@playwright/test').Route, body: unknown) => {
|
const fulfill = async (route: import('@playwright/test').Route, body: unknown) => {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
@@ -20,9 +22,15 @@ const mockSuggestionMint = async (page: Page): Promise<void> => {
|
|||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// no mint-address discovery support - the app falls back to the LNURL-pay
|
await page.route(/^https:\/\/mint\.600\.wtf\/\.well-known\/lnurlw\/mint/, (route) =>
|
||||||
await page.route(/^https:\/\/mint\.600\.wtf\/\.well-known\/lnurlw\//, (route) =>
|
fulfill(route, {
|
||||||
fulfill(route, { status: 'ERROR', reason: 'not supported' }),
|
tag: 'withdrawRequest',
|
||||||
|
callback: 'https://mint.600.wtf/w',
|
||||||
|
minWithdrawable: 1000,
|
||||||
|
maxWithdrawable: 100_000_000_000,
|
||||||
|
mintPubkey: MINT_PUBKEY,
|
||||||
|
payLink: 'https://mint.600.wtf/.well-known/lnurlp/mint',
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
await page.route(/^https:\/\/mint\.600\.wtf\/\.well-known\/lnurlp\/mint/, (route) =>
|
await page.route(/^https:\/\/mint\.600\.wtf\/\.well-known\/lnurlp\/mint/, (route) =>
|
||||||
fulfill(route, {
|
fulfill(route, {
|
||||||
@@ -31,7 +39,6 @@ const mockSuggestionMint = async (page: Page): Promise<void> => {
|
|||||||
minSendable: 1000,
|
minSendable: 1000,
|
||||||
maxSendable: 100_000_000_000,
|
maxSendable: 100_000_000_000,
|
||||||
withdrawLink: 'https://mint.600.wtf/note',
|
withdrawLink: 'https://mint.600.wtf/note',
|
||||||
mintPubkey: MINT_PUBKEY,
|
|
||||||
metadata: '[]',
|
metadata: '[]',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -291,13 +291,18 @@ const trustSuggestion = async (address: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const info = await fetchPayRequest(payUrl);
|
const info = await fetchPayRequest(payUrl);
|
||||||
if (!info.mintPubkey) {
|
// the signing key is announced on the mint-address (lnurlw discovery)
|
||||||
|
// response, not the payRequest: per the reference mint (lnurl-mint) a
|
||||||
|
// wallet paying the mint invoice recovers the node id from the invoice
|
||||||
|
// itself, so LUD-25 advertises mintPubkey on the withdraw side only
|
||||||
|
const announcedKey = nodeInfo?.nodePubkey ?? info.mintPubkey;
|
||||||
|
if (!announcedKey) {
|
||||||
throw new Error("This mint didn't announce its signing key - add it manually instead.");
|
throw new Error("This mint didn't announce its signing key - add it manually instead.");
|
||||||
}
|
}
|
||||||
const server = serverOf(payUrl);
|
const server = serverOf(payUrl);
|
||||||
const result = mints.trust(
|
const result = mints.trust(
|
||||||
server,
|
server,
|
||||||
info.mintPubkey,
|
announcedKey,
|
||||||
mintAddressCacheInfo(nodeInfo, lightningAddressUsername(payUrl)),
|
mintAddressCacheInfo(nodeInfo, lightningAddressUsername(payUrl)),
|
||||||
);
|
);
|
||||||
trustResult(result, server);
|
trustResult(result, server);
|
||||||
|
|||||||
Reference in New Issue
Block a user