diff --git a/swap/src/asb/kraken.rs b/swap/src/asb/kraken.rs index 62aa4d4d..4f8e36b0 100644 --- a/swap/src/asb/kraken.rs +++ b/swap/src/asb/kraken.rs @@ -66,23 +66,23 @@ impl From for Error { impl RateService { pub async fn new() -> Result { - let (tx, rx) = watch::channel(Err(Error::NotYetRetrieved)); + let (rate_update, rate_update_receiver) = watch::channel(Err(Error::NotYetRetrieved)); - let (ws, _response) = + let (rate_stream, _response) = tokio_tungstenite::connect_async(Url::parse(KRAKEN_WS_URL).expect("valid url")).await?; - let (mut write, mut read) = ws.split(); + let (mut rate_stream_sink, mut rate_stream) = rate_stream.split(); tokio::spawn(async move { - while let Some(msg) = read.next().await { + while let Some(msg) = rate_stream.next().await { let msg = match msg { Ok(Message::Text(msg)) => msg, Ok(_) => { - let _ = tx.send(Err(Error::NonTextMessage)); + let _ = rate_update.send(Err(Error::NonTextMessage)); continue; } Err(e) => { - let _ = tx.send(Err(e.into())); + let _ = rate_update.send(Err(e.into())); continue; } }; @@ -95,7 +95,7 @@ impl RateService { let ticker = match serde_json::from_str::(&msg) { Ok(ticker) => ticker, Err(e) => { - let _ = tx.send(Err(e.into())); + let _ = rate_update.send(Err(e.into())); continue; } }; @@ -103,18 +103,22 @@ impl RateService { let rate = match Rate::try_from(ticker) { Ok(rate) => rate, Err(e) => { - let _ = tx.send(Err(e)); + let _ = rate_update.send(Err(e)); continue; } }; - let _ = tx.send(Ok(rate)); + let _ = rate_update.send(Ok(rate)); } }); - write.send(SUBSCRIBE_XMR_BTC_TICKER_PAYLOAD.into()).await?; + rate_stream_sink + .send(SUBSCRIBE_XMR_BTC_TICKER_PAYLOAD.into()) + .await?; - Ok(Self { receiver: rx }) + Ok(Self { + receiver: rate_update_receiver, + }) } } diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index 9d12d8b6..a6d06006 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -89,12 +89,11 @@ impl SecretKey { // joint output for TxLock_Monero // tx_refund: multisig(A, B), published by bob - // bob can produce sig on B for tx_refund using b - // alice sends over an encrypted signature on A for tx_refund using a encrypted - // with S_b we want to leak s_b - - // produced (by Alice) encsig - published (by Bob) sig = s_b (it's not really - // subtraction, it's recover) + // bob can produce sig on B using b + // alice sends over an encrypted signature on A encrypted with S_b + // s_b is leaked to alice when bob publishes signed tx_refund allowing her to + // recover s_b: recover(encsig, S_b, sig_tx_refund) = s_b + // alice now has s_a and s_b and can refund monero // self = a, Y = S_b, digest = tx_refund pub fn encsign(&self, Y: PublicKey, digest: SigHash) -> EncryptedSignature {