Skip to content

Commit

Permalink
Transaction.toString(): Print more info
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer authored and oscarguindzberg committed Dec 20, 2018
1 parent fbf4c7e commit befee2f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/src/main/java/org/bitcoinj/core/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public String toString(@Nullable AbstractBlockChain chain) {
String scriptSigStr = in.getScriptSig().toString();
s.append(!Strings.isNullOrEmpty(scriptSigStr) ? scriptSigStr : "<no scriptSig>");
if (in.getValue() != null)
s.append(" ").append(in.getValue().toFriendlyString());
s.append(" ").append(in.getValue().toFriendlyString()).append(" (").append(in.getValue()).append(")");
s.append("\n ");
s.append("outpoint:");
final TransactionOutPoint outpoint = in.getOutpoint();
Expand Down Expand Up @@ -737,6 +737,13 @@ public String toString(@Nullable AbstractBlockChain chain) {
s.append(!Strings.isNullOrEmpty(scriptPubKeyStr) ? scriptPubKeyStr : "<no scriptPubKey>");
s.append(" ");
s.append(out.getValue().toFriendlyString());
s.append(" (");
s.append(out.getValue());
s.append(") ScriptPubKey: ");
s.append(HEX.encode(out.getScriptPubKey().getProgram()));
s.append(" Address:");
s.append(out.getScriptPubKey().getToAddress(params));
s.append(" ");
if (!out.isAvailableForSpending()) {
s.append(" Spent");
}
Expand All @@ -752,8 +759,8 @@ public String toString(@Nullable AbstractBlockChain chain) {
final Coin fee = getFee();
if (fee != null) {
final int size = unsafeBitcoinSerialize().length;
s.append(" fee ").append(fee.multiply(1000).divide(size).toFriendlyString()).append("/kB, ")
.append(fee.toFriendlyString()).append(" for ").append(size).append(" bytes\n");
s.append(" fee ").append(fee.toFriendlyString()).append(" for ").append(size).append(" bytes (")
.append(fee.divide(size).value).append(" Satoshi/Byte)\n");
}
if (purpose != null)
s.append(" prps ").append(purpose).append('\n');
Expand Down

0 comments on commit befee2f

Please sign in to comment.