Transaction extends NeoSerializable { @Override public byte[] toArray() { return super.toArray(); } Transaction();  Transaction(Neow3j neow, byte version, long nonce, long validUntilBlock, List<Signer> signers,
            long systemFee, long networkFee, List<TransactionAttribute> attributes, byte[] script,
            List<Witness> witnesses); byte getVersion(); long getNonce(); long getValidUntilBlock(); List<Signer> getSigners(); ScriptHash getSender(); long getSystemFee(); long getNetworkFee(); List<TransactionAttribute> getAttributes(); byte[] getScript(); List<Witness> getWitnesses(); void addWitness(Witness witness); String getTxId(); NeoSendRawTransaction send(); @Override int getSize(); @Override void deserialize(BinaryReader reader); @Override void serialize(BinaryWriter writer); byte[] toArrayWithoutWitnesses(); byte[] getHashData(); @Override byte[] toArray(); static final int HEADER_SIZE; }
@Test public void serializeWithoutAttributesAndWitnesses() { List<Signer> signers = new ArrayList<>(); signers.add(Signer.calledByEntry(account1)); List<Witness> witnesses = new ArrayList<>(); witnesses.add(new Witness(new byte[]{0x00}, new byte[]{0x00})); Transaction tx = new Transaction(neow, (byte) 0, 0x01020304L, 0x01020304L, signers, BigInteger.TEN.pow(8).longValue(), 1L, new ArrayList<>(), new byte[]{(byte) OpCode.PUSH1.getCode()}, new ArrayList<>()); byte[] actual = tx.toArray(); byte[] expected = Numeric.hexStringToByteArray("" + "00" + "04030201" + "00e1f50500000000" + "0100000000000000" + "04030201" + "01" + "23ba2703c53263e8d6e522dc32203339dcd8eee9" + "01" + "00" + "01" + OpCode.PUSH1.toString() + "00"); assertArrayEquals(expected, actual); }
@Test public void serializeWithAttributesAndWitnesses() { List<Signer> signers = new ArrayList<>(); signers.add(Signer.global(account1)); signers.add(Signer.calledByEntry(account2)); List<Witness> witnesses = new ArrayList<>(); witnesses.add(new Witness(new byte[]{0x00}, new byte[]{0x00})); Transaction tx = new Transaction(neow, (byte) 0, 0x01020304L, 0x01020304L, signers, BigInteger.TEN.pow(8).longValue(), 1L, new ArrayList<>(), new byte[]{(byte) OpCode.PUSH1.getCode()}, witnesses); byte[] actual = tx.toArray(); byte[] expected = Numeric.hexStringToByteArray("" + "00" + "04030201" + "00e1f50500000000" + "0100000000000000" + "04030201" + "02" + "23ba2703c53263e8d6e522dc32203339dcd8eee9" + "80" + "52eaab8b2aab608902c651912db34de36e7a2b0f" + "01" + "00" + "01" + OpCode.PUSH1.toString() + "01" + "01000100" ); assertArrayEquals(expected, actual); }