### Question:
TrezorMessageUtils { public static TrezorMessage.TxOutput newTxOutput(Transaction tx, int index) { Preconditions.checkNotNull(tx, "Transaction must be present"); Preconditions.checkElementIndex(index, tx.getOutputs().size(), "TransactionOutput not present at index " + index); TransactionOutput txOutput = tx.getOutput(index); TrezorMessage.TxOutput.Builder builder = TrezorMessage.TxOutput.newBuilder(); builder.setIndex(index); long satoshiAmount = txOutput.getValue().longValue(); builder.setAmount(satoshiAmount); try { builder.setAddress(txOutput.getScriptPubKey().getToAddress(MainNetParams.get()).toString()); } catch (ScriptException e) { throw new IllegalArgumentException("Transaction script pub key invalid", e); } builder.setScriptType(TrezorMessage.ScriptType.PAYTOADDRESS); if (index == 1) { builder.addAddressN(0); builder.addAddressN(1); } return builder.build(); } private  TrezorMessageUtils(); static void writeMessage(Message message, DataOutputStream out); static TrezorMessage.TxInput newTxInput(Transaction tx, int index); static TrezorMessage.TxOutput newTxOutput(Transaction tx, int index);  }### Answer:
@Test public void testNewTxOutput() throws Exception { Address ourReceivingAddress = FakeTransactions.getElectrumAddressN(new int[] {0,0}); Address ourChangeAddress = FakeTransactions.getElectrumAddressN(new int[] {0,1}); Address random2Address = FakeTransactions.asMainNetAddress("1MKw8vWxvBnaBcrL2yXvZceqyRMoeG2kRn"); Transaction tx = FakeTransactions.newMainNetFakeTx( ourReceivingAddress, ourChangeAddress, random2Address, BigInteger.TEN, BigInteger.ONE ); TrezorMessage.TxOutput txOutput0 = TrezorMessageUtils.newTxOutput(tx, 0); TrezorMessage.TxOutput txOutput1 = TrezorMessageUtils.newTxOutput(tx, 1); assertThat(txOutput0.getAmount()).isEqualTo(1L); assertThat(txOutput1.getAmount()).isEqualTo(9L); assertThat(txOutput0.getAddress()).isEqualTo(random2Address.toString()); assertThat(txOutput1.getAddress()).isEqualTo(ourChangeAddress.toString()); assertThat(txOutput0.getIndex()).isEqualTo(0); assertThat(txOutput1.getIndex()).isEqualTo(1); }