Skip to content

Commit

Permalink
docs: update readme with requestPayServiceParams and requestInvoiceWi…
Browse files Browse the repository at this point in the history
…thServiceParams
  • Loading branch information
dolcalmi committed Jan 23, 2022
1 parent 7e9abd0 commit 6812a19
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
with:
node-version: '14.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@galoy'
scope: '@dolcalmi'
- run: npm run addscope
- name: Publish to GitHub Packages
run: npm publish
Expand Down
145 changes: 118 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,33 @@ const { invoice, params, successAction } = await requestInvoice({
Request an invoice for lnurl o lightning address

```
{
lnUrlOrAddress: <Bech32 encoded url (lnurl) or lightning address String>
tokens: <Amount in satoshis Number>
[comment]: <Comment String>
[onionAllowed]: <Onion url allowed Bool> // Default to false
[fetchGet]: <Function to make a GET request Function> // Default to axios get
}
@throws <Error>
@returns
{
invoice: <Invoice returned by pay service String>
successAction: <Success action defined by lnurl-rfc Object>
params: {
callback: <Url used to request the invoice String>
fixed: <Indicates if amount must be a fixed amount Bool>
min: <Min amount in satoshis Number>
max: <Max amount in satoshis Number>
domain: <Callback domain String>
metadata: <Decoded metadata Array>
identifier: <Metadata identifier String>
description: <Metadata description String>
image: <Metadata base64 image String>
commentAllowed: <Number of characters accepted for the comment query parameter Number> // Default to 0 - not allowed
}
}
{
lnUrlOrAddress: <Bech32 encoded url (lnurl) or lightning address String>
tokens: <Amount in satoshis Number>
[comment]: <Comment String>
[onionAllowed]: <Onion url allowed Bool> // Default to false
[fetchGet]: <Function to make a GET request Function> // Default to axios get
}
@throws <Error>
@returns
{
invoice: <Invoice returned by pay service String>
successAction: <Success action defined by lnurl-rfc Object>
params: {
callback: <Url used to request the invoice String>
fixed: <Indicates if amount must be a fixed amount Bool>
min: <Min amount in satoshis Number>
max: <Max amount in satoshis Number>
domain: <Callback domain String>
metadata: <Decoded metadata Array>
identifier: <Metadata identifier String>
description: <Metadata description String>
image: <Metadata base64 image String>
commentAllowed: <Number of characters accepted for the comment query parameter Number> // Default to 0 - not allowed
}
}
```

Example:
Expand All @@ -87,6 +87,97 @@ const { invoice, params, successAction } = await requestInvoice({
})
```

### requestPayServiceParams

Request pay service params for lnurl o lightning address (1st step)

```
{
lnUrlOrAddress: <Bech32 encoded url (lnurl) or lightning address String>
[onionAllowed]: <Onion url allowed Bool> // Default to false
[fetchGet]: <Function to make a GET request Function> // Default to axios get
}
@throws <Error>
@returns
{
callback: <Url used to request the invoice String>
fixed: <Indicates if amount must be a fixed amount Bool>
min: <Min amount in satoshis Number>
max: <Max amount in satoshis Number>
domain: <Callback domain String>
metadata: <Decoded metadata Array>
identifier: <Metadata identifier String>
description: <Metadata description String>
image: <Metadata base64 image String>
commentAllowed: <Number of characters accepted for the comment query parameter Number> // Default to 0 - not allowed
}
```

Example:

```node
const params = await requestPayServiceParams({
lnUrlOrAddress:
'lnurl1dp68gurn8ghj7urp0yh8xarpva5kueewvaskcmme9e5k7tewwajkcmpdddhx7amw9akxuatjd3cz7atnv4erqgfuvv5',
})
```

### requestInvoiceWithServiceParams

Request an invoice for lnurl o lightning address with the given service params (2nd step)

```
{
params: {
callback: <Url used to request the invoice String>
fixed: <Indicates if amount must be a fixed amount Bool>
min: <Min amount in satoshis Number>
max: <Max amount in satoshis Number>
domain: <Callback domain String>
metadata: <Decoded metadata Array>
identifier: <Metadata identifier String>
description: <Metadata description String>
image: <Metadata base64 image String>
commentAllowed: <Number of characters accepted for the comment query parameter Number> // Default to 0 - not allowed
}
tokens: <Amount in satoshis Number>
[comment]: <Comment String>
[onionAllowed]: <Onion url allowed Bool> // Default to false
[fetchGet]: <Function to make a GET request Function> // Default to axios get
}
@throws <Error>
@returns
{
invoice: <Invoice returned by pay service String>
successAction: <Success action defined by lnurl-rfc Object>
params: {
callback: <Url used to request the invoice String>
fixed: <Indicates if amount must be a fixed amount Bool>
min: <Min amount in satoshis Number>
max: <Max amount in satoshis Number>
domain: <Callback domain String>
metadata: <Decoded metadata Array>
identifier: <Metadata identifier String>
description: <Metadata description String>
image: <Metadata base64 image String>
commentAllowed: <Number of characters accepted for the comment query parameter Number> // Default to 0 - not allowed
}
}
```

Example:

```node
const params = await requestInvoiceWithServiceParams({
params,
tokens: 333,
})
```

## Utils

- [decodeUrlOrAddress](#decodeUrlOrAddress) - Decode a bech32 encoded url (lnurl) or lightning address and return a url
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"package": "yarn build && yarn pack",
"test": "jest --no-cache --runInBand",
"test:cov": "jest --coverage --no-cache --runInBand",
"addscope": "node tools/packagejson name @galoy/lnurl-pay"
"addscope": "node tools/packagejson name @dolcalmi/lnurl-pay"
},
"publishConfig": {
"access": "public"
Expand All @@ -38,13 +38,13 @@
"lnurl-pay"
],
"license": "MIT",
"homepage": "https://github.com/GaloyMoney/lnurl-pay",
"homepage": "https://github.com/dolcalmi/lnurl-pay",
"repository": {
"type": "git",
"url": "[email protected]:GaloyMoney/lnurl-pay.git"
"url": "[email protected]:dolcalmi/lnurl-pay.git"
},
"bugs": {
"url": "https://github.com/GaloyMoney/lnurl-pay/issues"
"url": "https://github.com/dolcalmi/lnurl-pay/issues"
},
"dependencies": {
"axios": "^0.24.0",
Expand Down

0 comments on commit 6812a19

Please sign in to comment.