diff options
| author | Adam Soltys <[email protected]> | 2023-01-18 23:14:48 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-18 23:14:48 -0800 |
| commit | ef3679051214a9b3047b68f236eac656edcf8d38 (patch) | |
| tree | 426eda7cf7e36026c60da2ae28ce7c61804518f8 /lib/rpc.js | |
| parent | 90ddef9f0dd93e8f980eb728cf0519d9215163f0 (diff) | |
| download | coinos-server-ef3679051214a9b3047b68f236eac656edcf8d38.tar.gz coinos-server-ef3679051214a9b3047b68f236eac656edcf8d38.zip | |
bitcoin invoices
Diffstat (limited to 'lib/rpc.js')
| -rw-r--r-- | lib/rpc.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/rpc.js b/lib/rpc.js new file mode 100644 index 00000000..b8a2d0dd --- /dev/null +++ b/lib/rpc.js @@ -0,0 +1,26 @@ +import got from "got"; + +export default ({ host, port, wallet, username, password }) => + new Proxy( + {}, + { + get: (target, prop) => (...params) => + ((method, ...params) => { + let url = `http://${host}:${port}/wallet/${wallet}`; + return got + .post(url, { + json: { + method, + params + }, + headers: { + authorization: `Basic ${Buffer.from( + `${username}:${password}` + ).toString("base64")}` + } + }) + .json() + .then(({ result }) => result); + })(prop.toLowerCase(), ...params) + } + ); |
