mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
bin/cashierd: Finalize features refactor.
This commit is contained in:
4
bin/cashierd/.gitignore
vendored
4
bin/cashierd/.gitignore
vendored
@@ -1,3 +1 @@
|
||||
|
||||
/target
|
||||
Cargo.lock
|
||||
target
|
||||
|
||||
@@ -1,61 +1,82 @@
|
||||
[package]
|
||||
name = "cashier"
|
||||
version = "0.1.0"
|
||||
name = "cashierd"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[dependencies.darkfi]
|
||||
path = "../../"
|
||||
features = ["node", "rpc", "cli"]
|
||||
|
||||
[dependencies]
|
||||
darkfi = {path= "../../", features = ["node", "chain"]}
|
||||
# Async
|
||||
smol = "1.2.5"
|
||||
futures = "0.3.19"
|
||||
async-std = "1.10.0"
|
||||
async-trait = "0.1.52"
|
||||
async-channel = "1.6.1"
|
||||
async-executor = "1.4.1"
|
||||
easy-parallel = "3.2.0"
|
||||
|
||||
# Crypto
|
||||
rand = "0.8.4"
|
||||
|
||||
# Misc
|
||||
clap = {version = "3.0.7", features = ["derive"]}
|
||||
log = "0.4.14"
|
||||
num_cpus = "1.13.1"
|
||||
simplelog = "0.11.2"
|
||||
thiserror = "1.0.30"
|
||||
|
||||
# Encoding and parsing
|
||||
serde_json = "1.0.72"
|
||||
serde = {version = "1.0.130", features = ["derive"]}
|
||||
hex = "0.4.3"
|
||||
url = "2.2.2"
|
||||
serde = {version = "1.0.133", features = ["derive"], optional = true}
|
||||
serde_json = "1.0.74"
|
||||
|
||||
# Utilities
|
||||
clap = { version = "3.0.0", features = ["derive"] }
|
||||
log = "0.4.14"
|
||||
simplelog = "0.11.1"
|
||||
thiserror = "1.0.30"
|
||||
rand = "0.8.4"
|
||||
num_cpus = "1.13.0"
|
||||
lazy_static = "1.4.0"
|
||||
anyhow = "1.0.49"
|
||||
num-bigint = {version = "0.4.3", features = ["rand", "serde"]}
|
||||
|
||||
# Used for Websockets client implementation.
|
||||
async-tungstenite = "0.16.0"
|
||||
tungstenite = "0.16.0"
|
||||
|
||||
# Async
|
||||
async-std = "1.10.0"
|
||||
async-trait = "0.1.51"
|
||||
async-channel = "1.6.1"
|
||||
easy-parallel = "3.1.0"
|
||||
async-executor = "1.4.1"
|
||||
futures = "0.3.17"
|
||||
smol = "1.2.5"
|
||||
native-tls = "0.2.8"
|
||||
async-native-tls = "0.4.0"
|
||||
|
||||
# Cashier Bitcoin dependencies
|
||||
bdk = {version = "0.14.0", optional = true}
|
||||
# Bitcoin bridge dependencies
|
||||
bdk = {version = "0.15.0", optional = true}
|
||||
anyhow = {version = "1.0.52", optional = true}
|
||||
bitcoin = {version = "0.27.1", optional = true}
|
||||
secp256k1 = {version = "0.20.3", default-features = false, features = ["rand-std"], optional = true}
|
||||
secp256k1 = {version = "0.20.1", default-features = false, features = ["rand-std"], optional = true}
|
||||
|
||||
# Cashier Ethereum dependencies
|
||||
# Ethereum bridge dependencies
|
||||
hex = {version = "0.4.3", optional = true}
|
||||
hash-db = {version = "0.15.2", optional = true}
|
||||
lazy_static = {version = "1.4.0", optional = true}
|
||||
keccak-hasher = {version = "0.15.3", optional = true}
|
||||
num-bigint = {version = "0.4.3", features = ["rand", "serde"], optional = true}
|
||||
|
||||
# Cashier Solana dependencies
|
||||
solana-client = {version = "1.8.11", optional = true}
|
||||
solana-sdk = {version = "1.8.11", optional = true}
|
||||
# Solana bridge dependencies
|
||||
native-tls = {version = "0.2.8", optional = true}
|
||||
async-native-tls = {version = "0.4.0", optional = true}
|
||||
solana-client = {version = "1.8.12", optional = true}
|
||||
solana-sdk = {version = "1.8.12", optional = true}
|
||||
spl-associated-token-account = {version = "1.0.3", features = ["no-entrypoint"], optional = true}
|
||||
spl-token = {version = "3.2.0", features = ["no-entrypoint"], optional = true}
|
||||
tungstenite = {version = "0.16.0", optional = true}
|
||||
|
||||
[features]
|
||||
btc = ["bdk", "bitcoin", "secp256k1"]
|
||||
eth = ["keccak-hasher", "hash-db"]
|
||||
sol = ["solana-sdk", "solana-client", "spl-token", "spl-associated-token-account"]
|
||||
btc = [
|
||||
"anyhow",
|
||||
"bdk",
|
||||
"bitcoin",
|
||||
"secp256k1",
|
||||
]
|
||||
|
||||
eth = [
|
||||
"serde",
|
||||
"num-bigint",
|
||||
"keccak-hasher",
|
||||
"hash-db",
|
||||
"lazy_static",
|
||||
"hex",
|
||||
]
|
||||
|
||||
sol = [
|
||||
"async-native-tls",
|
||||
"native-tls",
|
||||
"serde",
|
||||
"solana-client",
|
||||
"solana-sdk",
|
||||
"spl-associated-token-account",
|
||||
"spl-token",
|
||||
"tungstenite",
|
||||
]
|
||||
|
||||
37
bin/cashierd/Makefile
Normal file
37
bin/cashierd/Makefile
Normal file
@@ -0,0 +1,37 @@
|
||||
.POSIX:
|
||||
|
||||
# Cargo binary
|
||||
CARGO = cargo
|
||||
|
||||
# Binary to be built
|
||||
BIN = cashierd
|
||||
|
||||
# Dependencies which should force the binaries to be rebuilt
|
||||
BINDEPS = \
|
||||
Cargo.toml \
|
||||
$(shell find src -type f) \
|
||||
$(shell find ../../sql -type f) \
|
||||
$(shell find ../../contrib/token -type f)
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
$(BIN): $(BINDEPS)
|
||||
$(CARGO) build --release --all-features
|
||||
cp -f target/release/$@ $@
|
||||
|
||||
check: $(BINDEPS)
|
||||
$(CARGO) hack check --release --feature-powerset --no-dev-deps
|
||||
|
||||
fix:
|
||||
$(CARGO) clippy --release --all-features --fix --allow-dirty
|
||||
|
||||
clippy:
|
||||
$(CARGO) clippy --release --all-features
|
||||
|
||||
test:
|
||||
$(CARGO) test --release --all-features
|
||||
|
||||
clean:
|
||||
rm -f $(BIN)
|
||||
|
||||
.PHONY: all check fix clippy test clean
|
||||
@@ -11,35 +11,30 @@ use serde_json::{json, Value};
|
||||
use simplelog::{ColorChoice, LevelFilter, TermLogger, TerminalMode};
|
||||
|
||||
use darkfi::{
|
||||
chain::{rocks::columns, Rocks, RocksColumn},
|
||||
blockchain::{rocks::columns, Rocks, RocksColumn},
|
||||
cli::{CashierdConfig, CliCashierd, Config},
|
||||
crypto::{
|
||||
address::Address,
|
||||
keypair::{PublicKey, SecretKey},
|
||||
proof::VerifyingKey,
|
||||
token_id::generate_id2,
|
||||
types::DrkTokenId,
|
||||
},
|
||||
node::{
|
||||
client::Client,
|
||||
state::State,
|
||||
wallet::{cashierdb::CashierDb, walletdb::WalletDb},
|
||||
},
|
||||
serial::serialize,
|
||||
types::DrkTokenId,
|
||||
util::{
|
||||
expand_path, generate_id2, join_config_path,
|
||||
parse::truncate,
|
||||
rpc::{
|
||||
jsonrpc::{
|
||||
error as jsonerr, response as jsonresp, ErrorCode::*, JsonRequest, JsonResult,
|
||||
},
|
||||
rpcserver::{listen_and_serve, RequestHandler, RpcServerConfig},
|
||||
},
|
||||
Address, NetworkName,
|
||||
rpc::{
|
||||
jsonrpc::{error as jsonerr, response as jsonresp, ErrorCode::*, JsonRequest, JsonResult},
|
||||
rpcserver::{listen_and_serve, RequestHandler, RpcServerConfig},
|
||||
},
|
||||
util::{expand_path, join_config_path, parse::truncate, serial::serialize, NetworkName},
|
||||
zk::circuit::{MintContract, SpendContract},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
use cashier::service::{bridge, bridge::Bridge};
|
||||
use cashierd::service::{bridge, bridge::Bridge};
|
||||
|
||||
fn handle_bridge_error(error_code: u32) -> Result<()> {
|
||||
match error_code {
|
||||
@@ -123,7 +118,7 @@ impl Cashierd {
|
||||
#[cfg(feature = "sol")]
|
||||
NetworkName::Solana => {
|
||||
debug!(target: "CASHIER DAEMON", "Adding solana network");
|
||||
use cashier::service::SolClient;
|
||||
use cashierd::service::SolClient;
|
||||
|
||||
let _bridge = self.bridge.clone();
|
||||
|
||||
@@ -141,7 +136,7 @@ impl Cashierd {
|
||||
NetworkName::Ethereum => {
|
||||
debug!(target: "CASHIER DAEMON", "Adding ethereum network");
|
||||
|
||||
use cashier::service::EthClient;
|
||||
use cashierd::service::EthClient;
|
||||
|
||||
let _bridge = self.bridge.clone();
|
||||
|
||||
@@ -161,7 +156,7 @@ impl Cashierd {
|
||||
#[cfg(feature = "btc")]
|
||||
NetworkName::Bitcoin => {
|
||||
debug!(target: "CASHIER DAEMON", "Adding bitcoin network");
|
||||
use cashier::service::btc::BtcClient;
|
||||
use cashierd::service::btc::BtcClient;
|
||||
|
||||
let _bridge = self.bridge.clone();
|
||||
|
||||
@@ -306,7 +301,7 @@ impl Cashierd {
|
||||
match network {
|
||||
#[cfg(feature = "sol")]
|
||||
NetworkName::Solana => {
|
||||
use cashier::service::sol::SOL_NATIVE_TOKEN_ID;
|
||||
use cashierd::service::sol::SOL_NATIVE_TOKEN_ID;
|
||||
if _token_id != SOL_NATIVE_TOKEN_ID {
|
||||
return Ok(Some(_token_id.to_string()))
|
||||
}
|
||||
@@ -314,7 +309,7 @@ impl Cashierd {
|
||||
}
|
||||
#[cfg(feature = "eth")]
|
||||
NetworkName::Ethereum => {
|
||||
use cashier::service::eth::ETH_NATIVE_TOKEN_ID;
|
||||
use cashierd::service::eth::ETH_NATIVE_TOKEN_ID;
|
||||
if _token_id != ETH_NATIVE_TOKEN_ID {
|
||||
return Ok(Some(_token_id.to_string()))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ use futures::stream::{FuturesUnordered, StreamExt};
|
||||
use log::{debug, error};
|
||||
|
||||
use darkfi::{
|
||||
crypto::keypair::PublicKey, node::wallet::cashierdb::TokenKey, types::*, util::NetworkName,
|
||||
crypto::{keypair::PublicKey, types::*},
|
||||
node::wallet::cashierdb::TokenKey,
|
||||
util::NetworkName,
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
|
||||
@@ -42,10 +42,13 @@ use secp256k1::{
|
||||
|
||||
use super::bridge::{NetworkClient, TokenNotification, TokenSubscribtion};
|
||||
use darkfi::{
|
||||
crypto::keypair::PublicKey as DrkPublicKey,
|
||||
crypto::{keypair::PublicKey as DrkPublicKey, token_id::generate_id2},
|
||||
node::wallet::cashierdb::{CashierDb, TokenKey},
|
||||
serial::{deserialize, serialize, Decodable, Encodable},
|
||||
util::{expand_path, generate_id2, load_keypair_to_str, NetworkName},
|
||||
util::{
|
||||
expand_path, load_keypair_to_str,
|
||||
serial::{deserialize, serialize, Decodable, Encodable},
|
||||
NetworkName,
|
||||
},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
|
||||
@@ -14,13 +14,12 @@ use serde_json::{json, Value};
|
||||
use super::bridge::{NetworkClient, TokenNotification, TokenSubscribtion};
|
||||
|
||||
use darkfi::{
|
||||
crypto::keypair::PublicKey,
|
||||
crypto::{keypair::PublicKey, token_id::generate_id2},
|
||||
node::wallet::cashierdb::{CashierDb, TokenKey},
|
||||
serial::{deserialize, serialize, Decodable, Encodable},
|
||||
rpc::{jsonrpc, jsonrpc::JsonResult},
|
||||
util::{
|
||||
generate_id2,
|
||||
parse::truncate,
|
||||
rpc::{jsonrpc, jsonrpc::JsonResult},
|
||||
serial::{deserialize, serialize, Decodable, Encodable},
|
||||
sleep, NetworkName,
|
||||
},
|
||||
Error, Result,
|
||||
|
||||
@@ -24,15 +24,16 @@ use tungstenite::Message;
|
||||
use super::bridge::{NetworkClient, TokenNotification, TokenSubscribtion};
|
||||
|
||||
use darkfi::{
|
||||
crypto::keypair::PublicKey,
|
||||
crypto::{keypair::PublicKey, token_id::generate_id2},
|
||||
node::wallet::cashierdb::{CashierDb, TokenKey},
|
||||
serial::{deserialize, serialize, Decodable, Encodable},
|
||||
rpc::{jsonrpc, jsonrpc::JsonResult, websockets, websockets::WsStream},
|
||||
util::{
|
||||
expand_path, generate_id2, load_keypair_to_str,
|
||||
expand_path, load_keypair_to_str,
|
||||
parse::truncate,
|
||||
rpc::{jsonrpc, jsonrpc::JsonResult, websockets, websockets::WsStream},
|
||||
sleep, Error, NetworkName, Result,
|
||||
serial::{deserialize, serialize, Decodable, Encodable},
|
||||
sleep, NetworkName,
|
||||
},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
pub const SOL_NATIVE_TOKEN_ID: &str = "So11111111111111111111111111111111111111112";
|
||||
|
||||
Reference in New Issue
Block a user