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

added decodeInvoice util #98

Merged
merged 5 commits into from
Jan 18, 2024
Merged

Conversation

Egge21M
Copy link
Collaborator

@Egge21M Egge21M commented Jan 17, 2024

Fixes: #94

Description

Added a decodeInvoice utility function that takes in a bolt11 invoice and returns an object of type InvoiceData

type InvoiceData = {
	paymentRequest: string;
	amountInSats: number;
	amountInMSats: number;
	timestamp: number;
	paymentHash: string;
	memo: string;
	expiry: number;
};

Changes

  • Added type InvoiceData
  • Added decodeInvoice to utils.ts
  • Added test

PR Tasks

  • Open PR
  • run npm run test --> no failing unit tests
  • run npm run format

Copy link
Collaborator

@gandlafbtc gandlafbtc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! We could add an import and export for this function in index.ts so it is easily accessible when importing the lib

@gandlafbtc gandlafbtc merged commit 5b6d14a into cashubtc:main Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add utility function to decode LN-invoice
2 participants