Skip to content

Commit

Permalink
docs: add parseNotes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 committed Dec 5, 2024
1 parent 66bbbab commit 7464ec2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const FedimintWalletSidebar = [
items: [
{ text: 'redeemEcash()', link: 'redeemEcash' },
{ text: 'spendNotes()', link: 'spendNotes' },
{ text: 'parseNotes()', link: 'parseNotes' },
],
},
{
Expand Down
21 changes: 21 additions & 0 deletions docs/core/FedimintWallet/MintService/parseNotes.md
Original file line number Diff line number Diff line change
@@ -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)
```
4 changes: 1 addition & 3 deletions docs/core/FedimintWallet/MintService/spendNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ 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()

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
```
2 changes: 2 additions & 0 deletions packages/core-web/src/services/MintService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,6 +79,7 @@ export class MintService {
}
}

/** https://web.fedimint.org/core/FedimintWallet/MintService/parseEcash */
async parseNotes(oobNotes: string) {
return await this.client.rpcSingle<MSats>('mint', 'validate_notes', {
oob_notes: oobNotes,
Expand Down

0 comments on commit 7464ec2

Please sign in to comment.