-
Notifications
You must be signed in to change notification settings - Fork 412
Contribute funding inputs on accepting dual-funded channel #3735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dunxen
wants to merge
11
commits into
lightningdevkit:main
Choose a base branch
from
dunxen:2025-04-contributeinputs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7bede60
Refactor shared output support (interactivetxs)
optout21 e7336d8
Add Shared Input support
optout21 b2e0da8
Fix tx-add-input serialization
optout21 4227603
Check if a batch is expected for commitment_signed
jkczyz 1e0cfe9
Remove #[rustfmt::skip] from FundedChannel::commitment_signed
jkczyz 0918999
`rustfmt`: Prepare `lightning/src/ln/peer_handler.rs`
tnull a7fafca
`rustfmt`: Run on `lightning/src/ln/peer_handler.rs`
tnull 252b231
LSPS2: Make opening_fee_params_menu order compliant with spec
martinsaposnic 9ff296f
Introduce `FundingTransactionReadyForSignatures` event
dunxen 80f9944
Allow passing funding inputs when manually accepting a dual-funded ch…
dunxen 60f58b1
wip acceptor contributes in tests
dunxen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5863,6 +5863,76 @@ where | |
result | ||
} | ||
|
||
/// Handles a signed funding transaction generated by interactive transaction construction and | ||
/// provided by the client. | ||
/// | ||
/// Do NOT broadcast the funding transaction yourself. When we have safely received our | ||
/// counterparty's signature(s) the funding transaction will automatically be broadcast via the | ||
/// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. | ||
/// | ||
/// SIGHASH_ALL MUST be used for all signatures when providing signatures. | ||
/// | ||
/// <div class="warning"> | ||
/// WARNING: LDK makes no attempt to prevent the counterparty from using non-standard inputs which | ||
/// will prevent the funding transaction from being relayed on the bitcoin network and hence being | ||
/// confirmed. | ||
/// </div> | ||
pub fn funding_transaction_signed( | ||
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, transaction: Transaction, | ||
) -> Result<(), APIError> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to acquire the |
||
let witnesses: Vec<_> = transaction | ||
.input | ||
.into_iter() | ||
.filter_map(|input| if input.witness.is_empty() { None } else { Some(input.witness) }) | ||
.collect(); | ||
|
||
let per_peer_state = self.per_peer_state.read().unwrap(); | ||
let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| { | ||
APIError::ChannelUnavailable { | ||
err: format!( | ||
"Can't find a peer matching the passed counterparty node_id {}", | ||
counterparty_node_id | ||
), | ||
} | ||
})?; | ||
|
||
let mut peer_state_lock = peer_state_mutex.lock().unwrap(); | ||
let peer_state = &mut *peer_state_lock; | ||
|
||
match peer_state.channel_by_id.get_mut(channel_id) { | ||
Some(channel) => match channel.as_funded_mut() { | ||
Some(chan) => { | ||
if let Some(tx_signatures) = | ||
chan.funding_transaction_signed(witnesses, &self.logger)? | ||
{ | ||
peer_state.pending_msg_events.push(MessageSendEvent::SendTxSignatures { | ||
node_id: *counterparty_node_id, | ||
msg: tx_signatures, | ||
}); | ||
} | ||
}, | ||
None => { | ||
return Err(APIError::APIMisuseError { | ||
err: format!( | ||
"Channel with id {} not expecting funding signatures", | ||
channel_id | ||
), | ||
}) | ||
}, | ||
}, | ||
None => { | ||
return Err(APIError::ChannelUnavailable { | ||
err: format!( | ||
"Channel with id {} not found for the passed counterparty node_id {}", | ||
channel_id, counterparty_node_id | ||
), | ||
}) | ||
}, | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Atomically applies partial updates to the [`ChannelConfig`] of the given channels. | ||
/// | ||
/// Once the updates are applied, each eligible channel (advertised with a known short channel | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on just tracking this as an
Option<()>
and we get the message from the signing session instead?