Application Server
App server
The server project is the aggregation of these three sub projects
The server project provides a away to access information from these three projects via a JSON RPC.
Building the server
You can build the server with the sbt native packager. The native packager offers numerous ways to package the project.
In this example we are going to use stage which will produce bash scripts we can easily execute. You can stage the server with the following command.
sbt appServer/universal:stage
This will produce a script to execute bitcoin-s which you can start with
./app/server/target/universal/stage/bin/bitcoin-s-server
Configuration
If you would like to pass in a custom datadir for your server, you can do
./app/server/target/universal/stage/bin/bitcoin-s-server --datadir /path/to/datadir/
To use a config file that is not the bitcoin-s.conf file in your datadir, you can do
./app/server/target/universal/stage/bin/bitcoin-s-server --conf /path/to/file.conf
You can also pass in a custom rpcport to bind to
./app/server/target/universal/stage/bin/bitcoin-s-server --rpcport 12345
For more information on configuring the server please see our configuration document
For more information on how to use our built in cli to interact with the server please see /docs/0.5.0/applications/cli
Server Endpoints
Blockchain
getblockcount- Get the current block heightgetfiltercount- Get the number of filtersgetfilterheadercount- Get the number of filter headersgetbestblockhash- Get the best block hashdecoderawtransactiontx-Decode the given raw hex transactiontx- Transaction encoded in hex to decode
Wallet
rescan[options]- Rescan for wallet UTXOs--force- Clears existing wallet records. Warning! Use with caution!--batch-size <value>- Number of filters that can be matched in one batch--start <value>- Start height--end <value>- End height--ignorecreationtime- Ignores the wallet creation date and will instead do a full rescan
isempty- Checks if the wallet contains any datawalletinfo- Returns data about the current wallet being usedgetbalance[options]- Get the wallet balance--sats- Display balance in satoshis
getconfirmedbalance[options]- Get the wallet balance of confirmed utxos--sats- Display balance in satoshis
getunconfirmedbalance[options]- Get the wallet balance of unconfirmed utxos--sats- Display balance in satoshis
getutxos- Returns list of all wallet utxosgetaddresses- Returns list of all wallet addresses currently being watchedgetspentaddresses- Returns list of all wallet addresses that have received funds and been spentgetfundedaddresses- Returns list of all wallet addresses that are holding fundsgetunusedaddresses- Returns list of all wallet addresses that have not been usedgetaccounts- Returns list of all wallet accountswalletinfo- Returns meta information about the walletcreatenewaccount- Creates a new wallet accountgetaddressinfoaddress- Returns list of all wallet accountsaddress- Address to get information about
getnewaddress- Get a new addresssendtoaddressaddressamount[options]- Send money to the given addressaddress- Address to send toamount- Amount to send in BTC--feerate <value>- Fee rate in sats per virtual byte
sendfromoutpointsoutpointsaddressamount[options]- Send money to the given addressoutpoints- Out Points to send fromaddress- Address to send toamount- Amount to send in BTC--feerate <value>- Fee rate in sats per virtual byte
sendwithalgoaddressamountalgo[options]- Send money to the given address using a specific coin selection algoaddress- Address to send toamount- Amount to send in BTCalgo- Coin selection algo--feerate <value>- Fee rate in sats per virtual byte
signpsbtpsbt- Signs the PSBT's inputs with keys that are associated with the walletpsbt- PSBT to sign
opreturncommitmessage[options]- Creates OP_RETURN commitment transactionmessage- message to put into OP_RETURN commitment--hashMessage- should the message be hashed before commitment--feerate <value>- Fee rate in sats per virtual byte
bumpfeecpfptxidfeerate- Bump the fee of the given transaction id with a child tx using the given fee ratetxid- Id of transaction to bump feefeerate- Fee rate in sats per virtual byte of the child transaction
bumpfeerbftxidfeerate- Replace given transaction with one with the new fee ratetxid- Id of transaction to bump feefeerate- New fee rate in sats per virtual byte
gettransactiontxid- Get detailed information about in-wallet transactiontxid- The transaction id
lockunspentunlocktransactions- Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.unlock- Whether to unlock (true) or lock (false) the specified transactionstransactions- The transaction outpoints to unlock/lock
importseedwalletnamewordspassphrase- Imports a mnemonic seed as a new seed filewalletname- Name to associate with this seedwords- Mnemonic seed words, space separatedpassphrase- Passphrase to encrypt this seed with
importxprvwalletnamexprvpassphrase- Imports a mnemonic seed as a new seed filewalletname- Name to associate with this seedxprv- base58 encoded extended private keypassphrase- Passphrase to encrypt this seed with
keymanagerpassphrasechangeoldpassphrasenewpassphrase- Changes the wallet passphraseoldpassphrase- The current passphrasenewpassphrase- The new passphrase
keymanagerpassphrasesetpassphrase- Encrypts the wallet with the given passphrasepassphrase- The passphrase to encrypt the wallet with
Network
getpeers- List the connected peersstop- Request a graceful shutdown of Bitcoin-SsendrawtransactiontxBroadcasts the raw transactiontx- Transaction serialized in hex
PSBT
decodepsbtpsbt- Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.psbt- PSBT serialized in hex or base64 format
combinepsbtspsbts- Combines all the given PSBTspsbts- PSBTs serialized in hex or base64 format
joinpsbtspsbts- Combines all the given PSBTspsbts- PSBTs serialized in hex or base64 format
finalizepsbtpsbt- Finalizes the given PSBT if it canpsbt- PSBT serialized in hex or base64 format
extractfrompsbtpsbt- Extracts a transaction from the given PSBT if it canpsbt- PSBT serialized in hex or base64 format
converttopsbtunsignedTx- Creates an empty psbt from the given transactionunsignedTx- serialized unsigned transaction in hex
Util
createmultisignrequiredkeys[address_type]- Creates a multi-signature address with n signature of m keys required.nrequired- The number of required signatures out of the n keys.keys- The hex-encoded public keys.address_type-The address type to use. Options are "legacy", "p2sh-segwit", and "bech32"
Sign PSBT with Wallet Example
Bitcoin-S CLI:
$ bitcoin-s-cli signpsbt cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA
cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA
CURL:
$ curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "signpsbt", "params": ["cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA"]}' -H "Content-Type: application/json" http://127.0.0.1:9999/
{"result":"cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA","error":null}