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

psbt: add verification method for utxo data #1964

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

ziggie1984
Copy link
Contributor

@ziggie1984 ziggie1984 commented Mar 20, 2023

This adds a method to verify the utxo data of a psbt package especially the NonWitnessUtxo | WitnessUtxo data.

This will be used in other packages to make sure we have the correct psbt structure with all relevant input fields populated.

Relates to lightningnetwork/lnd#7527

Happy to discuss other approaches, other PRs which call this function in lnd and btcwallet would follow if we want this function in this package ?

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Idea definitely makes sense, just a few comments around style and naming.

btcutil/psbt/utils.go Outdated Show resolved Hide resolved
btcutil/psbt/utils.go Outdated Show resolved Hide resolved
btcutil/psbt/utils.go Outdated Show resolved Hide resolved
btcutil/psbt/utils.go Outdated Show resolved Hide resolved
@ziggie1984
Copy link
Contributor Author

Thank you for taking a look so fast, really appreciate this :)

// type and the second reason is that the sighash calculation for taproot inputs
// include the previous output pkscripts.
func InputsReadyToSign(packet *Packet) error {
VerifyInputOutputLen(packet, true, true)

Choose a reason for hiding this comment

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

I guess we want to return an error if this function "fails"?

Copy link
Contributor Author

@ziggie1984 ziggie1984 Mar 21, 2023

Choose a reason for hiding this comment

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

Totally thank you

the new InputsReadyToSign method makes sure that inputs have either
the nonWitnessUtxo or the witnessUtxo data set.
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4476808113

  • 0 of 12 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 55.272%

Changes Missing Coverage Covered Lines Changed/Added Lines %
btcutil/psbt/utils.go 0 12 0.0%
Files with Coverage Reduction New Missed Lines %
mempool/mempool.go 1 66.75%
Totals Coverage Status
Change from base Build 4326890213: -0.01%
Covered Lines: 26650
Relevant Lines: 48216

💛 - Coveralls

Copy link

@positiveblue positiveblue left a comment

Choose a reason for hiding this comment

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

Thanks for this 🎉

@guggero guggero merged commit 7975168 into btcsuite:master Mar 22, 2023
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