Skip to content

Commit

Permalink
Make account parameter optional in API calls
Browse files Browse the repository at this point in the history
Account defaults to 0 for getmasterxpub and getdescriptors which is a good, safe choice for most users.
  • Loading branch information
sstone committed Jul 31, 2023
1 parent 26d9b1b commit 3f7a6cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/BitcoinCoreKeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This is an example of `eclair-signer.conf` configuration file:

3) Configure Eclair to handle private keys for this wallet

Set `eclair.bitcoind.wallet` to the name of the wallet just created (`eclair` in the example above) and restart Eclair.
Set `eclair.bitcoind.wallet` to the name of the wallet in your `eclair-signer.conf` file (`eclair` in the example above) and restart Eclair.
Eclair will automatically create a new, empty, descriptor-enabled, watch-only wallet in Bitcoin Core and import its descriptors.

:warning: Eclair will not import descriptors if the timestamp set in your `eclair-signer.conf` is more than 2 hours old. If the mnmeonics and
Expand All @@ -50,7 +50,7 @@ the steps described in the next section.
You now have a Bitcoin Core watch-only wallet for which only your Eclair node can sign transactions. This Bitcoin Core wallet can
safely be copied to another Bitcoin Core node to monitor your onchain funds.

You can also use `eclair-cli getmasterxpub --account=0` to get a BIP32 extended public key that you can import into any compatible Bitcoin wallet
You can also use `eclair-cli getmasterxpub` to get a BIP32 extended public key that you can import into any compatible Bitcoin wallet
to create a watch-only wallet (Electrum for example) that you can use to monitor your Bitcoin Core balance.

:warning: this means that your Bitcoin Core wallet cannot send funds on its own (since it cannot access private keys to sign transactions).
Expand Down Expand Up @@ -86,7 +86,7 @@ $ bitcoin-cli -named createwallet wallet_name=eclair disable_private_keys=true b

Copy `eclair-signer.conf` to your Eclair data directory but do not change `eclair.bitcoind.wallet`, and restart Eclair.

`eclair-cli getdescriptors --account=0` will return public wallet descriptors in a format that is compatible with Bitcoin Core, and that you can import with `bitcoin-cli -rpcwallet=eclair importdescriptors`
`eclair-cli getdescriptors` will return public wallet descriptors in a format that is compatible with Bitcoin Core, and that you can import with `bitcoin-cli -rpcwallet=eclair importdescriptors`
This is an example of descriptors generated by Eclair:

```json
Expand All @@ -109,7 +109,7 @@ This is an example of descriptors generated by Eclair:
You can generate the descriptors with your Eclair node and import them into a Bitcoin node with the following commands:

```shell
$ eclair-cli getdescriptors --account=0 | jq --raw-output -c > descriptors.json
$ eclair-cli getdescriptors | jq --raw-output -c > descriptors.json
$ cat descriptors.json | xargs -0 bitcoin-cli -rpcwallet=eclair importdescriptors
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ trait OnChain {
}

val getmasterxpub: Route = postRequest("getmasterxpub") { implicit t =>
formFields("account".as[Long]) { account =>
val xpub = this.eclairApi.getOnchainMasterPubKey(account)
formFields("account".as[Long].?) { account_opt =>
val xpub = this.eclairApi.getOnchainMasterPubKey(account_opt.getOrElse(0L))
complete(new JObject(List("xpub" -> JString(xpub))))
}
}
Expand Down

0 comments on commit 3f7a6cb

Please sign in to comment.