Skip to content

Commit

Permalink
wip fix timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguida committed Nov 11, 2023
1 parent 1353f03 commit cfe10d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ bdk_esplora = { git = "https://github.com/bitcoindevkit/bdk", rev = "8f38e96e454
# bdk_file_store = { version = "0.2.0" }
# bdk_file_store = { path = "../bdk/crates/file_store" }
bdk_file_store = { git = "https://github.com/bitcoindevkit/bdk", rev = "8f38e96e4542db2378e2e64cd9289638ee86ba1a" }
# bitcoincore-rpc = { path = "../rust-bitcoincore-rpc/client" }
bitcoincore-rpc = { git = "https://github.com/chrisguida/rust-bitcoincore-rpc", branch = "feat/scanblocks" }
bitcoincore-rpc = { path = "../rust-bitcoincore-rpc/client" }
# bitcoincore-rpc = { git = "https://github.com/chrisguida/rust-bitcoincore-rpc", branch = "feat/scanblocks" }
clap = { version = "4.4.0", features = ["derive"] }
cln-plugin = { git = "https://github.com/elementsproject/lightning", version = "0.1.4" }
# cln-plugin = { path = "../../lightning/plugins" }
Expand Down
42 changes: 27 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::ffi::OsString;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Duration;
use tokio::sync::Mutex;

use anyhow::Ok;
Expand All @@ -31,12 +32,7 @@ use tokio;
use bdk::TransactionDetails;
use smaug::state::{Smaug, State};


fn scanblocks<'a>(
brpc_user: String,
brpc_pass: String,
) -> Result<(), Error>
{
fn scanblocks<'a>(brpc_user: String, brpc_pass: String) -> Result<(), Error> {
// let external_descriptor = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/0'/0'/0/*)";
// mutinynet_descriptor = "wpkh(tprv8ZgxMBicQKsPdSAgthqLZ5ZWQkm5As4V3qNA5G8KKxGuqdaVVtBhytrUqRGPm4RxTktSdvch8JyUdfWR8g3ddrC49WfZnj4iGZN8y5L8NPZ/*)"
let _mutinynet_descriptor_ext = "wpkh(tprv8ZgxMBicQKsPdSAgthqLZ5ZWQkm5As4V3qNA5G8KKxGuqdaVVtBhytrUqRGPm4RxTktSdvch8JyUdfWR8g3ddrC49WfZnj4iGZN8y5L8NPZ/84'/0'/0'/0/*)";
Expand All @@ -48,11 +44,19 @@ fn scanblocks<'a>(

use bitcoincore_rpc::{Auth, Client, RpcApi};

let rpc = Client::new("http://localhost:18443",
Auth::UserPass(brpc_user, brpc_pass)
// Auth::CookieFile(PathBuf::from("/home/cguida/.bitcoin/regtest/.cookie"))
).unwrap();
let descriptor = ScanBlocksRequest::Extended { desc:_mutinynet_descriptor_ext.to_string(), range: None };
let brpc_host = "127.0.0.1";
let brpc_port = 18443;

let rpc = Client::new_with_timeout(
&format!("http://{}:{}", brpc_host, brpc_port),
Auth::UserPass(brpc_user, brpc_pass), // Auth::CookieFile(PathBuf::from("/home/cguida/.bitcoin/regtest/.cookie"))
Duration::from_secs(3600),
)
.unwrap();
let descriptor = ScanBlocksRequest::Extended {
desc: _mutinynet_descriptor_ext.to_string(),
range: None,
};
let descriptors = &[descriptor];
let res = rpc.scan_blocks_blocking(descriptors);
log::info!("scanblocks result: {:?}", res.unwrap());
Expand Down Expand Up @@ -112,16 +116,24 @@ async fn main() -> Result<(), anyhow::Error> {
let brpc_user = match configured_plugin.option("smaug_brpc_user") {
Some(smaug_brpc_user) => match smaug_brpc_user.as_str() {
Some(wdn) => wdn.to_owned(),
None => {return Err(anyhow!("must specify smaug_brpc_user"))},
None => return Err(anyhow!("must specify smaug_brpc_user")),
},
None => {return Err(anyhow!("must specify smaug_brpc_user (your bitcoind instance rpcuser)"))},
None => {
return Err(anyhow!(
"must specify smaug_brpc_user (your bitcoind instance rpcuser)"
))
}
};
let brpc_pass = match configured_plugin.option("smaug_brpc_pass") {
Some(smaug_brpc_pass) => match smaug_brpc_pass.as_str() {
Some(wdn) => wdn.to_owned(),
None => {return Err(anyhow!("must specify smaug_brpc_pass (your bitcoind instance rpcpassword)"))},
None => {
return Err(anyhow!(
"must specify smaug_brpc_pass (your bitcoind instance rpcpassword)"
))
}
},
None => {return Err(anyhow!("must specify smaug_brpc_user"))},
None => return Err(anyhow!("must specify smaug_brpc_user")),
};
let ln_dir: PathBuf = configured_plugin.configuration().lightning_dir.into();
// Create data dir if it does not exist
Expand Down

0 comments on commit cfe10d2

Please sign in to comment.