/** Returns a human readable debug string. */
 @Override
 public String toString() {
   try {
     Script script = getScriptPubKey();
     StringBuilder buf = new StringBuilder("TxOut of ");
     buf.append(Coin.valueOf(value).toFriendlyString());
     if (script.isSentToAddress() || script.isPayToScriptHash())
       buf.append(" to ").append(script.getToAddress(params));
     else if (script.isSentToRawPubKey())
       buf.append(" to pubkey ").append(Utils.HEX.encode(script.getPubKey()));
     else if (script.isSentToMultiSig()) buf.append(" to multisig");
     else buf.append(" (unknown type)");
     buf.append(" script:");
     buf.append(script);
     return buf.toString();
   } catch (ScriptException e) {
     throw new RuntimeException(e);
   }
 }
 @Override
 public void formatKeyWithAddress(
     boolean includePrivateKeys, StringBuilder builder, NetworkParameters params) {
   final Address address = toAddress(params);
   builder.append("  addr:");
   builder.append(address.toString());
   builder.append("  hash160:");
   builder.append(Utils.HEX.encode(getPubKeyHash()));
   builder.append("  (");
   builder.append(getPathAsString());
   builder.append(")");
   builder.append("\n");
   if (includePrivateKeys) {
     builder.append("  ");
     builder.append(toStringWithPrivate(params));
     builder.append("\n");
   }
 }