Skip to content

Commit 6733344

Browse files
committed
f use existing secp context
1 parent 23cc06c commit 6733344

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7636,7 +7636,6 @@ where
76367636
let all_prevouts = sighash::Prevouts::All(&prev_outputs[..]);
76377637

76387638
let mut cache = SighashCache::new(&built_tx);
7639-
let secp = Secp256k1::verification_only();
76407639

76417640
let script_pubkeys = unsigned_tx
76427641
.inputs()
@@ -7677,10 +7676,12 @@ where
76777676
.expect("Sighash is a SHA256 which is 32 bytes long");
76787677
let pubkey = PublicKey::from_slice(&witness[1]).map_err(|_| APIError::APIMisuseError { err: format!("The witness for input at index {input_idx} contains an invalid ECDSA public key") })?;
76797678
let sig = bitcoin::ecdsa::Signature::from_slice(&witness[0]).map_err(|_| APIError::APIMisuseError { err: format!("The witness for input at index {input_idx} contains an invalid signature") })?;
7680-
secp.verify_ecdsa(&msg, &sig.signature, &pubkey).map_err(|_| {
7681-
APIError::APIMisuseError { err:
7679+
self.context.secp_ctx.verify_ecdsa(&msg, &sig.signature, &pubkey).map_err(
7680+
|_| {
7681+
APIError::APIMisuseError { err:
76827682
format!("Failed signature verification for input at index {input_idx} for P2WPKH spend.") }
7683-
})?;
7683+
},
7684+
)?;
76847685
continue 'inputs;
76857686
}
76867687

@@ -7717,7 +7718,7 @@ where
77177718
_ => return Err(APIError::APIMisuseError { err: format!("The scriptPubKey of the previous output for input at index {input_idx} for a P2TR key path spend is invalid") }),
77187719
}.map_err(|_| APIError::APIMisuseError { err: format!("The scriptPubKey of the previous output for input at index {input_idx} for a P2TR key path spend has an invalid public key") })?;
77197720
let sig = bitcoin::taproot::Signature::from_slice(&witness[0]).map_err(|_| APIError::APIMisuseError { err: format!("The witness for input at index {input_idx} for a P2TR key path spend has an invalid signature") })?;
7720-
secp.verify_schnorr(&sig.signature, &msg, &pubkey).map_err(|_| {
7721+
self.context.secp_ctx.verify_schnorr(&sig.signature, &msg, &pubkey).map_err(|_| {
77217722
APIError::APIMisuseError { err: format!("Failed signature verification for input at index {input_idx} for P2WPKH spend.") }
77227723
})?;
77237724
continue 'inputs;

0 commit comments

Comments
 (0)