@Test public void testMultiSigOutputToString() throws Exception { sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, Coin.COIN); ECKey myKey = new ECKey(); this.wallet.importKey(myKey); ECKey otherKey = new ECKey(); Transaction multiSigTransaction = new Transaction(UNITTEST); ImmutableList<ECKey> keys = ImmutableList.of(myKey, otherKey); Script scriptPubKey = ScriptBuilder.createMultiSigOutputScript(2, keys); multiSigTransaction.addOutput(Coin.COIN, scriptPubKey); SendRequest req = SendRequest.forTx(multiSigTransaction); this.wallet.completeTx(req); TransactionOutput multiSigTransactionOutput = multiSigTransaction.getOutput(0); assertThat(multiSigTransactionOutput.toString(), CoreMatchers.containsString("CHECKMULTISIG")); }
@Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (ScriptPattern.isP2PKH(script) || ScriptPattern.isP2WPKH(script) || ScriptPattern.isP2SH(script)) buf.append(" to ").append(script.getToAddress(params)); else if (ScriptPattern.isP2PK(script)) buf.append(" to pubkey ").append(Utils.HEX.encode(ScriptPattern.extractKeyFromP2PK(script))); else if (ScriptPattern.isSentToMultisig(script)) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } }
TransactionOutput extends ChildMessage { @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (ScriptPattern.isP2PKH(script) || ScriptPattern.isP2WPKH(script) || ScriptPattern.isP2SH(script)) buf.append(" to ").append(script.getToAddress(params)); else if (ScriptPattern.isP2PK(script)) buf.append(" to pubkey ").append(Utils.HEX.encode(ScriptPattern.extractKeyFromP2PK(script))); else if (ScriptPattern.isSentToMultisig(script)) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } } }
TransactionOutput extends ChildMessage { @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (ScriptPattern.isP2PKH(script) || ScriptPattern.isP2WPKH(script) || ScriptPattern.isP2SH(script)) buf.append(" to ").append(script.getToAddress(params)); else if (ScriptPattern.isP2PK(script)) buf.append(" to pubkey ").append(Utils.HEX.encode(ScriptPattern.extractKeyFromP2PK(script))); else if (ScriptPattern.isSentToMultisig(script)) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } } TransactionOutput(NetworkParameters params, @Nullable Transaction parent, byte[] payload,
                             int offset);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, byte[] payload, int offset, MessageSerializer serializer);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, Address to);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, ECKey to);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, byte[] scriptBytes); }
TransactionOutput extends ChildMessage { @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (ScriptPattern.isP2PKH(script) || ScriptPattern.isP2WPKH(script) || ScriptPattern.isP2SH(script)) buf.append(" to ").append(script.getToAddress(params)); else if (ScriptPattern.isP2PK(script)) buf.append(" to pubkey ").append(Utils.HEX.encode(ScriptPattern.extractKeyFromP2PK(script))); else if (ScriptPattern.isSentToMultisig(script)) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } } TransactionOutput(NetworkParameters params, @Nullable Transaction parent, byte[] payload,
                             int offset);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, byte[] payload, int offset, MessageSerializer serializer);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, Address to);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, ECKey to);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, byte[] scriptBytes); Script getScriptPubKey(); @Nullable @Deprecated LegacyAddress getAddressFromP2PKHScript(NetworkParameters params); @Nullable @Deprecated LegacyAddress getAddressFromP2SH(NetworkParameters params); Coin getValue(); void setValue(Coin value); int getIndex(); boolean isDust(); Coin getMinNonDustValue(Coin feePerKb); Coin getMinNonDustValue(); void markAsSpent(TransactionInput input); void markAsUnspent(); boolean isAvailableForSpending(); byte[] getScriptBytes(); boolean isMineOrWatched(TransactionBag transactionBag); boolean isWatched(TransactionBag transactionBag); boolean isMine(TransactionBag transactionBag); @Override String toString(); @Nullable TransactionInput getSpentBy(); @Nullable Transaction getParentTransaction(); @Nullable Sha256Hash getParentTransactionHash(); int getParentTransactionDepthInBlocks(); TransactionOutPoint getOutPointFor(); TransactionOutput duplicateDetached(); @Override boolean equals(Object o); @Override int hashCode(); }
TransactionOutput extends ChildMessage { @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (ScriptPattern.isP2PKH(script) || ScriptPattern.isP2WPKH(script) || ScriptPattern.isP2SH(script)) buf.append(" to ").append(script.getToAddress(params)); else if (ScriptPattern.isP2PK(script)) buf.append(" to pubkey ").append(Utils.HEX.encode(ScriptPattern.extractKeyFromP2PK(script))); else if (ScriptPattern.isSentToMultisig(script)) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } } TransactionOutput(NetworkParameters params, @Nullable Transaction parent, byte[] payload,
                             int offset);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, byte[] payload, int offset, MessageSerializer serializer);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, Address to);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, ECKey to);  TransactionOutput(NetworkParameters params, @Nullable Transaction parent, Coin value, byte[] scriptBytes); Script getScriptPubKey(); @Nullable @Deprecated LegacyAddress getAddressFromP2PKHScript(NetworkParameters params); @Nullable @Deprecated LegacyAddress getAddressFromP2SH(NetworkParameters params); Coin getValue(); void setValue(Coin value); int getIndex(); boolean isDust(); Coin getMinNonDustValue(Coin feePerKb); Coin getMinNonDustValue(); void markAsSpent(TransactionInput input); void markAsUnspent(); boolean isAvailableForSpending(); byte[] getScriptBytes(); boolean isMineOrWatched(TransactionBag transactionBag); boolean isWatched(TransactionBag transactionBag); boolean isMine(TransactionBag transactionBag); @Override String toString(); @Nullable TransactionInput getSpentBy(); @Nullable Transaction getParentTransaction(); @Nullable Sha256Hash getParentTransactionHash(); int getParentTransactionDepthInBlocks(); TransactionOutPoint getOutPointFor(); TransactionOutput duplicateDetached(); @Override boolean equals(Object o); @Override int hashCode();  }