Skip to content

Commit

Permalink
rustfmt: change to new notation
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Aug 8, 2024
1 parent de4e2ec commit 4bab769
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/sign_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() {
}],
};

#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
#[rustfmt::skip]
let public_keys = vec![
bitcoin::PublicKey::from_slice(&[2; 33]).expect("key 1"),
bitcoin::PublicKey::from_slice(&[
Expand Down
38 changes: 19 additions & 19 deletions src/descriptor/csfs_cov/script_internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ impl CovOperations for script::Builder {
.push_opcode(all::OP_ENDIF)
}

#[rustfmt::skip]
fn verify_cov(self, key: &bitcoin::PublicKey) -> Self {
use elements::opcodes::all::{OP_CAT, OP_SWAP};

let mut builder = self;
// The miniscript is of type B, which should have pushed 1
// onto the stack if it satisfied correctly.(which it should)
Expand Down Expand Up @@ -100,25 +103,22 @@ impl CovOperations for script::Builder {
builder = builder.push_opcode(all::OP_TOALTSTACK);
// alt_stk = [bitcoinsig]
// stk = [ecsig i10 i9 i8 i7 i6 i5 i4 i3b i3 i2 i1]
// Ignore fmt skip because it butchers these lines
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
{
// Do the size checks on all respective items in sighash calculation
use elements::opcodes::all::{OP_CAT, OP_SWAP};
builder = builder.chk_size(4).push_opcode(OP_SWAP); // item 1: ver
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 2: hashprevouts
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3: hashsequence
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3b: hashissuances
builder = builder.chk_size(36).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 4: outpoint
// Item 5: Script code is of constant size because we only consider everything after
// codeseparator. This will be replaced with a push slice in a later commit
builder = builder.chk_size(3).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 5: script code
builder = builder.chk_amt().push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 6: check confAmt
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 7: sequence
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 8: hashoutputs
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 9: nlocktime
builder = builder.chk_size(4).push_opcode(OP_CAT); //item 10: sighash type
}

// Do the size checks on all respective items in sighash calculation
builder = builder.chk_size(4).push_opcode(OP_SWAP); // item 1: ver
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 2: hashprevouts
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3: hashsequence
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 3b: hashissuances
builder = builder.chk_size(36).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 4: outpoint
// Item 5: Script code is of constant size because we only consider everything after
// codeseparator. This will be replaced with a push slice in a later commit
builder = builder.chk_size(3).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 5: script code
builder = builder.chk_amt().push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 6: check confAmt
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 7: sequence
builder = builder.chk_size(32).push_opcode(OP_CAT).push_opcode(OP_SWAP);//item 8: hashoutputs
builder = builder.chk_size(4).push_opcode(OP_CAT).push_opcode(OP_SWAP); //item 9: nlocktime
builder = builder.chk_size(4).push_opcode(OP_CAT); //item 10: sighash type

// Now sighash is on the top of the stack
// alt_stk = [bitcoinsig]
// stk = [ecsig (i1||i2||i3||i3b||i4||i5||i6||i7||i8||i9||i10)]
Expand Down
10 changes: 5 additions & 5 deletions src/miniscript/ms_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod tests {
}

#[test]
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
#[rustfmt::skip]
fn invalid_tests_from_alloy() {
invalid_ms("or_b(or_i(0,sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))");
invalid_ms("or_b(s:pk_h(A),after(500000001))");
Expand Down Expand Up @@ -5646,7 +5646,7 @@ mod tests {
invalid_ms("c:or_b(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),pk_k(A))");
}
#[test]
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
#[rustfmt::skip]
fn mall_8f1e8_tests_from_alloy() {
ms_test("or_d(or_d(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(500000001))", "Bf");
ms_test("andor(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),or_d(multi(2,A,B,C),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))", "B");
Expand Down Expand Up @@ -9143,7 +9143,7 @@ mod tests {

}
#[test]
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
#[rustfmt::skip]
fn main_tests_from_alloy() {
ms_test("or_d(or_d(multi(2,A,B,C),or_d(multi(2,D,E,F),multi(2,G,I,J))),multi(2,K,L,M))", "Bdusem");
ms_test("andor(multi(2,A,B,C),or_d(multi(2,D,E,F),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),c:pk_h(G))", "Bdusem");
Expand Down Expand Up @@ -15044,7 +15044,7 @@ mod tests {
}

#[test]
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
#[rustfmt::skip]
fn malleable_tests_from_alloy() {
ms_test("and_v(v:after(500000001),or_d(j:multi(2,A,B,C),multi(2,D,E,F)))", "usB");
ms_test("or_b(j:multi(2,A,B,C),a:andor(multi(2,D,E,F),multi(2,G,I,J),multi(2,K,L,M)))", "dBesu");
Expand Down Expand Up @@ -22076,8 +22076,8 @@ mod tests {
// This does not actually test timelock mixing. See: https://github.com/rust-bitcoin/rust-miniscript/issues/514
// for details
#[test]
#[rustfmt::skip]
fn conflict_tests_from_alloy() {
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
{
ms_test("andor(multi(2,A,B,C),andor(multi(2,D,E,F),after(500000001),n:after(1)),0)","Bedsm");
ms_test("and_v(v:after(500000001),or_d(multi(2,A,B,C),and_b(multi(2,D,E,F),a:after(1))))","Busm");
Expand Down

0 comments on commit 4bab769

Please sign in to comment.