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

lib: Add Taproot support to libconsensus #21158

Closed
wants to merge 4 commits into from

Conversation

jrawsthorne
Copy link
Contributor

@jrawsthorne jrawsthorne commented Feb 11, 2021

This change exposes a new function in libconsensus that allows passing spent outputs for Taproot verification. It also adds a VERIFY_TAPROOT flag.

If spent outputs are not provided when the VERIFY_TAPROOT flag is enabled, there is a new error returned SPENT_OUTPUTS_REQUIRED. If the VERIFY_TAPROOT flag is enabled when verify or verify_with_amount then the same error is returned.

I also included testing the consensus lib in the qa asset test.

Closes #21133

@jrawsthorne jrawsthorne force-pushed the libconsensus_taproot branch 3 times, most recently from 512c9ca to 883cac2 Compare February 12, 2021 23:38
@jrawsthorne jrawsthorne marked this pull request as ready for review February 12, 2021 23:39
Copy link
Contributor

@ariard ariard 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 adding this. If the API is bumped, take care to notify library users through mentioning the change in 0.22 release note (doc/release-noted.md)

src/script/bitcoinconsensus.cpp Outdated Show resolved Hide resolved
src/script/bitcoinconsensus.cpp Show resolved Hide resolved
src/script/bitcoinconsensus.cpp Show resolved Hide resolved
@jrawsthorne
Copy link
Contributor Author

Thanks for adding this. If the API is bumped, take care to notify library users through mentioning the change in 0.22 release note (doc/release-noted.md)

@ariard Thanks for the review. Do you have a suggestion about which section the change should be mentioned in?

@ariard
Copy link
Contributor

ariard commented Feb 14, 2021

@jrawsthorne "Tools and Utilities" sounds good to me.

doc/shared-libraries.md Outdated Show resolved Hide resolved
doc/shared-libraries.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ariard ariard left a comment

Choose a reason for hiding this comment

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

Code Review ACK 28245a8, thanks for the changes

Up to you to take the nit.

doc/shared-libraries.md Show resolved Hide resolved
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 2, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot
Copy link
Contributor

🕵️ @harding has been requested to review this pull request as specified in the REVIEWERS file.

@ariard
Copy link
Contributor

ariard commented Apr 16, 2021

Code Review ACK 7c85ec9. Changes from last ACK is complying VerifyScript call to new MissingDataBehavior introduced by b77b0cc and mention of rust-bitcoin lib.

@ariard
Copy link
Contributor

ariard commented Apr 26, 2021

@jrawsthorne I think this needs rebase, but that would be cool to land this for downstream projects.

@jrawsthorne jrawsthorne force-pushed the libconsensus_taproot branch from 7c85ec9 to 096ab5c Compare April 26, 2021 17:43
@jrawsthorne
Copy link
Contributor Author

Thanks @ariard, rebased

@ariard
Copy link
Contributor

ariard commented Apr 30, 2021

Code Review ACK 096ab5c.

Diff since last ack is swallowing release-note changes.

@ariard
Copy link
Contributor

ariard commented Apr 30, 2021

@SomberNight I guess you're also interested to for downstream support, if you have time to review again, that would be cool :)

Copy link
Member

@sipa sipa left a comment

Choose a reason for hiding this comment

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

utACK 6983919

src/test/script_tests.cpp Outdated Show resolved Hide resolved
src/script/bitcoinconsensus.h Outdated Show resolved Hide resolved
@jrawsthorne jrawsthorne force-pushed the libconsensus_taproot branch from 6983919 to c23996a Compare June 13, 2021 13:08
@jrawsthorne
Copy link
Contributor Author

Thanks for your review @sipa, I've addressed your comments. Also pinging @ariard

std::vector<CTxOut> spent_outputs;
if (spentOutputs != nullptr) {
TxInputStream spent_outputs_stream(PROTOCOL_VERSION, spentOutputs, spentOutputsLen);
spent_outputs_stream >> spent_outputs;
Copy link
Member

Choose a reason for hiding this comment

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

Might be nicer to let the caller pass in an array rather than have to serialise the vector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong but I thought it would have to be a vector and that can't be exposed as part of the C API

Copy link
Member

Choose a reason for hiding this comment

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

It could take in a pointer to an array of {pointer to utxo, length} structs or so, as well as the number of inputs. That's not particularly convenient to use, but neither is the current interface (as it probably requires serialization code on the caller side).

- `int64_t amount` - The amount spent in the input
- `const unsigned char *txTo` - The transaction with the input that is spending the previous output.
- `unsigned int txToLen` - The number of bytes for the `txTo`.
- `const unsigned char *spentOutputs` - Previous outputs spent in the transaction
Copy link
Member

Choose a reason for hiding this comment

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

This leaves me guessing how to call this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want to add something like "serialized as a vector of TxOut" or something more substantial?

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?
  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@maflcko
Copy link
Member

maflcko commented Apr 29, 2022

Marked "up for grabs"

@fanquake fanquake closed this May 12, 2022
@bitcoin bitcoin locked and limited conversation to collaborators May 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Taproot support to libconsensus
8 participants