-
Notifications
You must be signed in to change notification settings - Fork 419
Refactor ConstructedTransaction
to contain Transaction
#4097
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
base: main
Are you sure you want to change the base?
Refactor ConstructedTransaction
to contain Transaction
#4097
Conversation
👋 Thanks for assigning @wpaulino as a reviewer! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4097 +/- ##
==========================================
+ Coverage 87.81% 88.61% +0.79%
==========================================
Files 176 176
Lines 131770 132071 +301
Branches 131770 132071 +301
==========================================
+ Hits 115719 117037 +1318
+ Misses 13416 12356 -1060
- Partials 2635 2678 +43
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fn add_local_witnesses(&mut self, witnesses: Vec<Witness>) { | ||
self.inputs | ||
self.tx | ||
.input | ||
.iter_mut() | ||
.zip(self.inputs.iter()) | ||
.enumerate() | ||
.filter(|(_, input)| input.is_local(self.holder_is_initiator)) | ||
.filter(|(_, (_, input))| input.is_local(self.holder_is_initiator)) | ||
.filter(|(index, _)| { | ||
self.shared_input_index | ||
.map(|shared_index| *index != shared_index as usize) | ||
.unwrap_or(true) | ||
}) | ||
.map(|(_, input)| &mut input.txin) | ||
.map(|(_, (txin, _))| txin) | ||
.zip(witnesses) | ||
.for_each(|(input, witness)| input.witness = witness); | ||
} |
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.
Wondering if we should have InteractiveTxSigningSession
store both local and remote signatures until finalize_funding_tx
is called. That way, ConstructedTransaction
would always contain an unsigned transaction instead of one that may be partially signed.
InteractiveTxConstructor::new converts inputs given in channel.rs to InputOwned. Instead of converting FundingTxInput in channel.rs to the type needed by that constructor, pass in FundingTxInput and have it converted directly to InputOwned there. This saves one conversion and Vec allocation. It also lets us use the satisfaction_weight in an upcoming refactor.
Instead of estimating the input weight, track the satisfaction_weight in InteractiveTxInput. This then can be used compute the transaction weight without storing individual weights in NegotiatedTxInput in an upcoming commit.
The weight is no longer needed once a ConstructedTransaction is created, so it doesn't need to be persisted.
Instead of defining a custom function for calculating a transaction's weight, have ConstructedTransaction hold a Transaction so that its weight method can be re-used. As a result NegotiatedTxInput no longer needs to store the transaction inputs.
Now that ConstructedTransaction holds the actual Transaction, there's no need to keep track of and persist the outputs separately. However, the serial IDs are still needed to later reconstruct which outputs were contributed.
f96f304
to
9eeaf52
Compare
Pushed |
ConstructedTransaction
tracks the result of theInteractiveTxConstruction
and is used during anInteractiveTxSigningSession
. This PR refactors it such that it holds an actualTransaction
rather than the contributed parts, though some metadata in the form ofNegotiatedTxInput
andNegotiatedTxOutput
need to be maintained.This allows us to re-use the weight calculation provided by
Transaction
. It also facilitates reconstructing contributed inputs and outputs to produce aSpliceFailed
event in #4077.