/// <summary>
            ///     Add, update, or remove a signer from the account. Signer is deleted if the weight = 0;
            /// </summary>
            /// <param name="signer">The signer key. Use <see cref="stellar_dotnetcore_sdk.Signer" /> helper to create this object.</param>
            /// <param name="weight">The weight to attach to the signer (0-255).</param>
            /// <returns>Builder object so you can chain methods.</returns>
            public Builder SetSigner(sdkxdr.SignerKey signer, int?weight)
            {
                this.signer = signer ?? throw new ArgumentNullException(nameof(signer), "signer cannot be null");

                if (weight == null)
                {
                    throw new ArgumentNullException(nameof(weight), "weight cannot be null");
                }

                signerWeight = weight.Value & 0xFF;
                return(this);
            }
Ejemplo n.º 2
0
        /// <summary>
        ///     Create <code>preAuthTx</code> <see cref="sdkxdr.SignerKey" /> from
        ///     a transaction hash.
        /// </summary>
        /// <param name="hash"></param>
        /// <returns>sdkxdr.SignerKey</returns>
        public static sdkxdr.SignerKey PreAuthTx(byte[] hash)
        {
            if (hash == null)
            {
                throw new ArgumentNullException(nameof(hash), "hash cannot be null");
            }

            var signerKey = new sdkxdr.SignerKey();
            var value     = CreateUint256(hash);

            signerKey.Discriminant = sdkxdr.SignerKeyType.Create(sdkxdr.SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX);
            signerKey.PreAuthTx    = value;

            return(signerKey);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Create <code>preAuthTx</code> <see cref="sdkxdr.SignerKey" /> from
        ///     a <see cref="sdkxdr.Transaction" /> hash.
        /// </summary>
        /// <param name="tx"></param>
        /// <returns>sdkxdr.SignerKey</returns>
        public static sdkxdr.SignerKey PreAuthTx(Transaction tx)
        {
            if (tx == null)
            {
                throw new ArgumentNullException(nameof(tx), "tx cannot be null");
            }

            var signerKey = new sdkxdr.SignerKey();
            var value     = CreateUint256(tx.Hash());

            signerKey.Discriminant = sdkxdr.SignerKeyType.Create(sdkxdr.SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX);
            signerKey.PreAuthTx    = value;

            return(signerKey);
        }
 private SetOptionsOperation(KeyPair inflationDestination, int?clearFlags, int?setFlags,
                             int?masterKeyWeight, int?lowThreshold, int?mediumThreshold,
                             int?highThreshold, string homeDomain, sdkxdr.SignerKey signer, int?signerWeight)
 {
     InflationDestination = inflationDestination;
     ClearFlags           = clearFlags;
     SetFlags             = setFlags;
     MasterKeyWeight      = masterKeyWeight;
     LowThreshold         = lowThreshold;
     MediumThreshold      = mediumThreshold;
     HighThreshold        = highThreshold;
     HomeDomain           = homeDomain;
     Signer       = signer;
     SignerWeight = signerWeight;
 }
 public Builder(sdkxdr.SetOptionsOp op)
 {
     if (op.InflationDest != null)
     {
         inflationDestination = KeyPair.FromXdrPublicKey(
             op.InflationDest.InnerValue);
     }
     if (op.ClearFlags != null)
     {
         clearFlags = op.ClearFlags.InnerValue;
     }
     if (op.SetFlags != null)
     {
         setFlags = op.SetFlags.InnerValue;
     }
     if (op.MasterWeight != null)
     {
         masterKeyWeight = op.MasterWeight.InnerValue;
     }
     if (op.LowThreshold != null)
     {
         lowThreshold = op.LowThreshold.InnerValue;
     }
     if (op.MedThreshold != null)
     {
         mediumThreshold = op.MedThreshold.InnerValue;
     }
     if (op.HighThreshold != null)
     {
         highThreshold = op.HighThreshold.InnerValue;
     }
     if (op.HomeDomain != null)
     {
         homeDomain = op.HomeDomain.InnerValue;
     }
     if (op.Signer != null)
     {
         signer       = op.Signer.Key;
         signerWeight = op.Signer.Weight.InnerValue & 0xFF;
     }
 }