### Question:
TrezorMessageUtils { public static TrezorMessage.TxInput newTxInput(Transaction tx, int index) { Preconditions.checkNotNull(tx, "Transaction must be present"); Preconditions.checkElementIndex(index, tx.getInputs().size(), "TransactionInput not present at index " + index); TransactionInput txInput = tx.getInput(index); TrezorMessage.TxInput.Builder builder = TrezorMessage.TxInput.newBuilder(); builder.setIndex(index); long prevIndex = txInput.getOutpoint().getIndex(); byte[] prevHash = txInput.getOutpoint().getHash().getBytes(); long satoshiAmount = txInput.getConnectedOutput().getValue().longValue(); builder.setAmount(satoshiAmount); try { byte[] scriptSig = txInput.getScriptSig().toString().getBytes(); builder.setScriptSig(ByteString.copyFrom(scriptSig)); builder.setPrevIndex((int) prevIndex); builder.setPrevHash(ByteString.copyFrom(prevHash)); builder.addAddressN(0); builder.addAddressN(index); return builder.build(); } catch (ScriptException e) { throw new IllegalStateException(e); } } 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 testNewTxInput() 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 ); byte[] expectedPrevHash = new byte[] {-37, 34, -99, 85, -58, 79, 11, -8, 14, 64, 35, -18, 54, 14, -46, -43, -91, -66, 98, -68, 117, 99, 67, 49, -63, 86, -77, -75, -115, -122, 69, -43}; byte[] expectedScriptSig = new byte[] {}; TrezorMessage.TxInput txInput = TrezorMessageUtils.newTxInput(tx, 0); assertThat(txInput.getAmount()).isEqualTo(BigInteger.TEN.longValue()); assertThat(txInput.getPrevHash().toByteArray()).isEqualTo(expectedPrevHash); assertThat(txInput.getPrevIndex()).isEqualTo(0); assertThat(txInput.getScriptSig().toByteArray()).isEqualTo(expectedScriptSig); }