Merge #215: update bitcoind connection and be more robust at startup

acd6929831964d643565f8f22b552f74613a3a1d doc: update for bitcoind 24.0.1 release (Antoine Poinsot)
650101525d890f50290989bd58c367024a69115c bitcoind: set minimum required version to 24.0 (Antoine Poinsot)
9211d849c191ff5d2552bde681edaa7038c8d049 bitcoind: be less stupid when loading the watchonly wallet (Antoine Poinsot)

Pull request description:

  Fixes #210
  Fixes #209
  Fixes #213

ACKs for top commit:
  darosior:
    self-ACK acd6929831964d643565f8f22b552f74613a3a1d

Tree-SHA512: 8cacf41b0e00faed877462dc57b595265ff2936937d45535d1be2b42fd1bf80df2928ccacbefd43f82d88a728aca898a8549899380e341de8b8e74d34ec74642
This commit is contained in:
Antoine Poinsot 2022-12-13 18:00:14 +01:00
commit 05bbb3eef2
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
5 changed files with 33 additions and 30 deletions

View File

@ -43,11 +43,10 @@ task:
set -xe
# Download the bitcoind binary
# TODO: cleanup by using env variables like in revaultd once 24.0 is out.
ARCHIVE_NAME="bitcoin-core-24.0rc1.tar.gz"
curl https://bitcoincore.org/bin/bitcoin-core-24.0/test.rc1/bitcoin-24.0rc1-x86_64-linux-gnu.tar.gz -o $ARCHIVE_NAME
tar -xzf $ARCHIVE_NAME
export BITCOIND_PATH=bitcoin-24.0rc1/bin/bitcoind
curl -O https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
echo "49df6e444515d457ea0b885d66f521f2a26ca92ccf73d5296082e633544253bf bitcoin-24.0.1-x86_64-linux-gnu.tar.gz" | sha256sum -c
tar -xzf bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
export BITCOIND_PATH=bitcoin-24.0.1/bin/bitcoind
# Run the functional tests
LIANAD_PATH=$PWD/target/release/lianad pytest $TEST_GROUP -vvv -n 2

View File

