Skip to content

Commit

Permalink
chore: Remove unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Feb 6, 2025
1 parent c05c5ce commit 95fc4e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 48 deletions.
34 changes: 1 addition & 33 deletions core/src/builder/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
// Currently generate_witness functions are not yet used.
#![allow(dead_code)]

use crate::{utils, EVMAddress};
use crate::EVMAddress;
use bitcoin::opcodes::OP_TRUE;
use bitcoin::script::PushBytesBuf;
use bitcoin::secp256k1::schnorr;
use bitcoin::{
opcodes::{all::*, OP_FALSE},
Expand Down Expand Up @@ -235,37 +234,6 @@ impl DepositScript {
}
}

/// Struct for withdrawal script.
pub struct WithdrawalScript(usize);

impl SpendableScript for WithdrawalScript {
fn as_any(&self) -> &dyn Any {
self
}

fn to_script_buf(&self) -> ScriptBuf {
let mut push_bytes = PushBytesBuf::new();
push_bytes
.extend_from_slice(&utils::usize_to_var_len_bytes(self.0))
.expect("Not possible to panic while converting index to slice");

Builder::new()
.push_opcode(OP_RETURN)
.push_slice(push_bytes)
.into_script()
}
}

impl WithdrawalScript {
fn generate_witness(&self, signature: schnorr::Signature) -> Witness {
Witness::from_slice(&[signature.serialize()])
}

pub fn new(index: usize) -> Self {
Self(index)
}
}

This comment has been minimized.

Copy link
@mmtftr

mmtftr Feb 6, 2025

Please revert this, I believe we're going to be using this soon.

#[cfg(test)]
fn get_script_from_arr<T: SpendableScript>(
arr: &Vec<Box<dyn SpendableScript>>,
Expand Down
9 changes: 3 additions & 6 deletions core/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ pub struct Operator {

impl Operator {
/// Creates a new `Operator`.
// #[tracing::instrument(skip_all, err(level = tracing::Level::ERROR))]
pub async fn new(config: BridgeConfig, _rpc: ExtendedRpc) -> Result<Self, BridgeError> {
// let num_verifiers = config.verifiers_public_keys.len();

pub async fn new(config: BridgeConfig, rpc: ExtendedRpc) -> Result<Self, BridgeError> {
let signer = Actor::new(
config.secret_key,
config.winternitz_secret_key,
Expand Down Expand Up @@ -82,7 +79,7 @@ impl Operator {
.get_sequential_collateral_txs(Some(&mut tx), idx as i32)
.await?;
let collateral_funding_txid = if sequential_collateral_txs.is_empty() {
let outpoint = _rpc
let outpoint = rpc
.send_to_address(&signer.address, Amount::from_sat(200_000_000))
.await?; // TODO: Is this OK to be a fixed value
db.set_sequential_collateral_tx(Some(&mut tx), idx as i32, 0, outpoint.txid, 0)
Expand All @@ -106,7 +103,7 @@ impl Operator {
);

Ok(Self {
rpc: _rpc,
rpc,
db,
signer,
config,
Expand Down
22 changes: 13 additions & 9 deletions core/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This tests checks if typical RPC flows works or not.
use bitcoin::{secp256k1::SecretKey, Address, Amount};
use clementine_core::rpc::clementine::{NewWithdrawalSigParams, WithdrawalFinalizedParams};
use clementine_core::rpc::clementine::NewWithdrawalSigParams;
use clementine_core::{actor::Actor, builder, UTXO};
use clementine_core::{config::BridgeConfig, database::Database, utils::initialize_logger};
use clementine_core::{extended_rpc::ExtendedRpc, utils::SECP};
Expand All @@ -24,7 +24,7 @@ async fn honest_operator_takes_refund() {
.await
.unwrap();

let (_verifiers, mut operators, _aggregator, _watchtowers, deposit_outpoint) =
let (_verifiers, mut operators, _aggregator, _watchtowers, _deposit_outpoint) =
run_single_deposit(config.clone()).await.unwrap();

let user_sk = SecretKey::from_slice(&[13u8; 32]).unwrap();
Expand Down Expand Up @@ -59,13 +59,17 @@ async fn honest_operator_takes_refund() {
output_script_pubkey: vec![],
output_amount: withdrawal_amount.to_sat(),
});
let _withdrawal_provide_txid = operators[1].new_withdrawal_sig(request).await.unwrap();

let request = Request::new(WithdrawalFinalizedParams {
withdrawal_id: 0,
deposit_outpoint: Some(deposit_outpoint.into()),
});
operators[1].withdrawal_finalized(request).await.unwrap();
let _withdrawal_provide_txid = operators[1]
.new_withdrawal_sig(request)
.await
.unwrap()
.into_inner();

// let request = Request::new(WithdrawalFinalizedParams {
// withdrawal_id: 0,
// deposit_outpoint: Some(deposit_outpoint.into()),
// });
// operators[1].withdrawal_finalized(request).await.unwrap();

// for tx in txs_to_be_sent.iter().take(txs_to_be_sent.len() - 1) {
// rpc.client.send_raw_transaction(tx.clone()).await.unwrap();
Expand Down

0 comments on commit 95fc4e2

Please sign in to comment.