-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Replace boost::optional with std::optional #20671
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
Conversation
Nice, concept ACK, this is a surprisingly small patch. |
Concept ACK. |
Concept ACK -- nice |
Concept ACK. #19806 could be rebased on this to remove the need for additional boost dependencies: #19806 (comment). @MarcoFalke do you still consider #19426 a prerequisite for this? (#19183 (comment)) |
Concept ACK: nice to get rid of old cruft |
I was hoping to get that in first, so that the first commit is easier to review. Though, it is not a strict requirement. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
Concept ACK. |
What do you think about explicitly stating that assumption at the top of the function: --- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -207,7 +207,11 @@ size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction& psbt) {
void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index)
{
- const CTxOut& out = psbt.tx->vout.at(index);
+ // tx must be filled before updating this PSBT.
+ assert(psbt.tx.has_value());
+ CMutableTransaction& tx = psbt.tx.value();
+
+ const CTxOut& out = tx.vout.at(index);
PSBTOutput& psbt_out = psbt.outputs.at(index);
// Fill a SignatureData with output info
@@ -217,7 +221,7 @@ void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransactio
// Construct a would-be spend of this output, to update sigdata with.
// Note that ProduceSignature is used to fill in metadata (not actual signatures),
// so provider does not need to provide any private keys (it can be a HidingSigningProvider).
- MutableTransactionSignatureCreator creator(&psbt.tx.value(), /* index */ 0, out.nValue, SIGHASH_ALL);
+ MutableTransactionSignatureCreator creator(&tx, /* index */ 0, out.nValue, SIGHASH_ALL); |
This was previously done implicitly in boost::optional by BOOST_ASSERT. Also, it was checked at runtime by valgrind if for some reason the assert was disabled. std::optional dereference won't assert, so add the Assert here explicitly. The explicit Assert also helps to document the code better.
The only use was to work around a compiler warning in an ancient compiler, which we no longer support.
cr ACK fa4435e: patch looks correct! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa4435e, I have reviewed the code and it looks OK, I agree it can be merged.
code review ACK fa4435e |
fa4435e Replace boost::optional with std::optional (MarcoFalke) fa7e803 Remove unused MakeOptional (MarcoFalke) fadd402 psbt: Assert that tx has a value in UpdatePSBTOutput (MarcoFalke) Pull request description: Now that we can use std::optional from the vanilla standard library, drop the third-party boost dependency ACKs for top commit: practicalswift: cr ACK fa4435e: patch looks correct! laanwj: code review ACK fa4435e hebasto: ACK fa4435e, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 50c5a1a130cac65e043e0177ba5b009fc2ba09343af4e23322ff2eb32184a55f8f2dea66e7a1b9d9acf56bc164eef4e47448750549a07f3b661199ac9bf9afef
Since this PR many of the functional tests fail with e.g. on 68c7acf
compiler version
|
I think it is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 |
See also #18785, an unrelated but similar issue |
backport: bitcoin#15141, bitcoin#15437, bitcoin#16240, bitcoin#18923, bitcoin#19219, bitcoin#19277, bitcoin#20016, bitcoin#20671 (auxiliary backports)
Now that we can use std::optional from the vanilla standard library, drop the third-party boost dependency