Skip to content

Derive weight from witness for p2wsh inputs - #862

Merged
arminsabouri merged 1 commit into
payjoin:masterfrom
arminsabouri:use-witness-for-expected-weight
Jul 14, 2025
Merged

arminsabouri merged 1 commit into
payjoin:masterfrom
arminsabouri:use-witness-for-expected-weight

Conversation

@arminsabouri

Copy link
Copy Markdown
Contributor

If witness is available for p2wsh inputs we should be using the size of the witness to get expected input weight. Doing this incidentally enables p2wsh inputs for the payjoin sender.

Related issue: #659

@coveralls

coveralls commented Jul 8, 2025 •

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 16268541609

Details

  • 45 of 47 (95.74%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 85.786%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/psbt/mod.rs 13 15 86.67%
Totals Coverage Status
Change from base Build 16252909037: 0.05%
Covered Lines: 7659
Relevant Lines: 8928

💛 - Coveralls

Comment thread payjoin/src/core/psbt/mod.rs Resolved
Comment thread payjoin/src/core/receive/mod.rs Resolved
@arminsabouri
arminsabouri force-pushed the use-witness-for-expected-weight branch 2 times, most recently from 1a369a9 to aecba17 Compare July 8, 2025 20:13
Comment thread payjoin/src/core/psbt/mod.rs Resolved
@arminsabouri
arminsabouri force-pushed the use-witness-for-expected-weight branch from aecba17 to 2901576 Compare July 9, 2025 13:21
@arminsabouri
arminsabouri requested a review from spacebear21 July 9, 2025 13:21
@arminsabouri

arminsabouri commented Jul 11, 2025 •

Copy link
Copy Markdown
Contributor Author

@spacebear21 when ever you get a chance. Do you mind taking another look at this one?

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

concept ACK with code comments

Comment thread payjoin/src/core/receive/mod.rs Outdated
}
(Ok(weight), None) => weight,
(Err(InputWeightError::NotSupported), Some(expected_weight)) => expected_weight,
(Err(InputWeightError::NotSupported), None) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this match arm is unnecessary because the catch-all arm would have the same effect.

Comment thread payjoin/src/core/receive/mod.rs Outdated
)
);

// p2wsh input with witness data should be supported and should **not** use the provided expected weight

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This comment looks obsolete.

Comment thread payjoin/src/core/psbt/mod.rs Resolved
@arminsabouri
arminsabouri force-pushed the use-witness-for-expected-weight branch from 2901576 to 2a9ed21 Compare July 13, 2025 21:16
@arminsabouri

Copy link
Copy Markdown
Contributor Author

Broke my own p2wsh tests with the last push. Will have to take a look at this tomorrow.

@arminsabouri
arminsabouri marked this pull request as draft July 13, 2025 21:38
If witness is available for p2wsh inputs we should be using the size of
the witness to get expected input weight. Doing this incidentally
enables p2wsh inputs for the payjoin sender.

Related issue: payjoin#659
@arminsabouri
arminsabouri force-pushed the use-witness-for-expected-weight branch from 2a9ed21 to 343e65f Compare July 14, 2025 13:43
@arminsabouri
arminsabouri requested a review from spacebear21 July 14, 2025 13:43
@arminsabouri
arminsabouri marked this pull request as ready for review July 14, 2025 13:43

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utACK 343e65f

@arminsabouri
arminsabouri merged commit eb5ff94 into payjoin:master Jul 14, 2025
@arminsabouri
arminsabouri deleted the use-witness-for-expected-weight branch July 14, 2025 18:56
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.

4 participants