Browse Source

PR feedback and fmt

compile-for-aarch64
Philipp Hoenisch 3 years ago
parent
commit
9b755b9a59
No known key found for this signature in database GPG Key ID: E5F8E74C672BC666
  1. 8
      daemon/src/maker_cfd.rs
  2. 24
      daemon/src/setup_contract.rs
  3. 2
      daemon/src/taker_cfd.rs
  4. 1
      daemon/src/wire.rs

8
daemon/src/maker_cfd.rs

@ -678,7 +678,7 @@ impl Actor {
order_id: OrderId,
ctx: &mut Context<Self>,
) -> Result<()> {
tracing::debug!(%order_id, "Maker accepts a roll_over proposal" );
tracing::debug!(%order_id, "Maker accepts a roll_over proposal" );
let mut conn = self.db.acquire().await?;
let cfd = load_cfd_by_order_id(order_id, &mut conn).await?;
@ -757,12 +757,12 @@ tracing::debug!(%order_id, "Maker accepts a roll_over proposal" );
});
self.remove_pending_proposal(&order_id)
.context("accepted roll_over")?;
.context("accepted roll_over")?;
Ok(())
}
async fn handle_reject_roll_over(&mut self, order_id: OrderId) -> Result<()> {
tracing::debug!(%order_id, "Maker rejects a roll_over proposal" );
tracing::debug!(%order_id, "Maker rejects a roll_over proposal" );
// Validate if order is actually being requested to be extended
let (_, taker_id) = match self.current_pending_proposals.get(&order_id) {
@ -786,7 +786,7 @@ tracing::debug!(%order_id, "Maker rejects a roll_over proposal" );
.await?;
self.remove_pending_proposal(&order_id)
.context("rejected roll_over")?;
.context("rejected roll_over")?;
Ok(())
}

24
daemon/src/setup_contract.rs

@ -8,7 +8,7 @@ use crate::{model, oracle, payout_curve};
use anyhow::{Context, Result};
use bdk::bitcoin::secp256k1::{schnorrsig, Signature, SECP256K1};
use bdk::bitcoin::util::psbt::PartiallySignedTransaction;
use bdk::bitcoin::{Amount, PublicKey, Transaction, TxIn};
use bdk::bitcoin::{Amount, PublicKey, Transaction};
use bdk::descriptor::Descriptor;
use bdk::miniscript::DescriptorTrait;
use cfd_protocol::secp256k1_zkp::EcdsaAdaptorSignature;
@ -289,23 +289,11 @@ pub async fn roll_over(
)]);
// unsign lock tx because PartiallySignedTransaction needs an unsigned tx
let unsigned_lock_tx = Transaction {
version: 0,
lock_time: dlc.lock.0.lock_time,
input: dlc
.lock
.0
.input
.iter()
.map(|txin| TxIn {
previous_output: txin.previous_output,
script_sig: txin.script_sig.clone(),
sequence: txin.sequence,
witness: vec![],
})
.collect(),
output: dlc.lock.0.output.clone(),
};
let mut unsigned_lock_tx = dlc.lock.0.clone();
unsigned_lock_tx
.input
.iter_mut()
.for_each(|input| input.witness.clear());
let lock_tx = PartiallySignedTransaction::from_unsigned_tx(unsigned_lock_tx)?;
let other_punish_params = PunishParams {

2
daemon/src/taker_cfd.rs

@ -447,7 +447,7 @@ impl Actor {
sender.send(msg).await?;
}
RollOverState::None => {
anyhow::bail!("Received message without an active roll_over setup")
anyhow::bail!("Received message without an active roll_over setup")
}
}

1
daemon/src/wire.rs

@ -328,6 +328,7 @@ pub struct RollOverMsg1 {
pub cets: HashMap<String, Vec<(RangeInclusive<u64>, EcdsaAdaptorSignature)>>,
pub refund: Signature,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RollOverMsg2 {
pub revocation_sk: SecretKey,

Loading…
Cancel
Save