From 0d5149eb968c73df1b009ca8f78a2090918db547 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Tue, 28 May 2024 11:10:48 +0200 Subject: [PATCH] import sp_client through sdk_common --- Cargo.toml | 1 - src/daemon.rs | 8 ++++---- src/main.rs | 43 ++++++++++++++++++++++++++++++------------- src/scan.rs | 12 ++++++------ 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7513f6f..fccc035 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ sdk_common = { git = "https://git.4nkweb.com/4nk/sdk_common.git", branch = "demo serde = { version = "1.0.193", features = ["derive"]} serde_json = "1.0" serde_with = "3.6.0" -sp_client = { git = "https://github.com/Sosthene00/sp-client", branch = "sp_client" } tokio = { version = "1.0.0", features = ["io-util", "rt-multi-thread", "macros", "sync"] } tokio-stream = "0.1" tokio-tungstenite = "0.21.0" diff --git a/src/daemon.rs b/src/daemon.rs index a3d8c80..222b68a 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -5,12 +5,12 @@ use bitcoincore_rpc::json::{ WalletCreateFundedPsbtOptions, }; use bitcoincore_rpc::{json, jsonrpc, Auth, Client, RpcApi}; -use sp_client::bitcoin::bip158::BlockFilter; -use sp_client::bitcoin::{ +use sdk_common::sp_client::bitcoin::bip158::BlockFilter; +use sdk_common::sp_client::bitcoin::{ block, Address, Amount, Block, BlockHash, Network, OutPoint, Psbt, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, }; -use sp_client::bitcoin::{consensus::deserialize, hashes::hex::FromHex}; +use sdk_common::sp_client::bitcoin::{consensus::deserialize, hashes::hex::FromHex}; // use crossbeam_channel::Receiver; // use parking_lot::Mutex; use serde_json::{json, Value}; @@ -328,7 +328,7 @@ impl Daemon { txid: &Txid, blockhash: Option, ) -> Result { - use sp_client::bitcoin::consensus::serde::{hex::Lower, Hex, With}; + use sdk_common::sp_client::bitcoin::consensus::serde::{hex::Lower, Hex, With}; let tx = self.get_transaction(txid, blockhash)?; #[derive(serde::Serialize)] diff --git a/src/main.rs b/src/main.rs index 5b6cdea..2c7f930 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,28 +10,45 @@ use std::{ use bitcoincore_rpc::json::{self as bitcoin_json}; use futures_util::{future, pin_mut, stream::TryStreamExt, FutureExt, StreamExt}; -use log::{debug, error}; -use sdk_common::{ - error::AnkError, network::{AnkFlag, AnkNetworkMsg, FaucetMessage, NewTxMessage}, silentpayments::create_transaction_for_address_with_shared_secret +use sdk_common::sp_client::bitcoin::{ + absolute::LockTime, + consensus::{deserialize, serialize}, + hex::{DisplayHex, FromHex}, + key::TapTweak, + script::PushBytesBuf, + sighash::{Prevouts, SighashCache}, + taproot::Signature, + transaction::Version, + Amount, Network, OutPoint, Psbt, ScriptBuf, TapSighashType, Transaction, TxIn, TxOut, Witness, + XOnlyPublicKey, }; -use sp_client::bitcoin::{ - absolute::LockTime, consensus::{deserialize, serialize}, hex::{DisplayHex, FromHex}, key::TapTweak, script::PushBytesBuf, sighash::{Prevouts, SighashCache}, taproot::Signature, transaction::Version, Amount, OutPoint, Psbt, ScriptBuf, TapSighashType, Transaction, TxIn, TxOut, Witness, XOnlyPublicKey -}; -use sp_client::{ +use sdk_common::sp_client::{ bitcoin::secp256k1::{ rand::{thread_rng, Rng}, Keypair, Message as Secp256k1Message, PublicKey, Secp256k1, ThirtyTwoByteHash, }, spclient::SpWallet, }; +use sdk_common::{ + error::AnkError, + network::{AnkFlag, AnkNetworkMsg, FaucetMessage, NewTxMessage}, + silentpayments::create_transaction_for_address_with_shared_secret, +}; -use sp_client::db::{JsonFile, Storage}; -use sp_client::silentpayments::sending::{generate_recipient_pubkeys, SilentPaymentAddress}; -use sp_client::silentpayments::utils::receiving::{calculate_tweak_data, get_pubkey_from_input}; -use sp_client::silentpayments::utils::sending::calculate_partial_secret; -use sp_client::spclient::{derive_keys_from_seed, Recipient, SpClient, SpendKey}; -use tokio::{net::{TcpListener, TcpStream}, time}; +use sdk_common::sp_client::db::{JsonFile, Storage}; +use sdk_common::sp_client::silentpayments::sending::{ + generate_recipient_pubkeys, SilentPaymentAddress, +}; +use sdk_common::sp_client::silentpayments::utils::receiving::{ + calculate_tweak_data, get_pubkey_from_input, +}; +use sdk_common::sp_client::silentpayments::utils::sending::calculate_partial_secret; +use sdk_common::sp_client::spclient::{derive_keys_from_seed, Recipient, SpClient, SpendKey}; use tokio::sync::mpsc::{unbounded_channel, UnboundedSender}; +use tokio::{ + net::{TcpListener, TcpStream}, + time, +}; use tokio_stream::wrappers::UnboundedReceiverStream; use tokio_tungstenite::tungstenite::Message; diff --git a/src/scan.rs b/src/scan.rs index 93f8f30..aac69ca 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -5,12 +5,12 @@ use std::sync::Arc; use anyhow::{Error, Result}; use electrum_client::ElectrumApi; use hex::FromHex; -use sp_client::bitcoin::bip158::BlockFilter; -use sp_client::bitcoin::hex::DisplayHex; -use sp_client::bitcoin::secp256k1::{All, PublicKey, Scalar, Secp256k1, SecretKey}; -use sp_client::bitcoin::{BlockHash, OutPoint, Transaction, TxOut, XOnlyPublicKey}; -use sp_client::silentpayments::receiving::Receiver; -use sp_client::spclient::{OutputSpendStatus, OwnedOutput}; +use sdk_common::sp_client::bitcoin::bip158::BlockFilter; +use sdk_common::sp_client::bitcoin::hex::DisplayHex; +use sdk_common::sp_client::bitcoin::secp256k1::{All, PublicKey, Scalar, Secp256k1, SecretKey}; +use sdk_common::sp_client::bitcoin::{BlockHash, OutPoint, Transaction, TxOut, XOnlyPublicKey}; +use sdk_common::sp_client::silentpayments::receiving::Receiver; +use sdk_common::sp_client::spclient::{OutputSpendStatus, OwnedOutput}; use tokio::time::Instant; use crate::{electrumclient, MutexExt, SharedDaemon, SilentPaymentWallet};