public Builder AddMemo(Generated.Memo memo)
            {
                if (this.Memo != null)
                {
                    throw new Exception("Memo has already been added.");
                }

                this.Memo = CheckNotNull(memo, "memo cannot be null.");
                return(this);
            }
        public Transaction(KeyPair sourceAccount, long sequenceNumber, Operation[] operations, Generated.Memo memo)
        {
            SourceAccount = CheckNotNull(sourceAccount, "sourceAccount cannot be null");
            SequenceNumber = CheckNotNull(sequenceNumber, "sequenceNumber cannot be null");
            mOperations = CheckNotNull(operations, "operations cannot be null");

            if (operations.Length <= 0)
            {
                throw new ArgumentException("At least one operation required");
            }

            mFee = operations.Length * BASE_FEE;
            mSignatures = new List<Generated.DecoratedSignature>();
            Memo = memo != null ? memo : Stellar.Memo.None();
        }
        public Transaction(KeyPair sourceAccount, long sequenceNumber, Operation[] operations, Generated.Memo memo)
        {
            SourceAccount  = CheckNotNull(sourceAccount, "sourceAccount cannot be null");
            SequenceNumber = CheckNotNull(sequenceNumber, "sequenceNumber cannot be null");
            mOperations    = CheckNotNull(operations, "operations cannot be null");

            if (operations.Length <= 0)
            {
                throw new ArgumentException("At least one operation required");
            }

            mFee        = operations.Length * BASE_FEE;
            mSignatures = new List <Generated.DecoratedSignature>();
            Memo        = memo != null ? memo : Stellar.Memo.None();
        }
Esempio n. 4
0
        public static Memo FromXDR(Generated.Memo memo)
        {
            switch (memo.Discriminant.InnerValue)
            {
            case Generated.MemoType.MemoTypeEnum.MEMO_NONE:
                return(MemoNone());

            case Generated.MemoType.MemoTypeEnum.MEMO_TEXT:
                return(MemoText(memo.Text));

            case Generated.MemoType.MemoTypeEnum.MEMO_ID:
                return(MemoId((long)memo.Id.InnerValue));

            case Generated.MemoType.MemoTypeEnum.MEMO_HASH:
                return(MemoHash(Encoding.ASCII.GetString(memo.Hash.InnerValue)));

            case Generated.MemoType.MemoTypeEnum.MEMO_RETURN:
                return(MemoReturnHash(Encoding.ASCII.GetString(memo.RetHash.InnerValue)));

            default:
                throw new ArgumentException("Invalid memo.");
            }
        }