-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
32 lines (24 loc) · 895 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { FedimintWallet } from '@fedimint/core-web'
// Create the Wallet client
const wallet = new FedimintWallet()
// Open the wallet (should be called once in the application lifecycle)
await wallet.open()
// Join a Federation (if not already open)
if (!wallet.isOpen()) {
const inviteCode = 'fed11qgqpw9thwvaz7t...'
await wallet.joinFederation(inviteCode)
}
// Get Wallet Balance
const balance = await wallet.balance.getBalance()
// Subscribe to Balance Updates
const unsubscribe = wallet.balance.subscribeBalance((balance: number) => {
// notwoslash
console.log('Updated balance:', balance)
})
// Remember to call unsubscribe() when done
// Receive Ecash Payments
await wallet.mint.redeemEcash('A11qgqpw9thwvaz7t...')
// Create Lightning Invoice
await wallet.lightning.createInvoice(10_000, 'description')
// Pay Lightning Invoice
await wallet.lightning.payInvoice('lnbc...')