mirror of
https://github.com/tompro/sattle.git
synced 2026-08-26 23:05:58 +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
|
||||
const MINT_PUBKEY = `02${'ab'.repeat(32)}`;
|
||||
|
||||
// the payRequest discovery behind a one-tap suggestion: the app resolves
|
||||
// "@mint.600.wtf" to https://mint.600.wtf/.well-known/lnurlp/mint and reads
|
||||
// the mint's signing key out of the response
|
||||
// the discovery behind a one-tap suggestion: the app resolves
|
||||
// "@mint.600.wtf" to https://mint.600.wtf/.well-known/lnurlp/mint, derives
|
||||
// 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 fulfill = async (route: import('@playwright/test').Route, body: unknown) => {
|
||||
await route.fulfill({
|
||||
@@ -20,9 +22,15 @@ const mockSuggestionMint = async (page: Page): Promise<void> => {
|
||||
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\//, (route) =>
|
||||
fulfill(route, { status: 'ERROR', reason: 'not supported' }),
|
||||
await page.route(/^https:\/\/mint\.600\.wtf\/\.well-known\/lnurlw\/mint/, (route) =>
|
||||
fulfill(route, {
|
||||
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) =>
|
||||
fulfill(route, {
|
||||
@@ -31,7 +39,6 @@ const mockSuggestionMint = async (page: Page): Promise<void> => {
|
||||
minSendable: 1000,
|
||||
maxSendable: 100_000_000_000,
|
||||
withdrawLink: 'https://mint.600.wtf/note',
|
||||
mintPubkey: MINT_PUBKEY,
|
||||
metadata: '[]',
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -291,13 +291,18 @@ const trustSuggestion = async (address: string) => {
|
||||
}
|
||||
}
|
||||
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.");
|
||||
}
|
||||
const server = serverOf(payUrl);
|
||||
const result = mints.trust(
|
||||
server,
|
||||
info.mintPubkey,
|
||||
announcedKey,
|
||||
mintAddressCacheInfo(nodeInfo, lightningAddressUsername(payUrl)),
|
||||
);
|
||||
trustResult(result, server);
|
||||
|
||||
Reference in New Issue
Block a user