/** 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); } }
public Address getAddressForOutput(TransactionOutput out) { try { Script script = out.getScriptPubKey(); if (script.isSentToRawPubKey()) { byte[] key = out.getScriptPubKey().getPubKey(); byte[] address_bytes = com.google.bitcoin.core.Utils.sha256hash160(key); Address a = new Address(params, address_bytes); return a; } else { Address a = script.getToAddress(params); return a; } } catch (ScriptException e) { // System.out.println(out.getParentTransaction().getHash() + " - " + out); // e.printStackTrace(); // jelly.getEventLog().log("Unable process tx output: " + // out.getParentTransaction().getHash()); } return null; }