public Builder(sdkxdr.PathPaymentStrictReceiveOp op)
 {
     _SendAsset   = Asset.FromXdr(op.SendAsset);
     _SendMax     = FromXdrAmount(op.SendMax.InnerValue);
     _Destination = MuxedAccount.FromXdrMuxedAccount(op.Destination);
     _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]);
     }
 }
Ejemplo n.º 2
0
        public static Transaction FromEnvelopeXdrV1(TransactionV1Envelope envelope)
        {
            var        transactionXdr = envelope.Tx;
            var        fee            = transactionXdr.Fee.InnerValue;
            var        sourceAccount  = MuxedAccount.FromXdrMuxedAccount(transactionXdr.SourceAccount);
            long       sequenceNumber = transactionXdr.SeqNum.InnerValue.InnerValue;
            Memo       memo           = Memo.FromXdr(transactionXdr.Memo);
            TimeBounds timeBounds     = TimeBounds.FromXdr(transactionXdr.TimeBounds);

            Operation[] operations = new Operation[transactionXdr.Operations.Length];
            for (int i = 0; i < transactionXdr.Operations.Length; i++)
            {
                operations[i] = Operation.FromXdr(transactionXdr.Operations[i]);
            }

            Transaction transaction = new Transaction(sourceAccount, fee, sequenceNumber, operations, memo, timeBounds);

            foreach (var signature in envelope.Signatures)
            {
                transaction.Signatures.Add(signature);
            }

            return(transaction);
        }
        public static FeeBumpTransaction FromEnvelopeXdr(TransactionEnvelope envelope)
        {
            {
                switch (envelope.Discriminant.InnerValue)
                {
                case EnvelopeType.EnvelopeTypeEnum.ENVELOPE_TYPE_TX_FEE_BUMP:
                    var tx        = envelope.FeeBump.Tx;
                    var fee       = tx.Fee.InnerValue;
                    var feeSource = MuxedAccount.FromXdrMuxedAccount(tx.FeeSource);
                    var innerTx   = Transaction.FromEnvelopeXdrV1(tx.InnerTx.V1);

                    var transaction = new FeeBumpTransaction(feeSource, innerTx, fee);
                    foreach (var signature in envelope.FeeBump.Signatures)
                    {
                        transaction.Signatures.Add(signature);
                    }

                    return(transaction);

                default:
                    throw new ArgumentException($"Invalid TransactionEnvelope: expected an ENVELOPE_TYPE_TX_FEE_BUMP but received {envelope.Discriminant.InnerValue}");
                }
            }
        }
 public Builder(xdr.ClawbackOp op)
 {
     _asset  = Asset.FromXdr(op.Asset);
     _amount = FromXdrAmount(op.Amount.InnerValue);
     _from   = MuxedAccount.FromXdrMuxedAccount(op.From);
 }
Ejemplo n.º 5
0
 ///<summary>
 /// Construct a new PaymentOperation builder from a PaymentOp XDR.
 ///</summary>
 ///<param name="op"><see cref="PaymentOp"/></param>
 public Builder(PaymentOp op)
 {
     _destination = MuxedAccount.FromXdrMuxedAccount(op.Destination);
     _asset       = Asset.FromXdr(op.Asset);
     _amount      = FromXdrAmount(op.Amount.InnerValue);
 }