Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sapio w/ Arbitrary Scripts #269

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ctv_emulators/src/connections/federated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

//! join together CTVEmulators as a multisig

use sapio_base::Policy;

use super::*;
/// Creates a multi-condition emulator with a certain threshold.
/// It implements CTVEmulator so that it itself can be used as a trait object.
Expand All @@ -25,13 +27,13 @@ impl FederatedEmulatorConnection {
}

impl CTVEmulator for FederatedEmulatorConnection {
fn get_signer_for(&self, h: Sha256) -> Result<Clause, EmulatorError> {
fn get_signer_for(&self, h: Sha256) -> Result<Policy, EmulatorError> {
let v = self
.emulators
.iter()
.map(|e| e.get_signer_for(h))
.collect::<Result<Vec<Clause>, EmulatorError>>()?;
Ok(Clause::Threshold(self.threshold as usize, v))
.collect::<Result<Vec<Policy>, EmulatorError>>()?;
Ok(Policy::Threshold(self.threshold as usize, v))
}
fn sign(
&self,
Expand Down
5 changes: 3 additions & 2 deletions ctv_emulators/src/connections/hd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ impl HDOracleEmulatorConnection {
}
}

use sapio_base::Policy;
use tokio::{runtime::Handle, sync::Mutex};
impl CTVEmulator for HDOracleEmulatorConnection {
fn get_signer_for(&self, h: Sha256) -> Result<Clause, EmulatorError> {
Ok(Clause::Key(self.derive(h)?.to_x_only_pub()))
fn get_signer_for(&self, h: Sha256) -> Result<Policy, EmulatorError> {
Ok(Policy::Key(self.derive(h)?.to_x_only_pub()))
}
fn sign(
&self,
Expand Down
8 changes: 5 additions & 3 deletions emulator-trait/src/emulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//! definitions of emulator traits required to use as a trait object in low-level libraries.
use bitcoin::hashes::sha256;
use bitcoin::util::psbt::PartiallySignedTransaction;
use sapio_base::miniscript::policy::Concrete;

Check warning on line 10 in emulator-trait/src/emulator.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `sapio_base::miniscript::policy::Concrete`

warning: unused import: `sapio_base::miniscript::policy::Concrete` --> emulator-trait/src/emulator.rs:10:5 | 10 | use sapio_base::miniscript::policy::Concrete; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
pub use sapio_base::Clause;
use sapio_base::Policy;
use std::fmt;
use std::sync::Arc;
/// Errors that an emulator might throw
Expand Down Expand Up @@ -43,7 +45,7 @@
pub trait CTVEmulator: Sync + Send {
/// For a given transaction hash, gets the corresponding Clause that the
/// Emulator would satisfy.
fn get_signer_for(&self, h: sha256::Hash) -> Result<Clause, EmulatorError>;
fn get_signer_for(&self, h: sha256::Hash) -> Result<Policy, EmulatorError>;
/// Adds the Emulators signature to the PSBT, if any.
fn sign(
&self,
Expand All @@ -58,8 +60,8 @@
/// a type tag that can be tossed inside an Arc to get CTV
pub struct CTVAvailable;
impl CTVEmulator for CTVAvailable {
fn get_signer_for(&self, h: sha256::Hash) -> Result<Clause, EmulatorError> {
Ok(Clause::TxTemplate(h))
fn get_signer_for(&self, h: sha256::Hash) -> Result<Policy, EmulatorError> {
Ok(Policy::TxTemplate(h))
}
fn sign(
&self,
Expand Down
6 changes: 6 additions & 0 deletions sapio-base/src/consts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// TODO: Fix the const fn version
use bitcoin::blockdata::opcodes::all;
///pub const FALSE_PATTERN: &[u8] = &[all::OP_PUSHBYTES_0.into_u8()];
pub const FALSE_PATTERN: &[u8] = &[0];
///pub const TRUE_PATTERN: &[u8] = &[all::OP_PUSHNUM_1.into_u8()];
pub const TRUE_PATTERN: &[u8] = &[81];
153 changes: 150 additions & 3 deletions sapio-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
#![deny(missing_docs)]
/// Extra functionality for working with Bitcoin types
pub mod util;
use bitcoin::XOnlyPublicKey;
pub use util::CTVHash;
use std::{
borrow::BorrowMut,

Check warning on line 12 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused imports: `Cell`, `borrow::BorrowMut`, `ops::DerefMut`, and `rc::Rc`

warning: unused imports: `Cell`, `borrow::BorrowMut`, `ops::DerefMut`, and `rc::Rc` --> sapio-base/src/lib.rs:12:5 | 12 | borrow::BorrowMut, | ^^^^^^^^^^^^^^^^^ 13 | cell::{Cell, RefCell}, | ^^^^ 14 | ops::DerefMut, | ^^^^^^^^^^^^^ 15 | rc::Rc, | ^^^^^^ | = note: `#[warn(unused_imports)]` on by default
cell::{Cell, RefCell},
ops::DerefMut,
rc::Rc,
};

use bitcoin::{blockdata::opcodes::all::OP_VERIFY, hashes::hex::FromHex, Script, XOnlyPublicKey};
use consts::TRUE_PATTERN;
pub use miniscript;
use miniscript::Tap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
pub use util::CTVHash;
pub mod plugin_args;
pub mod simp;

Expand All @@ -23,9 +34,145 @@
pub use effects::reverse_path;
pub mod serialization_helpers;

/// Any logical script clause
#[derive(Eq, Ord, Clone, PartialEq, PartialOrd, Debug, JsonSchema, Serialize, Deserialize)]
pub enum Clause {
/// Script fragment (must end with 1 or 0 on stack)
Script(bitcoin::Script),
/// Logical Conjunction
And(Box<RefCell<Clause>>, Box<RefCell<Clause>>),
/// Logical Or
Or(Box<RefCell<Clause>>, Box<RefCell<Clause>>, u64),
}

/// constants useful for various purposes
pub mod consts {
// TODO: Fix the const fn version
use bitcoin::blockdata::opcodes::all;

Check warning on line 51 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `bitcoin::blockdata::opcodes::all`

warning: unused import: `bitcoin::blockdata::opcodes::all` --> sapio-base/src/lib.rs:51:9 | 51 | use bitcoin::blockdata::opcodes::all; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
///pub const FALSE_PATTERN: &[u8] = &[all::OP_PUSHBYTES_0.into_u8()];
pub const FALSE_PATTERN: &[u8] = &[0];
///pub const TRUE_PATTERN: &[u8] = &[all::OP_PUSHNUM_1.into_u8()];
pub const TRUE_PATTERN: &[u8] = &[81];
}
impl Clause {
/// Returns true if this [`Clause`] is an OP_TRUE
pub fn is_trivial(&self) -> bool {
match self {
Clause::Script(s) => matches!(s.as_bytes(), consts::TRUE_PATTERN),
_ => false,
}
}
/// creates a trivial fragment
pub fn trivial() -> Clause {
Clause::Script(Script::from(TRUE_PATTERN.to_vec()))
}
///

Check warning on line 69 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

empty doc comment

warning: empty doc comment --> sapio-base/src/lib.rs:69:5 | 69 | /// | ^^^ | = help: consider removing or filling it = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_docs = note: `#[warn(clippy::empty_docs)]` on by default
pub fn wrap(self) -> Box<RefCell<Self>> {
Box::new(RefCell::new(self))
}
}
fn join_script_frags<'a, I: Iterator<Item = &'a Script>>(i: I) -> Script {
let mut acc = vec![];
for script in i {
acc.extend_from_slice(script.as_bytes());
acc.push(OP_VERIFY.into_u8());
}
// drop last verify
acc.pop();
Script::from_byte_iter(acc.iter().cloned().map(Ok)).unwrap()
}

fn assign_numbers_inner(p: &mut Clause, n: &mut u64) {
match p {
Clause::Script(v) => (),

Check warning on line 87 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `v`

warning: unused variable: `v` --> sapio-base/src/lib.rs:87:24 | 87 | Clause::Script(v) => (), | ^ help: if this is intentional, prefix it with an underscore: `_v` | = note: `#[warn(unused_variables)]` on by default
Clause::And(a, b) => {
assign_numbers_inner(a.get_mut(), n);
assign_numbers_inner(b.get_mut(), n);
}
Clause::Or(a, b, c) => {

Check warning on line 92 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `b`

warning: unused variable: `b` --> sapio-base/src/lib.rs:92:23 | 92 | Clause::Or(a, b, c) => { | ^ help: if this is intentional, prefix it with an underscore: `_b`

Check warning on line 92 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `a`

warning: unused variable: `a` --> sapio-base/src/lib.rs:92:20 | 92 | Clause::Or(a, b, c) => { | ^ help: if this is intentional, prefix it with an underscore: `_a`
*c = *n;
*n += 1;
}
}
}
fn assign_numbers(mut clause: Clause) -> (Clause, Vec<bool>) {
let mut n = 0;
assign_numbers_inner(&mut clause, &mut n);
(clause, vec![false; n as usize])
}

fn compile_opt(clause: &mut Clause, opt: &[bool]) -> Script {
match clause {
Clause::Script(s) => s.clone(),
Clause::And(a, b) => {
join_script_frags([compile_opt(a.get_mut(), opt), compile_opt(b.get_mut(), opt)].iter())
}
Clause::Or(a, b, idx) => {
if opt[*idx as usize] {
compile_opt(a.get_mut(), opt)
} else {
compile_opt(b.get_mut(), opt)
}
}
}
}

fn byte_to_bits(u: u8) -> [bool; 8] {
[
u & 1 > 0,
u & 2 > 0,
u & 4 > 0,
u & 8 > 0,
u & 16 > 0,
u & 32 > 0,
u & 64 > 0,
u & 128 > 0,
]
}

/// Fail on complex scripts
#[derive(Debug)]
pub struct ScriptComplexityTooManyOrs;
impl Clause {
/// generates all the leafs by letting each or be satisfied bit-by-bit
pub fn generate_leafs(p: Self) -> Result<Vec<Script>, ScriptComplexityTooManyOrs> {
let (mut clause, opt) = assign_numbers(p);
if opt.len() > 16 {
return Err(ScriptComplexityTooManyOrs);
}
let lim: u16 = 2u16.pow(opt.len() as u32);
let mut out = vec![];
for x in 0..lim {
// double check the bit order TODO:
let bytes = x.to_be_bytes();
let v = [byte_to_bits(bytes[1]), byte_to_bits(bytes[0])].concat();
out.push(compile_opt(&mut clause, &v[0..opt.len()]));
}
Ok(out)
}
}

/// Concrete Instantiation of Miniscript Policy. Because we need to be able to generate exact
/// transactions, we only work with `bitcoin::PublicKey` types.
pub type Clause = miniscript::policy::concrete::Policy<XOnlyPublicKey>;
pub type Policy = miniscript::policy::concrete::Policy<XOnlyPublicKey>;

/// Concrete Instantiation of Miniscript Policy. Because we need to be able to generate exact
/// transactions, we only work with `bitcoin::PublicKey` types.
pub type Pol = miniscript::policy::concrete::Policy<XOnlyPublicKey>;

/// Helper for things that can become clauses
pub trait IntoClause {
/// convert to clause
fn to_clause(&self) -> Result<Clause, ()>;

Check warning on line 166 in sapio-base/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this returns a `Result<_, ()>`

warning: this returns a `Result<_, ()>` --> sapio-base/src/lib.rs:166:5 | 166 | fn to_clause(&self) -> Result<Clause, ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use a custom `Error` type instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err = note: `#[warn(clippy::result_unit_err)]` on by default
}
impl IntoClause for Pol {
fn to_clause(&self) -> Result<Clause, ()> {
Ok(Clause::Script(
self.compile::<Tap>().map_err(|_| ())?.encode(),
))
}
}

#[cfg(test)]
mod tests {
#[test]
Expand Down
22 changes: 13 additions & 9 deletions sapio-base/src/timelocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use super::Clause;

Check warning on line 7 in sapio-base/src/timelocks.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `super::Clause`

warning: unused import: `super::Clause` --> sapio-base/src/timelocks.rs:7:5 | 7 | use super::Clause; | ^^^^^^^^^^^^^
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
Expand Down Expand Up @@ -115,6 +115,10 @@
pub use alias::*;

mod trait_impls {
use miniscript::policy::Concrete;

Check warning on line 118 in sapio-base/src/timelocks.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `miniscript::policy::Concrete`

warning: unused import: `miniscript::policy::Concrete` --> sapio-base/src/timelocks.rs:118:9 | 118 | use miniscript::policy::Concrete; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

use crate::Policy;

use super::*;
impl Absolutivity for Rel {
const IS_ABSOLUTE: bool = false;
Expand Down Expand Up @@ -169,17 +173,17 @@
}
}

impl<A, TT> From<LockTime<A, TT>> for Clause
impl<A, TT> From<LockTime<A, TT>> for Policy
where
A: Absolutivity,
TT: TimeType,
{
fn from(lt: LockTime<A, TT>) -> Clause {
fn from(lt: LockTime<A, TT>) -> Policy {
match (A::IS_ABSOLUTE, TT::IS_HEIGHT) {
(true, true) => Clause::After(lt.0),
(true, false) => Clause::After(lt.0),
(false, true) => Clause::Older(lt.0),
(false, false) => Clause::Older(lt.0),
(true, true) => Policy::After(lt.0),
(true, false) => Policy::After(lt.0),
(false, true) => Policy::Older(lt.0),
(false, false) => Policy::Older(lt.0),
}
}
}
Expand Down Expand Up @@ -244,23 +248,23 @@
}
}

impl From<AnyRelTimeLock> for Clause {
impl From<AnyRelTimeLock> for Policy {
fn from(lt: AnyRelTimeLock) -> Self {
match lt {
AnyRelTimeLock::RH(a) => a.into(),
AnyRelTimeLock::RT(a) => a.into(),
}
}
}
impl From<AnyAbsTimeLock> for Clause {
impl From<AnyAbsTimeLock> for Policy {
fn from(lt: AnyAbsTimeLock) -> Self {
match lt {
AnyAbsTimeLock::AH(a) => a.into(),
AnyAbsTimeLock::AT(a) => a.into(),
}
}
}
impl From<AnyTimeLock> for Clause {
impl From<AnyTimeLock> for Policy {
fn from(lt: AnyTimeLock) -> Self {
match lt {
AnyTimeLock::A(a) => a.into(),
Expand Down
10 changes: 5 additions & 5 deletions sapio-contrib/src/contracts/basic_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
impl ExampleA {
#[guard]
fn timeout(self, _ctx: sapio::Context) {
Clause::Older(100)
Pol::Older(100)

Check failure on line 32 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:32:9 | 32 | Pol::Older(100) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |
}
#[guard(cached)]
fn signed(self, _ctx: sapio::Context) {
Clause::And(vec![Clause::Key(self.alice), Clause::Key(self.bob)])
Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)])

Check failure on line 36 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:36:45 | 36 | Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)]) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |

Check failure on line 36 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:36:23 | 36 | Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)]) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |

Check failure on line 36 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:36:9 | 36 | Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)]) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |
}
}

Expand Down Expand Up @@ -79,9 +79,9 @@
impl<T: BState> ExampleB<T> {
#[guard(cached)]
fn all_signed(self, _ctx: Context) {
Clause::Threshold(
Pol::Threshold(

Check failure on line 82 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:82:9 | 82 | Pol::Threshold( | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |
T::get_n(self.threshold, self.participants.len() as u8) as usize,
self.participants.iter().map(|k| Clause::Key(*k)).collect(),
self.participants.iter().map(|k| Pol::Key(*k)).collect(),

Check failure on line 84 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:84:46 | 84 | self.participants.iter().map(|k| Pol::Key(*k)).collect(), | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |
)
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@
impl ExampleCompileIf {
#[guard]
fn cooperate(self, _ctx: Context) {
Clause::And(vec![Clause::Key(self.alice), Clause::Key(self.bob)])
Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)])

Check failure on line 138 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:138:45 | 138 | Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)]) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |

Check failure on line 138 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:138:23 | 138 | Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)]) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |

Check failure on line 138 in sapio-contrib/src/contracts/basic_examples.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `Pol`

error[E0433]: failed to resolve: use of undeclared type `Pol` --> sapio-contrib/src/contracts/basic_examples.rs:138:9 | 138 | Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)]) | ^^^ use of undeclared type `Pol` | help: consider importing one of these type aliases | 8 + use crate::contracts::sapio_base::Pol; | 8 + use sapio_base::Pol; |
}
/// `should_escrow` disables any branch depending on it. If not set,
/// it checks to make the branch required. This is done in a conflict-free way;
Expand Down
6 changes: 3 additions & 3 deletions sapio-contrib/src/contracts/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bitcoin::util::amount::CoinAmount;
use contract::*;

