TransactionInput: fix toString() throws on unparseable script

This commit is contained in:
Andreas Schildbach 2023-04-04 11:08:02 +02:00
parent 37fbe5ed7d
commit 86e0980d19

View File

@ -578,20 +578,21 @@ public class TransactionInput {
@Override
public String toString() {
StringBuilder s = new StringBuilder("TxIn");
try {
if (isCoinBase()) {
s.append(": COINBASE");
} else {
s.append(" for [").append(outpoint).append("]: ").append(getScriptSig());
if (isCoinBase()) {
s.append(": COINBASE");
} else {
s.append(" for [").append(outpoint).append("]: ");
try {
s.append(getScriptSig());
String flags = InternalUtils.commaJoin(hasWitness() ? "witness" : null,
hasSequence() ? "sequence: " + Long.toHexString(sequence) : null,
isOptInFullRBF() ? "opts into full RBF" : null);
if (!flags.isEmpty())
s.append(" (").append(flags).append(')');
} catch (ScriptException e) {
s.append(" [exception: ").append(e.getMessage()).append("]");
}
return s.toString();
} catch (ScriptException e) {
throw new RuntimeException(e);
}
return s.toString();
}
}