public Builder(sdkxdr.PathPaymentOp op)
 {
     _SendAsset   = Asset.FromXdr(op.SendAsset);
     _SendMax     = FromXdrAmount(op.SendMax.InnerValue);
     _Destination = KeyPair.FromXdrPublicKey(op.Destination.InnerValue);
     _DestAsset   = Asset.FromXdr(op.DestAsset);
     _DestAmount  = FromXdrAmount(op.DestAmount.InnerValue);
     _Path        = new Asset[op.Path.Length];
     for (var i = 0; i < op.Path.Length; i++)
     {
         _Path[i] = Asset.FromXdr(op.Path[i]);
     }
 }
 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;
     }
 }
Esempio n. 3
0
        /// <summary>
        ///  Generates Asset object from a given XDR object
        ///  </summary>
        /// <param name="thisXdr"></param>
        public static Asset FromXdr(xdr.Asset thisXdr)
        {
            switch (thisXdr.Discriminant.InnerValue)
            {
            case AssetType.AssetTypeEnum.ASSET_TYPE_NATIVE:
                return(new AssetTypeNative());

            case AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4:
                var assetCode4 = Util.PaddedByteArrayToString(thisXdr.AlphaNum4.AssetCode);
                var issuer4    = KeyPair.FromXdrPublicKey(thisXdr.AlphaNum4.Issuer.InnerValue);
                return(new AssetTypeCreditAlphaNum4(assetCode4, issuer4));

            case AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12:
                var assetCode12 = Util.PaddedByteArrayToString(thisXdr.AlphaNum12.AssetCode);
                var issuer12    = KeyPair.FromXdrPublicKey(thisXdr.AlphaNum12.Issuer.InnerValue);
                return(new AssetTypeCreditAlphaNum12(assetCode12, issuer12));

            default:
                throw new ArgumentException("Unknown asset type " + thisXdr.Discriminant.InnerValue);
            }
        }
            /// <summary>
            /// Builder to build the AllowTrust Operation given an XDR AllowTrustOp
            /// </summary>
            /// <param name="op"></param>
            /// <exception cref="Exception"></exception>
            public Builder(sdkxdr.AllowTrustOp op)
            {
                _trustor = KeyPair.FromXdrPublicKey(op.Trustor.InnerValue);
                switch (op.Asset.Discriminant.InnerValue)
                {
                case sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4:
                    _assetCode = Encoding.UTF8.GetString(op.Asset.AssetCode4);
                    break;

                case sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12:
                    _assetCode = Encoding.UTF8.GetString(op.Asset.AssetCode12);
                    break;

                case sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_NATIVE:
                    break;

                default:
                    throw new Exception("Unknown asset code");
                }
                _authorize = op.Authorize;
            }
 public Builder(CreateAccountOp createAccountOp)
 {
     destination     = KeyPair.FromXdrPublicKey(createAccountOp.Destination.InnerValue);
     startingBalance = FromXdrAmount(createAccountOp.StartingBalance.InnerValue);
 }
 /// <summary>
 /// Builder to build the AccountMerge Operation given an XDR OperationBody
 /// </summary>
 /// <param name="op"></param>
 public Builder(xdr.Operation.OperationBody op)
 {
     _destination = KeyPair.FromXdrPublicKey(op.Destination.InnerValue);
 }
 ///<summary>
 /// Construct a new PaymentOperation builder from a PaymentOp XDR.
 ///</summary>
 ///<param name="op"><see cref="PaymentOp"/></param>
 public Builder(PaymentOp op)
 {
     destination = KeyPair.FromXdrPublicKey(op.Destination.InnerValue);
     asset       = Asset.FromXdr(op.Asset);
     amount      = FromXdrAmount(op.Amount.InnerValue);
 }