Skip to content

Commit d1c93a1

Browse files
authored
Merge pull request #266 from sapio-lang/update-deps-01-16-24
Update Versions & Small Fixes
2 parents 89e1e1f + 6aecf71 commit d1c93a1

File tree

8 files changed

+72
-43
lines changed

8 files changed

+72
-43
lines changed

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ serde_derive = "1.0"
1818
clap = "=3.0.0-beta.2"
1919
base64 = "0.13.0"
2020
lazy_static = "1.4.0"
21-
bitcoincore-rpc-async = "4.0.1-alpha.1"
21+
bitcoincore-rpc-async = "4.0.1-alpha.2"
2222
tokio = { version = "1", features = ["full"] }
2323
directories = "3.0.1"
2424
rand = "^0.6"

examples/dcf_mining_pool/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ serde_json = "1.0"
1414
serde = "1.0"
1515
serde_derive = "1.0"
1616
tokio = { version = "1", features = ["full"] }
17-
bitcoincore-rpc-async = "4.0.1-alpha.1"
17+
bitcoincore-rpc-async = "4.0.1-alpha.2"
1818

1919

2020
[dependencies.bitcoin]

sapio-base/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ serde_derive = "1.0"
1919

2020
[dependencies.miniscript]
2121
package = "sapio-miniscript"
22-
version = "^7.0.0"
22+
version = "^7.0.1"
2323
features = ['compiler', 'use-serde', 'use-schemars', 'serde']
2424

2525
[dependencies.bitcoin]
2626
package = "sapio-bitcoin"
27-
version = "0.28.0"
27+
version = "0.28.2"
2828
features = ['use-serde']

sapio/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description = "A programming framework for bitcoin smart contracts."
1313

1414
[dependencies.miniscript]
1515
package = "sapio-miniscript"
16-
version = "^7.0.0"
16+
version = "^7.0.1"
1717
features = ['compiler', 'use-serde', 'use-schemars', 'serde']
1818

1919
[features]
@@ -37,7 +37,7 @@ features = ['impl_json_schema', 'derive']
3737

3838
[dependencies.bitcoin]
3939
package = "sapio-bitcoin"
40-
version = "0.28.0"
40+
version = "0.28.2"
4141
features = ['use-serde']
4242

4343

sapio/src/contract/compiler/mod.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Compilable for bitcoin::XOnlyPublicKey {
7272
}
7373
}
7474

75-
#[derive(PartialEq, Eq)]
75+
#[derive(PartialEq, Eq, Debug)]
7676
enum Nullable {
7777
Yes,
7878
No,
@@ -90,19 +90,20 @@ fn compute_all_effects<C, A: Default>(
9090
return Ok(def);
9191
}
9292
let mut applied_effects_ctx = top_effect_ctx.derive(PathFragment::Effects)?;
93-
top_effect_ctx
93+
let r = top_effect_ctx
9494
.get_effects(InternalCompilerTag { _secret: () })
9595
.get_value(top_effect_ctx.path())
9696
// always gets the default expansion, but will also attempt
9797
// operating with the effects passed in through the Context Object.
98-
.fold(Ok(def), |a: TxTmplIt, (k, arg)| -> TxTmplIt {
99-
let v = a?;
98+
.try_fold(def, |a, (k, arg)| -> TxTmplIt {
99+
let v = a;
100100
let c = applied_effects_ctx
101101
.derive(PathFragment::Named(SArc(k.clone())))
102102
.expect(UNIQUE_DERIVE_PANIC_MSG);
103103
let w = func.call_json(self_ref, c, arg.clone())?;
104104
Ok(Box::new(v.chain(w)))
105-
})
105+
});
106+
r
106107
}
107108

108109
struct Renamer {
@@ -252,6 +253,7 @@ where
252253
}
253254
.entry(h)
254255
.or_insert(txtmpl);
256+
255257
let extractor = func.get_extract_clause_from_txtmpl();
256258
(extractor)(txtmpl, &ctx)
257259
})
@@ -262,11 +264,12 @@ where
262264

