-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6747f35
commit cbef6b5
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
description = "Farcaster Atomic Swap protocol support for Tuxedo based chains" | ||
edition = "2021" | ||
name = "farcaster-tuxedo" | ||
version = "0.1.0" | ||
|
||
# TODO These were copy pasted. Prune them. | ||
[dependencies] | ||
parity-scale-codec = { features = [ "derive" ], workspace = true } | ||
scale-info = { features = [ "derive" ], workspace = true } | ||
serde = { features = [ "derive" ], workspace = true } | ||
sp-core = { default_features = false, workspace = true } | ||
sp-runtime = { default_features = false, workspace = true } | ||
sp-std = { default_features = false, workspace = true } | ||
tuxedo-core = { default-features = false, path = "../tuxedo-core" } | ||
|
||
[features] | ||
default = [ "std" ] | ||
std = [ | ||
"tuxedo-core/std", | ||
"parity-scale-codec/std", | ||
"sp-runtime/std", | ||
"serde/std", | ||
"sp-core/std", | ||
"sp-std/std", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//! The [Farcaster project](https://github.com/farcaster-project) s a cross-chain atomic swap protocol | ||
//! that allows swaps with Monero despite its lack of any on chain logic. | ||
//! | ||
//! This crate contains several Tuxedo `Verifier`s that implement the same logic as Farcaster's | ||
//! original Bitcoin scripts the allowing any Tuxedo chain to act on the arbitrating side of a | ||
//! Farcaster protocol swap. | ||
use parity_scale_codec::{Decode, Encode}; | ||
use scale_info::TypeInfo; | ||
use serde::{Deserialize, Serialize}; | ||
use sp_core::sr25519::{Public, Signature}; | ||
use tuxedo_core::Verifier; | ||
|
||
/// Allows coins on the arbitrating Tuxedo chain to be bought or moved into in intermediate | ||
/// utxo that represents the cancellation phase. | ||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] | ||
pub struct SwapLock { | ||
recipient: Public, | ||
canceller: Public, | ||
cancelation_timeout: u32, | ||
} | ||
|
||
impl Verifier for SwapLock { | ||
type Redeemer = UnlockSwap; | ||
|
||
fn verify(&self, simplified_tx: &[u8], block_height: u32, redeemer: &Self::Redeemer) -> bool { | ||
todo!() | ||
} | ||
} | ||
|
||
/// Satisfies a `SwapLock` verifier. | ||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] | ||
pub enum UnlockSwap { | ||
/// | ||
Buy, | ||
/// | ||
Cancel, | ||
} | ||
|
||
/// Allows coins in the intermediate cancellation state to be refunded to the original owner | ||
/// or for an alternate punish path. TODO better docs after I fully understand the punish path | ||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] | ||
pub struct SwapCancellation {} | ||
|
||
impl Verifier for SwapCancellation { | ||
type Redeemer = CompleteCancellation; | ||
|
||
fn verify(&self, simplified_tx: &[u8], block_height: u32, redeemer: &Self::Redeemer) -> bool { | ||
todo!() | ||
} | ||
} | ||
|
||
/// | ||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] | ||
pub enum CompleteCancellation { | ||
/// | ||
Refund, | ||
/// | ||
Punish, | ||
} |