示例#1
0
        public static Signer Decode(XdrDataInputStream stream)
        {
            Signer decodedSigner = new Signer();

            decodedSigner.Key    = SignerKey.Decode(stream);
            decodedSigner.Weight = Uint32.Decode(stream);
            return(decodedSigner);
        }
示例#2
0
            /// <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_dotnet_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);
            }
示例#3
0
 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;
 }
示例#4
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);
        }
示例#5
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);
        }
        public static void Encode(XdrDataOutputStream stream, SignerKey encodedSignerKey)
        {
            stream.WriteInt((int)encodedSignerKey.Discriminant.InnerValue);
            switch (encodedSignerKey.Discriminant.InnerValue)
            {
            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_ED25519:
                Uint256.Encode(stream, encodedSignerKey.Ed25519);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX:
                Uint256.Encode(stream, encodedSignerKey.PreAuthTx);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_HASH_X:
                Uint256.Encode(stream, encodedSignerKey.HashX);
                break;
            }
        }
示例#7
0
 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;
     }
 }
        public static SignerKey Decode(XdrDataInputStream stream)
        {
            SignerKey     decodedSignerKey = new SignerKey();
            SignerKeyType discriminant     = SignerKeyType.Decode(stream);

            decodedSignerKey.Discriminant = discriminant;
            switch (decodedSignerKey.Discriminant.InnerValue)
            {
            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_ED25519:
                decodedSignerKey.Ed25519 = Uint256.Decode(stream);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX:
                decodedSignerKey.PreAuthTx = Uint256.Decode(stream);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_HASH_X:
                decodedSignerKey.HashX = Uint256.Decode(stream);
                break;
            }
            return(decodedSignerKey);
        }
 /// <summary>
 ///     Create a new  builder with the given sponsoredId.
 /// </summary>
 /// <param name="accountId"></param>
 /// <param name="signerKey"></param>
 public Builder(KeyPair accountId, xdr.SignerKey signerKey)
 {
     _accountId = accountId ?? throw new ArgumentNullException(nameof(accountId));
     _signerKey = signerKey ?? throw new ArgumentNullException(nameof(signerKey));
 }
 /// <summary>
 ///     Construct a new BeginSponsoringFutureReserves builder from a BeginSponsoringFutureReservesOp XDR.
 /// </summary>
 /// <param name="op"></param>
 public Builder(xdr.RevokeSponsorshipOp.RevokeSponsorshipOpSigner op)
 {
     _accountId = KeyPair.FromXdrPublicKey(op.AccountID.InnerValue);
     _signerKey = op.SignerKey;
 }
 public RevokeSignerSponsorshipOperation(KeyPair accountId, xdr.SignerKey signerKey)
 {
     AccountId = accountId;
     SignerKey = signerKey;
 }
示例#12
0
 public static void Encode(XdrDataOutputStream stream, Signer encodedSigner)
 {
     SignerKey.Encode(stream, encodedSigner.Key);
     Uint32.Encode(stream, encodedSigner.Weight);
 }