예제 #1
0
        internal CreateMosaic(Connectivity.Connection connection, PublicKey signer, MosaicDefinition data) : base(connection, data.Model.MultisigAccount ?? signer, data.Model.Deadline)
        {
            // set connection
            Con = connection;

            // set signer of the transaction
            Signer = signer;

            // set mosaic definition data
            MosaicDefinition = data;

            // set the mosaic levy (sometimes null)
            Levy = data.Model.MosaicLevy;

            // serialize the data
            Serialize();

            // truncate bytes
            Bytes = ByteUtils.TruncateByteArray(_serializer.GetBytes(), Length);

            // update fee, transaction type, transaction version and concatonate all the parts of the transaction data bytes
            finalize();

            // add multisig headers if transaction is multisig and concatonate bytes
            AppendMultisig();
        }
예제 #2
0
        private void Serialize()
        {
            // all mosaic definition bytes inclusive of properties
            _serializer.WriteBytes(MosaicDefinition.GetBytes());

            // add mosaic definition part length plus length of transaction part
            Length += MosaicDefinition.Length + 56;

            if (Levy != null)
            {
                // all levy bytes if not null
                _serializer.WriteBytes(Levy.GetBytes());

                // add levy structure length minus 4 bytes that would otherwise have been a place holder in lue of a levy
                Length += Levy.Length - 4;
            }
            else
            {
                // if no levy, serialize 0 placeholder
                _serializer.WriteInt(DefaultValues.ZeroValuePlaceHolder);
            }

            // fee sink address length
            _serializer.WriteInt(ByteLength.AddressLength);

            // fee sink address
            _serializer.WriteString(AddressEncoding.ToEncoded(Con.GetNetworkVersion(), new PublicKey(DefaultValues.MainNetCreationFeeSink)));

            // creation fee
            _serializer.WriteLong(Fee.Creation);
        }