Skip to content

Commit

Permalink
fix lnd rest suffix url
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu89 committed Dec 20, 2021
1 parent 4f6364d commit 04dbd7c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
node_modules/
dist/
.vscode/
.vscode/
coverage/

# Testing files
docker-compose.yml
test.js
index.js
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "una-wrapper",
"version": "0.0.8-beta",
"version": "0.0.9-beta",
"description": "Universal Node API",
"scripts": {
"build": "tsup src/index.ts --format esm,cjs",
Expand Down Expand Up @@ -39,4 +39,4 @@
"dist/"
],
"types": "./dist/index.d.ts"
}
}
7 changes: 6 additions & 1 deletion src/backends/lnd-rest/lnd-rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,19 @@ export default class LndRest extends Backend {
})
}

const urlObject = URLToObject(this.config.url)
if (urlObject.pathname !== '/') {
path = `${urlObject.pathname}${path}`
}

return {
method,
path,
agent,
headers: {
'Grpc-Metadata-macaroon': this.config.hexMacaroon
},
...URLToObject(this.config.url)
...urlObject
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/backends/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ export const watchInvoices = (backend: IBackend, intervalMs: number | null = nul
}, intervalMs ?? 5000)
}

export const URLToObject = (urlStr: string): any => {
export const URLToObject = (urlStr: string): { protocol: string, hostname: string, port: string, pathname: string } => {
const url = new URL(urlStr)

return {
protocol: url.protocol,
hostname: url.hostname,
port: url.port
port: url.port,
pathname: url.pathname
}
}

Expand Down

0 comments on commit 04dbd7c

Please sign in to comment.