Skip to content

Commit

Permalink
Print transaction purpose in toString().
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Dec 20, 2015
1 parent ab169f0 commit 720f7d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/org/bitcoinj/core/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ public String toString(@Nullable AbstractBlockChain chain) {
Coin fee = getFee();
if (fee != null)
s.append(" fee ").append(fee.toFriendlyString()).append(String.format("%n"));
if (purpose != null)
s.append(" prps ").append(purpose).append(String.format("%n"));
return s.toString();
}

Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/bitcoinj/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.bitcoinj.core.listeners.WalletEventListener;
import org.bitcoinj.core.listeners.WalletChangeEventListener;
import org.bitcoinj.core.listeners.WalletCoinEventListener;
import org.bitcoinj.core.Transaction.Purpose;
import org.bitcoinj.core.TransactionConfidence.*;
import org.bitcoinj.crypto.*;
import org.bitcoinj.params.*;
Expand Down Expand Up @@ -3024,6 +3025,9 @@ private void toStringHelper(StringBuilder builder, Map<Sha256Hash, Transaction>
builder.append(tx.getValueSentToMe(this).toFriendlyString());
builder.append(", total value ");
builder.append(tx.getValue(this).toFriendlyString());
final Purpose purpose = tx.getPurpose();
if (purpose != null)
builder.append(", purpose: ").append(purpose);
builder.append(".\n");
} catch (ScriptException e) {
// Ignore and don't print this line.
Expand Down

0 comments on commit 720f7d2

Please sign in to comment.