combine imports

This commit is contained in:
f321x
2024-08-16 14:15:56 +02:00
parent 1ad021ab03
commit e9140d5821
11 changed files with 56 additions and 109 deletions

View File

@ -4,15 +4,6 @@ pub mod handler_errors;
use self::communication_utils::*; use self::communication_utils::*;
use super::*; use super::*;
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
routing::{get, post},
Extension, Json, Router,
};
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use tokio::net::TcpListener;
// //
// Axum handler functions // Axum handler functions

View File

@ -1,17 +1,4 @@
use super::*; use super::*;
use anyhow::Context;
use bdk::{
bitcoin::{
hashes::Hash,
key::XOnlyPublicKey,
psbt::{PartiallySignedTransaction, Prevouts},
sighash::{SighashCache, TapSighashType},
Address,
},
miniscript::Descriptor,
};
use musig2::{BinaryEncoding, LiftedSignature};
use std::str::FromStr;
#[derive(Debug)] #[derive(Debug)]
pub enum PayoutProcessingResult { pub enum PayoutProcessingResult {

View File

@ -3,15 +3,6 @@
use super::*; use super::*;
use anyhow::Ok; use anyhow::Ok;
use bdk::bitcoin::consensus::encode::deserialize;
use bdk::bitcoin::{OutPoint, Transaction};
use bdk::bitcoin::{TxIn, Txid};
use bdk::bitcoincore_rpc::{Client, RpcApi};
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::sync::RwLock;
use tokio::sync::oneshot;
struct Mempool { struct Mempool {
transactions: Arc<RwLock<HashMap<Txid, Vec<TxIn>>>>, transactions: Arc<RwLock<HashMap<Txid, Vec<TxIn>>>>,

View File

@ -1,14 +1,11 @@
pub mod bond_monitoring; pub mod bond_monitoring;
pub mod coordinator_utils; pub mod coordinator_utils;
// pub mod create_taproot;
pub mod mempool_monitoring; pub mod mempool_monitoring;
pub mod tx_confirmation_monitoring; pub mod tx_confirmation_monitoring;
// pub mod create_taproot;
use self::coordinator_utils::*;
use super::*; use super::*;
use musig2::{KeyAggContext, PartialSignature};
pub async fn process_order( pub async fn process_order(
coordinator: Arc<Coordinator>, coordinator: Arc<Coordinator>,
offer: &OfferRequest, offer: &OfferRequest,

View File

@ -1,13 +1,3 @@
use std::str::FromStr;
use bdk::{
bitcoin::Txid,
bitcoincore_rpc::{
jsonrpc::Error as JsonRpcError, Error as CoreRpcError, RpcApi,
},
};
use super::*; use super::*;
fn get_confirmations( fn get_confirmations(

View File

@ -1,17 +1,7 @@
#[cfg(test)] #[cfg(test)]
mod db_tests; mod db_tests;
use anyhow::Context;
use futures_util::StreamExt;
use super::*; use super::*;
use bdk::bitcoin::address::Address;
use sqlx::{sqlite::SqlitePoolOptions, Pool, Row, Sqlite};
use std::env;
use std::str::FromStr;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CoordinatorDB { pub struct CoordinatorDB {

View File

@ -3,24 +3,67 @@ mod coordinator;
mod database; mod database;
mod wallet; mod wallet;
use anyhow::{anyhow, Result}; use std::{
use bdk::{database::MemoryDatabase}; collections::{HashMap, HashSet},
env, fmt,
net::SocketAddr,
ops::Deref,
str::FromStr,
sync::{Arc, RwLock},
time::{SystemTime, UNIX_EPOCH},
};
use anyhow::{anyhow, Context, Result};
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
routing::{get, post},
Extension, Json, Router,
};
use bdk::{
bitcoin::{
self,
address::Payload,
bip32::ExtendedPrivKey,
consensus::encode::deserialize,
hashes::Hash,
key::{secp256k1, XOnlyPublicKey},
psbt::{Input, PartiallySignedTransaction, Prevouts},
sighash::{SighashCache, TapSighashType},
Address, Network, OutPoint, Transaction, TxIn, Txid,
},
bitcoincore_rpc::{
jsonrpc::Error as JsonRpcError, Client, Error as CoreRpcError, RawTx, RpcApi,
},
blockchain::{rpc::Auth, Blockchain, ConfigurableBlockchain, GetTx, RpcBlockchain, RpcConfig},
database::{Database, MemoryDatabase},
descriptor::Descriptor,
miniscript::{descriptor::TapTree, policy::Concrete, Tap, ToPublicKey},
sled::Tree,
template::Bip86,
wallet::verify::*,
KeychainKind, SignOptions, SyncOptions, Wallet,
};
use communication::{api::*, api_server, communication_utils::*, handler_errors::*}; use communication::{api::*, api_server, communication_utils::*, handler_errors::*};
use coordinator::{ use coordinator::{
bond_monitoring::*, coordinator_utils::*, bond_monitoring::*, coordinator_utils::*, mempool_monitoring::MempoolHandler,
tx_confirmation_monitoring::update_transaction_confirmations, *, tx_confirmation_monitoring::update_transaction_confirmations, *,
}; };
use database::CoordinatorDB; use database::CoordinatorDB;
use dotenvy::dotenv; use dotenvy::dotenv;
use futures_util::StreamExt;
use log::{debug, error, info, trace, warn}; use log::{debug, error, info, trace, warn};
use musig2::{AggNonce as MusigAggNonce, PubNonce as MusigPubNonce}; use musig2::{
use rand::Rng; secp256k1::PublicKey as MuSig2PubKey, AggNonce as MusigAggNonce, BinaryEncoding, KeyAggContext,
use std::{ LiftedSignature, PartialSignature, PubNonce as MusigPubNonce,
env, };
sync::Arc, use rand::Rng;
time::{SystemTime, UNIX_EPOCH}, use serde::{Deserialize, Serialize};
use sqlx::{sqlite::SqlitePoolOptions, Pool, Row, Sqlite};
use tokio::{
net::TcpListener,
sync::{oneshot, Mutex},
}; };
use tokio::sync::Mutex;
use validator::{Validate, ValidationError}; use validator::{Validate, ValidationError};
use wallet::{escrow_psbt::*, wallet_utils::*, *}; use wallet::{escrow_psbt::*, wallet_utils::*, *};

View File

@ -1,12 +1,4 @@
use super::*; use super::*;
use bdk::{
bitcoin::{psbt::PartiallySignedTransaction},
descriptor::{Descriptor},
miniscript::{descriptor::TapTree, policy::Concrete, Tap, ToPublicKey},
SignOptions,
};
use musig2::{secp256k1::PublicKey as MuSig2PubKey, KeyAggContext};
#[derive(Debug)] #[derive(Debug)]
pub struct EscrowPsbtConstructionData { pub struct EscrowPsbtConstructionData {

View File

@ -7,29 +7,6 @@ mod wallet_tests;
pub use self::escrow_psbt::*; pub use self::escrow_psbt::*;
use super::*; use super::*;
use anyhow::Context;
use bdk::{
bitcoin::{
self,
address::Payload,
bip32::ExtendedPrivKey,
consensus::encode::deserialize,
key::{secp256k1, XOnlyPublicKey},
Address,
Network::Regtest,
Transaction,
},
bitcoincore_rpc::{Client, RawTx, RpcApi},
blockchain::{rpc::Auth, Blockchain, ConfigurableBlockchain, RpcBlockchain, RpcConfig},
database::MemoryDatabase,
sled::{Tree},
template::Bip86,
wallet::verify::*,
KeychainKind, SyncOptions, Wallet,
};
use coordinator::mempool_monitoring::MempoolHandler;
use std::{collections::HashMap, str::FromStr};
use std::{fmt, ops::Deref};
// use verify_tx::*; // use verify_tx::*;
#[derive(Clone)] #[derive(Clone)]
@ -70,12 +47,12 @@ pub async fn init_coordinator_wallet() -> Result<CoordinatorWallet<MemoryDatabas
username: env::var("BITCOIN_RPC_USER")?, username: env::var("BITCOIN_RPC_USER")?,
password: env::var("BITCOIN_RPC_PASSWORD")?, password: env::var("BITCOIN_RPC_PASSWORD")?,
}, },
network: Regtest, network: Network::Regtest,
// wallet_name: env::var("BITCOIN_RPC_WALLET_NAME")?, // wallet_name: env::var("BITCOIN_RPC_WALLET_NAME")?,
wallet_name: bdk::wallet::wallet_name_from_descriptor( wallet_name: bdk::wallet::wallet_name_from_descriptor(
Bip86(wallet_xprv, KeychainKind::External), Bip86(wallet_xprv, KeychainKind::External),
Some(Bip86(wallet_xprv, KeychainKind::Internal)), Some(Bip86(wallet_xprv, KeychainKind::Internal)),
Regtest, Network::Regtest,
&secp_context, &secp_context,
)?, )?,
sync_params: None, sync_params: None,

View File

@ -1,9 +1,5 @@
/// construction of the transaction spending the escrow output after a successfull trade as keyspend transaction /// construction of the transaction spending the escrow output after a successfull trade as keyspend transaction
use super::*; use super::*;
use bdk::bitcoin::psbt::Input;
use bdk::bitcoin::OutPoint;
use bdk::miniscript::Descriptor;
fn get_tx_fees_abs_sat(blockchain_backend: &RpcBlockchain) -> Result<(u64, u64)> { fn get_tx_fees_abs_sat(blockchain_backend: &RpcBlockchain) -> Result<(u64, u64)> {
let feerate = blockchain_backend.estimate_fee(6)?; let feerate = blockchain_backend.estimate_fee(6)?;

View File

@ -1,11 +1,4 @@
use super::*; use super::*;
use bdk::{
bitcoin::{psbt::Input, Address, Network},
blockchain::GetTx,
database::Database,
};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct PsbtInput { pub struct PsbtInput {
pub psbt_input: Input, pub psbt_input: Input,