-
Notifications
You must be signed in to change notification settings - Fork 410
Anchor-outputs (2/3): Add anchors and support Commitment CPFP bumping #725
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
Closed
ariard
wants to merge
12
commits into
lightningdevkit:main
from
ariard:2020-09-anchor-cpfp-commitment
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
66d4199
Introduce UtxoPool
ariard 9bef93b
Integrate UtxoPool
ariard 2c112a6
Add get_anchor_script
ariard dee7aaf
Rename build_commitment_tx local/remote balances to new holder/counte…
ariard 1c91b14
Merge build_commitment_transaction `local`/`generated_by_local`
ariard 1528f32
Add funder anchor affordance checks
ariard 6e0ee88
Account for the size increase of commitment `count_tx_out`
ariard 4377b5c
Add anchor outputs pair in commitment tx
ariard 1e68aa3
Allocate UTXO for CPFP-strategy transactions
ariard 0769f7e
Modify HoldersCommitment's package_weight/amount to account for CPFP
ariard 021717e
Extend ChannelKeys API with sign_cpfp
ariard 3b4a7da
Build and broadcast CPFP for HolderCommitmentTx
ariard 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ use ln::chan_utils; | |
use ln::msgs::DecodeError; | ||
use chain::chaininterface::{FeeEstimator, ConfirmationTarget, MIN_RELAY_FEE_SAT_PER_1000_WEIGHT}; | ||
use chain::keysinterface::Sign; | ||
use chain::utxointerface::UtxoPool; | ||
use chain::onchaintx::OnchainTxHandler; | ||
use util::byte_utils; | ||
use util::logger::Logger; | ||
|
@@ -248,19 +249,23 @@ impl_writeable_tlv_based!(HolderHTLCOutput, { | |
#[derive(Clone, PartialEq)] | ||
pub(crate) struct HolderFundingOutput { | ||
funding_redeemscript: Script, | ||
utxo_input: Option<(BitcoinOutPoint, BumpingOutput)> | ||
} | ||
|
||
impl HolderFundingOutput { | ||
pub(crate) fn build(funding_redeemscript: Script) -> Self { | ||
HolderFundingOutput { | ||
funding_redeemscript, | ||
utxo_input: None | ||
} | ||
} | ||
} | ||
|
||
impl_writeable_tlv_based!(HolderFundingOutput, { | ||
(0, funding_redeemscript), | ||
}, {}, {}); | ||
}, { | ||
(2, utxo_input), | ||
}, {}); | ||
|
||
/// A wrapper encapsulating all in-protocol differing outputs types. | ||
/// | ||
|
@@ -492,6 +497,24 @@ impl PackageTemplate { | |
pub(crate) fn outpoints(&self) -> Vec<&BitcoinOutPoint> { | ||
self.inputs.iter().map(|(o, _)| o).collect() | ||
} | ||
pub(crate) fn set_bumping_utxo<U: Deref>(&mut self, utxo_pool: &U) | ||
where U::Target: UtxoPool, | ||
{ | ||
// CPFP'ed package can't spent more than one input (for now). | ||
assert_eq!(self.inputs.len(), 1); | ||
for (_, input_solving_data) in self.inputs.iter_mut() { | ||
match input_solving_data { | ||
PackageSolvingData::HolderFundingOutput(data) => { | ||
if data.utxo_input.is_some() { return; } | ||
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. What if the previously set UTXO is no longer sufficient to cover the necessary fees? |
||
data.utxo_input = utxo_pool.allocate_utxo(0); | ||
}, | ||
PackageSolvingData::HolderHTLCOutput(..) => { | ||
return; //TODO: Should we anchor output HTLC-txn? | ||
}, | ||
_ => panic!("Malleable package should be bumped through RBF") | ||
} | ||
} | ||
} | ||
pub(crate) fn split_package(&mut self, split_outp: &BitcoinOutPoint) -> Option<PackageTemplate> { | ||
match self.malleability { | ||
PackageMalleability::Malleable => { | ||
|
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.
Should this take the required fee to pass to
allocate_utxo
?