|
@@ -536,7 +536,11 @@ impl Darkfid {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async fn start(executor: Arc<Executor<'_>>, config: &DarkfidConfig) -> Result<()> {
|
|
|
|
|
|
|
+async fn start(
|
|
|
|
|
+ executor: Arc<Executor<'_>>,
|
|
|
|
|
+ local_cashier: Option<&str>,
|
|
|
|
|
+ config: &DarkfidConfig,
|
|
|
|
|
+) -> Result<()> {
|
|
|
let wallet = WalletDb::new(
|
|
let wallet = WalletDb::new(
|
|
|
expand_path(&config.wallet_path)?.as_path(),
|
|
expand_path(&config.wallet_path)?.as_path(),
|
|
|
config.wallet_password.clone(),
|
|
config.wallet_password.clone(),
|
|
@@ -547,21 +551,35 @@ async fn start(executor: Arc<Executor<'_>>, config: &DarkfidConfig) -> Result<()
|
|
|
let mut cashiers = Vec::new();
|
|
let mut cashiers = Vec::new();
|
|
|
let mut cashier_keys = Vec::new();
|
|
let mut cashier_keys = Vec::new();
|
|
|
|
|
|
|
|
- for cashier in config.clone().cashiers {
|
|
|
|
|
- if cashier.public_key.is_empty() {
|
|
|
|
|
- return Err(Error::CashierKeysNotFound);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if let Some(cpub) = local_cashier {
|
|
|
|
|
|
|
|
- let cashier_public: jubjub::SubgroupPoint =
|
|
|
|
|
- deserialize(&bs58::decode(cashier.public_key).into_vec()?)?;
|
|
|
|
|
|
|
+ let cashier_public: jubjub::SubgroupPoint = deserialize(&bs58::decode(cpub).into_vec()?)?;
|
|
|
|
|
|
|
|
cashiers.push(Cashier {
|
|
cashiers.push(Cashier {
|
|
|
- name: cashier.name,
|
|
|
|
|
- rpc_url: cashier.rpc_url,
|
|
|
|
|
|
|
+ name: "localCashier".into(),
|
|
|
|
|
+ rpc_url: "tcp://127.0.0.1:9000".into(),
|
|
|
public_key: cashier_public,
|
|
public_key: cashier_public,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
cashier_keys.push(cashier_public);
|
|
cashier_keys.push(cashier_public);
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ for cashier in config.clone().cashiers {
|
|
|
|
|
+ if cashier.public_key.is_empty() {
|
|
|
|
|
+ return Err(Error::CashierKeysNotFound);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let cashier_public: jubjub::SubgroupPoint =
|
|
|
|
|
+ deserialize(&bs58::decode(cashier.public_key).into_vec()?)?;
|
|
|
|
|
+
|
|
|
|
|
+ cashiers.push(Cashier {
|
|
|
|
|
+ name: cashier.name,
|
|
|
|
|
+ rpc_url: cashier.rpc_url,
|
|
|
|
|
+ public_key: cashier_public,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ cashier_keys.push(cashier_public);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Load trusted setup parameters
|
|
// Load trusted setup parameters
|
|
@@ -628,11 +646,12 @@ async fn main() -> Result<()> {
|
|
|
(@arg CONFIG: -c --config +takes_value "Sets a custom config file")
|
|
(@arg CONFIG: -c --config +takes_value "Sets a custom config file")
|
|
|
(@arg verbose: -v --verbose "Increase verbosity")
|
|
(@arg verbose: -v --verbose "Increase verbosity")
|
|
|
(@arg refresh: -r --refresh "Refresh the wallet and slabstore")
|
|
(@arg refresh: -r --refresh "Refresh the wallet and slabstore")
|
|
|
|
|
+ (@arg cashier: --cashier +takes_value "Local cashier public key")
|
|
|
)
|
|
)
|
|
|
.get_matches();
|
|
.get_matches();
|
|
|
|
|
|
|
|
let config_path = if args.is_present("CONFIG") {
|
|
let config_path = if args.is_present("CONFIG") {
|
|
|
- PathBuf::from(args.value_of("CONFIG").unwrap())
|
|
|
|
|
|
|
+ expand_path(args.value_of("CONFIG").unwrap())?
|
|
|
} else {
|
|
} else {
|
|
|
join_config_path(&PathBuf::from("darkfid.toml"))?
|
|
join_config_path(&PathBuf::from("darkfid.toml"))?
|
|
|
};
|
|
};
|
|
@@ -647,6 +666,7 @@ async fn main() -> Result<()> {
|
|
|
|
|
|
|
|
let config: DarkfidConfig = Config::<DarkfidConfig>::load(config_path)?;
|
|
let config: DarkfidConfig = Config::<DarkfidConfig>::load(config_path)?;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
if args.is_present("refresh") {
|
|
if args.is_present("refresh") {
|
|
|
debug!(target: "DARKFI DAEMON", "Refresh the wallet and the database");
|
|
debug!(target: "DARKFI DAEMON", "Refresh the wallet and the database");
|
|
|
|
|
|
|
@@ -667,6 +687,12 @@ async fn main() -> Result<()> {
|
|
|
return Ok(());
|
|
return Ok(());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ let mut local_cashier: Option<&str> = None;
|
|
|
|
|
+
|
|
|
|
|
+ if args.is_present("cashier") {
|
|
|
|
|
+ local_cashier = Some(args.value_of("cashier").unwrap())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let ex = Arc::new(Executor::new());
|
|
let ex = Arc::new(Executor::new());
|
|
|
let (signal, shutdown) = async_channel::unbounded::<()>();
|
|
let (signal, shutdown) = async_channel::unbounded::<()>();
|
|
|
|
|
|
|
@@ -682,7 +708,7 @@ async fn main() -> Result<()> {
|
|
|
// Run the main future on the current thread.
|
|
// Run the main future on the current thread.
|
|
|
.finish(|| {
|
|
.finish(|| {
|
|
|
smol::future::block_on(async move {
|
|
smol::future::block_on(async move {
|
|
|
- start(ex2, &config).await?;
|
|
|
|
|
|
|
+ start(ex2, local_cashier, &config).await?;
|
|
|
drop(signal);
|
|
drop(signal);
|
|
|
Ok::<(), drk::Error>(())
|
|
Ok::<(), drk::Error>(())
|
|
|
})
|
|
})
|