Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Sep 30, 2022
1 parent 5304cde commit a43e090
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/pset_blind_coinjoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {
bitcoin::Denomination::Bitcoin,
)
.unwrap()
.as_sat(),
.to_sat(),
asset: AssetId::from_hex(&v["asset"].as_str().unwrap()).unwrap(),
},
};
Expand Down
2 changes: 1 addition & 1 deletion examples/raw_blind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn parse_txout(txout_info: &str) -> (TxOut, Secrets, pset::Input) {
bitcoin::Denomination::Bitcoin,
)
.unwrap()
.as_sat(),
.to_sat(),
asset: AssetId::from_hex(&v["asset"].as_str().unwrap()).unwrap(),
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/blind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ mod tests {
let spent_utxo_secrets = TxOutSecrets {
asset: AssetId::from_hex("b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23").unwrap(),
asset_bf: AssetBlindingFactor::from_hex("a5b3d111cdaa5fc111e2723df4caf315864f25fb4610cc737f10d5a55cd4096f").unwrap(),
value: bitcoin::Amount::from_str_in("20999997.97999114", bitcoin::Denomination::Bitcoin).unwrap().as_sat(),
value: bitcoin::Amount::from_str_in("20999997.97999114", bitcoin::Denomination::Bitcoin).unwrap().to_sat(),
value_bf: ValueBlindingFactor::from_hex("e36a4de359469f547571d117bc5509fb74fba73c84b0cdd6f4edfa7ff7fa457d").unwrap(),
};

Expand Down
12 changes: 5 additions & 7 deletions src/confidential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,14 +957,13 @@ impl AddAssign for ValueBlindingFactor {
// for scalar arethematic, we need to abuse secret key
// operations for this
let sk2 = SecretKey::from_slice(self.into_inner().as_ref()).expect("Valid key");
let mut sk = SecretKey::from_slice(other.into_inner().as_ref()).expect("Valid key");
let sk = SecretKey::from_slice(other.into_inner().as_ref()).expect("Valid key");
// The only reason that secret key addition can fail
// is when the keys add up to zero since we have already checked
// keys are in valid secret keys
if sk.add_assign(&sk2.into()).is_err() {
*self = Self::zero();
} else {
*self = ValueBlindingFactor::from_slice(sk.as_ref()).expect("Valid Tweak")
match sk.add_tweak(&sk2.into()) {
Ok(sk_tweaked) => *self = ValueBlindingFactor::from_slice(sk_tweaked.as_ref()).expect("Valid Tweak"),
Err(_) => *self = Self::zero(),
}
}
}
Expand All @@ -977,8 +976,7 @@ impl Neg for ValueBlindingFactor {
if self.0.as_ref() == &[0u8; 32] {
self
} else {
let mut sk = SecretKey::from_slice(self.into_inner().as_ref()).expect("Valid key");
sk.negate_assign();
let sk = SecretKey::from_slice(self.into_inner().as_ref()).expect("Valid key").negate();
ValueBlindingFactor::from_slice(sk.as_ref()).expect("Valid Tweak")
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ mod tests {
bitcoin::Denomination::Bitcoin,
)
.unwrap()
.as_sat(),
.to_sat(),
asset: AssetId::from_hex(&v["asset"].as_str().unwrap()).unwrap(),
};

Expand Down
3 changes: 1 addition & 2 deletions src/schnorr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ impl TapTweak for UntweakedPublicKey {
let tweak_value = Scalar::from_be_bytes(tweak_value).expect("hash value greater than curve order");

//Tweak the internal key by the tweak value
let mut output_key = self.clone();
let parity = output_key.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
let (output_key, parity) = self.clone().add_tweak(secp, &tweak_value).expect("Tap tweak failed");
debug_assert!(self.tweak_add_check(&secp, &output_key, parity, tweak_value));

(TweakedPublicKey(output_key), parity)
Expand Down
7 changes: 3 additions & 4 deletions tests/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn funded_tap_txout(
&PARAMS,
);
let amt = Amount::from_sat(1_000_000);
let txid_hex = elementsd.send_to_address(&addr.to_string(), &amt.as_btc().to_string());
let txid_hex = elementsd.send_to_address(&addr.to_string(), &amt.to_btc().to_string());
elementsd.generate(1);
let tx_hex = elementsd.get_transaction(&txid_hex);

Expand Down Expand Up @@ -220,16 +220,15 @@ fn taproot_spend_test(
)
.unwrap();

let mut output_keypair = test_data.internal_keypair; // type is copy
let output_keypair = test_data.internal_keypair; // type is copy
let tweak = TapTweakHash::from_key_and_tweak(
test_data.internal_pk,
test_data.spend_info.merkle_root(),
);
let tweak = secp256k1_zkp::Scalar::from_be_bytes(tweak.into_inner()).expect("hash value greater than curve order");
output_keypair.tweak_add_assign(&secp, &tweak).unwrap();
let sig = secp.sign_schnorr(
&secp256k1_zkp::Message::from_slice(&sighash_msg[..]).unwrap(),
&output_keypair,
&output_keypair.add_xonly_tweak(&secp, &tweak).unwrap(),
);

let schnorr_sig = SchnorrSig {
Expand Down

0 comments on commit a43e090

Please sign in to comment.