Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUT-05: description for invoice, integration test without bolt11 decode #176

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/CashuWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
type TokenEntry,
CheckStateEnum,
SerializedBlindedSignature,
MeltQuoteState
MeltQuoteState,
MintQuoteResponse
} from './model/types/index.js';
import {
bytesToNumber,
Expand Down Expand Up @@ -331,12 +332,14 @@ class CashuWallet {
/**
* Requests a mint quote form the mint. Response returns a Lightning payment request for the requested given amount and unit.
* @param amount Amount requesting for mint.
* @param description optional description for the mint quote
* @returns the mint will return a mint quote with a Lightning invoice for minting tokens of the specified amount and unit
*/
async createMintQuote(amount: number) {
async createMintQuote(amount: number, description?: string) {
const mintQuotePayload: MintQuotePayload = {
unit: this._unit,
amount: amount
amount: amount,
description: description
};
return await this.mint.createMintQuote(mintQuotePayload);
}
Expand Down
4 changes: 4 additions & 0 deletions src/model/types/wallet/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export type MintQuotePayload = {
* Amount to be minted
*/
amount: number;
/**
* Description for the invoice
*/
description?: string;
};

/**
Expand Down
7 changes: 7 additions & 0 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ describe('mint api', () => {
// because local invoice, fee should be 0
expect(fee).toBe(0);
});
test('invoice with description', async () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
const quote = await wallet.createMintQuote(100, 'test description');
expect(quote).toBeDefined();
console.log(`invoice with description: ${quote.request}`);
});
test('get fee for external invoice', async () => {
const mint = new CashuMint(mintUrl);
const wallet = new CashuWallet(mint, { unit });
Expand Down
Loading