/// <summary>
        ///     Returns the Allow Trust XDR Operation Body
        /// </summary>
        /// <returns></returns>
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.AllowTrustOp op = new sdkxdr.AllowTrustOp();

            // trustor
            sdkxdr.AccountID trustor = new sdkxdr.AccountID();
            trustor.InnerValue = Trustor.XdrPublicKey;
            op.Trustor         = trustor;
            // asset
            sdkxdr.AllowTrustOp.AllowTrustOpAsset 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;

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();
            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.ALLOW_TRUST);
            body.AllowTrustOp = op;
            return(body);
        }
Exemplo n.º 2
0
        public override xdr.Asset ToXdr()
        {
            xdr.Asset thisXdr = new xdr.Asset();
            thisXdr.Discriminant = AssetType.Create(AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12);
            xdr.Asset.AssetAlphaNum12 credit = new xdr.Asset.AssetAlphaNum12();
            credit.AssetCode = Util.PaddedByteArray(Code, 12);
            AccountID accountID = new AccountID();

            accountID.InnerValue = Issuer.XdrPublicKey;
            credit.Issuer        = accountID;
            thisXdr.AlphaNum12   = credit;
            return(thisXdr);
        }
        public MemoHashAbstract(byte[] bytes)
        {
            if (bytes.Length < 32)
            {
                bytes = Util.PaddedByteArray(bytes, 32);
            }
            else if (bytes.Length > 32)
            {
                throw new MemoTooLongException("MEMO_HASH can contain 32 bytes at max.");
            }

            _MemoBytes = bytes;
        }