gui: start internal bitcoind with given config
This will allow bitcoind to start also in case of using rpcauth. The cookie file is canonicalized in the installer beforehand instead. There is now no need for the config parameter to be mutable.
This commit is contained in:
parent
b5980fbc4f
commit
7584b6347b
@ -1,7 +1,7 @@
|
||||
use base64::Engine;
|
||||
use bitcoin_hashes::{sha256, Hash, HashEngine, Hmac, HmacEngine};
|
||||
use liana::{
|
||||
config::{BitcoindConfig, BitcoindRpcAuth},
|
||||
config::BitcoindConfig,
|
||||
miniscript::bitcoin::{self, Network},
|
||||
random::{random_bytes, RandomnessError},
|
||||
};
|
||||
@ -402,7 +402,7 @@ impl Bitcoind {
|
||||
/// Start internal bitcoind for the given network.
|
||||
pub fn start(
|
||||
network: &bitcoin::Network,
|
||||
mut config: BitcoindConfig,
|
||||
config: BitcoindConfig,
|
||||
liana_datadir: &PathBuf,
|
||||
) -> Result<Self, StartInternalBitcoindError> {
|
||||
let bitcoind_datadir = internal_bitcoind_datadir(liana_datadir);
|
||||
@ -477,10 +477,6 @@ impl Bitcoind {
|
||||
thread::sleep(time::Duration::from_millis(500));
|
||||
}
|
||||
|
||||
config.rpc_auth = BitcoindRpcAuth::CookieFile(cookie_path.canonicalize().map_err(|e| {
|
||||
StartInternalBitcoindError::CouldNotCanonicalizeCookiePath(e.to_string())
|
||||
})?);
|
||||
|
||||
liana::BitcoinD::new(&config, "internal_bitcoind_start".to_string())
|
||||
.map_err(|e| StartInternalBitcoindError::BitcoinDError(e.to_string()))?;
|
||||
|
||||
|
||||
@ -693,17 +693,24 @@ impl Step for InternalBitcoindStep {
|
||||
}
|
||||
}
|
||||
message::InternalBitcoindMsg::Start => {
|
||||
if let Err(e) = self.bitcoind_datadir.canonicalize() {
|
||||
self.started = Some(Err(
|
||||
StartInternalBitcoindError::CouldNotCanonicalizeDataDir(e.to_string()),
|
||||
));
|
||||
return Command::none();
|
||||
}
|
||||
|
||||
let cookie_path = bitcoind::internal_bitcoind_cookie_path(
|
||||
&self.bitcoind_datadir,
|
||||
&self.network,
|
||||
);
|
||||
let bitcoind_datadir = match self.bitcoind_datadir.canonicalize() {
|
||||
Ok(path) => path,
|
||||
Err(e) => {
|
||||
self.started = Some(Err(
|
||||
StartInternalBitcoindError::CouldNotCanonicalizeDataDir(
|
||||
e.to_string(),
|
||||
),
|
||||
));
|
||||
return Command::none();
|
||||
}
|
||||
};
|
||||
// Pass the canonicalized `bitcoind_datadir` so that the cookie path returned
|
||||
// by `internal_bitcoind_cookie_path` is also canonicalized. This way, the
|
||||
// canonicalized path will later be saved to the config file.
|
||||
// We cannot use `cookie_path.canonicalize()` as we have not yet started
|
||||
// bitcoind and so the path does not exist.
|
||||
let cookie_path =
|
||||
bitcoind::internal_bitcoind_cookie_path(&bitcoind_datadir, &self.network);
|
||||
|
||||
let rpc_port = self
|
||||
.internal_bitcoind_config
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user