UNPKG

bitcoin-cli-ts

Version:

Auto-generated Bitcoin client library for bitcoind JSON-RPC API

18 lines (17 loc) 856 B
import { __assign } from "tslib"; var defaultConfig = { protocol: 'http', host: '127.0.0.1', username: 'rpcuser', password: '', timeout: 15000, port: 18443, walletName: '', }; export function authenticatedBitcoind(config) { var mergedConfig = __assign(__assign({}, defaultConfig), config); var protocol = mergedConfig.protocol, host = mergedConfig.host, port = mergedConfig.port, walletName = mergedConfig.walletName, username = mergedConfig.username, password = mergedConfig.password; var walletPath = walletName ? "/wallet/".concat(walletName) : '/'; var auth = Buffer.from("".concat(username, ":").concat(password)).toString('base64'); return __assign(__assign({}, mergedConfig), { url: "".concat(protocol, "://").concat(host, ":").concat(port).concat(walletPath), authHeader: "Basic ".concat(auth) }); }