Skip to content

Commit

Permalink
Merge pull request #176 from cashubtc/nut-05-invoice-description
Browse files Browse the repository at this point in the history
NUT-05: description for invoice, integration test without bolt11 decode
  • Loading branch information
callebtc authored Sep 9, 2024
2 parents d61ad07 + 56ee3dd commit 8909ece
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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

0 comments on commit 8909ece

Please sign in to comment.