141: Clean-up r=D4nte a=D4nte

Remove dead code I noticed while starting to work on network revamp.

Co-authored-by: Franck Royer <franck@coblox.tech>
This commit is contained in:
bors[bot] 2021-01-14 02:10:10 +00:00 committed by GitHub
commit a4cd75d394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 61 deletions

View File

@ -1,7 +1,7 @@
@startuml
database Bitcoin
actor Bob
Actor Alice
actor Bob as "Bob (User)"
Actor Alice as "Alice (Service Provider)"
database Monero
group Negotiation
@ -20,22 +20,22 @@ end
group Execution Setup
group Phase A [Messages can be exchanged in any order]
Bob -> Alice: Message0
Bob -> Alice: bob::Message0
note left: Pubkeys\ndleq proof s_b\nxmr viewkey v_b\nbtc refund addr
Alice -> Bob: Message1
Alice -> Bob: alice::Message0
note right: Pubkeys\ndleq proof s_a\nxmr view key v_a\nbtc redeem addr\nbtc punish addr
end
group Phase B [Messages must be exchanged in the given order]
Bob -> Alice: Message2
Bob -> Alice: Message1
note left: unsigned btc lock tx
Alice -> Bob: Message3
Alice -> Bob: Message2
note right: btc cancel tx sig\nbtc refund tx enc sig S_b
Bob -> Alice: Message4
Bob -> Alice: Message3
note left: btc punish tx sig\nbtc cancel tx sig
end
@ -46,10 +46,10 @@ group Execution
Alice ->> Monero: Lock
Alice -> Bob: Message5
Alice -> Bob: Message4
note right: xmr lock tx transfer proof\nThis can be removed if Bob watches the blockchain.
Bob -> Alice: Message6
Bob -> Alice: Message5
note left: redeem tx enc sig S_a
Alice ->> Bitcoin: Redeem

View File

@ -469,10 +469,6 @@ impl TxPunish {
}
}
pub fn txid(&self) -> Txid {
self.inner.txid()
}
pub fn digest(&self) -> SigHash {
self.digest
}

View File

@ -16,8 +16,6 @@ use crate::{
config::Config,
};
pub const TX_LOCK_MINE_TIMEOUT: u64 = 3600;
#[derive(Debug)]
pub struct Wallet {
pub inner: bitcoin_harness::Wallet,

View File

@ -20,10 +20,9 @@ use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
pub mod bitcoin;
pub mod cli;
pub mod config;
pub mod database;
pub mod fs;
mod fs;
pub mod monero;
pub mod network;
pub mod protocol;

View File

@ -13,6 +13,7 @@
#![forbid(unsafe_code)]
#![allow(non_snake_case)]
use crate::cli::{Command, Options, Resume};
use anyhow::{bail, Context, Result};
use libp2p::{core::Multiaddr, PeerId};
use prettytable::{row, Table};
@ -21,7 +22,6 @@ use std::sync::Arc;
use structopt::StructOpt;
use swap::{
bitcoin,
cli::{Command, Options, Resume},
config::Config,
database::{Database, Swap},
monero, network,
@ -34,6 +34,8 @@ use swap::{
use tracing::{info, log::LevelFilter};
use uuid::Uuid;
mod cli;
#[macro_use]
extern crate prettytable;

View File

@ -23,12 +23,6 @@ pub use wallet::Wallet;
pub const PICONERO_OFFSET: u64 = 1_000_000_000_000;
pub fn random_private_key<R: RngCore + CryptoRng>(rng: &mut R) -> PrivateKey {
let scalar = Scalar::random(rng);
PrivateKey::from_scalar(scalar)
}
pub fn private_key_from_secp256k1_scalar(scalar: bitcoin::Scalar) -> PrivateKey {
let mut bytes = scalar.to_bytes();

View File

@ -1,4 +1,3 @@
use crate::monero;
use async_trait::async_trait;
use futures::prelude::*;
use libp2p::{
@ -28,7 +27,6 @@ const BUF_SIZE: usize = 1024 * 1024;
pub enum BobToAlice {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
AmountsFromBtc(::bitcoin::Amount),
AmountsFromXmr(monero::Amount),
Message0(Box<bob::Message0>),
Message1(bob::Message1),
Message2(bob::Message2),

View File

@ -39,40 +39,5 @@ pub fn build(id_keys: identity::Keypair) -> Result<SwapTransport> {
Ok(transport)
}
/// Builds a libp2p transport with Tor and with the following features:
/// - TCP connection over the Tor network
/// - DNS name resolution
/// - authentication via noise
/// - multiplexing via yamux or mplex
pub fn build_tor(
id_keys: identity::Keypair,
address_port_pair: Option<(libp2p::core::Multiaddr, u16)>,
) -> Result<SwapTransport> {
use libp2p_tokio_socks5::Socks5TokioTcpConfig;
use std::collections::HashMap;
let mut map = HashMap::new();
if let Some((addr, port)) = address_port_pair {
map.insert(addr, port);
}
let dh_keys = noise::Keypair::<X25519Spec>::new().into_authentic(&id_keys)?;
let noise = NoiseConfig::xx(dh_keys).into_authenticated();
let socks = Socks5TokioTcpConfig::default().nodelay(true).onion_map(map);
let dns = DnsConfig::new(socks)?;
let transport = dns
.upgrade(Version::V1)
.authenticate(noise)
.multiplex(SelectUpgrade::new(
yamux::Config::default(),
MplexConfig::new(),
))
.map(|(peer, muxer), _| (peer, StreamMuxerBox::new(muxer)))
.boxed();
Ok(transport)
}
pub type SwapTransport = Boxed<(PeerId, StreamMuxerBox)>;