mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 06:59:36 -05:00
Split RefundBitcoin into CancelBitcoin and RefundBitcoin
This commit is contained in:
parent
d813957c5a
commit
969ca63081
@ -69,10 +69,8 @@ pub enum Action {
|
||||
spend_key: monero::PrivateKey,
|
||||
view_key: monero::PrivateViewKey,
|
||||
},
|
||||
RefundBitcoin {
|
||||
tx_cancel: bitcoin::Transaction,
|
||||
tx_refund: bitcoin::Transaction,
|
||||
},
|
||||
CancelBitcoin(bitcoin::Transaction),
|
||||
RefundBitcoin(bitcoin::Transaction),
|
||||
}
|
||||
|
||||
// TODO: This could be moved to the monero module
|
||||
@ -250,8 +248,6 @@ where
|
||||
if let Err(SwapFailed::AfterBtcLock(_)) = swap_result {
|
||||
let tx_cancel =
|
||||
bitcoin::TxCancel::new(&tx_lock, refund_timelock, A.clone(), b.public());
|
||||
let tx_refund = bitcoin::TxRefund::new(&tx_cancel, &refund_address);
|
||||
|
||||
let signed_tx_cancel = {
|
||||
let sig_a = tx_cancel_sig_a.clone();
|
||||
let sig_b = b.sign(tx_cancel.digest());
|
||||
@ -262,7 +258,11 @@ where
|
||||
.expect("sig_{a,b} to be valid signatures for tx_cancel")
|
||||
};
|
||||
|
||||
co.yield_(Action::CancelBitcoin(signed_tx_cancel)).await;
|
||||
|
||||
let signed_tx_refund = {
|
||||
let tx_refund = bitcoin::TxRefund::new(&tx_cancel, &refund_address);
|
||||
|
||||
let adaptor = Adaptor::<Sha256, Deterministic<Sha256>>::default();
|
||||
|
||||
let sig_a =
|
||||
@ -274,11 +274,7 @@ where
|
||||
.expect("sig_{a,b} to be valid signatures for tx_refund")
|
||||
};
|
||||
|
||||
co.yield_(Action::RefundBitcoin {
|
||||
tx_cancel: signed_tx_cancel,
|
||||
tx_refund: signed_tx_refund,
|
||||
})
|
||||
.await;
|
||||
co.yield_(Action::RefundBitcoin(signed_tx_refund)).await;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -48,14 +48,12 @@ async fn swap_as_bob(
|
||||
.create_and_load_wallet_for_output(spend_key, view_key)
|
||||
.await?;
|
||||
}
|
||||
GeneratorState::Yielded(Action::RefundBitcoin {
|
||||
tx_cancel,
|
||||
tx_refund,
|
||||
}) => {
|
||||
GeneratorState::Yielded(Action::CancelBitcoin(tx_cancel)) => {
|
||||
let _ = bitcoin_wallet
|
||||
.broadcast_signed_transaction(tx_cancel)
|
||||
.await?;
|
||||
|
||||
}
|
||||
GeneratorState::Yielded(Action::RefundBitcoin(tx_refund)) => {
|
||||
let _ = bitcoin_wallet
|
||||
.broadcast_signed_transaction(tx_refund)
|
||||
.await?;
|
||||
|
Loading…
Reference in New Issue
Block a user