projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1922 from wpaulino/avoid-remaining-redundant-commitment-broadcasts
[rust-lightning]
/
lightning
/
src
/
ln
/
chan_utils.rs
diff --git
a/lightning/src/ln/chan_utils.rs
b/lightning/src/ln/chan_utils.rs
index f02e995c0f662440cbcb51e03c32cc87a7878d23..408f1cd7e477ca3eb0e4acde601cde9eb0c908f1 100644
(file)
--- a/
lightning/src/ln/chan_utils.rs
+++ b/
lightning/src/ln/chan_utils.rs
@@
-462,7
+462,7
@@
impl_writeable_tlv_based!(TxCreationKeys, {
});
/// One counterparty's public keys which do not change over the life of a channel.
});
/// One counterparty's public keys which do not change over the life of a channel.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone,
Debug,
PartialEq, Eq)]
pub struct ChannelPublicKeys {
/// The public key which is used to sign all commitment transactions, as it appears in the
/// on-chain channel lock-in 2-of-2 multisig output.
pub struct ChannelPublicKeys {
/// The public key which is used to sign all commitment transactions, as it appears in the
/// on-chain channel lock-in 2-of-2 multisig output.
@@
-739,17
+739,12
@@
pub fn build_htlc_input_witness(
} else {
EcdsaSighashType::All
};
} else {
EcdsaSighashType::All
};
- let mut remote_sig = remote_sig.serialize_der().to_vec();
- remote_sig.push(remote_sighash_type as u8);
-
- let mut local_sig = local_sig.serialize_der().to_vec();
- local_sig.push(EcdsaSighashType::All as u8);
let mut witness = Witness::new();
// First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
witness.push(vec![]);
let mut witness = Witness::new();
// First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
witness.push(vec![]);
- witness.push
(remote_sig
);
- witness.push
(local_sig
);
+ witness.push
_bitcoin_signature(&remote_sig.serialize_der(), remote_sighash_type
);
+ witness.push
_bitcoin_signature(&local_sig.serialize_der(), EcdsaSighashType::All
);
if let Some(preimage) = preimage {
witness.push(preimage.0.to_vec());
} else {
if let Some(preimage) = preimage {
witness.push(preimage.0.to_vec());
} else {
@@
-801,9
+796,10
@@
pub(crate) fn get_anchor_output<'a>(commitment_tx: &'a Transaction, funding_pubk
/// Returns the witness required to satisfy and spend an anchor input.
pub fn build_anchor_input_witness(funding_key: &PublicKey, funding_sig: &Signature) -> Witness {
let anchor_redeem_script = chan_utils::get_anchor_redeemscript(funding_key);
/// Returns the witness required to satisfy and spend an anchor input.
pub fn build_anchor_input_witness(funding_key: &PublicKey, funding_sig: &Signature) -> Witness {
let anchor_redeem_script = chan_utils::get_anchor_redeemscript(funding_key);
- let mut funding_sig = funding_sig.serialize_der().to_vec();
- funding_sig.push(EcdsaSighashType::All as u8);
- Witness::from_vec(vec![funding_sig, anchor_redeem_script.to_bytes()])
+ let mut ret = Witness::new();
+ ret.push_bitcoin_signature(&funding_sig.serialize_der(), EcdsaSighashType::All);
+ ret.push(anchor_redeem_script.as_bytes());
+ ret
}
/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
}
/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
@@
-811,7
+807,7
@@
pub fn build_anchor_input_witness(funding_key: &PublicKey, funding_sig: &Signatu
///
/// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
/// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
///
/// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
/// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
-#[derive(Clone, PartialEq)]
+#[derive(Clone,
Debug,
PartialEq)]
pub struct ChannelTransactionParameters {
/// Holder public keys
pub holder_pubkeys: ChannelPublicKeys,
pub struct ChannelTransactionParameters {
/// Holder public keys
pub holder_pubkeys: ChannelPublicKeys,
@@
-835,7
+831,7
@@
pub struct ChannelTransactionParameters {
}
/// Late-bound per-channel counterparty data used to build transactions.
}
/// Late-bound per-channel counterparty data used to build transactions.
-#[derive(Clone, PartialEq)]
+#[derive(Clone,
Debug,
PartialEq)]
pub struct CounterpartyChannelTransactionParameters {
/// Counter-party public keys
pub pubkeys: ChannelPublicKeys,
pub struct CounterpartyChannelTransactionParameters {
/// Counter-party public keys
pub pubkeys: ChannelPublicKeys,
@@
-1037,17
+1033,13
@@
impl HolderCommitmentTransaction {
// First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
let mut tx = self.inner.built.transaction.clone();
tx.input[0].witness.push(Vec::new());
// First push the multisig dummy, note that due to BIP147 (NULLDUMMY) it must be a zero-length element.
let mut tx = self.inner.built.transaction.clone();
tx.input[0].witness.push(Vec::new());
- let mut ser_holder_sig = holder_sig.serialize_der().to_vec();
- ser_holder_sig.push(EcdsaSighashType::All as u8);
- let mut ser_cp_sig = self.counterparty_sig.serialize_der().to_vec();
- ser_cp_sig.push(EcdsaSighashType::All as u8);
if self.holder_sig_first {
if self.holder_sig_first {
- tx.input[0].witness.push
(ser_holder_sig
);
- tx.input[0].witness.push
(ser_cp_sig
);
+ tx.input[0].witness.push
_bitcoin_signature(&holder_sig.serialize_der(), EcdsaSighashType::All
);
+ tx.input[0].witness.push
_bitcoin_signature(&self.counterparty_sig.serialize_der(), EcdsaSighashType::All
);
} else {
} else {
- tx.input[0].witness.push
(ser_cp_sig
);
- tx.input[0].witness.push
(ser_holder_sig
);
+ tx.input[0].witness.push
_bitcoin_signature(&self.counterparty_sig.serialize_der(), EcdsaSighashType::All
);
+ tx.input[0].witness.push
_bitcoin_signature(&holder_sig.serialize_der(), EcdsaSighashType::All
);
}
tx.input[0].witness.push(funding_redeemscript.as_bytes().to_vec());
}
tx.input[0].witness.push(funding_redeemscript.as_bytes().to_vec());