use sapio::*;
use sapio_base::Clause;
use sapio_base::Pol;
use sapio_macros::guard;
use schemars::JsonSchema;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Expand Down Expand Up @@ -228,11 +228,11 @@ where
{
#[guard]
fn timeout(self, _ctx: Context) {
Clause::Older(100)
Pol::Older(100)
}
#[guard(cached)]
fn signed(self, _ctx: Context) {
Clause::And(vec![Clause::Key(self.alice), Clause::Key(self.bob)])
Pol::And(vec![Pol::Key(self.alice), Pol::Key(self.bob)])
}

#[continuation(guarded_by = "[Self::signed]", coerce_args = "coerce_args")]
Expand Down
6 changes: 3 additions & 3 deletions sapio-contrib/src/contracts/coin_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use sapio::contract::*;
use sapio::util::amountrange::AmountF64;
use sapio::*;
use sapio_base::timelocks::AnyRelTimeLock;
use sapio_base::Clause;
use sapio_base::Pol;

use schemars::JsonSchema;
use serde::Deserialize;
Expand All @@ -21,7 +21,7 @@ type Payouts = Vec<(Arc<Mutex<dyn Compilable>>, AmountF64)>;
/// cooperatively share a UTXO.
pub struct CoinPool {
/// The list of stakeholders
pub clauses: Vec<Clause>,
pub clauses: Vec<Pol>,
/// How to refund people if no update agreed on
pub refunds: Payouts,
}
Expand Down Expand Up @@ -71,7 +71,7 @@ impl CoinPool {
#[guard]
/// everyone has signed off on the transaction
fn all_approve(self, _ctx: Context) {
Clause::Threshold(self.clauses.len(), self.clauses.clone())
Pol::Threshold(self.clauses.len(), self.clauses.clone())
}
/// move the coins to the next state -- payouts may recursively contain pools itself
#[continuation(
Expand Down
Loading
Loading