Bitflash BTF · RandomX · MIT

DocsJSON-RPC

JSON-RPC

The interface an exchange, a payment processor or a block explorer integrates a coin through. It is shaped like bitcoind's — same method names, same arguments, same result fields — so an integration written for any Bitcoin-derived coin works here unchanged.

Bitcoin 0.1.0 had no RPC; it arrived in 0.3.x and this tree never inherited it. Until 1.2.23 there was no way for anybody else's software to run a Bitflash wallet: no deposit address per user, no way to notice a deposit had landed, no way to pay a withdrawal.

Starting it

Nothing listens unless both credentials are given:

bitflash-node -nogui -datadir=/var/lib/bitflash \
  -rpcuser=exchange -rpcpassword='a long random string, sixteen characters at least'

Calling it

JSON-RPC 1.0 over HTTP POST /. Batches (a JSON array of requests) are accepted and answered in order.

curl -u exchange:SECRET -H 'Content-Type: application/json' \
  -d '{"id":1,"method":"getblockcount","params":[]}' http://127.0.0.1:8432/
{"id":1,"result":31770,"error":null}

Errors come back as {"code":-1,"message":"..."} in error, with result null.

Methods

methodargumentsreturns
getinfo—version, protocol, blocks, connections, balance, testnet, walletlocked
getblockcount—height of the best chain
getblockhashheightblock hash at that height
getblockhashheight, confirmations, time, merkle root, tx (txids), prev/next hash
getnewaddress—a fresh receiving address, one per call
validateaddressaddressisvalid, and ismine when it is
getbalance[minconf=1]spendable balance, excluding immature mining rewards
sendtoaddressaddress, amounttxid of the transaction it created and broadcast
gettransactiontxidamount, confirmations, block, details per output
listtransactions[count=10]the last count wallet transactions, oldest first
listsinceblock[blockhash]every wallet transaction in blocks after that one, plus unconfirmed, and lastblock
gettorinfo—transport (direct, user, or a bundled rung such as snowflake), Tor's bootstrap percent and bootstrapline, the ladder of bundled rungs, userbridges count and file, lastworking, connections
settorbridges["line", ...] \"now" \"forget"lines: save to bridges.txt and switch Tor to them now; now: climb to the next bundled rung right away; forget: next start tries direct Tor first again
gettreasuryinfo—configured, network, page; when configured: required, keys, the script decoded, howToPay, this node's treasuryShare and poolFeeTo
donateamounttxid of a transaction paying the treasury; the same as sendtoaddress treasury <amount>

amount and balance are BTF as JSON numbers. sendtoaddress accepts the amount as a number or as a string. The word treasury stands for the treasury's multisig script wherever an address is taken (sendtoaddress, createrawtransaction outputs); docs/treasury.md.

The loop an exchange runs

  1. getnewaddress once per user, stored against the account.
  2. listsinceblock <last seen block> on a timer. Credit each receive entry once confirmations reaches the number you trust; store the returned lastblock and pass it next time.
  3. sendtoaddress for withdrawals; keep the txid and confirm it with gettransaction.

details[].category tells the kinds apart: receive, send, and for mining rewards immature until they can be spent and generate after. An exchange should not credit immature.

Change is never listed. In a transaction this wallet funded, its own outputs are change, not receipts, and they do not appear under receive -- so summing the receive entries to credit deposits is safe. The transaction's amount is still the wallet's net, change included.

Addresses from getnewaddress come from the HD key pool and are covered by the wallet's recovery phrase. A wallet restored from its phrase gets every deposit address it ever handed out.

Confirmations to trust

Blocks arrive every two minutes and the retarget is every thirty, so the chain reacts fast to hashrate arriving or leaving. Ten confirmations is twenty minutes; that is a reasonable floor for a young network. Coinbase maturity is 120 blocks.

What it does not do

No walletpassphrase — if the wallet is encrypted, start the node with the passphrase and the RPC spends from the unlocked wallet. No listunspent, no raw transaction building, no importprivkey. Those can be added when somebody needs them; the set above is what every exchange integration actually calls.


Rendered from docs/rpc.md in the repository. Read the source.