/// <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)); }
/// <summary> /// Sign the transaction with a given account. /// </summary> /// <param name="account">The account.</param> /// <returns>CosignatureSignedTransactionDTO.</returns> /// <exception cref="ArgumentNullException">account</exception> public CosignatureSignedTransactionDTO SignWith(KeyPair account) { if (account == null) { throw new ArgumentNullException(nameof(account)); } var bytes = Hash.FromHex(); var signatureBytes = TransactionExtensions.SignHash(account, bytes); return(new CosignatureSignedTransactionDTO { ParentHash = Hash, Signature = signatureBytes.ToHexLower(), Signer = account.PublicKeyString }); }