/// <summary> /// Returns the Allow Trust XDR Operation Body /// </summary> /// <returns></returns> public override sdkxdr.Operation.OperationBody ToOperationBody() { var op = new sdkxdr.AllowTrustOp(); // trustor var trustor = new sdkxdr.AccountID(); trustor.InnerValue = Trustor.XdrPublicKey; op.Trustor = trustor; // asset var asset = new sdkxdr.AllowTrustOp.AllowTrustOpAsset(); if (AssetCode.Length <= 4) { asset.Discriminant = sdkxdr.AssetType.Create(sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4); asset.AssetCode4 = Util.PaddedByteArray(AssetCode, 4); } else { asset.Discriminant = sdkxdr.AssetType.Create(sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12); asset.AssetCode12 = Util.PaddedByteArray(AssetCode, 12); } op.Asset = asset; // authorize op.Authorize = Authorize; var body = new sdkxdr.Operation.OperationBody(); body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.ALLOW_TRUST); body.AllowTrustOp = op; return(body); }
public override sdkxdr.Operation.OperationBody ToOperationBody() { var op = new sdkxdr.PathPaymentOp(); // sendAsset op.SendAsset = SendAsset.ToXdr(); // sendMax var sendMax = new sdkxdr.Int64(); sendMax.InnerValue = ToXdrAmount(SendMax); op.SendMax = sendMax; // destination var destination = new sdkxdr.AccountID(); destination.InnerValue = Destination.XdrPublicKey; op.Destination = destination; // destAsset op.DestAsset = DestAsset.ToXdr(); // destAmount var destAmount = new sdkxdr.Int64(); destAmount.InnerValue = ToXdrAmount(DestAmount); op.DestAmount = destAmount; // path var path = new sdkxdr.Asset[Path.Length]; for (var i = 0; i < Path.Length; i++) { path[i] = Path[i].ToXdr(); } op.Path = path; var body = new sdkxdr.Operation.OperationBody(); body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.PATH_PAYMENT); body.PathPaymentOp = op; return(body); }
public override sdkxdr.Operation.OperationBody ToOperationBody() { var op = new sdkxdr.SetOptionsOp(); if (InflationDestination != null) { var inflationDestination = new sdkxdr.AccountID(); inflationDestination.InnerValue = InflationDestination.XdrPublicKey; op.InflationDest = inflationDestination; } if (ClearFlags != null) { var clearFlags = new sdkxdr.Uint32(); clearFlags.InnerValue = ClearFlags.Value; op.ClearFlags = clearFlags; } if (SetFlags != null) { var setFlags = new sdkxdr.Uint32(); setFlags.InnerValue = SetFlags.Value; op.SetFlags = setFlags; } if (MasterKeyWeight != null) { var uint32 = new sdkxdr.Uint32(); uint32.InnerValue = MasterKeyWeight.Value; op.MasterWeight = uint32; } if (LowThreshold != null) { var uint32 = new sdkxdr.Uint32(); uint32.InnerValue = LowThreshold.Value; op.LowThreshold = uint32; } if (MediumThreshold != null) { var uint32 = new sdkxdr.Uint32(); uint32.InnerValue = MediumThreshold.Value; op.MedThreshold = uint32; } if (HighThreshold != null) { var uint32 = new sdkxdr.Uint32(); uint32.InnerValue = HighThreshold.Value; op.HighThreshold = uint32; } if (HomeDomain != null) { var homeDomain = new sdkxdr.String32(); homeDomain.InnerValue = HomeDomain; op.HomeDomain = homeDomain; } if (Signer != null) { var signer = new sdkxdr.Signer(); var weight = new sdkxdr.Uint32(); weight.InnerValue = SignerWeight.Value & 0xFF; signer.Key = Signer; signer.Weight = weight; op.Signer = signer; } var body = new sdkxdr.Operation.OperationBody(); body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.SET_OPTIONS); body.SetOptionsOp = op; return(body); }