Ejemplo n.º 1
0
        /// <summary>
        /// Signs the aggregate transaction with cosigners.
        /// </summary>
        /// <param name="initiatorAccount">The initiator account.</param>
        /// <param name="cosignatories">The cosignatories.</param>
        /// <returns>SignedTransaction.</returns>
        /// <exception cref="ArgumentNullException">
        /// initiatorAccount
        /// or
        /// cosignatories
        /// </exception>
        public SignedTransaction SignWithAggregateCosigners(KeyPair initiatorAccount, List <Account> cosignatories)
        {
            if (initiatorAccount == null)
            {
                throw new ArgumentNullException(nameof(initiatorAccount));
            }
            if (cosignatories == null)
            {
                throw new ArgumentNullException(nameof(cosignatories));
            }

            var signedTransaction = SignWith(initiatorAccount);
            var payload           = signedTransaction.Payload.FromHex();

            foreach (var cosignatory in cosignatories)
            {
                var bytes = signedTransaction.Hash.FromHex();

                var signatureBytes = TransactionExtensions.SignHash(cosignatory.KeyPair, bytes);

                payload = payload.Concat(cosignatory.KeyPair.PublicKey.Concat(signatureBytes)).ToArray();

                Cosignatures.Add(new AggregateTransactionCosignature(signatureBytes.ToHexLower(), new PublicAccount(cosignatory.KeyPair.PublicKey.ToHexLower(), Blockchain.NetworkType.Types.MIJIN_TEST)));
            }

            payload = BitConverter.GetBytes(payload.Length).Concat(payload.Take(4, payload.Length - 4).ToArray()).ToArray();

            return(SignedTransaction.Create(payload, signedTransaction.Hash.FromHex(), initiatorAccount.PublicKey, TransactionType));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LockFundsTransaction"/> class.
 /// </summary>
 /// <param name="version">The transaction version.</param>
 /// <param name="deadline">The deadline.</param>
 /// <param name="duration">The duration.</param>
 /// <param name="fee">The transaction fee.</param>
 /// <param name="mosaic">The mosaic.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="networkType">Type of the network.</param>
 /// <param name="signature">The signature.</param>
 /// <param name="signer">The signer.</param>
 /// <param name="transactionInfo">The transaction information.</param>
 public LockFundsTransaction(NetworkType.Types networkType, int version, Deadline deadline, ulong fee, Mosaic mosaic, ulong duration, SignedTransaction transaction, string signature, PublicAccount signer, TransactionInfo transactionInfo)
 {
     if (transaction.TransactionType != TransactionTypes.Types.AggregateBonded)
     {
         throw new ArgumentException("Cannot lock non-aggregate-bonded transaction");
     }
     Deadline        = deadline;
     Version         = version;
     Duration        = duration;
     Mosaic          = mosaic;
     NetworkType     = networkType;
     Transaction     = transaction;
     TransactionType = TransactionTypes.Types.LockFunds;
     Signer          = signer;
     Signature       = signature;
     TransactionInfo = transactionInfo;
     Fee             = fee;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Signs the transaction with the given <see cref="KeyPair"/>.
        /// </summary>
        /// <param name="keyPair">The <see cref="KeyPair"/>.</param>
        /// <returns><see cref="SignedTransaction"/>.</returns>
        /// <exception cref="ArgumentNullException">keyPair</exception>
        public SignedTransaction SignWith(KeyPair keyPair)
        {
            if (keyPair == null)
            {
                throw new ArgumentNullException(nameof(keyPair));
            }

            Signer = PublicAccount.CreateFromPublicKey(keyPair.PublicKeyString, NetworkType);

            Bytes = GenerateBytes();

            var sig = TransactionExtensions.SignTransaction(keyPair, Bytes);

            var signedBuffer = Bytes.Take(4)
                               .Concat(sig)
                               .Concat(keyPair.PublicKey)
                               .Concat(
                Bytes.Take(4 + 64 + 32, Bytes.Length - (4 + 64 + 32))
                ).ToArray();

            return(SignedTransaction.Create(signedBuffer, TransactionExtensions.Hasher(signedBuffer), keyPair.PublicKey, TransactionType));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LockFundsTransaction"/> class.
 /// </summary>
 /// <param name="version">The transaction version.</param>
 /// <param name="deadline">The deadline.</param>
 /// <param name="duration">The duration.</param>
 /// <param name="fee">The transaction fee.</param>
 /// <param name="mosaic">The mosaic.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="networkType">Type of the network.</param>
 public LockFundsTransaction(NetworkType.Types networkType, int version, Deadline deadline, ulong fee, Mosaic mosaic, ulong duration, SignedTransaction transaction)
     : this(networkType, version, deadline, fee, mosaic, duration, transaction, null, null, null)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates the specified HashLockTransaction.
 /// </summary>
 /// <param name="deadline">The deadline.</param>
 /// <param name="duration">The duration.</param>
 /// <param name="fee">The transaction fee.</param>
 /// <param name="mosaic">The mosaic.</param>
 /// <param name="transaction">The transaction.</param>
 /// <param name="netowrkType">Type of the netowrk.</param>
 /// <returns><see cref="LockFundsTransaction"/>.</returns>
 public static LockFundsTransaction Create(NetworkType.Types netowrkType, Deadline deadline, ulong fee, Mosaic mosaic, ulong duration, SignedTransaction transaction)
 {
     return(new LockFundsTransaction(netowrkType, 3, deadline, fee, mosaic, duration, transaction));
 }