|
| 1 | +Bcoin ships with bcoin-cli as its default HTTP client for command line access. |
| 2 | + |
| 3 | +## Configuration |
| 4 | + |
| 5 | +Examples: |
| 6 | + |
| 7 | +``` bash |
| 8 | +$ export BCOIN_API_KEY=hunter2 |
| 9 | +$ export BCOIN_NETWORK=main |
| 10 | +$ export BCOIN_URI=http://localhost:8332 |
| 11 | +$ bcoin cli info |
| 12 | +``` |
| 13 | + |
| 14 | +``` bash |
| 15 | +$ bcoin cli info --api-key=hunter2 --uri=http://localhost |
| 16 | +``` |
| 17 | + |
| 18 | +``` bash |
| 19 | +$ echo 'api-key: hunter2' > ~/cli.conf |
| 20 | +$ bcoin cli info --config=~/cli.conf |
| 21 | +``` |
| 22 | + |
| 23 | +## Examples |
| 24 | + |
| 25 | +``` bash |
| 26 | +$ export BCOIN_API_KEY=your-api-key |
| 27 | + |
| 28 | +# View the genesis block |
| 29 | +$ bcoin cli block 0 |
| 30 | + |
| 31 | +# View the mempool |
| 32 | +$ bcoin cli mempool |
| 33 | + |
| 34 | +# View primary wallet |
| 35 | +$ bcoin wallet get |
| 36 | + |
| 37 | +# View transaction history |
| 38 | +$ bcoin wallet history |
| 39 | + |
| 40 | +# Send a transaction |
| 41 | +$ bcoin wallet send [address] 0.01 |
| 42 | + |
| 43 | +# View balance |
| 44 | +$ bcoin wallet balance |
| 45 | + |
| 46 | +# Derive new address |
| 47 | +$ bcoin wallet address |
| 48 | + |
| 49 | +# Create a new account |
| 50 | +$ bcoin wallet account create foo |
| 51 | + |
| 52 | +# Send from account |
| 53 | +$ bcoin wallet send [address] 0.01 --account=foo |
| 54 | +``` |
| 55 | + |
| 56 | +RPC examples: |
| 57 | + |
| 58 | +``` bash |
| 59 | +$ bcoin rpc getblockchaininfo |
| 60 | +$ bcoin rpc getwalletinfo |
| 61 | +$ bcoin rpc getpeerinfo |
| 62 | +$ bcoin rpc getbalance |
| 63 | +$ bcoin rpc listtransactions |
| 64 | +$ bcoin rpc sendtoaddress [address] 0.01 |
| 65 | +``` |
| 66 | + |
| 67 | +## Commands |
| 68 | + |
| 69 | +bcoin-cli commands are split into 3 categories: cli, rpc, and wallet. |
| 70 | + |
| 71 | +### Top-level Commands |
| 72 | + |
| 73 | +- `info`: Get server info. |
| 74 | +- `wallets`: List all wallets. |
| 75 | +- `wallet create [id]`: Create wallet. |
| 76 | +- `broadcast [tx-hex]`: Broadcast transaction. |
| 77 | +- `mempool`: Get mempool snapshot. |
| 78 | +- `tx [hash/address]`: View transactions. |
| 79 | +- `coin [hash+index/address]`: View coins. |
| 80 | +- `block [hash/height]`: View block. |
| 81 | +- `rescan [height]`: Rescan for transactions. |
| 82 | +- `reset [height/hash]`: Reset chain to desired block. |
| 83 | +- `resend`: Resend pending transactions. |
| 84 | +- `backup [path]`: Backup the wallet db. |
| 85 | +- `wallet [command]`: Execute wallet command. |
| 86 | +- `rpc [command] [args]`: Execute RPC command. |
| 87 | + |
| 88 | +### Wallet Commands |
| 89 | + |
| 90 | +- `listen`: Listen for events. |
| 91 | +- `get`: View wallet. |
| 92 | +- `master`: View wallet master key. |
| 93 | +- `shared add [xpubkey]`: Add key to wallet. |
| 94 | +- `shared remove [xpubkey]`: Remove key from wallet. |
| 95 | +- `balance`: Get wallet balance. |
| 96 | +- `history`: View TX history. |
| 97 | +- `pending`: View pending TXs. |
| 98 | +- `coins`: View wallet coins. |
| 99 | +- `account list`: List account names. |
| 100 | +- `account create [account-name]`: Create account. |
| 101 | +- `account get [account-name]`: Get account details. |
| 102 | +- `address`: Derive new receiving address. |
| 103 | +- `change`: Derive new change address. |
| 104 | +- `nested`: Derive new nested address. |
| 105 | +- `retoken`: Create new api key. |
| 106 | +- `send [address] [value]`: Send transaction. |
| 107 | +- `mktx [address] [value]`: Create transaction. |
| 108 | +- `sign [tx-hex]`: Sign transaction. |
| 109 | +- `zap [age?]`: Zap pending wallet TXs. |
| 110 | +- `tx [hash]`: View transaction details. |
| 111 | +- `blocks`: List wallet blocks. |
| 112 | +- `block [height]`: View wallet block. |
| 113 | +- `view [tx-hex]`: Parse and view transaction. |
| 114 | +- `import [wif|hex]`: Import private or public key. |
| 115 | +- `watch [address]`: Import an address. |
| 116 | +- `key [address]`: Get wallet key by address. |
| 117 | +- `dump [address]`: Get wallet key WIF by address. |
| 118 | +- `lock`: Lock wallet. |
| 119 | +- `unlock [passphrase] [timeout?]`: Unlock wallet. |
| 120 | +- `resend`: Resend pending transactions. |
| 121 | + |
| 122 | +### RPC Commands |
| 123 | + |
| 124 | +Bcoin implements nearly all bitcoind calls along with some custom calls. |
| 125 | + |
| 126 | +- `stop` |
| 127 | +- `help` |
| 128 | +- `getblockchaininfo` |
| 129 | +- `getbestblockhash` |
| 130 | +- `getblockcount` |
| 131 | +- `getblock` |
| 132 | +- `getblockhash` |
| 133 | +- `getblockheader` |
| 134 | +- `getchaintips` |
| 135 | +- `getdifficulty` |
| 136 | +- `getmempoolancestors` |
| 137 | +- `getmempooldescendants` |
| 138 | +- `getmempoolentry` |
| 139 | +- `getmempoolinfo` |
| 140 | +- `getrawmempool` |
| 141 | +- `gettxout` |
| 142 | +- `gettxoutsetinfo` |
| 143 | +- `verifychain` |
| 144 | +- `invalidateblock` |
| 145 | +- `reconsiderblock` |
| 146 | +- `getnetworkhashps` |
| 147 | +- `getmininginfo` |
| 148 | +- `prioritisetransaction` |
| 149 | +- `getwork` |
| 150 | +- `getworklp` |
| 151 | +- `getblocktemplate` |
| 152 | +- `submitblock` |
| 153 | +- `setgenerate` |
| 154 | +- `getgenerate` |
| 155 | +- `generate` |
| 156 | +- `generatetoaddress` |
| 157 | +- `estimatefee` |
| 158 | +- `estimatepriority` |
| 159 | +- `estimatesmartfee` |
| 160 | +- `estimatesmartpriority` |
| 161 | +- `getinfo` |
| 162 | +- `validateaddress` |
| 163 | +- `createmultisig` |
| 164 | +- `createwitnessaddress` |
| 165 | +- `verifymessage` |
| 166 | +- `signmessagewithprivkey` |
| 167 | +- `setmocktime` |
| 168 | +- `getconnectioncount` |
| 169 | +- `ping` |
| 170 | +- `getpeerinfo` |
| 171 | +- `addnode` |
| 172 | +- `disconnectnode` |
| 173 | +- `getaddednodeinfo` |
| 174 | +- `getnettotals` |
| 175 | +- `getnetworkinfo` |
| 176 | +- `setban` |
| 177 | +- `listbanned` |
| 178 | +- `clearbanned` |
| 179 | +- `getrawtransaction` |
| 180 | +- `createrawtransaction` |
| 181 | +- `decoderawtransaction` |
| 182 | +- `decodescript` |
| 183 | +- `sendrawtransaction` |
| 184 | +- `signrawtransaction` |
| 185 | +- `gettxoutproof` |
| 186 | +- `verifytxoutproof` |
| 187 | +- `fundrawtransaction` |
| 188 | +- `resendwallettransactions` |
| 189 | +- `abandontransaction` |
| 190 | +- `addmultisigaddress` |
| 191 | +- `addwitnessaddress` |
| 192 | +- `backupwallet` |
| 193 | +- `dumpprivkey` |
| 194 | +- `dumpwallet` |
| 195 | +- `encryptwallet` |
| 196 | +- `getaccountaddress` |
| 197 | +- `getaccount` |
| 198 | +- `getaddressesbyaccount` |
| 199 | +- `getbalance` |
| 200 | +- `getnewaddress` |
| 201 | +- `getrawchangeaddress` |
| 202 | +- `getreceivedbyaccount` |
| 203 | +- `getreceivedbyaddress` |
| 204 | +- `gettransaction` |
| 205 | +- `getunconfirmedbalance` |
| 206 | +- `getwalletinfo` |
| 207 | +- `importprivkey` |
| 208 | +- `importwallet` |
| 209 | +- `importaddress` |
| 210 | +- `importprunedfunds` |
| 211 | +- `importpubkey` |
| 212 | +- `keypoolrefill` |
| 213 | +- `listaccounts` |
| 214 | +- `listaddressgroupings` |
| 215 | +- `listlockunspent` |
| 216 | +- `listreceivedbyaccount` |
| 217 | +- `listreceivedbyaddress` |
| 218 | +- `listsinceblock` |
| 219 | +- `listtransactions` |
| 220 | +- `listunspent` |
| 221 | +- `lockunspent` |
| 222 | +- `move` |
| 223 | +- `sendfrom` |
| 224 | +- `sendmany` |
| 225 | +- `sendtoaddress` |
| 226 | +- `setaccount` |
| 227 | +- `settxfee` |
| 228 | +- `signmessage` |
| 229 | +- `walletlock` |
| 230 | +- `walletpassphrasechange` |
| 231 | +- `walletpassphrase` |
| 232 | +- `removeprunedfunds` |
| 233 | +- `getmemory` |
| 234 | +- `selectwallet` |
| 235 | +- `setloglevel` |
0 commit comments