2019-12-22 10:47:15 -06:00
---
2019-12-04 07:25:03 -06:00
id: server
2020-03-13 09:54:07 -05:00
title: Application Server
2019-12-04 07:25:03 -06:00
---
2021-02-20 05:24:04 -06:00
## App server
2019-12-04 07:25:03 -06:00
2020-08-27 14:11:24 -05:00
The server project is the aggregation of these three sub projects
2019-12-04 07:25:03 -06:00
2020-03-13 09:54:07 -05:00
1. [Wallet ](../wallet/wallet.md )
2. [Chain ](../chain/chain.md )
2020-03-15 15:52:58 -05:00
3. [Node ](../node/node.md )
2019-12-04 07:25:03 -06:00
The server project provides a away to access information from these three projects via a JSON RPC.
2021-02-20 05:24:04 -06:00
## Building the server
2019-12-04 07:25:03 -06:00
2021-02-20 05:24:04 -06:00
### Java binary
2019-12-04 07:25:03 -06:00
You can build the server with the [sbt native packager ](https://github.com/sbt/sbt-native-packager ).
The native packager offers [numerous ways to package the project ](https://github.com/sbt/sbt-native-packager#examples ).
2020-08-13 10:53:25 -05:00
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.
2019-12-04 07:25:03 -06:00
```bash
2020-10-02 08:29:49 -07:00
sbt appServer/universal:stage
2019-12-04 07:25:03 -06:00
```
This will produce a script to execute bitcoin-s which you can start with
```bash
2020-10-02 08:29:49 -07:00
./app/server/target/universal/stage/bin/bitcoin-s-server
2019-12-04 07:25:03 -06:00
```
2021-02-20 05:24:04 -06:00
### Docker
2021-02-18 13:57:18 -06:00
The oracle server also has docker support. You can build a docker image with the following commands
2021-02-20 05:24:04 -06:00
#### Using an existing docker image
We publish docker images on every PR that is merged to bitcoin-s.
You can find the docker repo for the app server [here ](https://hub.docker.com/r/bitcoinscala/bitcoin-s-server/tags?page=1&ordering=last_updated )
#### Building a docker image
2021-02-18 13:57:18 -06:00
```
sbt "appServer/docker:stage"
```
This will build a `Dockerfile` that is located in `app/server/target/docker/stage`
You can now build the docker image with
```
2022-03-29 06:10:34 -07:00
docker build app/server/target/docker/stage/ -t bitcoinscala/bitcoin-s-server:latest
2021-02-18 13:57:18 -06:00
```
Finally, let's run the image! It's important that you correctly configure port forwarding with the docker container so
you can interact with the running container with `bitcoin-s-cli` or `curl` . By default, our oracle
2022-01-12 14:07:11 -06:00
server listens for requests on port `9999` . By default, the server listens for websocket connections on port `19999` at `/events` .
2021-02-18 13:57:18 -06:00
This means we need to forward requests on the host machine to the docker container correctly.
This can be done with the following command
```
2022-04-21 06:15:57 -05:00
docker run -d -p 9999:9999 -p 19999:19999 -e BITCOIN_S_SERVER_RPC_PASSWORD='topsecret' bitcoinscala/bitcoin-s-server:latest
2021-02-18 13:57:18 -06:00
```
Now you can send requests with `bitcoin-s-cli` or `curl` .
Here is an example with `bitcoin-s-cli`
```
2022-04-21 06:15:57 -05:00
./bitcoin-s-cli getblockcount --password topsecret
2021-02-18 13:57:18 -06:00
10000
```
For more information on build configuration options with `sbt` please see the [sbt native packager docs ](https://sbt-native-packager.readthedocs.io/en/latest/formats/docker.html#tasks )
2021-02-20 05:24:04 -06:00
## Configuration
2020-08-13 10:53:25 -05:00
2021-02-26 07:35:20 -06:00
### Java binary configuration
2020-02-24 09:50:40 -06:00
If you would like to pass in a custom datadir for your server, you can do
```bash
./app/server/target/universal/stage/bin/bitcoin-s-server --datadir /path/to/datadir/
```
2020-05-04 19:09:32 -05:00
2020-08-13 10:53:25 -05:00
To use a config file that is not the `bitcoin-s.conf` file in your datadir, you can do
```bash
./app/server/target/universal/stage/bin/bitcoin-s-server --conf /path/to/file.conf
```
2020-05-04 19:09:32 -05:00
You can also pass in a custom `rpcport` to bind to
```bash
./app/server/target/universal/stage/bin/bitcoin-s-server --rpcport 12345
```
2022-01-12 14:07:11 -06:00
Or set a custom `wsport` to bind to
```bash
./app/server/target/universal/stage/bin/bitcoin-s-server --wsport 54321
```
2020-03-15 15:52:58 -05:00
For more information on configuring the server please see our [configuration ](../config/configuration.md ) document
2019-12-04 07:25:03 -06:00
2020-06-04 06:41:07 -05:00
For more information on how to use our built in `cli` to interact with the server please see [cli.md ](cli.md )
2021-02-26 07:35:20 -06:00
### Docker configuration
2020-06-04 06:41:07 -05:00
2021-03-04 14:29:00 -06:00
In this example, we are using the latest docker image published to our [docker hub ](https://hub.docker.com/repository/docker/bitcoinscala/bitcoin-s-oracle-server/tags?page=1&ordering=last_updated )
which is referenced by `bitcoinscala/bitcoin-s-server:latest`
2021-02-26 07:35:20 -06:00
You can use bitcoin-s with docker volumes. You can also pass in a custom configuration at container runtime.
#### Using a docker volume
```basrc
docker volume create bitcoin-s
2022-01-12 14:07:11 -06:00
docker run -p 9999:9999 -p 19999:19999 \
2021-03-04 14:29:00 -06:00
--mount source=bitcoin-s,target=/home/bitcoin-s/ bitcoinscala/bitcoin-s-server:latest
2021-02-26 07:35:20 -06:00
```
Now you can re-use this volume across container runs. It will keep the same oracle database
and seeds directory located at `/home/bitcoin-s/.bitcoin-s/seeds` in the volume.
#### Using a custom bitcoin-s configuration with docker
You can also specify a custom bitcoin-s configuration at container runtime.
You can mount the configuration file on the docker container and that
configuration will be used in the docker container runtime rather than
the default one we provide [here ](https://github.com/bitcoin-s/bitcoin-s/blob/master/app/oracle-server/src/universal/docker-application.conf )
You can do this with the following command
```bashrc
2022-01-12 14:07:11 -06:00
docker run -p 9999:9999 -p 19999:19999 \
2021-02-26 07:35:20 -06:00
--mount type=bind,source=/my/new/config/,target=/home/bitcoin-s/.bitcoin-s/ \
2021-03-04 14:29:00 -06:00
bitcoinscala/bitcoin-s-server:latest --conf /home/bitcoin-s/.bitcoin-s/bitcoin-s.conf
2021-02-26 07:35:20 -06:00
```
Note: If you adjust the `bitcoin-s.server.rpcport` setting you will need to adjust
the `-p 9999:9999` port mapping on the docker container to adjust for this.
## Server Endpoints
2021-09-27 07:42:21 -05:00
### Common
- `getversion` - The version of our application you are using
2021-12-20 08:19:46 -06:00
- `zipdatadir` `location` - Backs up the datadir in a safe and consistent manner.
- `location` - The locations of the backup zip
2021-09-27 07:42:21 -05:00
2021-02-26 07:35:20 -06:00
### Blockchain
2020-06-04 06:41:07 -05:00
- `getblockcount` - Get the current block height
- `getfiltercount` - Get the number of filters
- `getfilterheadercount` - Get the number of filter headers
- `getbestblockhash` - Get the best block hash
2021-03-21 14:09:34 -05:00
- `getblockheader` - Returns information about block header < hash >
- `hash` - The block hash
2020-10-10 00:13:20 -05:00
- `decoderawtransaction` `tx` - `Decode the given raw hex transaction`
- `tx` - Transaction encoded in hex to decode
2021-12-22 14:15:30 -08:00
- `getmediantimepast` - Returns the median time past
2022-08-22 10:09:00 -05:00
- `getinfo` returns general information about our blockchain state
2020-06-04 06:41:07 -05:00
2021-02-26 07:35:20 -06:00
### Wallet
2020-06-04 06:41:07 -05:00
- `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 data
2021-01-22 13:55:21 -06:00
- `walletinfo` - Returns data about the current wallet being used
2020-06-04 06:41:07 -05:00
- `getbalance` `[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
2021-05-04 12:19:15 -05:00
- `getbalances` `[options]` - Get the wallet balance by utxo state
- `--sats ` - Display balance in satoshis
2020-06-04 06:41:07 -05:00
- `getutxos` - Returns list of all wallet utxos
- `getaddresses` - Returns list of all wallet addresses currently being watched
- `getspentaddresses` - Returns list of all wallet addresses that have received funds and been spent
- `getfundedaddresses` - Returns list of all wallet addresses that are holding funds
- `getunusedaddresses` - Returns list of all wallet addresses that have not been used
- `getaccounts` - Returns list of all wallet accounts
2021-01-28 08:27:11 -06:00
- `walletinfo` - Returns meta information about the wallet
2020-06-04 06:41:07 -05:00
- `createnewaccount` - Creates a new wallet account
- `getaddressinfo` `address` - Returns list of all wallet accounts
- `address` - Address to get information about
- `getnewaddress` - Get a new address
2021-05-03 08:08:23 -05:00
- `listreservedutxos` - lists all utxos that are reserved in the wallet
2020-06-04 06:41:07 -05:00
- `sendtoaddress` `address` `amount` `[options]` - Send money to the given address
- `address` - Address to send to
- `amount` - Amount to send in BTC
- `--feerate <value>` - Fee rate in sats per virtual byte
- `sendfromoutpoints` `outpoints` `address` `amount` `[options]` - Send money to the given address
- `outpoints` - Out Points to send from
- `address` - Address to send to
- `amount` - Amount to send in BTC
- `--feerate <value>` - Fee rate in sats per virtual byte
2021-06-16 12:37:40 -07:00
- `sweepwallet` `address` `[options]` - Sends the entire wallet balance to the given address
2021-09-02 08:18:17 -05:00
- `address` - Address to send to
- `--feerate <value>` - Fee rate in sats per virtual byte
2020-06-04 06:41:07 -05:00
- `sendwithalgo` `address` `amount` `algo` `[options]` - Send money to the given address using a specific coin selection algo
- `address` - Address to send to
- `amount` - Amount to send in BTC
- `algo` - Coin selection algo
- `--feerate <value>` - Fee rate in sats per virtual byte
2020-11-07 09:25:59 -06:00
- `signpsbt` `psbt` - Signs the PSBT's inputs with keys that are associated with the wallet
- `psbt` - PSBT to sign
2020-06-04 06:41:07 -05:00
- `opreturncommit` `message` `[options]` - Creates OP_RETURN commitment transaction
- `message` - message to put into OP_RETURN commitment
- `--hashMessage` - should the message be hashed before commitment
2020-12-22 14:19:46 -06:00
- `--feerate <value>` - Fee rate in sats per virtual byte
- `bumpfeecpfp` `txid` `feerate` - Bump the fee of the given transaction id with a child tx using the given fee rate
- `txid` - Id of transaction to bump fee
- `feerate` - Fee rate in sats per virtual byte of the child transaction
- `bumpfeerbf` `txid` `feerate` - Replace given transaction with one with the new fee rate
- `txid` - Id of transaction to bump fee
- `feerate` - New fee rate in sats per virtual byte
2020-12-18 07:18:13 -06:00
- `gettransaction` `txid` - Get detailed information about in-wallet transaction < txid >
- `txid` - The transaction id
2020-09-21 12:37:15 -05:00
- `lockunspent` `unlock` `transactions` - Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.
- `unlock` - Whether to unlock (true) or lock (false) the specified transactions
2021-04-29 07:57:14 -05:00
- `transactions` - The transaction outpoints to unlock/lock, empty to apply to all utxos
2022-06-22 06:14:11 -07:00
- `importseed` `walletname` `words` `passphrase` - Imports a mnemonic seed as a new seed file
- `walletname` - Name to associate with this seed
- `words` - Mnemonic seed words, space separated
- `passphrase` - Passphrase to encrypt this seed with
- `importxprv` `walletname` `xprv` `passphrase` - Imports a mnemonic seed as a new seed file
- `walletname` - Name to associate with this seed
- `xprv` - base58 encoded extended private key
- `passphrase` - Passphrase to encrypt this seed with
- `exportseed` `walletname` `passphrase` - Exports the mnemonic seed phrase
2021-09-02 08:18:17 -05:00
- `walletname` - Name to associate with this seed
2022-06-22 06:14:11 -07:00
- `passphrase` - Passphrase to decrypt this seed with
- `markseedasbackedup` `walletname` `passphrase` - Marks the seed as backed up. It prevents `exportseed` from returning the mnemonic phrase
2021-09-02 08:18:17 -05:00
- `walletname` - Name to associate with this seed
2022-06-22 06:14:11 -07:00
- `passphrase` - Passphrase to decrypt this seed with
- `getseedbackuptime` `walletname` `passphrase` - Returns time when the seed was backed up
- `walletname` - Name to associate with this seed
- `passphrase` - Passphrase to decrypt this seed with
2020-12-21 06:53:20 -06:00
- `keymanagerpassphrasechange` `oldpassphrase` `newpassphrase` - Changes the wallet passphrase
2020-11-15 08:07:49 -06:00
- `oldpassphrase` - The current passphrase
- `newpassphrase` - The new passphrase
2020-12-21 06:53:20 -06:00
- `keymanagerpassphraseset` `passphrase` - Encrypts the wallet with the given passphrase
2020-11-15 08:07:49 -06:00
- `passphrase` - The passphrase to encrypt the wallet with
2022-08-05 15:34:14 -07:00
- `loadwallet` `walletname` `passphrase` - Loads a wallet
- `walletname` - Name to associate with this seed
- `passphrase` - Passphrase to decrypt this seed with
- `listwallets` - Returns a list of all wallets
2020-06-04 06:41:07 -05:00
2021-09-02 08:18:17 -05:00
### DLC
2021-10-05 06:24:25 -05:00
- `createcontractinfo` `announcement` `totalCollateral` `payouts`
- the announcement to build the contract info for
- the total amount of collateral in the DLC
2021-10-15 19:56:00 -05:00
- The payouts can be in two formats
1. `{ "outcomes" : { "outcome0" : 0, "outcome1": 1, ... }}` . The number is the amount of sats paid to YOU for that outcome.
2. `[{"outcome":0,"payout":0,"extraPrecision":0,"isEndpoint":true}, {"outcome":1,"payout":1,"extraPrecision":0,"isEndpoint":true}, ...]`
2021-09-03 09:46:09 -05:00
- `decodecontractinfo` `contractinfo` - Decodes a contract info into json
- `contractinfo` - Hex encoded contract info
- `decodeoffer` `offer` - Decodes an offer message into json
- `offer` - Hex encoded dlc offer message
2021-12-01 13:30:18 -06:00
- `decodeaccept` `accept` - Decodes an accept message into json
- `accept` - Hex encoded dlc accept message
- `decodesign` `sign` - Decodes a sign message into json
- `sign` - Hex encoded dlc sign message
2021-09-03 09:46:09 -05:00
- `decodeannouncement` `announcement` - Decodes an oracle announcement message into json
- `announcement` - Hex encoded oracle announcement message
- `decodeattestments` `attestments` - Decodes an oracle attestments message into json
- `attestments` - Hex encoded oracle attestments message
2021-09-02 08:18:17 -05:00
- `getdlchostaddress` - Returns the public listening address of the DLC Node
2022-04-25 14:30:32 -05:00
- `createdlcoffer` `contractInfo` `collateral` `[feerate]` `refundlocktime` `[options]` - Creates a DLC offer that another party can accept
2021-09-02 08:18:17 -05:00
- `contractInfo` - Hex encoded contractInfo message
- `collateral` - Satoshis to fund your side of the DLC
- `feerate` - Fee rate for both funding and closing transactions, in sats/vbytes
- `refundlocktime` - Locktime of the refund transaction
2022-06-14 06:14:28 -07:00
- `cetlocktime <value>` - Should not be set unless you know what you are doing. Locktime of the contract execution transactions (defaults to current height)
- `peer` - Peer's network address
2021-09-02 08:18:17 -05:00
- `acceptdlc` `offer` `peer` - Accepts a DLC offer given from another party
- `offer` - Hex encoded dlc offer message
- `peer` - Peer's network address
- `acceptdlcoffer` `offer` - Accepts a DLC offer given from another party
- `offer` - Hex encoded offer message
2022-06-14 06:14:28 -07:00
- `peer` - Peer's network address
2021-09-02 08:18:17 -05:00
- `acceptdlcofferfromfile` `path` `[destination]` - Accepts a DLC offer given from another party
2022-06-14 06:14:28 -07:00
- `path` - Path to dlc offer file
- `destination` - Path to write dlc accept message
2022-04-21 11:02:35 -07:00
- `contact-add` `alias` `address` `memo`
- `alias` - alias for the address like a name
- `address` - the tor address for the peer
- `memo` - a memo for this contact
- `contacts-list` - lists all contacts in the wallet
- `contact-remove` `address`
- `address` - the tor address for the peer to remove
2022-06-14 06:14:28 -07:00
- `dlc-contact-add` `dlcid` `address` - Associated a DLC with a peer
- `dlc-contact-remove` `dlcid` - Removes a DLC-peer association
- `address` - the tor address for the peer to remove
2021-09-02 08:18:17 -05:00
- `signdlc` `accept` - Signs a DLC
- `accept` - Hex encoded dlc accept message
- `signdlcfromfile` `path` `[destination]` - Signs a DLC
- `path` - Path to dlc accept file
- `destination` - Path to write dlc sign message
- `adddlcsigs` `sigs` - Adds DLC Signatures into the database
- `sigs` - Hex encoded dlc sign message
- `adddlcsigsfromfile` `path` - Adds DLC Signatures into the database
- `path` - Path to dlc sign file
- `adddlcsigsandbroadcast` `sigs` - Adds DLC Signatures into the database and broadcasts the funding transaction
- `sigs` - Hex encoded dlc sign message
- `adddlcsigsandbroadcastfromfile` `path` - Adds DLC Signatures into the database and broadcasts the funding transaction
- `path` - Path to dlc sign file
- `getdlcfundingtx` `contractId` - Returns the Funding Tx corresponding to the DLC with the given contractId
- `contractId` - ContractId of the DLC
- `broadcastdlcfundingtx` `contractId` - Broadcasts the funding Tx corresponding to the DLC with the given contractId
- `contractId` - ContractId of the DLC
- `executedlc` `contractId` `oraclesigs` `[options]` - Executes the DLC with the given contractId
- `contractId` - ContractId of the DLC
- `oraclesigs` - Array of oracle attestations
- `--noBroadcast` - Gives full serialized transaction instead of broadcasting
- `executedlcrefund` `contractId` `[options]` - Executes the Refund transaction for the given DLC
- `contractId` - ContractId of the DLC
- `--noBroadcast` - Gives full serialized transaction instead of broadcasting
- `canceldlc` `dlcId` - Cancels a DLC and unreserves used utxos
- `dlcId` - Internal id of the DLC
- `getdlcs` - Returns all dlcs in the wallet
2022-06-14 06:14:28 -07:00
- `address` - optional contact address, if specified the RPC returns only DLCs associated with the given address
2021-09-02 08:18:17 -05:00
- `getdlc` `dlcId` - Gets a specific dlc in the wallet
- `dlcId` - Internal id of the DLC
2022-03-03 19:00:32 -08:00
- `offer-add` `offerTLV` `peerAddress` `message` - Puts an incoming offer into the inbox
2022-02-28 12:25:46 -08:00
- `offerTLV` - Offer TLV
- `peer` - Peer URI (optional)
- `message` - Peer's message or note (optional)
2022-03-03 19:00:32 -08:00
- `"offer-remove` `hash` - Remove an incoming offer from inbox
2022-02-28 12:25:46 -08:00
- `hash` - Hash of the offer TLV
2022-03-09 15:36:44 -06:00
- `offer-send` `offerOrTempContractId` `peerAddress` `message` - Sends an offer to a peer. `offerOrTempContractId` is either an offer TLV or a temporary contract ID.
- `offers-list` - List all incoming offers from the inbox
- `getdlcoffer` `tempContractId` - Gets a DLC offer by temporary contract ID.
- `getaddresslabel` `address` - gets all labels for an address
- `getaddresslabels` - returns all addresses with labels in the wallet
- `dropaddresslabel` `address` `label` - drops the label for a given address
- `dropaddresslabels` `address` - drops all labels for the given address
2021-09-02 08:18:17 -05:00
2021-02-26 07:35:20 -06:00
### Network
2020-06-04 06:41:07 -05:00
- `getpeers` - List the connected peers
- `stop` - Request a graceful shutdown of Bitcoin-S
- `sendrawtransaction` `tx` `Broadcasts the raw transaction`
- `tx` - Transaction serialized in hex
2021-02-26 07:35:20 -06:00
### PSBT
2020-11-06 06:56:46 -06:00
- `decodepsbt` `psbt` - Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.
- `psbt` - PSBT serialized in hex or base64 format
2020-06-04 06:41:07 -05:00
- `combinepsbts` `psbts` - Combines all the given PSBTs
- `psbts` - PSBTs serialized in hex or base64 format
- `joinpsbts` `psbts` - Combines all the given PSBTs
- `psbts` - PSBTs serialized in hex or base64 format
- `finalizepsbt` `psbt` - Finalizes the given PSBT if it can
- `psbt` - PSBT serialized in hex or base64 format
- `extractfrompsbt` `psbt` - Extracts a transaction from the given PSBT if it can
- `psbt` - PSBT serialized in hex or base64 format
- `converttopsbt` `unsignedTx` - Creates an empty psbt from the given transaction
- `unsignedTx` - serialized unsigned transaction in hex
2020-11-07 09:25:59 -06:00
2021-02-26 07:35:20 -06:00
### Util
2021-01-09 09:54:34 -06:00
- `createmultisig` `nrequired` `keys` `[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"
2021-04-28 16:43:20 -05:00
- `estimatefee` - Returns the recommended fee rate using the fee provider
2020-11-07 09:25:59 -06:00
2022-08-22 10:09:00 -05:00
## getinfo
```bash
curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getinfo", "params": []}' -H "Content-Type: application/json" http://127.0.0.1:9999/
{"result":{"network":"main","blockHeight":750129,"blockHash":"00000000000000000002f7d39ca6c914329a8d87010215ef6466c17ffaba0a1f","torStarted":true,"syncing":false,"isinitialblockdownload":false},"error":null}
```
2021-02-26 07:35:20 -06:00
## Sign PSBT with Wallet Example
2020-11-07 09:25:59 -06:00
Bitcoin-S CLI:
```bash
2022-02-12 08:18:14 -06:00
bitcoin-s-cli signpsbt cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA
2020-11-07 09:25:59 -06:00
cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA
```
CURL:
```bash
2022-02-12 08:18:14 -06:00
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/
2020-11-07 09:25:59 -06:00
{"result":"cHNidP8BAP0FAQIAAAABWUWxYiPKgdGfXcIxJ6MRDxEpUecw59Gk4NpROI5oukoBAAAAAAAAAAAEPttkvdwAAAAXqRSOVAp6Qe/u2hq74e/ThB8foBKn7IfZYMgGCAAAAADbmaQ2nwAAAEdRIQLpfVqyaL9Jb/IkveatNyVeONE8Q/6TzXAWosxLo9e21SECc5G3XiK7xKLlkBG7prMx7p0fMeQwMH5e9H10mBon39JSrtgtgjjLAQAAUGMhAn2YaZnv25I6d6vbb1kw6Xp5IToDrEzl/0VBIW21gHrTZwXg5jGdALJ1IQKyNpDNiOiN6lWpYethib04+XC9bpFXrdpec+xO3U5IM2is9ckf5AABAD0CAAAAAALuiOL0rRcAABYAFPnpLByQq1Gg3vwiP6qR8FmOOjwxvVllM08DAAALBfXJH+QAsXUAAK4AAAAAAQcBAAAAAAAA","error":null}
```
2021-12-25 11:11:04 -06:00
## Websocket endpoints
Bitcoin-s offers websocket endpoints. By default, the endpoint is `ws://localhost:1999/events`
You can configure where how the endpoints are configured inside your `bitcoin-s.conf`
```
bitcoin-s.server.wsbind=localhost
bitcoin-s.server.wsport=19999
```
These events are implemented using our [internal callback mechanism ](../wallet/wallet-callbacks.md#wallet-callbacks ).
An example event that is defined is our `blockprocess` event.
Everytime our wallet processes a block, our wallet will notify you via websockets.
Here is an example payload
The current types of events defined are
1. `txprocessed` - when the wallet processes a transaction. Every transaction in a block will get relayed currently
2. `reservedutxos` - when the wallet reserves OR unreserves utxos
3. `newaddress` - when the wallet generates a new address
4. `txbroadcast` - when the wallet broadcasts a tx
5. `blockprocessed` - when the wallet processes a block
```
{"type":"blockprocessed","payload":{"raw":"04e0ff2ffce8c3e866e367d305886a3f9d353e557524f61f9cf0c26c46000000000000001206d2e396387bff1c13cbe572d4646abae1ae405f4066ab5e6f5edd6d8f028008a8bb61ffff001af23dd47e","hash":"00000000000000de21f23f6945f028d5ecb47863428f6e9e035ab2fb7a3ef356","confirmations":1,"height":2131641,"version":805298180,"versionHex":"2fffe004","merkleroot":"80028f6ddd5e6f5eab66405f40aee1ba6a64d472e5cb131cff7b3896e3d20612","time":1639688200,"mediantime":1639688200,"nonce":2127838706,"bits":"1a00ffff","difficulty":1.6069135243303364E60,"chainwork":"00000000000000000000000000000000000000000000062438437ddd009e698b","previousblockhash":"00000000000000466cc2f09c1ff62475553e359d3f6a8805d367e366e8c3e8fc","nextblockhash":null}}
```