log: Remove trailing and embedded newlines from log messages

bitcoin/bitcoin: PR #36904

1 minor finding · 1 suggestion

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Single-line CTransaction::ToString() removes item breaks in the Qt debug view

When a debug log category is enabled, the Qt transaction details dialog now renders the transaction dump as one wrapped paragraph instead of separate lines for its header, inputs, witnesses and outputs.

Location: src/primitives/transaction.cpp:118 (head).

Details and suggested fix

TransactionDesc passes the dump through GUIUtil::HtmlEscape(wtx.tx->ToString(), true), which converts newlines into <br> elements. The old formatter supplied a newline after each item; the new formatter supplies none, making transactions with several inputs, outputs or witness stacks harder to scan. Unlike the logging consumer, this GUI consumer used those newlines as visible layout rather than escaping them as \x0a. Keep the single-line logging representation, but give the GUI a separate multiline formatter so it retains explicit item boundaries.


Optional improvements

Link

[suggestion] · The fa0c4cf message omits transaction content changes

The commit message describes newline removal but leaves changes to field names, field order, txid length and input/witness grouping unexplained, making the intended scope harder to validate.

Location: src/primitives/transaction.cpp:118 at fa0c4cfcee9e (commit) (commit).

Details and suggested fix

Commit fa0c4cfcee9e82f1bd47a58d80de5af8d47ca42f also replaces the ten-character hash prefix with the full txid, renames the header fields, moves locktime ahead of the counts, and pairs each witness with its input rather than listing all witnesses afterward. Expand its message to identify these deliberate content changes, so reviewers can distinguish them from the newline cleanup. Keeping the accompanying src/wallet/wallet.cpp change in this commit makes sense: removing the RemoveSuffixView workaround and the embedded prefix newline belongs with the producer's newline removal. No split is needed.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

A prior transaction-string proposal explicitly treated ToString output as a debugging aid, emphasizing visibility of witness data rather than a stable presentation format. Its discussion considered changing input/witness ordering and removing duplicated information; it did not establish a multiline or parser-compatibility requirement.

PR #33711 proposed adding witness information to CTxIn::ToString. A participant identified the existing CTransaction ordering—first inputs, then witnesses—and offered several ordering/duplication choices; the author reported updating the proposal to remove duplication. The proposal was subsequently closed for inactivity, so this is evidence of debugging intent and considered tradeoffs, not an adopted formatting contract. The pinned change similarly reorganizes inputs and witnesses while replacing multiline output.

Source 1 · Source 2 · Source 3 · Source 4

Ralph's inferences

The existing exception layout was shared human-facing diagnostic presentation, not merely a debug.log serialization detail; however, the inspected code alone cannot establish why its multiline layout was chosen or whether consumers were promised stability.

At the pinned base, PrintExceptionContinue sends the same formatted exception body to both LogWarning and stderr, with blank lines and an asterisk separator. At the head, both destinations receive the new single-line format. Consequently, the compatibility question extends to stderr independently of logging newline escaping. No inspected historical discussion resolves whether that presentation was contractual.