263265
// N.B. the order of the matches below is significant
264266
Ok(if func.get_returned_txtmpls_modify_guards() {
265-
(
267+
let r = (
266268
None,
267269
combine_txtmpls(nullability, txtmpl_clauses, guards)?,
268270
guard_metadata,
269-
)
271+
);
272+
r
270273
} else {
271274
let mut cp =
272275
ContinuationPoint::at(func.get_schema().clone(), effect_path.clone());
@@ -346,6 +349,9 @@ where
346349
Err(CompilationError::MinFeerateError)
347350
} else {
348351
let metadata_ctx = ctx.derive(PathFragment::Metadata)?;
352+
let metadata = self
353+
.metadata(metadata_ctx)?
354+
.add_guard_simps(all_guard_simps)?;
349355
Ok(Compiled {
350356
ctv_to_tx: comitted_txns,
351357
suggested_txs: other_txns,
@@ -354,9 +360,7 @@ where
354360
address,
355361
descriptor,
356362
amount_range,
357-
metadata: self
358-
.metadata(metadata_ctx)?
359-
.add_guard_simps(all_guard_simps)?,
363+
metadata,
360364
})
361365
}
362366
}
@@ -394,10 +398,13 @@ fn combine_txtmpls(
394398
// Error if 0 templates return and we don't want to be nullable
395399
(Nullable::No, 0, _) => Err(CompilationError::MissingTemplates),
396400
// If the guard is trivial, return the hashes standalone
397-
(_, _, Clause::Trivial) => Ok(txtmpl_clauses
398-
.into_iter()
399-
.map(|policy| policy.compile().map_err(Into::<CompilationError>::into))
400-
.collect::<Result<Vec<_>, _>>()?),
401+
(_, _, Clause::Trivial) => {
402+
let r = Ok(txtmpl_clauses
403+
.into_iter()
404+
.map(|policy| policy.compile().map_err(Into::<CompilationError>::into))
405+
.collect::<Result<Vec<_>, _>>()?);
406+
r
407+
}
401408
// If the guard is non-trivial, zip it to each hash
402409
// TODO: Arc in miniscript to dedup memory?
403410
// This could be Clause::Shared(x) or something...

sapio/src/template/builder.rs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ use super::input::InputMetadata;
99
pub use super::{Output, OutputMeta};
1010
use super::{Template, TemplateMetadata};
1111
use crate::contract::{CompilationError, Context};
12+
use crate::util::extended_address::ExtendedAddress;
1213
use bitcoin::util::amount::Amount;
13-
use bitcoin::VarInt;
1414
use bitcoin::Witness;
15+
use bitcoin::{Script, VarInt};
1516
use sapio_base::effects::PathFragment;
1617
use sapio_base::simp::SIMPAttachableAt;
1718
use sapio_base::simp::TemplateInputLT;
@@ -20,7 +21,6 @@ use sapio_base::timelocks::*;
2021
use sapio_base::CTVHash;
2122
use sapio_base::Clause;
2223
use std::convert::TryFrom;
23-
use std::convert::TryInto;
2424

2525
/// Builder can be used to interactively put together a transaction template before
2626
/// finalizing into a Template.
@@ -229,28 +229,36 @@ impl Builder {
229229
pub fn get_tx(&self) -> bitcoin::Transaction {
230230
let default_seq = RelTime::try_from(0).unwrap().into();
231231
let default_nlt = AbsHeight::try_from(0).unwrap().into();
232-
bitcoin::Transaction {
232+
let input = self
233+
.sequences
234+
.iter()
235+
.map(|sequence| bitcoin::TxIn {
236+
previous_output: Default::default(),
237+
script_sig: Default::default(),
238+
sequence: sequence.unwrap_or(default_seq).get(),
239+
witness: Witness::new(),
240+
})
241+
.collect();
242+
let output = self
243+
.outputs
244+
.iter()
245+
.map(|out| {
246+
let value = out.amount.as_sat();
247+
248+
let script_pubkey: Script = From::<&ExtendedAddress>::from(&out.contract.address);
249+
bitcoin::TxOut {
250+
value,
251+
script_pubkey,
252+
}
253+
})
254+
.collect();
255+
let t = bitcoin::Transaction {
233256
version: self.version,
234257
lock_time: self.lock_time.unwrap_or(default_nlt).get(),
235-
input: self
236-
.sequences
237-
.iter()
238-
.map(|sequence| bitcoin::TxIn {
239-
previous_output: Default::default(),
240-
script_sig: Default::default(),
241-
sequence: sequence.unwrap_or(default_seq).get(),
242-
witness: Witness::new(),
243-
})
244-
.collect(),
245-
output: self
246-
.outputs
247-
.iter()
248-
.map(|out| bitcoin::TxOut {
249-
value: TryInto::<Amount>::try_into(out.amount).unwrap().as_sat(),
250-
script_pubkey: out.contract.address.clone().into(),
251-
})
252-
.collect(),
253-
}
258+
input,
259+
output,
260+
};
261+
t
254262
}
255263

256264
/// Sets the feerate if not set, and then sets the value to the min of the

sapio/src/util/extended_address.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,17 @@ impl From<ExtendedAddress> for Script {
8888
}
8989
}
9090
}
91+
92+
impl From<&ExtendedAddress> for Script {
93+
fn from(s: &ExtendedAddress) -> Self {
94+
match s {
95+
ExtendedAddress::Address(a) => a.script_pubkey(),
96+
ExtendedAddress::OpReturn(OpReturn(s)) => s.clone(),
97+
ExtendedAddress::Unknown(s) => s.clone(),
98+
ExtendedAddress::Descriptor(d) => {
99+
let r = d.script_pubkey();
100+
r
101+
}
102+
}
103+
}
104+
}

tools/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ serde_json = "1.0"
1414
serde = "1.0"
1515
serde_derive = "1.0"
1616
tokio = { version = "1", features = ["full"] }
17-
bitcoincore-rpc-async = "4.0.1-alpha.1"
17+
bitcoincore-rpc-async = "4.0.1-alpha.2"
1818

1919
[dependencies.miniscript]
2020
package = "sapio-miniscript"

0 commit comments

Comments
 (0)