CTxIn using the ToString, we get the scriptSig, but would also help to get the witness.
CTxIn using the ToString, we get the scriptSig, but would also help to get the witness.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33711.
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| Stale ACK | optout21 |
If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
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.
Concept ACK 61cd0e53ca45684cd5ef9084829ecc6d59154595
I notice that CTransaction::ToString() prints the inputs and the input script witnesses additionally, with that change script witnesses will be included duplicated. The order there is first all inputs, then all witnesses. Please consider removing the duplication.
Options:
CTxIn::ToString() without witness?https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.cpp#L126
0 for (const auto& tx_in : vin)
1 str += " " + tx_in.ToString() + "\n";
2 for (const auto& tx_in : vin)
3 str += " " + tx_in.scriptWitness.ToString() + "\n";
I notice that CTransaction::ToString() prints the inputs and the input script witnesses additionally, with that change script witnesses will be included duplicated. The order there is first all inputs, then all witnesses. Please consider removing the duplication.
Hey, good call out. Updated to remove duplicate. Think this makes the most sense.
43@@ -44,8 +44,10 @@ std::string CTxIn::ToString() const
44 str += prevout.ToString();
45 if (prevout.IsNull())
46 str += strprintf(", coinbase %s", HexStr(scriptSig));
47- else
48+ else {
49 str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24));
50+ str += strprintf(", scriptWitness=%s", scriptWitness.ToString());
scriptWitness.ToString() is called directly, while scriptSig uses HexStr().substr(0, 24). Shouldn’t there be some symmetry ?
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.
124@@ -123,8 +125,6 @@ std::string CTransaction::ToString() const
125 nLockTime);
126 for (const auto& tx_in : vin)
127 str += " " + tx_in.ToString() + "\n";
128- for (const auto& tx_in : vin)
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.
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.
CTransaction::ToString() output looks the same now, my concern is addressed.
CTransaction::ToString() and break existing debug output?
utACK 812495a426a3ea9ef15567983ff31e22d05e9f5d
Minor extension to the ToString() method of the CTxIn class. Well localized change, minimal risk of unintended impact. Thanks for the initiative.
125@@ -122,7 +126,7 @@ std::string CTransaction::ToString() const
126 vout.size(),
127 nLockTime);
128 for (const auto& tx_in : vin)
129- str += " " + tx_in.ToString() + "\n";
130+ str += " " + tx_in.ToString(false) + "\n";
pls use named args and snake_case:
0 str += " " + tx_in.ToString(/*include_witness=*/false) + "\n";