Problem
Fixes #932.
Running getrawtransaction on a very large non-standard transaction in the bitcoin-qt console causes the GUI to become completely unresponsive.
Reproduction:
getrawtransaction 30794005e228089a56cca58b6ad85e8cc0667cdc06b0ee6f9fe72aa19f50acd2
The transaction is ~3.98 MB and sits in block 938523. Entering the command above leaves the node window frozen until the process is killed. Reported in #932.
Root cause
The hang is not in the node or the RPC execution path. It occurs in the Qt UI thread after the result is delivered to the console widget.
Two operations in RPCConsole::message() scale badly with payload size:
GUIUtil::HtmlEscape()processes the result string character-by-character. A 3.98 MB transaction encodes to ~7.96 MB of hex, all of which this function walks before returning.QTextEdit::append()is then called with an HTML string of the same magnitude. Qt re-lays-out the entire text document on each call; for a payload this size the layout pass does not complete in any practical amount of time, stalling the event loop indefinitely.
Fix
Add a 1 MiB size guard in RPCExecutor::request(), immediately after RPCExecuteCommandLine() returns and before QString::fromStdString() is called. When the result exceeds the limit the widget receives a short notice instead of the raw output:
Response too large to display (7962624 bytes). Use bitcoin-cli to retrieve the full result.
Because the guard fires before QString conversion, the oversized string is never converted to UTF-16, never HTML-escaped, and never handed to the text widget.
The 1 MiB threshold:
- reuses the
_MiBliteral already present in this file (ui->lineEdit->setMaxLength(16_MiB)) - is well above any realistic interactive debugging output
- is well below the ~7.96 MiB that triggers the hang
Tests
A mock RPC command rpcLargeOutput is registered in src/qt/test/rpcnestedtests.cpp. It returns a string of 1_MiB + 1 bytes. The test asserts that RPCExecuteCommandLine returns the complete result unmodified, confirming the size guard in
RPCExecutor::request() does not affect the underlying RPC call, only what is rendered in the console widget.