Skip to content

Commit

Permalink
Support shared signature in InteractiveTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Sep 9, 2024
1 parent 9b46d1f commit 9963c63
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider

let funding_ready_for_sig_event = None;
if our_funding_satoshis == 0 {
signing_session.provide_holder_witnesses(self.context().channel_id, Vec::new());
signing_session.provide_holder_witnesses(self.context().channel_id, Vec::new(), signing_session.shared_signature);
} else {
// TODO(dual_funding): Send event for signing if we've contributed funds.
}
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4830,7 +4830,7 @@ where
Some(ChannelPhase::Funded(chan)) => {
chan.verify_interactive_tx_signatures(&witnesses);
if let Some(ref mut signing_session) = chan.interactive_tx_signing_session {
if let Some(tx_signatures) = signing_session.provide_holder_witnesses(*channel_id, witnesses) {
if let Some(tx_signatures) = signing_session.provide_holder_witnesses(*channel_id, witnesses, signing_session.shared_signature) {
peer_state.pending_msg_events.push(events::MessageSendEvent::SendTxSignatures {
node_id: *counterparty_node_id,
msg: tx_signatures,
Expand Down
8 changes: 6 additions & 2 deletions lightning/src/ln/interactivetxs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use bitcoin::consensus::Encodable;
use bitcoin::constants::WITNESS_SCALE_FACTOR;
use bitcoin::policy::MAX_STANDARD_TX_WEIGHT;
use bitcoin::secp256k1::PublicKey;
use bitcoin::secp256k1::ecdsa::Signature;
use bitcoin::transaction::Version;
use bitcoin::{OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, Weight, Witness};

Expand Down Expand Up @@ -283,6 +284,8 @@ pub(crate) struct InteractiveTxSigningSession {
received_commitment_signed: Option<CommitmentSigned>,
holder_tx_signatures: Option<TxSignatures>,
counterparty_tx_signatures: Option<TxSignatures>,
/// Used in case of splicing, signature shared by both peers
pub(crate) shared_signature: Option<Signature>,
}

impl InteractiveTxSigningSession {
Expand Down Expand Up @@ -326,14 +329,14 @@ impl InteractiveTxSigningSession {
}

pub fn provide_holder_witnesses(
&mut self, channel_id: ChannelId, witnesses: Vec<Witness>,
&mut self, channel_id: ChannelId, witnesses: Vec<Witness>, shared_signature: Option<Signature>,
) -> Option<TxSignatures> {
self.unsigned_tx.add_local_witnesses(witnesses.clone());
self.holder_tx_signatures = Some(TxSignatures {
channel_id,
tx_hash: self.unsigned_tx.txid(),
witnesses: witnesses.into_iter().collect(),
shared_input_signature: None,
shared_input_signature: shared_signature,
});
if self.received_commitment_signed.is_some()
&& (self.holder_sends_tx_signatures_first || self.counterparty_tx_signatures.is_some())
Expand Down Expand Up @@ -962,6 +965,7 @@ macro_rules! define_state_transitions {
received_commitment_signed: None,
holder_tx_signatures: None,
counterparty_tx_signatures: None,
shared_signature: None,
};
Ok(NegotiationComplete(signing_session))
}
Expand Down

0 comments on commit 9963c63

Please sign in to comment.