Corresponding address or script must previously be included in wallet.
Does NOT check if imported coins are already spent, rescan may be required after the point in time in which the specified transaciton was included in the blockchain. See gettxoutproof and removeprunedfunds.
Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls may report that the imported address exists but related. importaddress "address" ("label" rescan p2sh) Adds a script (in hex) or during that time, other rpc calls may report that the imported address exists but related.
Lock or unlock specified transaction outputs. If no outputs are specified, ALL coins will be unlocked unlock only. Get list of currently locked unspendable outputs. See lockunspent and lock-coin-outpoints. Get all transactions in blocks since a block specified by hash, or all transactions if no block is specifiied. Get all recent transactions for specified account up to a limit, starting from a specified index. Set the fee rate for all new transactions until the fee is changed again, or set to 0 will return to automatic fee. Sign an arbitrary message with the private key corresponding to a specified Bitcoin address in the wallet.
Locks the wallet by removing the decryption key from memory. See walletpassphrase. Deletes the specified transaction from the wallet database. See importprunedfunds. Get information about memory usage.
Identical to node RPC call getmemoryinfo. Examples below describe usage with bsock specifically. For a deeper dive into events and sockets in bcoin, including a tutorial on using bsock and bclient , see the bcoin. Instead of joining wallets, the node server offers two "channels" of events: chain and mempool. When the node has no mempool for example in SPV mode transaction events will be relayed from the pool of peers instead. In both channels, transactions are only returned if they match a bloom filter sent in advance see set filter. Unlike the wallet events, data returned by node events are not converted into JSON format.
The results are raw Buffers or arrays of Buffers. Be sure to observe how the examples use library modules from bcoin and fromRaw methods to recreate the objects. Load a bloom filter to the node socket server. Only transactions matching the filter will be returned. Applies to node tx events and the array of transactions returned by the block connect event. Add an array of Buffers to the existing Bloom filter. Returns a chain entry requested by little-endian block hash or by integer height. No response if entry is not found. Returns an estimated fee rate in satoshis per kB necessary to include a transaction in the specified number of blocks.
Send a raw transaction as Buffer to node server to broadcast. Server will attempt to broadcast the transaction without any checks. Rescan the chain from the specified integer height OR little-endian block hash as Buffer. Requires Bloom filter. Returns a call back to the client after scanning each block:. Where block is a raw ChainEntry and txs is an array of filter-matched transactions as Buffers. Note that this is NOT a wallet rescan, but the returned data can be used by a client-side wallet to update its state.
Emitted when a block is added to the chain. Returns raw ChainEntry of new block. If a Bloom filter has been loaded in advance , this call will also return an array of filter-matching transactions as raw Buffers. Emitted when a block is removed from the chain. Returns raw ChainEntry of the block being removed. Emitted when a transaction that matches a previously set Bloom filter is received by the node server.
Returns transaction as raw Buffer. After creating a websocket and authing with the server, you must send a join event to listen for events on a wallet. Leave a wallet with the leave event. Wallet or admin token is required if wallet-auth is true.
All wallet events return the wallet-id in addition to the JSON data described below. The only wallet calls available are covered in the previous section. Emitted when a transaction is received by the wallet account's current receive address, causing the wallet to derive a new receive address. Returns an array of KeyRing objects with new address details.
Any errors will be returned with an http status code other than , containing a JSON object in the form:. Introduction Welcome to the bcoin API! Example bcoin. Because there is a request timeout set on CLI http requests. Imported private key. Imported public key. Not Supported in CLI. Not supported in CLI. Not available in CLI. Wallet Dump created by Bcoin 2.
End of dump. See JavaScript example.
The extended public key for the primary account in the new wallet. This value is ignored if watchOnly is false account-key for CLI. A mnemonic phrase to use to instantiate an hd private key. All existing inputs must have their previous output transaction be in the wallet. Parameter 1—The hex string of the raw transaction.
The generate RPC nearly instantly generates blocks. Parameter 1—the number of blocks to generate. Result—the generated block header hashes. Using regtest mode also works in normal mode , generate 2 blocks :. The generatetoaddress RPC mines blocks immediately to a specified address. Using regtest mode , generate 2 blocks with maximal iterations:.
The getaccountaddress RPC returns the current Bitcoin address for receiving payments to this account. Once a payment has been received to an address , future calls to this RPC for the same account will return a different address. Result—a bitcoin address. Get an address for the default account:. The getaccount RPC returns the name of the account associated with the given address. Parameter 1—a Bitcoin address. The getaddednodeinfo RPC returns information about the given added node , or all added nodes except onetry nodes.
Only nodes which have been manually added using the addnode RPC will have their information displayed. Parameter 2—what node to display information about. Result—a list of added nodes.
The getaddressesbyaccount RPC returns a list of every address assigned to a particular account. Result—a list of addresses. The getbalance RPC gets the balance in decimal bitcoins across all accounts or for a particular account. Parameter 2—the minimum number of confirmations. Parameter 3—whether to include watch-only addresses. Result—the balance in bitcoins. The getbestblockhash RPC returns the header hash of the most recent block on the best block chain.
Result—hash of the tip from the best block chain. The getblock RPC gets a block with a particular header hash from the local block database either as a JSON object or as a serialized block. Parameter 1— header hash. After the 0.
Result if format was 0 —a serialized block. Result if format was 1 or omitted —a JSON block. Result if format was 2 — a decoded block as a JSON object with verbose transaction data. Get a block in raw hex:. Get the same block in JSON:. The getblockchaininfo RPC provides information about the current state of the block chain.
The getblockcount RPC returns the number of blocks in the local best block chain.