|
| 1 | +//! The [Farcaster project](https://github.com/farcaster-project) s a cross-chain atomic swap protocol |
| 2 | +//! that allows swaps with Monero despite its lack of any on chain logic. |
| 3 | +//! |
| 4 | +//! This crate contains several Tuxedo `Verifier`s that implement the same logic as Farcaster's |
| 5 | +//! original Bitcoin scripts the allowing any Tuxedo chain to act on the arbitrating side of a |
| 6 | +//! Farcaster protocol swap. |
| 7 | +
|
| 8 | +use parity_scale_codec::{Decode, Encode}; |
| 9 | +use scale_info::TypeInfo; |
| 10 | +use serde::{Deserialize, Serialize}; |
| 11 | +use sp_core::sr25519::{Public, Signature}; |
| 12 | +use tuxedo_core::Verifier; |
| 13 | + |
| 14 | +/// Allows coins on the arbitrating Tuxedo chain to be bought or moved into in intermediate |
| 15 | +/// utxo that represents the cancellation phase. |
| 16 | +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] |
| 17 | +pub struct SwapLock { |
| 18 | + recipient: Public, |
| 19 | + canceller: Public, |
| 20 | + cancelation_timeout: u32, |
| 21 | +} |
| 22 | + |
| 23 | +impl Verifier for SwapLock { |
| 24 | + type Redeemer = UnlockSwap; |
| 25 | + |
| 26 | + fn verify(&self, simplified_tx: &[u8], block_height: u32, redeemer: &Self::Redeemer) -> bool { |
| 27 | + todo!() |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +/// Satisfies a `SwapLock` verifier. |
| 32 | +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] |
| 33 | +pub enum UnlockSwap { |
| 34 | + /// |
| 35 | + Buy, |
| 36 | + /// |
| 37 | + Cancel, |
| 38 | +} |
| 39 | + |
| 40 | +/// Allows coins in the intermediate cancellation state to be refunded to the original owner |
| 41 | +/// or for an alternate punish path. TODO better docs after I fully understand the punish path |
| 42 | +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] |
| 43 | +pub struct SwapCancellation {} |
| 44 | + |
| 45 | +impl Verifier for SwapCancellation { |
| 46 | + type Redeemer = CompleteCancellation; |
| 47 | + |
| 48 | + fn verify(&self, simplified_tx: &[u8], block_height: u32, redeemer: &Self::Redeemer) -> bool { |
| 49 | + todo!() |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +/// |
| 54 | +#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)] |
| 55 | +pub enum CompleteCancellation { |
| 56 | + /// |
| 57 | + Refund, |
| 58 | + /// |
| 59 | + Punish, |
| 60 | +} |
0 commit comments