});
/// 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.
} 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![]);
- 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 {
/// 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).
///
/// 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,
}
/// 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,
// 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 {
- 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 {
- 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());