diff --git a/src/com/google/bitcoin/core/Wallet.java b/src/com/google/bitcoin/core/Wallet.java index f5a57831..58cf8eb4 100644 --- a/src/com/google/bitcoin/core/Wallet.java +++ b/src/com/google/bitcoin/core/Wallet.java @@ -1230,27 +1230,44 @@ public class Wallet implements Serializable { // Print the transactions themselves if (unspent.size() > 0) { builder.append("\nUNSPENT:\n"); - for (Transaction tx : unspent.values()) builder.append(tx); + toStringHelper(builder, unspent); } if (spent.size() > 0) { builder.append("\nSPENT:\n"); - for (Transaction tx : spent.values()) builder.append(tx); + toStringHelper(builder, spent); } if (pending.size() > 0) { builder.append("\nPENDING:\n"); - for (Transaction tx : pending.values()) builder.append(tx); + toStringHelper(builder, pending); } if (inactive.size() > 0) { builder.append("\nINACTIVE:\n"); - for (Transaction tx : inactive.values()) builder.append(tx); + toStringHelper(builder, inactive); } if (dead.size() > 0) { builder.append("\nDEAD:\n"); - for (Transaction tx : dead.values()) builder.append(tx); + toStringHelper(builder, dead); } return builder.toString(); } + private void toStringHelper(StringBuilder builder, Map transactionMap) { + for (Transaction tx : transactionMap.values()) { + try { + builder.append("Sends "); + builder.append(Utils.bitcoinValueToFriendlyString(tx.getValueSentFromMe(this))); + builder.append(" and receives "); + builder.append(Utils.bitcoinValueToFriendlyString(tx.getValueSentToMe(this))); + builder.append(", total value "); + builder.append(Utils.bitcoinValueToFriendlyString(tx.getValue(this))); + builder.append(".\n"); + } catch (ScriptException e) { + // Ignore and don't print this line. + } + builder.append(tx); + } + } + /** * Called by the {@link BlockChain} when the best chain (representing total work done) has changed. In this case, * we need to go through our transactions and find out if any have become invalid. It's possible for our balance