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. 22
      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, order_id: OrderId,
ctx: &mut Context<Self>, ctx: &mut Context<Self>,
) -> Result<()> { ) -> 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 mut conn = self.db.acquire().await?;
let cfd = load_cfd_by_order_id(order_id, &mut conn).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) self.remove_pending_proposal(&order_id)
.context("accepted roll_over")?; .context("accepted roll_over")?;
Ok(()) Ok(())
} }
async fn handle_reject_roll_over(&mut self, order_id: OrderId) -> Result<()> { 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 // Validate if order is actually being requested to be extended
let (_, taker_id) = match self.current_pending_proposals.get(&order_id) { 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?; .await?;
self.remove_pending_proposal(&order_id) self.remove_pending_proposal(&order_id)
.context("rejected roll_over")?; .context("rejected roll_over")?;
Ok(()) Ok(())
} }

22
daemon/src/setup_contract.rs

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

2
daemon/src/taker_cfd.rs

@ -447,7 +447,7 @@ impl Actor {
sender.send(msg).await?; sender.send(msg).await?;
} }
RollOverState::None => { 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 cets: HashMap<String, Vec<(RangeInclusive<u64>, EcdsaAdaptorSignature)>>,
pub refund: Signature, pub refund: Signature,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct RollOverMsg2 { pub struct RollOverMsg2 {
pub revocation_sk: SecretKey, pub revocation_sk: SecretKey,

Loading…
Cancel
Save