commit 5db4ac33ffedae7977bb8a86654a5e4ceb7b783c
parent 79f0adf3132feab2135ddf51e58e33a7f9c4dc81
Author: Antoine A <>
Date: Sun, 6 Feb 2022 19:28:19 +0100
Update dependencies and use taler-config to parse configuration
Diffstat:
12 files changed, 94 insertions(+), 81 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
@@ -127,9 +127,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
-version = "0.10.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95"
+checksum = "03588e54c62ae6d763e2a80090d50353b785795361b4ff5b3bf0a5097fc31c0b"
dependencies = [
"generic-array",
]
@@ -312,9 +312,9 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
-version = "0.9.6"
+version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762"
+checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
dependencies = [
"cfg-if",
"crossbeam-utils",
@@ -325,9 +325,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
-version = "0.8.6"
+version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
+checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
dependencies = [
"cfg-if",
"lazy_static",
@@ -492,9 +492,9 @@ dependencies = [
[[package]]
name = "ethbloom"
-version = "0.11.1"
+version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8"
+checksum = "c927489503a5d331fdb25a3ac8d80e433ee6aa96951c99346d66e7be2b0400a0"
dependencies = [
"crunchy",
"fixed-hash",
@@ -504,9 +504,9 @@ dependencies = [
[[package]]
name = "ethereum-types"
-version = "0.12.1"
+version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf"
+checksum = "6e6307a3fa100563ce323e6b654c5935c8d919aeee56b0ccef1c65c5ecd2ecf6"
dependencies = [
"ethbloom",
"fixed-hash",
@@ -574,9 +574,9 @@ dependencies = [
[[package]]
name = "futures"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4"
+checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e"
dependencies = [
"futures-channel",
"futures-core",
@@ -589,9 +589,9 @@ dependencies = [
[[package]]
name = "futures-channel"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b"
+checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
dependencies = [
"futures-core",
"futures-sink",
@@ -599,15 +599,15 @@ dependencies = [
[[package]]
name = "futures-core"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7"
+checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
[[package]]
name = "futures-executor"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a"
+checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6"
dependencies = [
"futures-core",
"futures-task",
@@ -616,15 +616,15 @@ dependencies = [
[[package]]
name = "futures-io"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2"
+checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
[[package]]
name = "futures-macro"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c"
+checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [
"proc-macro2",
"quote",
@@ -633,21 +633,21 @@ dependencies = [
[[package]]
name = "futures-sink"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508"
+checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868"
[[package]]
name = "futures-task"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72"
+checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
[[package]]
name = "futures-util"
-version = "0.3.19"
+version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164"
+checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
dependencies = [
"futures-channel",
"futures-core",
@@ -879,9 +879,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.116"
+version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"
+checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
[[package]]
name = "listenfd"
@@ -1196,9 +1196,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "primitive-types"
-version = "0.10.1"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373"
+checksum = "db5a3482110d085cee2a284278b42a4361bc611d008eddfbf04fd84735ae521f"
dependencies = [
"fixed-hash",
"impl-serde",
@@ -1415,9 +1415,9 @@ dependencies = [
[[package]]
name = "semver"
-version = "1.0.4"
+version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
+checksum = "0486718e92ec9a68fbed73bb5ef687d71103b142595b406835649bebd33f72c7"
[[package]]
name = "serde"
@@ -1737,9 +1737,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
-version = "0.1.29"
+version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
+checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9"
dependencies = [
"cfg-if",
"pin-project-lite",
@@ -1748,9 +1748,9 @@ dependencies = [
[[package]]
name = "tracing-core"
-version = "0.1.21"
+version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
+checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23"
dependencies = [
"lazy_static",
]
@@ -1769,9 +1769,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "uint"
-version = "0.9.2"
+version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b1b413ebfe8c2c74a69ff124699dd156a7fa41cb1d09ba6df94aa2f2b0a4a3a"
+checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0"
dependencies = [
"byteorder",
"crunchy",
diff --git a/btc-wire/Cargo.toml b/btc-wire/Cargo.toml
@@ -3,6 +3,7 @@ name = "btc-wire"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
+rust-version = "1.56.1"
[features]
# Enable random failures
diff --git a/btc-wire/src/bin/btc-wire-cli.rs b/btc-wire/src/bin/btc-wire-cli.rs
@@ -15,19 +15,20 @@
*/
use btc_wire::{
config::{BitcoinConfig, WIRE_WALLET_NAME},
- rpc::{Rpc, Error, ErrorCode},
+ rpc::{Error, ErrorCode, Rpc},
rpc_utils::default_data_dir,
};
use common::{
config::{Config, CoreConfig},
- postgres::{Client, NoTls}, log::init,
+ log::init,
+ postgres::{Client, NoTls},
};
fn main() {
init();
let args: Vec<_> = std::env::args().collect();
// Parse taler config
- let config = CoreConfig::load_from_file(&args[2]);
+ let config = CoreConfig::load_taler_config(Some(&args[2]));
assert_eq!(config.currency, "BTC");
// Connect to database
let mut db = Client::connect(&config.db_url, NoTls).expect("Failed to connect to database");
@@ -48,12 +49,10 @@ fn main() {
}
"initwallet" => {
// Parse bitcoin config
- let btc_conf =
- BitcoinConfig::load(config.data_dir.unwrap_or_else(default_data_dir))
- .expect("Failed to load bitcoin configuration");
+ let btc_conf = BitcoinConfig::load(config.data_dir.unwrap_or_else(default_data_dir))
+ .expect("Failed to load bitcoin configuration");
// Connect to bitcoin node
- let mut rpc =
- Rpc::common(&btc_conf).expect("Failed to connect to bitcoin RPC server");
+ let mut rpc = Rpc::common(&btc_conf).expect("Failed to connect to bitcoin RPC server");
// Skip previous blocks
let info = rpc
diff --git a/btc-wire/src/bin/btc-wire-utils.rs b/btc-wire/src/bin/btc-wire-utils.rs
@@ -163,7 +163,7 @@ fn main() {
}
}
Cmd::ResetDB(ResetCmd { config }) => {
- let config = CoreConfig::load_from_file(&config);
+ let config = CoreConfig::load_taler_config(Some(&config));
let hash: BlockHash = app.rpc.get_block_hash(0).unwrap();
let mut db = Client::connect(&config.db_url, NoTls).unwrap();
let mut tx = db.transaction().unwrap();
diff --git a/btc-wire/src/main.rs b/btc-wire/src/main.rs
@@ -43,7 +43,7 @@ pub struct WireState {
fn main() {
common::log::init();
- let config = load_btc_config(std::env::args_os().nth(1).expect("Missing conf path arg"));
+ let config = load_btc_config(Some(&std::env::args().nth(1).expect("Missing conf path arg")));
let data_dir = config
.core
.data_dir
diff --git a/common/Cargo.toml b/common/Cargo.toml
@@ -3,6 +3,7 @@ name = "common"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
+rust-version = "1.56.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/common/src/config.rs b/common/src/config.rs
@@ -14,16 +14,26 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
use ini::{Ini, Properties};
-use std::{
- path::{Path, PathBuf},
- str::FromStr,
-};
+use std::{path::PathBuf, process::Command, str::FromStr};
use url::Url;
pub trait Config: Sized {
- /// Load from a file
- fn load_from_file(config_file: impl AsRef<Path>) -> Self {
- let conf = ini::Ini::load_from_file(config_file).expect("Failed to open the config file");
+ /// Load using taler-config
+ fn load_taler_config(file: Option<&str>) -> Self {
+ let mut cmd = Command::new("taler-config");
+ cmd.arg("-d");
+ if let Some(path) = file {
+ cmd.args(["-c", path]);
+ }
+ let output = cmd.output().expect("Failed to execute taler-config");
+ if !output.status.success() {
+ panic!(
+ "taler-config failure:\n{}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ }
+ let conf = ini::Ini::load_from_str(&String::from_utf8_lossy(&output.stdout))
+ .expect("Failed to parse config");
let taler = section(&conf, "taler");
let currency = require(taler, "CURRENCY", string);
let section_name = match currency.as_str() {
@@ -115,16 +125,16 @@ impl<const DEFAULT_FEE: u64, const DEFAULT_CONFIRMATION: u16> Config
pub type BtcConfig = WireConfig<1000, 6>;
-pub fn load_btc_config(path: impl AsRef<Path>) -> BtcConfig {
- let config = WireConfig::load_from_file(path);
+pub fn load_btc_config(path: Option<&str>) -> BtcConfig {
+ let config = WireConfig::load_taler_config(path);
assert_eq!(config.core.currency, "BTC");
return config;
}
pub type EthConfig = WireConfig<1000000, 24>;
-pub fn load_eth_config(path: impl AsRef<Path>) -> EthConfig {
- let config = WireConfig::load_from_file(path);
+pub fn load_eth_config(path: Option<&str>) -> EthConfig {
+ let config = WireConfig::load_taler_config(path);
assert_eq!(config.core.currency, "ETH");
return config;
}
diff --git a/eth-wire/Cargo.toml b/eth-wire/Cargo.toml
@@ -3,6 +3,7 @@ name = "eth-wire"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
+rust-version = "1.56.1"
[dependencies]
# Cli args
@@ -13,7 +14,7 @@ serde_json = "1.0.78"
serde_repr = "0.1.7"
hex = "0.4.3"
# Ethereum serializable types
-ethereum-types = { version = "0.12.1", default-features = false, features = [
+ethereum-types = { version = "0.13.0", default-features = false, features = [
"serialize",
] }
# Error macros
diff --git a/eth-wire/src/bin/eth-wire-cli.rs b/eth-wire/src/bin/eth-wire-cli.rs
@@ -24,7 +24,7 @@ use common::{
fn main() {
init();
let args: Vec<_> = std::env::args().collect();
- let config = CoreConfig::load_from_file(&args[2]);
+ let config = CoreConfig::load_taler_config(Some(&args[2]));
assert_eq!(config.currency, "ETH");
let mut db = Client::connect(&config.db_url, NoTls).expect("Failed to connect to database");
diff --git a/eth-wire/src/main.rs b/eth-wire/src/main.rs
@@ -54,7 +54,7 @@ fn main() {
common::log::init();
let path = std::env::args().nth(1).unwrap();
- let config = load_eth_config(path);
+ let config = load_eth_config(Some(&path));
let state: &'static WireState = Box::leak(Box::new(WireState {
confirmation: AtomicU16::new(config.confirmation),
diff --git a/wire-gateway/Cargo.toml b/wire-gateway/Cargo.toml
@@ -3,7 +3,7 @@ name = "wire-gateway"
version = "0.1.0"
edition = "2021"
license = "AGPL-3.0-or-later"
-
+rust-version = "1.56.1"
[dependencies]
# Http library
@@ -34,7 +34,7 @@ common = { path = "../common" }
# Bitcoin types
bitcoin = { version = "0.27.1", optional = true }
# Euthereum types
-ethereum-types = { version = "0.12.1", default-features = false, optional = true }
+ethereum-types = { version = "0.13.0", default-features = false, optional = true }
[features]
diff --git a/wire-gateway/src/main.rs b/wire-gateway/src/main.rs
@@ -13,6 +13,19 @@
You should have received a copy of the GNU Affero General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+use common::{
+ api_common::{ShortHashCode, Timestamp},
+ api_wire::{
+ HistoryParams, IncomingBankTransaction, IncomingHistory, OutgoingBankTransaction,
+ OutgoingHistory, TransferRequest, TransferResponse,
+ },
+ config::{Config, GatewayConfig},
+ error_codes::ErrorCode,
+ log::log::{error, info, log, Level},
+ postgres::{fallible_iterator::FallibleIterator, Client},
+ sql::{sql_amount, sql_array, sql_safe_u64, sql_url},
+ url::Url,
+};
use deadpool_postgres::{Pool, Runtime};
use error::{CatchResult, ServerError};
use hyper::{
@@ -28,19 +41,6 @@ use std::{
sync::atomic::{AtomicBool, AtomicU32, Ordering},
time::{Duration, Instant},
};
-use common::{
- api_common::{ShortHashCode, Timestamp},
- api_wire::{
- HistoryParams, IncomingBankTransaction, IncomingHistory, OutgoingBankTransaction,
- OutgoingHistory, TransferRequest, TransferResponse,
- },
- config::{Config, GatewayConfig},
- error_codes::ErrorCode,
- log::log::{error, info, log, Level},
- postgres::{fallible_iterator::FallibleIterator, Client},
- sql::{sql_amount, sql_array, sql_safe_u64, sql_url},
- url::Url,
-};
use tokio::sync::Notify;
use tokio_postgres::{config::Host, NoTls};
@@ -88,8 +88,9 @@ impl ServerState {
async fn main() {
common::log::init();
- let conf =
- GatewayConfig::load_from_file(std::env::args_os().nth(1).expect("Missing conf path arg"));
+ let conf = GatewayConfig::load_taler_config(Some(
+ &std::env::args().nth(1).expect("Missing conf path arg"),
+ ));
#[cfg(feature = "test")]
common::log::log::warn!("Running with test admin endpoint unsuitable for production");