コード例 #1
0
ファイル: Bundle.cs プロジェクト: SeeSharp7/tangle-.net
        /// <summary>
        /// The sign.
        /// </summary>
        /// <param name="keyGenerator">
        /// The key Generator.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// Thrown when bundle is not finalized.
        /// </exception>
        public void Sign(IKeyGenerator keyGenerator)
        {
            if (this.Hash == null)
            {
                throw new InvalidOperationException("BundleHash must be finalized in order to sign it!");
            }

            var i = 0;

            while (i < this.Transactions.Count)
            {
                var transaction = this.Transactions[i];

                if (transaction.Value < 0)
                {
                    var privateKey = keyGenerator.GetKeyFor(transaction.Address);
                    privateKey.SignInputTransactions(this.Transactions, i);

                    i += transaction.Address.SecurityLevel;
                }
                else
                {
                    i += 1;
                }
            }
        }