Skip to content
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

Validate sender input to complete e2e payjoin test with receiver contribution #22

Merged
merged 2 commits into from
Feb 5, 2023

Conversation

DanGould
Copy link
Contributor

@DanGould DanGould commented Jan 23, 2023

Finally! Not just input substitution! Full on payjoin!

The sender change includes Sender input verification

  • For each inputs in the proposal:
    • If it is one of the receiver's input
      • Verify the PSBT input is finalized
      • Verify that non_witness_utxo or witness_utxo are filled in.

AND weight calculation for the amount of weight those inputs add. Please review for both design and correctness.

payjoin/src/sender/mod.rs Outdated Show resolved Hide resolved
payjoin/src/sender/mod.rs Outdated Show resolved Hide resolved
@DanGould DanGould changed the title E2e test receiver that adds input Validate sender input to complete e2e payjoin test with receiver contribution Feb 3, 2023
);
if let Some(script_sig) = &proposed.psbtin.final_script_sig {
total_weight += Weight::from_non_witness_data_size(
32 + 4 + 4 + script_sig.encoded_size(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's no script_sig you don't add the 32 + 4 + 4 to the total weight, I assume that is the outpoint and sequence values

Copy link
Contributor Author

@DanGould DanGould Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review Ben 🎈

Your assumption is correct, and is now documented.

Isn't this the branch where there is indeed a script_sig? The no script_sig should be handled by if let Some(script_witness) below. Do you mean if the transaction has no segwit inputs?

Do you have a clue what unit tests for this code might be useful? I guess I should find some transactions with known weights and check this code against them. There are some examples in that referenced issue but I don't know where they came from.

payjoin/tests/integration.rs Outdated Show resolved Hide resolved
@DanGould DanGould force-pushed the e2e-receiver-adds-input branch 2 times, most recently from 39df3b6 to 5911ef1 Compare February 4, 2023 14:53
Verify receiver PSBT inputs are finalized and contribute weight.

final_script_sig, final_script_witness may be independent or present
together as in the case of a P2WSH spend. This only adds input-specific
weight. The check_fees method calculates cumulative weight changes.
@DanGould DanGould merged commit 24d83f3 into payjoin:master Feb 5, 2023
@DanGould DanGould deleted the e2e-receiver-adds-input branch February 5, 2023 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants