diff --git a/docs/.vitepress/sidebar.ts b/docs/.vitepress/sidebar.ts index 262e196..0d327ec 100644 --- a/docs/.vitepress/sidebar.ts +++ b/docs/.vitepress/sidebar.ts @@ -97,6 +97,7 @@ const FedimintWalletSidebar = [ items: [ { text: 'redeemEcash()', link: 'redeemEcash' }, { text: 'spendNotes()', link: 'spendNotes' }, + { text: 'parseNotes()', link: 'parseNotes' }, ], }, { diff --git a/docs/core/FedimintWallet/MintService/parseNotes.md b/docs/core/FedimintWallet/MintService/parseNotes.md new file mode 100644 index 0000000..5f12924 --- /dev/null +++ b/docs/core/FedimintWallet/MintService/parseNotes.md @@ -0,0 +1,21 @@ +# Spend Ecash + +### `mint.parseNotes(oobNotes: string)` + +Parses an ecash note string without redeeming it. Use [`redeemEcash()`](./redeemEcash) to redeem the notes. + +```ts twoslash +// @esModuleInterop +import { FedimintWallet } from '@fedimint/core-web' + +const wallet = new FedimintWallet() +wallet.open() + +const longEcashNoteString = '01A...' + +const valueMsats = await wallet.mint.parseNotes(longEcashNoteString) // [!code focus] + +// later... + +await wallet.mint.redeemEcash(longEcashNoteString) +``` diff --git a/docs/core/FedimintWallet/MintService/spendNotes.md b/docs/core/FedimintWallet/MintService/spendNotes.md index 3eb16e2..3604769 100644 --- a/docs/core/FedimintWallet/MintService/spendNotes.md +++ b/docs/core/FedimintWallet/MintService/spendNotes.md @@ -7,7 +7,6 @@ Generates ecash notes for spending. ```ts twoslash // @esModuleInterop import { FedimintWallet } from '@fedimint/core-web' -import type { LnReceiveState } from '@fedimint/core-web' const wallet = new FedimintWallet() wallet.open() @@ -15,6 +14,5 @@ wallet.open() const amountMsats = 10_000 // [!code focus] const result = await wallet.mint.spendNotes(amountMsats) // [!code focus] -console.log(result.notes) -console.log(result.operation_id) +console.log(result.notes) // ecash notes ``` diff --git a/packages/core-web/src/services/MintService.ts b/packages/core-web/src/services/MintService.ts index 0604ab4..b729e7f 100644 --- a/packages/core-web/src/services/MintService.ts +++ b/packages/core-web/src/services/MintService.ts @@ -45,6 +45,7 @@ export class MintService { return unsubscribe } + /** https://web.fedimint.org/core/FedimintWallet/MintService/spendNotes */ async spendNotes( amountMsats: number, // Tells the wallet to automatically try to cancel the spend if it hasn't completed @@ -78,6 +79,7 @@ export class MintService { } } + /** https://web.fedimint.org/core/FedimintWallet/MintService/parseEcash */ async parseNotes(oobNotes: string) { return await this.client.rpcSingle('mint', 'validate_notes', { oob_notes: oobNotes,