Skip to content

Commit 5a403ae

Browse files
committed
Rename BitcoinSig -> BitcoinECSig
1 parent 2720f53 commit 5a403ae

File tree

11 files changed

+57
-57
lines changed

11 files changed

+57
-57
lines changed

examples/sign_multisig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn main() {
111111
// Attempt to satisfy at age 0, height 0
112112
let original_txin = tx.input[0].clone();
113113

114-
let mut sigs = HashMap::<bitcoin::PublicKey, miniscript::BitcoinSig>::new();
114+
let mut sigs = HashMap::<bitcoin::PublicKey, miniscript::BitcoinECSig>::new();
115115

116116
// Doesn't work with no signatures
117117
assert!(my_descriptor.satisfy(&mut tx.input[0], &sigs).is_err());

examples/verify_tx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn main() {
139139
.expect("Can only fail in sighash single when corresponding output is not present");
140140
// Restrict to sighash_all just to demonstrate how to add additional filters
141141
// `&_` needed here because of https://github.com/rust-lang/rust/issues/79187
142-
let vfyfn = move |pk: &_, bitcoinsig: miniscript::BitcoinSig| {
142+
let vfyfn = move |pk: &_, bitcoinsig: miniscript::BitcoinECSig| {
143143
bitcoinsig.1 == bitcoin::SigHashType::All && vfyfn(pk, bitcoinsig)
144144
};
145145

src/descriptor/bare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Pkh<Pk> {
324324
Pk: ToPublicKey,
325325
S: Satisfier<Pk>,
326326
{
327-
if let Some(sig) = satisfier.lookup_sig(&self.pk) {
327+
if let Some(sig) = satisfier.lookup_ec_sig(&self.pk) {
328328
let mut sig_vec = sig.0.serialize_der().to_vec();
329329
sig_vec.push(sig.1.as_u32() as u8);
330330
let script_sig = script::Builder::new()

src/descriptor/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ mod tests {
635635
DescriptorPublicKey, DescriptorSecretKey, DescriptorSinglePub, DescriptorXKey,
636636
};
637637
use hex_script;
638-
use miniscript::satisfy::BitcoinSig;
638+
use miniscript::satisfy::BitcoinECSig;
639639
use std::cmp;
640640
use std::collections::HashMap;
641641
use std::str::FromStr;
@@ -924,7 +924,7 @@ mod tests {
924924
}
925925

926926
impl Satisfier<bitcoin::PublicKey> for SimpleSat {
927-
fn lookup_sig(&self, pk: &bitcoin::PublicKey) -> Option<BitcoinSig> {
927+
fn lookup_ec_sig(&self, pk: &bitcoin::PublicKey) -> Option<BitcoinECSig> {
928928
if *pk == self.pk {
929929
Some((self.sig, bitcoin::SigHashType::All))
930930
} else {

src/descriptor/segwitv0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Wpkh<Pk> {
422422
Pk: ToPublicKey,
423423
S: Satisfier<Pk>,
424424
{
425-
if let Some(sig) = satisfier.lookup_sig(&self.pk) {
425+
if let Some(sig) = satisfier.lookup_ec_sig(&self.pk) {
426426
let mut sig_vec = sig.0.serialize_der().to_vec();
427427
sig_vec.push(sig.1.as_u32() as u8);
428428
let script_sig = Script::new();

src/interpreter/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use miniscript::context::NoChecks;
2626
use miniscript::ScriptContext;
2727
use Miniscript;
2828
use Terminal;
29-
use {BitcoinSig, Descriptor, ToPublicKey};
29+
use {BitcoinECSig, Descriptor, ToPublicKey};
3030

3131
mod error;
3232
mod inner;
@@ -81,7 +81,7 @@ impl<'txin> Interpreter<'txin> {
8181
///
8282
/// Running the iterator through will consume the internal stack of the
8383
/// `Iterpreter`, and it should not be used again after this.
84-
pub fn iter<'iter, F: FnMut(&bitcoin::PublicKey, BitcoinSig) -> bool>(
84+
pub fn iter<'iter, F: FnMut(&bitcoin::PublicKey, BitcoinECSig) -> bool>(
8585
&'iter mut self,
8686
verify_sig: F,
8787
) -> Iter<'txin, 'iter, F> {
@@ -189,7 +189,7 @@ impl<'txin> Interpreter<'txin> {
189189
unsigned_tx: &'a bitcoin::Transaction,
190190
input_idx: usize,
191191
amount: u64,
192-
) -> Result<impl Fn(&bitcoin::PublicKey, BitcoinSig) -> bool + 'a, Error> {
192+
) -> Result<impl Fn(&bitcoin::PublicKey, BitcoinECSig) -> bool + 'a, Error> {
193193
// Precompute all sighash types because the borrowck doesn't like us
194194
// pulling self into the closure
195195
let sighashes = [
@@ -311,7 +311,7 @@ struct NodeEvaluationState<'intp> {
311311
///
312312
/// In case the script is actually dissatisfied, this may return several values
313313
/// before ultimately returning an error.
314-
pub struct Iter<'intp, 'txin: 'intp, F: FnMut(&bitcoin::PublicKey, BitcoinSig) -> bool> {
314+
pub struct Iter<'intp, 'txin: 'intp, F: FnMut(&bitcoin::PublicKey, BitcoinECSig) -> bool> {
315315
verify_sig: F,
316316
public_key: Option<&'intp bitcoin::PublicKey>,
317317
state: Vec<NodeEvaluationState<'intp>>,
@@ -325,7 +325,7 @@ pub struct Iter<'intp, 'txin: 'intp, F: FnMut(&bitcoin::PublicKey, BitcoinSig) -
325325
impl<'intp, 'txin: 'intp, F> Iterator for Iter<'intp, 'txin, F>
326326
where
327327
NoChecks: ScriptContext,
328-
F: FnMut(&bitcoin::PublicKey, BitcoinSig) -> bool,
328+
F: FnMut(&bitcoin::PublicKey, BitcoinECSig) -> bool,
329329
{
330330
type Item = Result<SatisfiedConstraint<'intp, 'txin>, Error>;
331331

@@ -346,7 +346,7 @@ where
346346
impl<'intp, 'txin: 'intp, F> Iter<'intp, 'txin, F>
347347
where
348348
NoChecks: ScriptContext,
349-
F: FnMut(&bitcoin::PublicKey, BitcoinSig) -> bool,
349+
F: FnMut(&bitcoin::PublicKey, BitcoinECSig) -> bool,
350350
{
351351
/// Helper function to push a NodeEvaluationState on state stack
352352
fn push_evaluation_state(
@@ -754,7 +754,7 @@ fn verify_sersig<'txin, F>(
754754
sigser: &[u8],
755755
) -> Result<secp256k1::Signature, Error>
756756
where
757-
F: FnOnce(&bitcoin::PublicKey, BitcoinSig) -> bool,
757+
F: FnOnce(&bitcoin::PublicKey, BitcoinECSig) -> bool,
758758
{
759759
if let Some((sighash_byte, sig)) = sigser.split_last() {
760760
let sighashtype = bitcoin::SigHashType::from_u32_standard(*sighash_byte as u32)
@@ -778,7 +778,7 @@ mod tests {
778778
use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d, Hash};
779779
use bitcoin::secp256k1::{self, Secp256k1, VerifyOnly};
780780
use miniscript::context::NoChecks;
781-
use BitcoinSig;
781+
use BitcoinECSig;
782782
use Miniscript;
783783
use MiniscriptKey;
784784
use ToPublicKey;
@@ -832,7 +832,7 @@ mod tests {
832832
ms: &'elem Miniscript<bitcoin::PublicKey, NoChecks>,
833833
) -> Iter<'elem, 'txin, F>
834834
where
835-
F: FnMut(&bitcoin::PublicKey, BitcoinSig) -> bool,
835+
F: FnMut(&bitcoin::PublicKey, BitcoinECSig) -> bool,
836836
{
837837
Iter {
838838
verify_sig: verify_fn,

src/interpreter/stack.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use bitcoin;
1818
use bitcoin::blockdata::{opcodes, script};
1919
use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d, Hash};
2020

21-
use {BitcoinSig, ToPublicKey};
21+
use {BitcoinECSig, ToPublicKey};
2222

2323
use super::{verify_sersig, Error, HashLockType, SatisfiedConstraint};
2424

@@ -132,7 +132,7 @@ impl<'txin> Stack<'txin> {
132132
pk: &'intp bitcoin::PublicKey,
133133
) -> Option<Result<SatisfiedConstraint<'intp, 'txin>, Error>>
134134
where
135-
F: FnMut(&bitcoin::PublicKey, BitcoinSig) -> bool,
135+
F: FnMut(&bitcoin::PublicKey, BitcoinECSig) -> bool,
136136
{
137137
if let Some(sigser) = self.pop() {
138138
match sigser {
@@ -171,7 +171,7 @@ impl<'txin> Stack<'txin> {
171171
pkh: &'intp hash160::Hash,
172172
) -> Option<Result<SatisfiedConstraint<'intp, 'txin>, Error>>
173173
where
174-
F: FnOnce(&bitcoin::PublicKey, BitcoinSig) -> bool,
174+
F: FnOnce(&bitcoin::PublicKey, BitcoinECSig) -> bool,
175175
{
176176
if let Some(Element::Push(pk)) = self.pop() {
177177
let pk_hash = hash160::Hash::hash(pk);
@@ -367,7 +367,7 @@ impl<'txin> Stack<'txin> {
367367
pk: &'intp bitcoin::PublicKey,
368368
) -> Option<Result<SatisfiedConstraint<'intp, 'txin>, Error>>
369369
where
370-
F: FnOnce(&bitcoin::PublicKey, BitcoinSig) -> bool,
370+
F: FnOnce(&bitcoin::PublicKey, BitcoinECSig) -> bool,
371371
{
372372
if let Some(witness_sig) = self.pop() {
373373
if let Element::Push(sigser) = witness_sig {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub use descriptor::{Descriptor, DescriptorPublicKey, DescriptorTrait};
126126
pub use interpreter::Interpreter;
127127
pub use miniscript::context::{BareCtx, Legacy, ScriptContext, Segwitv0, Tap};
128128
pub use miniscript::decode::Terminal;
129-
pub use miniscript::satisfy::{BitcoinSig, Preimage32, Satisfier};
129+
pub use miniscript::satisfy::{BitcoinECSig, Preimage32, Satisfier};
130130
pub use miniscript::Miniscript;
131131

132132
///Public key trait which can be converted to Hash type

src/miniscript/satisfy.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ use ScriptContext;
3535
use Terminal;
3636

3737
/// Type alias for a signature/hashtype pair
38-
pub type BitcoinSig = (secp256k1::Signature, bitcoin::SigHashType);
38+
pub type BitcoinECSig = (secp256k1::Signature, bitcoin::SigHashType);
3939
/// Type alias for 32 byte Preimage.
4040
pub type Preimage32 = [u8; 32];
4141

42-
/// Helper function to create BitcoinSig from Rawsig
42+
/// Helper function to create BitcoinECSig from Rawsig
4343
/// Useful for downstream when implementing Satisfier.
4444
/// Returns underlying secp if the Signature is not of correct format
45-
pub fn bitcoinsig_from_rawsig(rawsig: &[u8]) -> Result<BitcoinSig, ::interpreter::Error> {
45+
pub fn bitcoin_ecsig_from_rawsig(rawsig: &[u8]) -> Result<BitcoinECSig, ::interpreter::Error> {
4646
let (flag, sig) = rawsig.split_last().unwrap();
4747
let flag = bitcoin::SigHashType::from_u32_standard(*flag as u32)
4848
.map_err(|_| ::interpreter::Error::NonStandardSigHash([sig, &[*flag]].concat().to_vec()))?;
@@ -54,8 +54,8 @@ pub fn bitcoinsig_from_rawsig(rawsig: &[u8]) -> Result<BitcoinSig, ::interpreter
5454
/// on every query. Users are expected to override the methods that they
5555
/// have data for.
5656
pub trait Satisfier<Pk: MiniscriptKey + ToPublicKey> {
57-
/// Given a public key, look up a signature with that key
58-
fn lookup_sig(&self, _: &Pk) -> Option<BitcoinSig> {
57+
/// Given a public key, look up an EC signature with that key
58+
fn lookup_ec_sig(&self, _: &Pk) -> Option<BitcoinECSig> {
5959
None
6060
}
6161

@@ -64,11 +64,11 @@ pub trait Satisfier<Pk: MiniscriptKey + ToPublicKey> {
6464
None
6565
}
6666

67-
/// Given a keyhash, look up the signature and the associated key
67+
/// Given a keyhash, look up the EC signature and the associated key
6868
/// Even if signatures for public key Hashes are not available, the users
6969
/// can use this map to provide pkh -> pk mapping which can be useful
7070
/// for dissatisfying pkh.
71-
fn lookup_pkh_sig(&self, _: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinSig)> {
71+
fn lookup_pkh_ec_sig(&self, _: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinECSig)> {
7272
None
7373
}
7474

@@ -146,41 +146,41 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for After {
146146
}
147147
}
148148

149-
impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for HashMap<Pk, BitcoinSig> {
150-
fn lookup_sig(&self, key: &Pk) -> Option<BitcoinSig> {
149+
impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for HashMap<Pk, BitcoinECSig> {
150+
fn lookup_ec_sig(&self, key: &Pk) -> Option<BitcoinECSig> {
151151
self.get(key).map(|x| *x)
152152
}
153153
}
154154

155-
impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for HashMap<Pk::Hash, (Pk, BitcoinSig)>
155+
impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for HashMap<Pk::Hash, (Pk, BitcoinECSig)>
156156
where
157157
Pk: MiniscriptKey + ToPublicKey,
158158
{
159-
fn lookup_sig(&self, key: &Pk) -> Option<BitcoinSig> {
159+
fn lookup_ec_sig(&self, key: &Pk) -> Option<BitcoinECSig> {
160160
self.get(&key.to_pubkeyhash()).map(|x| x.1)
161161
}
162162

163163
fn lookup_pkh_pk(&self, pk_hash: &Pk::Hash) -> Option<Pk> {
164164
self.get(pk_hash).map(|x| x.0.clone())
165165
}
166166

167-
fn lookup_pkh_sig(&self, pk_hash: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinSig)> {
167+
fn lookup_pkh_ec_sig(&self, pk_hash: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinECSig)> {
168168
self.get(pk_hash)
169169
.map(|&(ref pk, sig)| (pk.to_public_key(), sig))
170170
}
171171
}
172172

173173
impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'a S {
174-
fn lookup_sig(&self, p: &Pk) -> Option<BitcoinSig> {
175-
(**self).lookup_sig(p)
174+
fn lookup_ec_sig(&self, p: &Pk) -> Option<BitcoinECSig> {
175+
(**self).lookup_ec_sig(p)
176176
}
177177

178178
fn lookup_pkh_pk(&self, pkh: &Pk::Hash) -> Option<Pk> {
179179
(**self).lookup_pkh_pk(pkh)
180180
}
181181

182-
fn lookup_pkh_sig(&self, pkh: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinSig)> {
183-
(**self).lookup_pkh_sig(pkh)
182+
fn lookup_pkh_ec_sig(&self, pkh: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinECSig)> {
183+
(**self).lookup_pkh_ec_sig(pkh)
184184
}
185185

186186
fn lookup_sha256(&self, h: sha256::Hash) -> Option<Preimage32> {
@@ -209,16 +209,16 @@ impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'
209209
}
210210

211211
impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'a mut S {
212-
fn lookup_sig(&self, p: &Pk) -> Option<BitcoinSig> {
213-
(**self).lookup_sig(p)
212+
fn lookup_ec_sig(&self, p: &Pk) -> Option<BitcoinECSig> {
213+
(**self).lookup_ec_sig(p)
214214
}
215215

216216
fn lookup_pkh_pk(&self, pkh: &Pk::Hash) -> Option<Pk> {
217217
(**self).lookup_pkh_pk(pkh)
218218
}
219219

220-
fn lookup_pkh_sig(&self, pkh: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinSig)> {
221-
(**self).lookup_pkh_sig(pkh)
220+
fn lookup_pkh_ec_sig(&self, pkh: &Pk::Hash) -> Option<(bitcoin::PublicKey, BitcoinECSig)> {
221+
(**self).lookup_pkh_ec_sig(pkh)
222222
}
223223

224224
fn lookup_sha256(&self, h: sha256::Hash) -> Option<Preimage32> {
@@ -254,23 +254,23 @@ macro_rules! impl_tuple_satisfier {
254254
Pk: MiniscriptKey + ToPublicKey,
255255
$($ty: Satisfier< Pk>,)*
256256
{
257-
fn lookup_sig(&self, key: &Pk) -> Option<BitcoinSig> {
257+
fn lookup_ec_sig(&self, key: &Pk) -> Option<BitcoinECSig> {
258258
let &($(ref $ty,)*) = self;
259259
$(
260-
if let Some(result) = $ty.lookup_sig(key) {
260+
if let Some(result) = $ty.lookup_ec_sig(key) {
261261
return Some(result);
262262
}
263263
)*
264264
None
265265
}
266266

267-
fn lookup_pkh_sig(
267+
fn lookup_pkh_ec_sig(
268268
&self,
269269
key_hash: &Pk::Hash,
270-
) -> Option<(bitcoin::PublicKey, BitcoinSig)> {
270+
) -> Option<(bitcoin::PublicKey, BitcoinECSig)> {
271271
let &($(ref $ty,)*) = self;
272272
$(
273-
if let Some(result) = $ty.lookup_pkh_sig(key_hash) {
273+
if let Some(result) = $ty.lookup_pkh_ec_sig(key_hash) {
274274
return Some(result);
275275
}
276276
)*
@@ -402,7 +402,7 @@ impl Ord for Witness {
402402
impl Witness {
403403
/// Turn a signature into (part of) a satisfaction
404404
fn signature<Pk: ToPublicKey, S: Satisfier<Pk>>(sat: S, pk: &Pk) -> Self {
405-
match sat.lookup_sig(pk) {
405+
match sat.lookup_ec_sig(pk) {
406406
Some((sig, hashtype)) => {
407407
let mut ret = sig.serialize_der().to_vec();
408408
ret.push(hashtype.as_u32() as u8);
@@ -425,7 +425,7 @@ impl Witness {
425425

426426
/// Turn a key/signature pair related to a pkh into (part of) a satisfaction
427427
fn pkh_signature<Pk: ToPublicKey, S: Satisfier<Pk>>(sat: S, pkh: &Pk::Hash) -> Self {
428-
match sat.lookup_pkh_sig(pkh) {
428+
match sat.lookup_pkh_ec_sig(pkh) {
429429
Some((pk, (sig, hashtype))) => {
430430
let mut ret = sig.serialize_der().to_vec();
431431
ret.push(hashtype.as_u32() as u8);

src/policy/compiler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ mod tests {
11681168
use miniscript::{satisfy, Legacy, Segwitv0};
11691169
use policy::Liftable;
11701170
use script_num_size;
1171-
use BitcoinSig;
1171+
use BitcoinECSig;
11721172

11731173
type SPolicy = Concrete<String>;
11741174
type BPolicy = Concrete<bitcoin::PublicKey>;
@@ -1367,10 +1367,10 @@ mod tests {
13671367
let mut sigvec = sig.serialize_der().to_vec();
13681368
sigvec.push(1); // sighash all
13691369

1370-
let no_sat = HashMap::<bitcoin::PublicKey, BitcoinSig>::new();
1371-
let mut left_sat = HashMap::<bitcoin::PublicKey, BitcoinSig>::new();
1370+
let no_sat = HashMap::<bitcoin::PublicKey, BitcoinECSig>::new();
1371+
let mut left_sat = HashMap::<bitcoin::PublicKey, BitcoinECSig>::new();
13721372
let mut right_sat =
1373-
HashMap::<hashes::hash160::Hash, (bitcoin::PublicKey, BitcoinSig)>::new();
1373+
HashMap::<hashes::hash160::Hash, (bitcoin::PublicKey, BitcoinECSig)>::new();
13741374

13751375
for i in 0..5 {
13761376
left_sat.insert(keys[i], bitcoinsig);

0 commit comments

Comments
 (0)