public byte[] encode() {
        int seqLength = 0;
        EncodeStream stream = new EncodeStream(256);

        //
        //  The transaction splits are encoded as an optional context-specific
        //  field with identifier 2
        //
        if (splits != null && !splits.isEmpty()) {
            int splitsLength = 0;

            for (int i=splits.size()-1; i>=0; i--)
                splitsLength += splits.get(i).encode(stream);

            seqLength += stream.makeSequence(splitsLength,
                                             (byte)(Asn1Stream.ASN1_CONTEXT_SPECIFIC+2));
        }

        //
        //  The transfer account is encoded as an optional context-specific field
        //  with identifier 1
        //
        if (transferAccount != null)
            seqLength += stream.encodeInteger(transferAccount.getID(),
                                              (byte)(Asn1Stream.ASN1_CONTEXT_SPECIFIC+1));

        //
        //  The category is encoded as an optional context-specific field
        //  with identifier 0
        //
        if (category != null)
            seqLength += stream.encodeInteger(category.getID(),
                                              (byte)(Asn1Stream.ASN1_CONTEXT_SPECIFIC+0));

        //
        //  Encode the amount, account, date and schedule type
        //
        seqLength += stream.encodeDouble(amount);
        seqLength += stream.encodeInteger(account.getID());
        seqLength += stream.encodeString(description);
        seqLength += stream.encodeTime(date);
        seqLength += stream.encodeInteger(type);

        //
        //  Make the ScheduleRecord sequence
        //
        stream.makeSequence(seqLength, tagID);
        return stream.getData();
    }