0.0.3 • Published 2 years ago

@finney/rpc v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

@finney/rpc

A dependency-free TypeScript client for Bitcoin Core's JSON-RPC.

  • Targets 100% coverage of the JSON-RPC
  • Exports types for each RPC response
  • Dependency-free (aside from development dependencies)
  • Targets the Bun runtime first

Usage

Copy .env.template to .env and replace the values with those for your node. Otherwise, set them in the environment.

Then, import and initialize:

import BitcoinRPC from '@finney/rpc';

const bitcoinRPC = new BitcoinRPC();

Every procedure in Bitcoin Core 0.24.0 is implemented as an async function on this imported class, and every function return value is expected to be a strongly typed using a generic Promise<RPCResponse<T>>.

const block = await bitcoinRPC.getblock({ getblock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f' });
console.log(block.result?.hash);

If the procedure failed, you can expect error to be present:

const block = await bitcoinRPC.getblock({ getblock: 'badhash' });
console.error(block.result.error);

Roadmap

  • Use named arguments instead of positional ones
  • Prefer function overloading over union returns
  • Camel cased types
  • Network support
  • Hidden generating RPCs
  • Update to 0.24.1
  • Typed error response
  • SSL support
  • Batch support
  • BigNumber support
  • Multiple wallets support

Procedures

  • getbestblockhash
  • getblock
  • getblockchaininfo
  • getblockcount
  • getblockfilter
  • getblockfrompeer
  • getblockhash
  • getblockheader
  • getblockstats
  • getchaintips
  • getchaintxstats
  • getdeploymentinfo
  • getdifficulty
  • getmempoolancestors
  • getmempooldescendants
  • getmempoolentry
  • getmempoolinfo
  • getrawmempool
  • gettxout
  • gettxoutproof
  • gettxoutsetinfo
  • preciousblock
  • pruneblockchain
  • savemempool
  • scantxoutset
  • verifychain
  • verifytxoutproof
  • getmemoryinfo
  • getrpcinfo
  • help
  • logging
  • stop
  • uptime
  • getblocktemplate
  • getmininginfo
  • getnetworkhashps
  • prioritisetransaction
  • submitblock
  • submitheader
  • addnode
  • clearbanned
  • disconnectnode
  • getaddednodeinfo
  • getconnectioncount
  • getnettotals
  • getnetworkinfo
  • getnodeaddresses
  • getpeerinfo
  • listbanned
  • ping
  • setban
  • setnetworkactive
  • analyzepsbt
  • combinepsbt
  • combinerawtransaction
  • converttopsbt
  • createpsbt
  • createrawtransaction
  • decodepsbt
  • decoderawtransaction
  • decodescript
  • finalizepsbt
  • fundrawtransaction
  • getrawtransaction
  • joinpsbts
  • sendrawtransaction
  • signrawtransactionwithkey
  • testmempoolaccept
  • utxoupdatepsbt
  • enumeratesigners
  • createmultisig
  • deriveaddresses
  • estimatesmartfee
  • getdescriptorinfo
  • getindexinfo
  • signmessagewithprivkey
  • validateaddress
  • verifymessage
  • abandontransaction
  • abortrescan
  • addmultisigaddress
  • backupwallet
  • bumpfee
  • createwallet
  • dumpprivkey
  • dumpwallet
  • encryptwallet
  • getaddressesbylabel
  • getaddressinfo
  • getbalance
  • getbalances
  • getnewaddress
  • getrawchangeaddress
  • getreceivedbyaddress
  • getreceivedbylabel
  • gettransaction
  • getunconfirmedbalance
  • getwalletinfo
  • importaddress
  • importdescriptors
  • importmulti
  • importprivkey
  • importprunedfunds
  • importpubkey
  • importwallet
  • keypoolrefill
  • listaddressgroupings
  • listdescriptors
  • listlabels
  • listlockunspent
  • listreceivedbyaddress
  • listreceivedbylabel
  • listsinceblock
  • listtransactions
  • listunspent
  • listwalletdir
  • listwallets
  • loadwallet
  • lockunspent
  • migratewallet
  • newkeypool
  • psbtbumpfee
  • removeprunedfunds
  • rescanblockchain
  • restorewallet
  • send
  • sendall
  • sendmany
  • sendtoaddress
  • sethdseed
  • setlabel
  • settxfee
  • setwalletflag
  • signmessage
  • signrawtransactionwithwallet
  • simulaterawtransaction
  • unloadwallet
  • upgradewallet
  • walletcreatefundedpsbt
  • walletdisplayaddress
  • walletlock
  • walletpassphrase
  • walletpassphrasechange
  • walletprocesspsbt
  • getzmqnotifications
0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

3 years ago