You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let secret = self.get_secret(commitment_number).unwrap();
2444
2444
let per_commitment_key = ignore_error!(SecretKey::from_slice(&secret));
2445
2445
let per_commitment_point = PublicKey::from_secret_key(&self.secp_ctx,&per_commitment_key);
2446
-
let revocation_pubkey = ignore_error!(chan_utils::derive_public_revocation_key(&self.secp_ctx,&per_commitment_point,&self.holder_revocation_basepoint));
2447
-
let delayed_key = ignore_error!(chan_utils::derive_public_key(&self.secp_ctx,&PublicKey::from_secret_key(&self.secp_ctx,&per_commitment_key),&self.counterparty_commitment_params.counterparty_delayed_payment_base_key));
2446
+
let revocation_pubkey = chan_utils::derive_public_revocation_key(&self.secp_ctx,&per_commitment_point,&self.holder_revocation_basepoint);
2447
+
let delayed_key = chan_utils::derive_public_key(&self.secp_ctx,&PublicKey::from_secret_key(&self.secp_ctx,&per_commitment_key),&self.counterparty_commitment_params.counterparty_delayed_payment_base_key);
2448
2448
2449
2449
let revokeable_redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey,self.counterparty_commitment_params.on_counterparty_tx_csv,&delayed_key);
2450
2450
let revokeable_p2wsh = revokeable_redeemscript.to_v0_p2wsh();
Copy file name to clipboardExpand all lines: lightning/src/chain/keysinterface.rs
+17-23Lines changed: 17 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -655,8 +655,7 @@ impl InMemorySigner {
655
655
if spend_tx.input[input_idx].previous_output != descriptor.outpoint.into_bitcoin_outpoint(){returnErr(());}
656
656
if spend_tx.input[input_idx].sequence.0 != descriptor.to_self_delayasu32{returnErr(());}
657
657
658
-
let delayed_payment_key = chan_utils::derive_private_key(&secp_ctx,&descriptor.per_commitment_point,&self.delayed_payment_base_key)
659
-
.expect("We constructed the payment_base_key, so we can only fail here if the RNG is busted.");
658
+
let delayed_payment_key = chan_utils::derive_private_key(&secp_ctx,&descriptor.per_commitment_point,&self.delayed_payment_base_key);
660
659
let delayed_payment_pubkey = PublicKey::from_secret_key(&secp_ctx,&delayed_payment_key);
661
660
let witness_script = chan_utils::get_revokeable_redeemscript(&descriptor.revocation_pubkey, descriptor.to_self_delay,&delayed_payment_pubkey);
662
661
let sighash = hash_to_message!(&sighash::SighashCache::new(spend_tx).segwit_signature_hash(input_idx,&witness_script, descriptor.output.value,EcdsaSighashType::All).unwrap()[..]);
@@ -710,7 +709,7 @@ impl BaseSign for InMemorySigner {
710
709
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc,self.opt_anchors(),&keys);
711
710
let htlc_sighashtype = ifself.opt_anchors(){EcdsaSighashType::SinglePlusAnyoneCanPay}else{EcdsaSighashType::All};
712
711
let htlc_sighash = hash_to_message!(&sighash::SighashCache::new(&htlc_tx).segwit_signature_hash(0,&htlc_redeemscript, htlc.amount_msat / 1000, htlc_sighashtype).unwrap()[..]);
713
-
let holder_htlc_key = chan_utils::derive_private_key(&secp_ctx,&keys.per_commitment_point,&self.htlc_base_key).map_err(|_| ())?;
712
+
let holder_htlc_key = chan_utils::derive_private_key(&secp_ctx,&keys.per_commitment_point,&self.htlc_base_key);
let revocation_key = chan_utils::derive_private_revocation_key(&secp_ctx,&per_commitment_key,&self.revocation_base_key).map_err(|_| ())?;
745
+
let revocation_key = chan_utils::derive_private_revocation_key(&secp_ctx,&per_commitment_key,&self.revocation_base_key);
747
746
let per_commitment_point = PublicKey::from_secret_key(secp_ctx,&per_commitment_key);
748
-
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx,&per_commitment_point,&self.pubkeys().revocation_basepoint).map_err(|_| ())?;
747
+
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx,&per_commitment_point,&self.pubkeys().revocation_basepoint);
749
748
let witness_script = {
750
-
let counterparty_delayedpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.counterparty_pubkeys().delayed_payment_basepoint).map_err(|_| ())?;
749
+
let counterparty_delayedpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.counterparty_pubkeys().delayed_payment_basepoint);
let revocation_key = chan_utils::derive_private_revocation_key(&secp_ctx,&per_commitment_key,&self.revocation_base_key).map_err(|_| ())?;
758
+
let revocation_key = chan_utils::derive_private_revocation_key(&secp_ctx,&per_commitment_key,&self.revocation_base_key);
760
759
let per_commitment_point = PublicKey::from_secret_key(secp_ctx,&per_commitment_key);
761
-
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx,&per_commitment_point,&self.pubkeys().revocation_basepoint).map_err(|_| ())?;
760
+
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx,&per_commitment_point,&self.pubkeys().revocation_basepoint);
762
761
let witness_script = {
763
-
let counterparty_htlcpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.counterparty_pubkeys().htlc_basepoint).map_err(|_| ())?;
764
-
let holder_htlcpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.pubkeys().htlc_basepoint).map_err(|_| ())?;
762
+
let counterparty_htlcpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.counterparty_pubkeys().htlc_basepoint);
763
+
let holder_htlcpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.pubkeys().htlc_basepoint);
let sighash = hash_to_message!(&sighash_parts.segwit_signature_hash(input,&witness_script, amount,EcdsaSighashType::All).unwrap()[..]);
783
-
returnOk(sign(secp_ctx,&sighash,&htlc_key))
784
-
}
785
-
Err(())
772
+
let htlc_key = chan_utils::derive_private_key(&secp_ctx,&per_commitment_point,&self.htlc_base_key);
773
+
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx,&per_commitment_point,&self.pubkeys().revocation_basepoint);
774
+
let counterparty_htlcpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.counterparty_pubkeys().htlc_basepoint);
775
+
let htlcpubkey = chan_utils::derive_public_key(&secp_ctx,&per_commitment_point,&self.pubkeys().htlc_basepoint);
776
+
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc,self.opt_anchors(),&counterparty_htlcpubkey,&htlcpubkey,&revocation_pubkey);
let witness_script = chan_utils::get_revokeable_redeemscript(&chan_keys.revocation_key, outp.on_counterparty_tx_csv,&chan_keys.broadcaster_delayed_payment_key);
386
-
//TODO: should we panic on signer failure ?
387
-
ifletOk(sig) = onchain_handler.signer.sign_justice_revoked_output(&bumped_tx, i, outp.amount,&outp.per_commitment_key,&onchain_handler.secp_ctx){
let chan_keys = TxCreationKeys::derive_new(&onchain_handler.secp_ctx,&outp.per_commitment_point,&outp.counterparty_delayed_payment_base_key,&outp.counterparty_htlc_base_key,&onchain_handler.signer.pubkeys().revocation_basepoint,&onchain_handler.signer.pubkeys().htlc_basepoint);
385
+
let witness_script = chan_utils::get_revokeable_redeemscript(&chan_keys.revocation_key, outp.on_counterparty_tx_csv,&chan_keys.broadcaster_delayed_payment_key);
386
+
//TODO: should we panic on signer failure ?
387
+
ifletOk(sig) = onchain_handler.signer.sign_justice_revoked_output(&bumped_tx, i, outp.amount,&outp.per_commitment_key,&onchain_handler.secp_ctx){
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, onchain_handler.opt_anchors(),&chan_keys.broadcaster_htlc_key,&chan_keys.countersignatory_htlc_key,&chan_keys.revocation_key);
399
-
//TODO: should we panic on signer failure ?
400
-
ifletOk(sig) = onchain_handler.signer.sign_justice_revoked_htlc(&bumped_tx, i, outp.amount,&outp.per_commitment_key,&outp.htlc,&onchain_handler.secp_ctx){
let chan_keys = TxCreationKeys::derive_new(&onchain_handler.secp_ctx,&outp.per_commitment_point,&outp.counterparty_delayed_payment_base_key,&outp.counterparty_htlc_base_key,&onchain_handler.signer.pubkeys().revocation_basepoint,&onchain_handler.signer.pubkeys().htlc_basepoint);
397
+
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, onchain_handler.opt_anchors(),&chan_keys.broadcaster_htlc_key,&chan_keys.countersignatory_htlc_key,&chan_keys.revocation_key);
398
+
//TODO: should we panic on signer failure ?
399
+
ifletOk(sig) = onchain_handler.signer.sign_justice_revoked_htlc(&bumped_tx, i, outp.amount,&outp.per_commitment_key,&outp.htlc,&onchain_handler.secp_ctx){
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, onchain_handler.opt_anchors(),&chan_keys.broadcaster_htlc_key,&chan_keys.countersignatory_htlc_key,&chan_keys.revocation_key);
let chan_keys = TxCreationKeys::derive_new(&onchain_handler.secp_ctx,&outp.per_commitment_point,&outp.counterparty_delayed_payment_base_key,&outp.counterparty_htlc_base_key,&onchain_handler.signer.pubkeys().revocation_basepoint,&onchain_handler.signer.pubkeys().htlc_basepoint);
409
+
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, onchain_handler.opt_anchors(),&chan_keys.broadcaster_htlc_key,&chan_keys.countersignatory_htlc_key,&chan_keys.revocation_key);
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, onchain_handler.opt_anchors(),&chan_keys.broadcaster_htlc_key,&chan_keys.countersignatory_htlc_key,&chan_keys.revocation_key);
425
-
426
-
bumped_tx.lock_time = PackedLockTime(outp.htlc.cltv_expiry);// Right now we don't aggregate time-locked transaction, if we do we should set lock_time before to avoid breaking hash computation
let chan_keys = TxCreationKeys::derive_new(&onchain_handler.secp_ctx,&outp.per_commitment_point,&outp.counterparty_delayed_payment_base_key,&outp.counterparty_htlc_base_key,&onchain_handler.signer.pubkeys().revocation_basepoint,&onchain_handler.signer.pubkeys().htlc_basepoint);
421
+
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, onchain_handler.opt_anchors(),&chan_keys.broadcaster_htlc_key,&chan_keys.countersignatory_htlc_key,&chan_keys.revocation_key);
422
+
423
+
bumped_tx.lock_time = PackedLockTime(outp.htlc.cltv_expiry);// Right now we don't aggregate time-locked transaction, if we do we should set lock_time before to avoid breaking hash computation
0 commit comments