From 720f7d2a92bd87b855e11232b0160ee7c9d18007 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 17 Dec 2015 08:57:34 +0100 Subject: [PATCH] Print transaction purpose in toString(). --- core/src/main/java/org/bitcoinj/core/Transaction.java | 2 ++ core/src/main/java/org/bitcoinj/core/Wallet.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/core/src/main/java/org/bitcoinj/core/Transaction.java b/core/src/main/java/org/bitcoinj/core/Transaction.java index 08df2daf9..68c6e9199 100644 --- a/core/src/main/java/org/bitcoinj/core/Transaction.java +++ b/core/src/main/java/org/bitcoinj/core/Transaction.java @@ -717,6 +717,8 @@ public class Transaction extends ChildMessage { 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(); } diff --git a/core/src/main/java/org/bitcoinj/core/Wallet.java b/core/src/main/java/org/bitcoinj/core/Wallet.java index 3b3e0df27..c28cef610 100644 --- a/core/src/main/java/org/bitcoinj/core/Wallet.java +++ b/core/src/main/java/org/bitcoinj/core/Wallet.java @@ -31,6 +31,7 @@ import org.bitcoinj.core.listeners.TransactionReceivedInBlockListener; 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.*; @@ -3024,6 +3025,9 @@ public class Wallet extends BaseTaggableObject 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.