mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-13 11:36:15 +01:00
Transaction: do a better job at showing invalid scriptSigs in toString()
Previously, it was just showing an exception message. This is improved as follows: - if an input scriptSig cannot be parsed, the raw bytes are shown instead - also, the input value is shown if available - for the coinbase input, which may be arbitrary bytes, the exception message is suppressed
This commit is contained in:
parent
2e297169b1
commit
9b28fdbfa0
2 changed files with 10 additions and 2 deletions
|
@ -810,7 +810,15 @@ public class Transaction extends BaseMessage {
|
|||
s.append('\n');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s.append("[exception: ").append(e.getMessage()).append("]\n");
|
||||
s.append(ByteUtils.formatHex(getInput(0).getScriptBytes()));
|
||||
if (!isCoinBase()) {
|
||||
final Coin value = in.getValue();
|
||||
if (value != null)
|
||||
s.append(" ").append(value.toFriendlyString());
|
||||
s.append('\n');
|
||||
s.append(indent).append(" exception: ").append(e.getMessage());
|
||||
}
|
||||
s.append('\n');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -515,7 +515,7 @@ public class TransactionTest {
|
|||
};
|
||||
|
||||
tx.addInput(ti);
|
||||
assertTrue(tx.toString().contains("[exception: "));
|
||||
assertTrue(tx.toString().contains("exception: "));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Reference in a new issue