@ -34,7 +34,7 @@ Therefore in order to use Liana you need to have Bitcoin Core running on your ma
desired network. The `bitcoind` installation may be pruned (note this may affect block chain
rescans) up to the maximum (around 550MB of blocks).
The minimum supported version of Bitcoin Core is `24.0`. If you don't have Bitcoin Core installed on
The minimum supported version of Bitcoin Core is `24.0.1`. If you don't have Bitcoin Core installed on
your machine yet, you can download it [there](https://bitcoincore.org/en/download/).
### Installing the software

View File

@ -45,15 +45,13 @@ cd liana_quicktry
## Step 1: setup `bitcoind`
Liana needs `bitcoind` to communicate with the Bitcoin network. Minimum supported version is 24.0.
Liana needs `bitcoind` to communicate with the Bitcoin network. Minimum supported version is 24.0.1.
### Download
TODO: update to 24.0.1 when it's released.
Download the `bitcoind` binary from [the official website of the Bitcoin Core
project](https://bitcoincore.org/bin/bitcoin-core-24.0/) according to your platform (in the context
of this guide, it is most likely `bitcoin-24.0-x86_64-linux-gnu.tar.gz`).
project](https://bitcoincore.org/bin/bitcoin-core-24.0.1/) according to your platform (in the context
of this guide, it is most likely `bitcoin-24.0.1-x86_64-linux-gnu.tar.gz`).
Then verify the signature against a key you trust. The Bitcoin Core Github repo contains [a
list](https://github.com/bitcoin/bitcoin/blob/master/contrib/builder-keys/keys.txt) of frequent
@ -62,11 +60,11 @@ signers. Mine is `590B7292695AFFA5B672CBB2E13FC145CD3F4304`.
Finally, uncompress the archive to get access to the `bitcoind` binary.
```
curl -O https://bitcoincore.org/bin/bitcoin-core-24.0/bitcoin-24.0-x86_64-linux-gnu.tar.gz -O https://bitcoincore.org/bin/bitcoin-core-24.0/SHA256SUMS -O https://bitcoincore.org/bin/bitcoin-core-24.0/SHA256SUMS.asc
curl -O https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz -O https://bitcoincore.org/bin/bitcoin-core-24.0.1/SHA256SUMS -O https://bitcoincore.org/bin/bitcoin-core-24.0/SHA256SUMS.asc
sha256sum --ignore-missing --check SHA256SUMS
gpg --keyserver hkps://keys.openpgp.org --receive 590B7292695AFFA5B672CBB2E13FC145CD3F4304
gpg --verify SHA256SUMS.asc
tar -xzf bitcoin-24.0-x86_64-linux-gnu.tar.gz
tar -xzf bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
```
For details on verifying your download, or for verifying the download on a non-Linux machine refer
@ -77,14 +75,14 @@ to
Run `bitcoind` in the background on the public signet network.
```
./bitcoin-24.0/bin/bitcoind -signet -daemon
./bitcoin-24.0.1/bin/bitcoind -signet -daemon
```
If it is the first time you start a signet Bitcoin on this machine it will take a few minutes to
synchronize (depends on your connection and hardware of course, but it shouldn't take longer than a
handful of minutes). You can track the progress using the `getblockchaininfo` command:
```
./bitcoin-24.0/bin/bitcoin-cli -signet getblockchaininfo
./bitcoin-24.0.1/bin/bitcoin-cli -signet getblockchaininfo
```
You do not need to wait for full synchronisation before moving on to the next step.

View File

@ -35,7 +35,7 @@ const RPC_SOCKET_TIMEOUT: u64 = 180;
const BITCOIND_RETRY_LIMIT: usize = 60;
// The minimum bitcoind version that can be used with lianad.
const MIN_BITCOIND_VERSION: u64 = 239900;
const MIN_BITCOIND_VERSION: u64 = 240000;
/// An error in the bitcoind interface.
#[derive(Debug)]
@ -553,16 +553,15 @@ impl BitcoinD {
Ok(())
}
/// Try to load the watchonly wallet in bitcoind. It will continue on error (since it's
/// likely the wallet is just already loaded) and log it as info instead.
pub fn try_load_watchonly_wallet(&self) {
// TODO: check if it's not loaded instead of blindly trying to load it.
if let Err(e) = self.make_fallible_node_request(
"loadwallet",
&params!(Json::String(self.watchonly_wallet_path.clone()),),
) {
log::info!("Got error '{}' while trying to load watchonly on bitcoind. It is possibly already loaded.", e);
/// Load the watchonly wallet on bitcoind, if it isn't already.
pub fn maybe_load_watchonly_wallet(&self) -> Result<(), BitcoindError> {
if !self.list_wallets().contains(&self.watchonly_wallet_path) {
self.make_fallible_node_request(
"loadwallet",
&params!(Json::String(self.watchonly_wallet_path.clone()),),
)?;
}
Ok(())
}
/// Perform various sanity checks on the bitcoind instance.

View File

@ -203,7 +203,7 @@ fn setup_bitcoind(
bitcoind.create_watchonly_wallet(&config.main_descriptor)?;
log::info!("Created a new watchonly wallet on bitcoind.");
}
bitcoind.try_load_watchonly_wallet();
bitcoind.maybe_load_watchonly_wallet()?;
bitcoind.sanity_check(&config.main_descriptor, config.bitcoin_config.network)?;
log::info!("Connection to bitcoind established and checked.");
@ -433,10 +433,10 @@ mod tests {
stream.flush().unwrap();
}
// Send them a pruned getblockchaininfo telling them we are at version 23.99
// Send them a pruned getblockchaininfo telling them we are at version 24.0
fn complete_version_check(server: &net::TcpListener) {
let net_resp =
"HTTP/1.1 200\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"version\":239900}}\n"
"HTTP/1.1 200\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"version\":240000}}\n"
.as_bytes();
let (mut stream, _) = server.accept().unwrap();
read_til_json_end(&mut stream);
@ -488,12 +488,19 @@ mod tests {
// Send them a dummy result to loadwallet.
fn complete_wallet_loading(server: &net::TcpListener) {
let net_resp =
let listwallets_resp =
"HTTP/1.1 200\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":[]}\n".as_bytes();
let (mut stream, _) = server.accept().unwrap();
read_til_json_end(&mut stream);
stream.write_all(listwallets_resp).unwrap();
stream.flush().unwrap();
let loadwallet_resp =
"HTTP/1.1 200\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"name\":\"dummy\"}}\n"
.as_bytes();
let (mut stream, _) = server.accept().unwrap();
read_til_json_end(&mut stream);
stream.write_all(net_resp).unwrap();
stream.write_all(loadwallet_resp).unwrap();
stream.flush().unwrap();
}