PassportTransactionFormatter { public byte[][] buildRawTransaction() { byte[] step1 = new BigInteger("01000000", 16).toByteArray(); byte[] step2 = new byte[]{0x01}; if (utxo.getParentTransactionHash() == null) return null; byte[] step3 = utxo.getParentTransactionHash().getReversedBytes(); byte[] step4 = ByteBuffer.allocate(4).putInt(Integer.reverseBytes(utxo.getIndex())).array(); byte[] step5 = new byte[] {(byte) (utxo.getScriptBytes().length & 0xFF)}; byte[] step6 = utxo.getScriptBytes(); byte[] step7 = Util.hexStringToByteArray("FFFFFFFF"); byte[] step8 = Util.hexStringToByteArray("01"); byte[] step9 = Util.hexStringToByteArray("0000000000000000"); byte[] step10 = new byte[]{(byte) (step6.length & 0xFF)}; byte[] step11 = step6.clone(); System.arraycopy(this.destination.getHash160(), 0, step11, 3, 20); byte[] step12 = Util.hexStringToByteArray("00000000"); byte[] step13 = Util.hexStringToByteArray("01000000"); return new byte[][]{step1, step2, step3, step4, step5, step6, step7, step8, step9, step10, step11, step12, step13}; } PassportTransactionFormatter(TransactionOutput utxo, Address destination); void setDestinationAddress(Address destination); void setUTXO(TransactionOutput utxo); byte[] buildAndSign(PublicKey pubKey, PassportConnection pcon); byte[][] buildRawTransaction(); byte[] signRawTransaction(PublicKey pubkey, byte[][] parts, PassportConnection pcon);  }
@Test public void testBuildRawTransaction() { byte[][] transaction = ptf.buildRawTransaction(); assertEquals(1, value(transaction[0])); assertEquals(1, value(transaction[1])); assertEquals(1, value(transaction[7])); assertEquals(0, value(transaction[8])); assertEquals(25, value(transaction[9])); byte[] raw = Bytes.concat(transaction[0], transaction[1], transaction[2], transaction[3], transaction[4], transaction[5], transaction[6], transaction[7], transaction[8], transaction[9], transaction[10], transaction[11], transaction[12]); byte[] hashRaw = Sha256Hash.hash(Sha256Hash.hash(raw)); byte[] correctHash = Util.hexStringToByteArray("09AB317A17BBEB4F46EFA2BDA80F137059608AA6696FF5155F0E2A72DC6C249E"); for(int i=0; i< correctHash.length; i++) { assertEquals(correctHash[i], hashRaw[i]); } }