diff --git a/Cargo.lock b/Cargo.lock index 3ab8c72..9c98128 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,6 +154,7 @@ dependencies = [ "anyhow", "bdk", "bitcoin", + "itertools", "rand 0.6.5", "rand_chacha 0.1.1", "secp256k1-zkp", @@ -206,6 +207,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + [[package]] name = "electrum-client" version = "0.8.0" @@ -269,6 +276,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" diff --git a/cfd_protocol/Cargo.toml b/cfd_protocol/Cargo.toml index b900225..f12bf9e 100644 --- a/cfd_protocol/Cargo.toml +++ b/cfd_protocol/Cargo.toml @@ -6,6 +6,7 @@ edition = "2018" [dependencies] anyhow = "1" bdk = { git = "https://github.com/bitcoindevkit/bdk/", rev = "acf157a99a305226203d2b55a567291a93c64720" } +itertools = "0.10" rand = "0.6" rand_chacha = "0.1" secp256k1-zkp = { version = "0.4", features = ["hashes", "global-context"] } diff --git a/cfd_protocol/src/lib.rs b/cfd_protocol/src/lib.rs index beb498c..884b914 100644 --- a/cfd_protocol/src/lib.rs +++ b/cfd_protocol/src/lib.rs @@ -13,6 +13,7 @@ use bdk::{ descriptor::Descriptor, miniscript::{descriptor::Wsh, DescriptorTrait}, }; +use itertools::Itertools; use secp256k1_zkp::EcdsaAdaptorSignature; use secp256k1_zkp::SecretKey; use secp256k1_zkp::SECP256K1; @@ -428,7 +429,7 @@ impl PunishTransaction { revoked_commit_tx: &Transaction, ) -> Result { // CommitTransaction has only one input - let input = revoked_commit_tx.input[0].clone(); + let input = revoked_commit_tx.input.clone().into_iter().exactly_one()?; // Extract all signatures from witness stack let mut sigs = Vec::new();