-
Notifications
You must be signed in to change notification settings - Fork 38.7k
transaction: Adding script witness to ToString for CTxIn #33711
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
base: master
Are you sure you want to change the base?
transaction: Adding script witness to ToString for CTxIn #33711
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33711. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste 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 61cd0e53ca45684cd5ef9084829ecc6d59154595 I notice that
https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.cpp#L126 for (const auto& tx_in : vin)
str += " " + tx_in.ToString() + "\n";
for (const auto& tx_in : vin)
str += " " + tx_in.scriptWitness.ToString() + "\n"; |
61cd0e5 to
e8b262a
Compare
Hey, good call out. Updated to remove duplicate. Think this makes the most sense. |
frankomosh
left a comment
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.
I think the goal for this is reasonable, but doesn't it remove witness data from CTransaction::ToString() and break existing debug output?
src/primitives/transaction.cpp
Outdated
| str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24)); | ||
| str += strprintf(", scriptWitness=%s", scriptWitness.ToString()); |
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.
I think there might be an inconsistency in formatting here. scriptWitness.ToString() is called directly, while scriptSig uses HexStr().substr(0, 24). Shouldn't there be some symmetry ?
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.
I see your point, but the underlying structures are different for ScriptSig and ScriptWitness: simple byte vector for script sig ScriptSig and vector of byte vectors for the ScriptWitness. So these are more accurate representatives of what is happening under the hood imo. Its also standard to print script sig like this from what i can see.
| @@ -123,8 +125,6 @@ std::string CTransaction::ToString() const | |||
| nLockTime); | |||
| for (const auto& tx_in : vin) | |||
| str += " " + tx_in.ToString() + "\n"; | |||
| for (const auto& tx_in : vin) | |||
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.
Though I have not done a thorough test, I think that completely removing this might affect debug workflow. Before removing it, Ctransaction::ToString() is able to print all inputs, then a separate block with all witnesses, then all outputs. I don’t think this is possible anymore.
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.
yes but its better to roll up responsibility to the object that holds it? Can you point out exactly where maybe? so we can see? if not, this seems like a better approach to me.
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.
To be safe, I suggest keeping the output here as it was, as I have no idea what was the rationale for it: just so happened, or to reflect that segwit segregation.
A way to do it is to have a version of Tx tostring that omits the witness, and use that here, and print the witnesses separately as before.
I think this is less intrusive change and higher change of positive review.
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.
yes but its better to roll up responsibility to the object that holds it? Can you point out exactly where maybe? so we can see? if not, this seems like a better approach to me.
I think rolling the witness into CTxIn::ToString() is fine only if you keep the old separate witness block in CTransaction::ToString() (or try adding a flag to suppress it). Right now you’ve deleted that block, so every existing log, test and user script would lose the witness section.
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.
It wouldn't lose the witness section @frankomosh it would just be rolled up. It would still print, it would just print in the txIn instead. However i can breaking such a fundamental log would be a problem so I'm okay with making the change less intrusive
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.
@frankomosh should be addressed
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.
@optout21 for vision
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.
The CTransaction::ToString() output looks the same now, my concern is addressed.
e8b262a to
812495a
Compare
optout21
left a comment
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.
utACK 812495a426a3ea9ef15567983ff31e22d05e9f5d
Minor extension to the ToString() method of the CTxIn class. Well localized change, minimal risk of unintended impact. Thanks for the initiative.
812495a to
bc02cc8
Compare
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
When debugging and trying to print the details of a
CTxInusing theToString, we get thescriptSig, but would also help to get the witness.