pull down to refresh
21 sats \ 3 replies \ @justin_shocknet 14h \ parent \ on: Implementing CLINK Static Offers nostr
Couldn't repro, but we did just bump the SDK to address some potential
To mitigate a possible a version mismatch between with nostr-tools gen secret, I updated the example to use the clink wrapped nostr-tools... i dont think this was the problem though otherwise the log would show an error about it
Potentially are race with clock skew since the sub is set up after the request, moved that around just in case
Update CLINK to 1.5.1
NPM registry seems to not be rendering the readme yet, but its on github... pasting it here jic
I noticed the example is using SendNofferRequest while the NPM snippet is using sdk.Noffer. Does that matter?
const handleGetInvoice = async () => {
if (!decodedOffer) {
alert("Offer data is missing. Please decode a new offer first.");
return;
}
nofferInput.disabled = true;
offerActions.style.display = 'none';
resultHeader.textContent = 'Invoice';
resultData.textContent = 'Requesting invoice...';
try {
const amountSats = amountInput.value ? parseInt(amountInput.value, 10) : undefined;
// Use the CLINK SDK to send a request for an invoice from the offer provider.
// This request is sent over Nostr and signed with our ephemeral client key.
const response = await SendNofferRequest(
pool, clientPrivateKey, [decodedOffer.relay], decodedOffer.pubkey,
{ offer: decodedOffer.offer, amount_sats: amountSats }
);
if ('bolt11' in response && typeof response.bolt11 === 'string') {
resultData.textContent = response.bolt11;
qrCanvas.style.display = 'block';
QRCode.toCanvas(qrCanvas, response.bolt11.toUpperCase(), { width: 256, margin: 1 });
} else {
resultHeader.textContent = 'Error Response';
resultData.textContent = JSON.stringify(response, null, 2);
}
} catch (error) {
console.error("Error getting invoice:", error);
resultHeader.textContent = 'Error';
resultData.textContent = `Error: ${error instanceof Error ? error.message : String(error)}`;
} finally {
isInvoiceDisplayed = true;
decodeOfferButton.textContent = 'Reset';
decodeOfferButton.style.display = 'block';
scrollIntoView();
}
};
reply
Shouldn't matter, they're the same... sdk one just handle creating the pool
reply
Hmm ok. I’ll try a bit more later and keep you posted.
reply