From 3f7a6cbc90abc41e1f3ce32532df2d7b25bec285 Mon Sep 17 00:00:00 2001 From: sstone Date: Thu, 20 Jul 2023 10:16:21 +0200 Subject: [PATCH] Make account parameter optional in API calls Account defaults to 0 for getmasterxpub and getdescriptors which is a good, safe choice for most users. --- docs/BitcoinCoreKeys.md | 8 ++++---- .../main/scala/fr/acinq/eclair/api/handlers/OnChain.scala | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/BitcoinCoreKeys.md b/docs/BitcoinCoreKeys.md index eb36a01fcf..4f9eeb2617 100644 --- a/docs/BitcoinCoreKeys.md +++ b/docs/BitcoinCoreKeys.md @@ -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 @@ -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). @@ -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 @@ -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 ``` diff --git a/eclair-node/src/main/scala/fr/acinq/eclair/api/handlers/OnChain.scala b/eclair-node/src/main/scala/fr/acinq/eclair/api/handlers/OnChain.scala index 51772a2d3f..e89b94c7ce 100644 --- a/eclair-node/src/main/scala/fr/acinq/eclair/api/handlers/OnChain.scala +++ b/eclair-node/src/main/scala/fr/acinq/eclair/api/handlers/OnChain.scala @@ -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)))) } }