Remove redundant fields from WantsInputs event#1106
Remove redundant fields from WantsInputs event#1106arminsabouri merged 1 commit intopayjoin:masterfrom
WantsInputs event#1106Conversation
| #[cfg(feature = "v2")] | ||
| pub(crate) fn payjoin_proposal(&self) -> Psbt { self.payjoin_psbt.clone() } |
There was a problem hiding this comment.
I see why you preferred the field to this in #1102 because the feature flag can be avoided. Though I'm not sure why you're using pub(crate) when pub(super) seems sufficient.
There was a problem hiding this comment.
Good point. Pub(super) would work fine here.
Last push removes the feature flagged getter infavor if a pub(super) field.
The primary information obtained from `WantsOutputs` is the outputs being commited. The session event should reflect new primary information only.
c54059c to
35ed7d7
Compare
Pull Request Test Coverage Report for Build 17981042076Details
💛 - Coveralls |
| let mut payjoin_proposal = self.inner.payjoin_psbt.clone(); | ||
| let outputs_len = outputs.len(); | ||
| // Add the outputs that may have been replaced | ||
| payjoin_proposal.unsigned_tx.output = outputs; | ||
| payjoin_proposal.outputs = vec![Default::default(); outputs_len]; | ||
|
|
||
| let mut inner = self.state.inner.commit_outputs(); | ||
| inner.payjoin_psbt = payjoin_proposal; |
There was a problem hiding this comment.
What happens with legacy pre-segwit outputs? I suppose there is never a case where you need bitcoin::psbt::Output because, well, they're outputs being spent to and all you need is the TxOut.script_pubkey to spend to them? perhaps a comment explaining why the Default payjoin_proposal.outputs are appropriate would clarify.
This is making me think the SessionEvent variants might need renames. This WantsInputs event does produce a WantsInputs type but it's really an event which does ~CommitOutputs, since it encapsulates those outputs. I think that tripped me up on first read.
There was a problem hiding this comment.
This is making me think the SessionEvent variants might need renames.
I agree, event variants should describe "what event happened" instead of "what this event produces". We already do this for the Created and Closed variants. Could be something like:
{
//...
IdentifiedReceiverOutputs(Vec<usize>),
CommittedOutputs(Vec<bitcoin::TxOut>),
CommittedInputs(Vec<InputPair>),
//...
}and so on for the other variants.
There was a problem hiding this comment.
I prefer these get named in imperative mood over past tense but otherwise agree
There was a problem hiding this comment.
I suppose there is never a case where you need bitcoin::psbt::Output because, well, they're outputs being spent to and all you need is the TxOut.script_pubkey to spend to them?
Correct. I actually copied this code from the common abstraction
// Update the payjoin PSBT outputs
payjoin_psbt.outputs = vec![Default::default(); outputs.len()];
payjoin_psbt.unsigned_tx.output = outputs;The PSBT outputs are being set to default regardless if the receiver replaces their outputs.
That may be an issue for some implementations that expect BIP32 paths to be present in order to validate change address. But in those cases the implementation could mutate the PSBT pre-signing.
The primary information obtained from
WantsOutputsis the outputs being commited. The session event should reflect new primary information only.Related ticket: #1103
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.