
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
rpc-bitcoin
Advanced tools
A TypeScript library to make RPC and HTTP REST requests to Bitcoin Core.
npm install rpc-bitcoin
const { RPCClient } = require("rpc-bitcoin");
const url = "http://192.168.0.10";
const user = "rpcuser";
const pass = "rpcpassword";
const port = 18832;
const timeout = 10000;
const client = new RPCClient({ url, port, timeout, user, pass });
const response = await client.batch([
{ method: "getbestblockhash", id: 1 },
{ method: "help", params: { command: "help" }, id: "custom-id" },
{ method: "getzmqnotifications", params: {}, id: 2 }
]);
const hex = await client.getbestblockhash();
const blockhash =
"000000004182034f427d463b92162d35d0accef9ea0c5354a87e870ca1815b4c";
const verbosity = 2;
const block = await client.getblock({ blockhash, verbosity });
const info = await client.getblockchaininfo();
const count = await client.getblockcount();
const height = 1583782;
const hash = await client.getblockhash({ height });
const blockhash =
"000000004182034f427d463b92162d35d0accef9ea0c5354a87e870ca1815b4c";
const verbose = false;
const header = await client.getblockheader({ blockhash, verbose });
const hash_or_height =
"000000004182034f427d463b92162d35d0accef9ea0c5354a87e870ca1815b4c";
const stats = ["txs", "time"];
const info = await client.getblockstats({ hash_or_height, stats });
const tips = await client.getchaintips();
const nblocks = 2016;
const blockhash =
"000000004182034f427d463b92162d35d0accef9ea0c5354a87e870ca1815b4c";
const data = await client.getchaintxstats({ nblocks, blockhash });
const difficulty = await client.getdifficulty();
const verbose = true;
const txid = "3e128c38f35520d4121d582f15998b7f74b44f17aa650b4d60decf975e642b9a";
const data = await client.getmempoolancestors({ txid, verbose });
const verbose = true;
const txid = "ff758ffd73729be8afae0d683547f7840bdaee75ad5e5c464fb621b2509c366b";
const data = await client.getmempooldescendants({ txid, verbose });
const txid = "0629e01f05088728b089715f247de82a160428c06d6c85484adab2aa66574ace";
const data = await client.getmempoolentry({ txid });
const info = await client.getmempoolinfo();
const verbose = true;
const data = await client.getrawmempool({ verbose });
const txid = "d2f6b1d1844e483ce350a4a22fbaef36c31ebe88730415b7408c1f34b834fab5";
const n = 1;
const include_mempool = true;
const data = await client.gettxout({ txid, n, include_mempool });
const txids = [
"42e75d074cf5b836170d20fc09593245c65a3f07283a497c3350c4d109b38bb6"
];
const blockhash =
"000000000000000000055bc30b762904ab996430603cafe846cc6adc82c4af1e";
const data = await client.gettxoutproof({ txids, blockhash });
const info = await client.gettxoutsetinfo();
const blockhash =
"00000000000000261a35cf378bf8fa1bf6ac87800d798ce2a11f581f562e92ba";
const data = await client.preciousblock({ blockhash });
const height = 1000;
const result = await client.pruneblockchain({ height });
const result = await client.savemempool();
const action = "start";
const scanobjects = [
"addr(mxosQ4CvQR8ipfWdRktyB3u16tauEdamGc)",
{
desc:
"wpkh([d34db33f/84'/0'/0']tpubD6NzVbkrYhZ4YTN7usjEzYmfu4JKqnfp9RCbDmdKH78vTyuwgQat8vRw5cX1YaZZvFfQrkHrM2XsyfA8cZE1thA3guTBfTkKqbhCDpcKFLG/0/*)#8gfuh6ex",
range: [1, 3]
}
];
const result = await client.scantxoutset({ action, scanobjects });
const checklevel = 1;
const nblocks = 10;
const result = await client.verifychain({ checklevel, nblocks });
const proof =
"00000020ed07b12f0398e45fd403db11dbe894dc3301ce1a7725424e0b5e460c0000000066fca14db436f305aea37b3ae0f8b188cbf112dff3854c3d419f3ff3ebbc821f6c0c975dffff001d8fd5a7d2eb00000009e7acd3f605d1b957d684d9eeca9c472d803d90c0d17e29e5606f9b080b177a4abcd854622ad3900b5bc1ae71e99699a05eb972d46bd439c08eb7fbd20bba6494542222b2d1388f52c6d23ac12b32245ca47b02fc2f0a283a88aabca1f4db43ca8a4da8ffd7d9ae403b0c34ccbf14d2318c34fabb713c48f6d6490c6095250b6f08f26f020275d448dfb9967c62bedefaf29260021671a191f620f7783252788549b1e033dc815e2cd36ff204b398046f834643859f881a4d93b3fc5b91413a009c5069be274e1dcc675183ea2a989ef598422c0ed02e407aade8eaa6ef7ec1120ca4ffdef21b5fd26c4525a27c78cc38026b257f9d23f0d796603b1d3cbf539bdf87ccf9e81954f58e072d67eff2891339f203cbdec68bbbabbbbc0c070cceea03bf0a00";
const result = await client.verifytxoutproof({ proof });
const result = await client.getzmqnotifications();
const { RESTClient } = require("rpc-bitcoin");
const url = "http://192.168.0.101";
const port = 17230;
const timeout = 20000;
const restClient = new RESTClient({ url, port, timeout });
const hash = "00000000099de420b319c7804c4bfee5357d3f5ddbfd3c71c15b3625347792bf";
const format = "hex";
await restClient.getBlock({ hash, format });
const hash = "00000000099de420b319c7804c4bfee5357d3f5ddbfd3c71c15b3625347792bf";
const format = "hex";
await restClient.getBlockNoTxDetails({ hash, format });
const height = 1;
const format = "hex";
await restClient.getBlockHashByHeight({ height, format });
await restClient.getChainInfo();
const checkmempool = true;
const outpoints = [
{
txid: "e346be6c1ef4d24f3a26ea8e1b45a2645d339fbee9da8b9dc03aeef1c4179716",
n: 0
},
{
txid: "e346be6c1ef4d24f3a26ea8e1b45a2645d339fbee9da8b9dc03aeef1c4179716",
n: 1
}
];
const format = "hex";
await restClient.getUtxos({ checkmempool, outpoints, format });
const count = 5;
const hash = "00000000000001f0be142e57e99d3528212e1204157209c6c10bd11326cc5b35";
const format = "hex";
await restClient.getHeaders({ count, hash, format });
await restClient.getMemPoolContents();
await restClient.getMemPoolInfo();
const txid = "93520a51cc6c694e79913f1daf0288cb10e0d7946723c06b4e7b6c2e5b057933";
const format = "hex";
await restClient.getTx({ txid, format });
FAQs
A TypeScript library to make RPC and HTTP REST requests to Bitcoin Core
The npm package rpc-bitcoin receives a total of 6,764 weekly downloads. As such, rpc-bitcoin popularity was classified as popular.
We found that rpc-bitcoin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.