lnurlcash-kit 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +13 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +13 -3
- package/llms.txt +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.1 - 2026-09-11
|
|
4
|
+
|
|
5
|
+
- `fetchNoteInfo` compares the mint's echoed `k1` with the one it asked
|
|
6
|
+
about as the note each names (`noteIdOf`), not as strings. One Part 2 note
|
|
7
|
+
has many valid `ck1`s: anyone can turn one into its high-S twin, and its
|
|
8
|
+
holder can re-sign, so a mint echoing another spelling of the same note
|
|
9
|
+
was reported as having handed back a different note. An echo that names no
|
|
10
|
+
note at all is still refused, and a Part 1 secret compares as it always did.
|
|
11
|
+
|
|
12
|
+
## 0.12.0 - 2026-09-11
|
|
13
|
+
|
|
14
|
+
**A Part 2 branch rooted in a Nostr key.**
|
|
15
|
+
|
|
16
|
+
- `deriveNostrCashSeed(secretKey)` and `deriveNostrAddressNode(secretKey,
|
|
17
|
+
host)`: a Part 2 address branch rooted in a Nostr identity key, for a holder
|
|
18
|
+
with no BIP-39 words. The seed is `HMAC-SHA256(key, "LNURLcash/nostr-seed")`
|
|
19
|
+
and the path from it is the reference wallet's. heartwood-esp32 derives the
|
|
20
|
+
same branch on the device, and `test/vectors/nostr-seed.json` is the file
|
|
21
|
+
both grade against.
|
|
22
|
+
- `deriveCashMaster(seed)`: the BIP-32 master node, exported beside
|
|
23
|
+
`deriveCashChild` for walking a path the kit does not name, such as
|
|
24
|
+
nsec-tree's `m/44'/1237'/727'/0'/0'`.
|
|
25
|
+
|
|
3
26
|
## 0.11.0 - 2026-09-11
|
|
4
27
|
|
|
5
28
|
**The wire calls take LUD-25 Part 2 notes.**
|
package/README.md
CHANGED
|
@@ -422,8 +422,19 @@ Three things worth knowing:
|
|
|
422
422
|
- **`i` is any uint32**, serialised as 4 bytes big-endian, never hardened.
|
|
423
423
|
lnurl-wallet and lnurl-mint agree on that; the spec does not say.
|
|
424
424
|
|
|
425
|
-
`
|
|
426
|
-
|
|
425
|
+
The tests grade against lnurlcash-conformance's `vectors/part2.json`, built
|
|
426
|
+
from the primitives there and identical to vectors generated from lnurl-wallet
|
|
427
|
+
and checked against lnurl-mint.
|
|
428
|
+
|
|
429
|
+
**A branch rooted in a Nostr key.** A holder with no BIP-39 words, such as a
|
|
430
|
+
hardware signer that keeps only its identity key, or a wallet that never made
|
|
431
|
+
any, can still be paid to keys of its own. `deriveNostrAddressNode(secretKey,
|
|
432
|
+
host)` takes the branch from the key that owns the lightning address:
|
|
433
|
+
`HMAC-SHA256(key = secret key, msg = "LNURLcash/nostr-seed")`, then the path
|
|
434
|
+
above unchanged. heartwood-esp32 derives exactly this on the device, graded
|
|
435
|
+
against the same values as conformance's `vectors/nostr-seed.json`, so its notes come back from
|
|
436
|
+
its nsec (or the phrase the nsec came from) without the device. This is ours,
|
|
437
|
+
not LUD-25's; a mint sees an ordinary `cx1` either way.
|
|
427
438
|
|
|
428
439
|
## Minting a note you named yourself
|
|
429
440
|
|
package/dist/index.d.ts
CHANGED
|
@@ -262,6 +262,7 @@ type CashNode = {
|
|
|
262
262
|
chainCode: Uint8Array;
|
|
263
263
|
};
|
|
264
264
|
declare const deriveCashChild: (node: CashNode, index: number) => CashNode;
|
|
265
|
+
declare const deriveCashMaster: (seed: Uint8Array) => CashNode;
|
|
265
266
|
declare const deriveCashRoot: (seed: Uint8Array) => CashNode;
|
|
266
267
|
declare const cashDomainIndices: (root: CashNode, host: string) => number[];
|
|
267
268
|
declare const deriveCashDomainNode: (root: CashNode, host: string) => CashNode;
|
|
@@ -297,6 +298,9 @@ declare const noteIdOf: (k1: string) => string | null;
|
|
|
297
298
|
declare const noteLookupOf: (k1: string) => string | null;
|
|
298
299
|
declare const deriveCashAddressNode: (root: CashNode, host: string) => CashNode;
|
|
299
300
|
declare const cashNodeToCx1: (node: CashNode) => Cx1;
|
|
301
|
+
declare const NOSTR_CASH_SEED_LABEL = "LNURLcash/nostr-seed";
|
|
302
|
+
declare const deriveNostrCashSeed: (secretKey: Uint8Array) => Uint8Array;
|
|
303
|
+
declare const deriveNostrAddressNode: (secretKey: Uint8Array, host: string) => CashNode;
|
|
300
304
|
|
|
301
305
|
declare const PAYMENT_REQUEST_PREFIX = "lnurlcashreq1";
|
|
302
306
|
type PaymentRequestMethodDetails = {
|
|
@@ -405,4 +409,4 @@ declare const createClient: (options?: LnurlcashOptions) => {
|
|
|
405
409
|
};
|
|
406
410
|
type LnurlcashClient = ReturnType<typeof createClient>;
|
|
407
411
|
|
|
408
|
-
export { AmbiguousMintError, AmbiguousMutationError, type BoundMintCommitment, type CashNode, type Cx1, type DecodeOptions, HashLookupUnsupportedError, type HashedMutationResult, type HashedSplitResult, InsufficientValueError, type InvoiceRequestOptions, type InvoiceResult, type LnurlcashClient, LnurlcashError, type LnurlcashOptions, type MeltResult, type MintAddressInfo, type MintClaim, type MintContact, type MintFee, type MintFeeBand, type NoteInfoByHash, type NoteScheme, NoteSpentError, NoteUnknownError, PAYMENT_REQUEST_PREFIX, type PayRequestInfo, type PaymentRequest, type PaymentRequestMethodDetails, PendingNoteError, ProtocolError, type RandomSecret, RequestRefusedError, type RestoreOptions, type RestoreResult, type RestoredNote, type RotateResult, type SeedRestoreOptions, type SeedRestoreResult, ServiceRejectedError, type SettleForValueOptions, type SettledForValue, type SettledNote, type SignatureCheck, type SplitResult, type UnresolvedIndex, UnverifiableNoteError, type ValidatedBoundMintReceipt, type VerifyResult, type WithdrawRequestInfo, type WithdrawSuccessResponse, applyMintFee, buildNoteInfoUrlByHash, buildNoteUrl, cashDomainIndices, cashNodeFromHex, cashNodeToCx1, cashNodeToHex, cashSecretAt, cashSecretSource, claimMintedNote, classifyNoteError, createClient, decodeBolt11AmountMsat, decodeCk1, decodeCp1, decodeCs1, decodeCx1, decodePaymentRequest, defaultRandomSecret, deriveCashAddressNode, deriveCashChild, deriveCashDomainNode, deriveCashRoot, deriveCashSecret, deriveNotePubkey, deriveNoteRoot, deriveNoteSecret, deriveNoteSecretKey, derivedSecretSource, describeMintFee, encodeCk1, encodeCp1, encodeCs1, encodeCx1, encodePaymentRequest, fetchInvoiceVerification, fetchMintAddress, fetchNoteInfo, fetchNoteInfoByHash, fetchPayRequest, formatFeePercent, fromBech32Lnurl, fromLud17, grossUpForMintFee, hashK1, isAllowedServiceUrl, isBech32Lnurl, isBolt11Invoice, isCk1, isCp1, isCs1, isCx1, isLightningAddress, isPaymentRequest, isPreimage, isValidNoteInput, lightningAddressUsername, meltNote, mergeBatches, mergeNotes, mergeNotesWithHash, mintAddressUrl, mintFeeBand, namesMintOutput, newSecretsOf, noteDeclaredAmount, noteIdOf, noteK1, noteLookupOf, noteSignature, noteSignatureDigest, noteSignatureDigestForHash, noteSignatureMessage, noteSignatureMessageForHash, parseMintFee, paymentRequestAmountMsat, probeBurnedNote, recoverNoteOwnershipPubkey, requestInvoice, requireBoundMintQuote, requireNoteK1, resolveLnurlInput, resolveMintInput, resolveNoteInput, restoreFromSeed, restoreNotes, rotateNote, rotateNoteWithHash, sameInvoice, serverOf, settleNote, settleNoteForValue, signNoteOwnership, splitNote, splitNoteWithHash, toBech32Lnurl, toLud17w, validateBoundMintReceipt, verifyNoteSignature, verifyNoteSignatureAgainst, verifyNoteSignatureHash, verifyNoteSignatureHashAgainst, withNewK1, withinMintFeeBand, withoutK1 };
|
|
412
|
+
export { AmbiguousMintError, AmbiguousMutationError, type BoundMintCommitment, type CashNode, type Cx1, type DecodeOptions, HashLookupUnsupportedError, type HashedMutationResult, type HashedSplitResult, InsufficientValueError, type InvoiceRequestOptions, type InvoiceResult, type LnurlcashClient, LnurlcashError, type LnurlcashOptions, type MeltResult, type MintAddressInfo, type MintClaim, type MintContact, type MintFee, type MintFeeBand, NOSTR_CASH_SEED_LABEL, type NoteInfoByHash, type NoteScheme, NoteSpentError, NoteUnknownError, PAYMENT_REQUEST_PREFIX, type PayRequestInfo, type PaymentRequest, type PaymentRequestMethodDetails, PendingNoteError, ProtocolError, type RandomSecret, RequestRefusedError, type RestoreOptions, type RestoreResult, type RestoredNote, type RotateResult, type SeedRestoreOptions, type SeedRestoreResult, ServiceRejectedError, type SettleForValueOptions, type SettledForValue, type SettledNote, type SignatureCheck, type SplitResult, type UnresolvedIndex, UnverifiableNoteError, type ValidatedBoundMintReceipt, type VerifyResult, type WithdrawRequestInfo, type WithdrawSuccessResponse, applyMintFee, buildNoteInfoUrlByHash, buildNoteUrl, cashDomainIndices, cashNodeFromHex, cashNodeToCx1, cashNodeToHex, cashSecretAt, cashSecretSource, claimMintedNote, classifyNoteError, createClient, decodeBolt11AmountMsat, decodeCk1, decodeCp1, decodeCs1, decodeCx1, decodePaymentRequest, defaultRandomSecret, deriveCashAddressNode, deriveCashChild, deriveCashDomainNode, deriveCashMaster, deriveCashRoot, deriveCashSecret, deriveNostrAddressNode, deriveNostrCashSeed, deriveNotePubkey, deriveNoteRoot, deriveNoteSecret, deriveNoteSecretKey, derivedSecretSource, describeMintFee, encodeCk1, encodeCp1, encodeCs1, encodeCx1, encodePaymentRequest, fetchInvoiceVerification, fetchMintAddress, fetchNoteInfo, fetchNoteInfoByHash, fetchPayRequest, formatFeePercent, fromBech32Lnurl, fromLud17, grossUpForMintFee, hashK1, isAllowedServiceUrl, isBech32Lnurl, isBolt11Invoice, isCk1, isCp1, isCs1, isCx1, isLightningAddress, isPaymentRequest, isPreimage, isValidNoteInput, lightningAddressUsername, meltNote, mergeBatches, mergeNotes, mergeNotesWithHash, mintAddressUrl, mintFeeBand, namesMintOutput, newSecretsOf, noteDeclaredAmount, noteIdOf, noteK1, noteLookupOf, noteSignature, noteSignatureDigest, noteSignatureDigestForHash, noteSignatureMessage, noteSignatureMessageForHash, parseMintFee, paymentRequestAmountMsat, probeBurnedNote, recoverNoteOwnershipPubkey, requestInvoice, requireBoundMintQuote, requireNoteK1, resolveLnurlInput, resolveMintInput, resolveNoteInput, restoreFromSeed, restoreNotes, rotateNote, rotateNoteWithHash, sameInvoice, serverOf, settleNote, settleNoteForValue, signNoteOwnership, splitNote, splitNoteWithHash, toBech32Lnurl, toLud17w, validateBoundMintReceipt, verifyNoteSignature, verifyNoteSignatureAgainst, verifyNoteSignatureHash, verifyNoteSignatureHashAgainst, withNewK1, withinMintFeeBand, withoutK1 };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { bech32, base64urlnopad, bech32m } from '@scure/base';
|
|
2
2
|
import { secp256k1 } from '@noble/curves/secp256k1.js';
|
|
3
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
3
4
|
import { sha256, sha512 } from '@noble/hashes/sha2.js';
|
|
4
5
|
import { utf8ToBytes, bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
|
|
5
|
-
import { hmac } from '@noble/hashes/hmac.js';
|
|
6
6
|
|
|
7
7
|
// src/urls.ts
|
|
8
8
|
var isBech32Lnurl = (data) => data.trim().toUpperCase().startsWith("LNURL1");
|
|
@@ -154,6 +154,7 @@ var deriveCashChild = (node, index) => {
|
|
|
154
154
|
}
|
|
155
155
|
return { privateKey: to32Bytes(key), chainCode: material.slice(32) };
|
|
156
156
|
};
|
|
157
|
+
var deriveCashMaster = (seed) => masterFrom(seed);
|
|
157
158
|
var masterFrom = (seed) => {
|
|
158
159
|
if (seed.length < 16 || seed.length > 64) {
|
|
159
160
|
throw new RangeError(
|
|
@@ -346,6 +347,14 @@ var cashNodeToCx1 = (node) => ({
|
|
|
346
347
|
pubkeyXOnly: secp256k1.getPublicKey(node.privateKey, true).slice(1),
|
|
347
348
|
chainCode: node.chainCode.slice()
|
|
348
349
|
});
|
|
350
|
+
var NOSTR_CASH_SEED_LABEL = "LNURLcash/nostr-seed";
|
|
351
|
+
var deriveNostrCashSeed = (secretKey) => {
|
|
352
|
+
if (!(secretKey instanceof Uint8Array) || secretKey.length !== 32) {
|
|
353
|
+
throw new RangeError("A Nostr secret key is 32 bytes.");
|
|
354
|
+
}
|
|
355
|
+
return hmac(sha256, secretKey, utf8ToBytes(NOSTR_CASH_SEED_LABEL));
|
|
356
|
+
};
|
|
357
|
+
var deriveNostrAddressNode = (secretKey, host) => deriveCashAddressNode(deriveCashRoot(deriveNostrCashSeed(secretKey)), host);
|
|
349
358
|
|
|
350
359
|
// src/note.ts
|
|
351
360
|
var noteK1 = (url) => {
|
|
@@ -958,7 +967,8 @@ var fetchNoteInfo = async (url, options = {}) => {
|
|
|
958
967
|
requireMintPubkey: opts.requireSignatures
|
|
959
968
|
});
|
|
960
969
|
const queried = noteK1(url);
|
|
961
|
-
|
|
970
|
+
const echoed = noteIdOf(body.k1);
|
|
971
|
+
if (queried && (echoed === null || echoed !== noteIdOf(queried))) {
|
|
962
972
|
throw new ProtocolError(
|
|
963
973
|
"The service echoed back a different k1 than was queried - the note may have been redeemed elsewhere, or the service isn't spec-compliant."
|
|
964
974
|
);
|
|
@@ -1738,4 +1748,4 @@ var createClient = (options = {}) => ({
|
|
|
1738
1748
|
settleNoteForValue: (noteUrl, terms) => settleNoteForValue(noteUrl, terms, options)
|
|
1739
1749
|
});
|
|
1740
1750
|
|
|
1741
|
-
export { AmbiguousMintError, AmbiguousMutationError, HashLookupUnsupportedError, InsufficientValueError, LnurlcashError, NoteSpentError, NoteUnknownError, PAYMENT_REQUEST_PREFIX, PendingNoteError, ProtocolError, RequestRefusedError, ServiceRejectedError, UnverifiableNoteError, applyMintFee, buildNoteInfoUrlByHash, buildNoteUrl, cashDomainIndices, cashNodeFromHex, cashNodeToCx1, cashNodeToHex, cashSecretAt, cashSecretSource, claimMintedNote, classifyNoteError, createClient, decodeBolt11AmountMsat, decodeCk1, decodeCp1, decodeCs1, decodeCx1, decodePaymentRequest, defaultRandomSecret, deriveCashAddressNode, deriveCashChild, deriveCashDomainNode, deriveCashRoot, deriveCashSecret, deriveNotePubkey, deriveNoteRoot, deriveNoteSecret, deriveNoteSecretKey, derivedSecretSource, describeMintFee, encodeCk1, encodeCp1, encodeCs1, encodeCx1, encodePaymentRequest, fetchInvoiceVerification, fetchMintAddress, fetchNoteInfo, fetchNoteInfoByHash, fetchPayRequest, formatFeePercent, fromBech32Lnurl, fromLud17, grossUpForMintFee, hashK1, isAllowedServiceUrl, isBech32Lnurl, isBolt11Invoice, isCk1, isCp1, isCs1, isCx1, isLightningAddress, isPaymentRequest, isPreimage, isValidNoteInput, lightningAddressUsername, meltNote, mergeBatches, mergeNotes, mergeNotesWithHash, mintAddressUrl, mintFeeBand, namesMintOutput, newSecretsOf, noteDeclaredAmount, noteIdOf, noteK1, noteLookupOf, noteSignature, noteSignatureDigest, noteSignatureDigestForHash, noteSignatureMessage, noteSignatureMessageForHash, parseMintFee, paymentRequestAmountMsat, probeBurnedNote, recoverNoteOwnershipPubkey, requestInvoice, requireBoundMintQuote, requireNoteK1, resolveLnurlInput, resolveMintInput, resolveNoteInput, restoreFromSeed, restoreNotes, rotateNote, rotateNoteWithHash, sameInvoice, serverOf, settleNote, settleNoteForValue, signNoteOwnership, splitNote, splitNoteWithHash, toBech32Lnurl, toLud17w, validateBoundMintReceipt, verifyNoteSignature, verifyNoteSignatureAgainst, verifyNoteSignatureHash, verifyNoteSignatureHashAgainst, withNewK1, withinMintFeeBand, withoutK1 };
|
|
1751
|
+
export { AmbiguousMintError, AmbiguousMutationError, HashLookupUnsupportedError, InsufficientValueError, LnurlcashError, NOSTR_CASH_SEED_LABEL, NoteSpentError, NoteUnknownError, PAYMENT_REQUEST_PREFIX, PendingNoteError, ProtocolError, RequestRefusedError, ServiceRejectedError, UnverifiableNoteError, applyMintFee, buildNoteInfoUrlByHash, buildNoteUrl, cashDomainIndices, cashNodeFromHex, cashNodeToCx1, cashNodeToHex, cashSecretAt, cashSecretSource, claimMintedNote, classifyNoteError, createClient, decodeBolt11AmountMsat, decodeCk1, decodeCp1, decodeCs1, decodeCx1, decodePaymentRequest, defaultRandomSecret, deriveCashAddressNode, deriveCashChild, deriveCashDomainNode, deriveCashMaster, deriveCashRoot, deriveCashSecret, deriveNostrAddressNode, deriveNostrCashSeed, deriveNotePubkey, deriveNoteRoot, deriveNoteSecret, deriveNoteSecretKey, derivedSecretSource, describeMintFee, encodeCk1, encodeCp1, encodeCs1, encodeCx1, encodePaymentRequest, fetchInvoiceVerification, fetchMintAddress, fetchNoteInfo, fetchNoteInfoByHash, fetchPayRequest, formatFeePercent, fromBech32Lnurl, fromLud17, grossUpForMintFee, hashK1, isAllowedServiceUrl, isBech32Lnurl, isBolt11Invoice, isCk1, isCp1, isCs1, isCx1, isLightningAddress, isPaymentRequest, isPreimage, isValidNoteInput, lightningAddressUsername, meltNote, mergeBatches, mergeNotes, mergeNotesWithHash, mintAddressUrl, mintFeeBand, namesMintOutput, newSecretsOf, noteDeclaredAmount, noteIdOf, noteK1, noteLookupOf, noteSignature, noteSignatureDigest, noteSignatureDigestForHash, noteSignatureMessage, noteSignatureMessageForHash, parseMintFee, paymentRequestAmountMsat, probeBurnedNote, recoverNoteOwnershipPubkey, requestInvoice, requireBoundMintQuote, requireNoteK1, resolveLnurlInput, resolveMintInput, resolveNoteInput, restoreFromSeed, restoreNotes, rotateNote, rotateNoteWithHash, sameInvoice, serverOf, settleNote, settleNoteForValue, signNoteOwnership, splitNote, splitNoteWithHash, toBech32Lnurl, toLud17w, validateBoundMintReceipt, verifyNoteSignature, verifyNoteSignatureAgainst, verifyNoteSignatureHash, verifyNoteSignatureHashAgainst, withNewK1, withinMintFeeBand, withoutK1 };
|
package/llms.txt
CHANGED
|
@@ -64,6 +64,10 @@ deriveNoteSecretKey(p, chainCode, i) -> sk negates p first when P has odd y
|
|
|
64
64
|
signNoteOwnership(sk) -> 65 bytes RFC6979 over fixed "LNURLcash"
|
|
65
65
|
recoverNoteOwnershipPubkey(sig) -> pk | null
|
|
66
66
|
verifyNoteSignature also takes a ck1 as k1 and a cs1 as the signature
|
|
67
|
+
deriveCashMaster(seed) -> CashNode the BIP-32 master, for walking a path the kit does not name
|
|
68
|
+
deriveNostrCashSeed(secretKey) -> 32-byte seed HMAC-SHA256(key, "LNURLcash/nostr-seed")
|
|
69
|
+
deriveNostrAddressNode(secretKey, host) -> CashNode the address path from that seed;
|
|
70
|
+
a branch for a holder with no BIP-39 words (heartwood-esp32 derives the same)
|
|
67
71
|
noteIdOf(k1) -> id | null sha256(k1) for a secret, the recovered key for a
|
|
68
72
|
ck1. One note has many valid ck1 strings: compare notes by this, not by k1
|
|
69
73
|
noteLookupOf(k1) -> string hash, or cp1 for a ck1; for fetchNoteInfoByHash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lnurlcash-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "LNURLcash (LUD-25) bearer note client for TypeScript - mint, rotate, split, merge, melt, and verify offline",
|
|
5
5
|
"author": "TheCryptoDonkey",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^26.2.0",
|
|
63
|
-
"lnurlcash-conformance": "^0.
|
|
63
|
+
"lnurlcash-conformance": "^0.9.0",
|
|
64
64
|
"tsup": "^8.5.0",
|
|
65
65
|
"typescript": "^5.7.0",
|
|
66
66
|
"vitest": "^3.0.0"
|