fees.get(&Target::HighPriority)
.unwrap()
.store(high_prio_estimate, Ordering::Release);
- // match fees.get(Target::Background) {
- // Some(fee) => fee.store(background_estimate, Ordering::Release),
- // None =>
- // }
- // if let Some(fee) = background_estimate.feerate {
- // fees.get("background").unwrap().store(fee, Ordering::Release);
- // }
- // if let Some(fee) = normal_estimate.feerate {
- // fees.get("normal").unwrap().store(fee, Ordering::Release);
- // }
- // if let Some(fee) = high_prio_estimate.feerate {
- // fees.get("high_prio").unwrap().store(fee, Ordering::Release);
- // }
tokio::time::sleep(Duration::from_secs(60)).await;
}
});
self.fees.get(&Target::HighPriority).unwrap().load(Ordering::Acquire)
}
}
- // self.fees.g
- // 253
- // match confirmation_target {
- // ConfirmationTarget::Background =>
- // }
- // let mut rpc = self.bitcoind_rpc_client.lock().unwrap();
-
- // let (conf_target, estimate_mode, default) = match confirmation_target {
- // ConfirmationTarget::Background => (144, "ECONOMICAL", 253),
- // ConfirmationTarget::Normal => (18, "ECONOMICAL", 20000),
- // ConfirmationTarget::HighPriority => (6, "CONSERVATIVE", 50000),
- // };
-
- // // This function may be called from a tokio runtime, or not. So we need to check before
- // // making the call to avoid the error "cannot run a tokio runtime from within a tokio runtime".
- // let conf_target_json = serde_json::json!(conf_target);
- // let estimate_mode_json = serde_json::json!(estimate_mode);
- // let resp = match Handle::try_current() {
- // Ok(_) => tokio::task::block_in_place(|| {
- // runtime
- // .block_on(rpc.call_method::<FeeResponse>(
- // "estimatesmartfee",
- // &vec![conf_target_json, estimate_mode_json],
- // ))
- // .unwrap()
- // }),
- // _ => runtime
- // .block_on(rpc.call_method::<FeeResponse>(
- // "estimatesmartfee",
- // &vec![conf_target_json, estimate_mode_json],
- // ))
- // .unwrap(),
- // };
- // if resp.errored {
- // return default;
- // }
- // resp.feerate.unwrap()
}
}
let mut rpc = bitcoind_rpc_client.lock().await;
rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]).await.unwrap();
});
- // let bitcoind_rpc_client = self.bitcoind_rpc_client.clone();
- // tokio::spawn(async move {
- // let rpc = bitcoind_rpc_client.lock().await;
- // rpc.call_method::<R>
- // });
- // let mut rpc = self.bitcoind_rpc_client.lock().unwrap();
- // let runtime = self.runtime.lock().unwrap();
-
- // let tx_serialized = serde_json::json!(encode::serialize_hex(tx));
- // // This function may be called from a tokio runtime, or not. So we need to check before
- // // making the call to avoid the error "cannot run a tokio runtime from within a tokio runtime".
- // match Handle::try_current() {
- // Ok(_) => {
- // tokio::task::block_in_place(|| {
- // runtime
- // .block_on(
- // rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]),
- // )
- // .unwrap();
- // });
- // }
- // _ => {
- // runtime
- // .block_on(rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]))
- // .unwrap();
- // }
- // }
}
}
continue;
};
- // let private_channel = match words.next().as_ref().map(String::as_str) {
let announce_channel = match words.next() {
Some("--public") | Some("--public=true") => true,
Some("--public=false") => false,
Some(info) => info,
None => continue,
};
- println!("VMW: adding routehop, info.fee base: {}", forwarding_info.fee_base_msat);
invoice = invoice.route(vec![lightning_invoice::RouteHop {
pubkey: channel.remote_network_id,
short_channel_id,
pub struct FeeResponse {
pub feerate: Option<u32>,
- // pub errors: Array<String>,
pub errored: bool,
}
let errored = !self.0["errors"].is_null();
Ok(FeeResponse {
errored,
- feerate: match self.0["feerate"].as_f64() {
- Some(fee) => Some((fee * 100_000_000.0).round() as u32),
- None => None
- }
- // true => None,
- // // The feerate from bitcoind is in BTC/kb, and we want satoshis/kb.
- // false => Some((self.0["feerate"].as_f64().unwrap() * 100_000_000.0).round() as u32),
+ feerate: match self.0["feerate"].as_f64() {
+ Some(fee) => Some((fee * 100_000_000.0).round() as u32),
+ None => None,
+ },
})
}
}
tokio::spawn(async move {
let min = time_forwardable.as_secs();
let seconds_to_sleep = thread_rng().gen_range(min, min * 5);
- // thread::sleep(Duration::new(seconds_to_sleep, 0));
tokio::time::sleep(Duration::from_secs(seconds_to_sleep)).await;
forwarding_channel_manager.process_pending_htlc_forwards();
});
fs::create_dir_all(ldk_data_dir.clone()).unwrap();
// Initialize our bitcoind client.
- let mut bitcoind_client = match BitcoindClient::new(
+ let bitcoind_client = match BitcoindClient::new(
args.bitcoind_rpc_host.clone(),
args.bitcoind_rpc_port,
args.bitcoind_rpc_username.clone(),
return;
}
};
- // let mut bitcoind_rpc_client = bitcoind_client.get_new_rpc_client().unwrap();
// ## Setup
// Step 1: Initialize the FeeEstimator
}
chain_tip = Some(
init::synchronize_listeners(
- // &mut bitcoind_rpc_client,
&mut bitcoind_client.deref(),
args.network,
&mut cache,
// Step 17: Connect and Disconnect Blocks
if chain_tip.is_none() {
- // chain_tip = Some(init::validate_best_block_header(&mut bitcoind_client).await.unwrap());
chain_tip =
Some(init::validate_best_block_header(&mut bitcoind_client.deref()).await.unwrap());
- // chain_tip = Some(init::validate_best_block_header(&mut bitcoind_rpc_client).await.unwrap());
}
let channel_manager_listener = channel_manager.clone();
let chain_monitor_listener = chain_monitor.clone();
let bitcoind_block_source = bitcoind_client.clone();
let network = args.network;
tokio::spawn(async move {
- // let chain_poller = poll::ChainPoller::new(&mut bitcoind_client, network);
let mut derefed = bitcoind_block_source.deref();
- // let chain_poller = poll::ChainPoller::new(&mut bitcoind_block_source.deref(), network);
let chain_poller = poll::ChainPoller::new(&mut derefed, network);
- // let chain_poller = poll::ChainPoller::new(&mut bitcoind_rpc_client, network);
let chain_listener = (chain_monitor_listener, channel_manager_listener);
let mut spv_client =
SpvClient::new(chain_tip.unwrap(), chain_poller, &mut cache, &chain_listener);
let payment_info: PaymentInfoStorage = Arc::new(Mutex::new(HashMap::new()));
let payment_info_for_events = payment_info.clone();
let network = args.network;
- // let bitcoind = BitcoindClient::new(
- // args.bitcoind_rpc_host.clone(),
- // args.bitcoind_rpc_port,
- // args.bitcoind_rpc_username.clone(),
- // args.bitcoind_rpc_password.clone(),
- // ).await.unwrap();
let bitcoind_rpc = bitcoind_client.clone();
tokio::spawn(async move {
handle_ldk_events(
peer_manager_event_listener,
channel_manager_event_listener,
chain_monitor_event_listener,
- // bitcoind_client.clone(),
bitcoind_rpc,
- // bitcoind,
keys_manager_listener,
payment_info_for_events,
network,