Exemplo n.º 1
0
        static void PaymentFromMaster(KeyPair kp, long amount)
        {
            // get master
            var     master       = KeyPair.Master();
            Account masterSource = new Account(master, 1);

            // load asset
            Stellar.Generated.Asset asset = Stellar.Asset.Native();

            var operation =
                new PaymentOperation.Builder(kp, asset, amount)
                .SetSourceAccount(masterSource.KeyPair)
                .Build();

            masterSource.IncrementSequenceNumber();

            Stellar.Transaction transaction =
                new Stellar.Transaction.Builder(masterSource)
                .AddOperation(operation)
                .Build();

            transaction.Sign(masterSource.KeyPair);

            string message = transaction.ToEnvelopeXdrBase64();

            string response = GetResult(message);

            Console.WriteLine(response);
        }
Exemplo n.º 2
0
        static void Payment(KeyPair from, KeyPair to, long amount)
        {
            Account source = new Account(from, GetSequence(from.Address));

            // load asset
            Stellar.Generated.Asset asset = Stellar.Asset.Native();

            var operation =
                new PaymentOperation.Builder(to, asset, amount)
                .SetSourceAccount(from)
                .Build();

            source.IncrementSequenceNumber();

            Stellar.Transaction transaction =
                new Stellar.Transaction.Builder(source)
                .AddOperation(operation)
                .Build();

            transaction.Sign(source.KeyPair);

            var tx = transaction.ToEnvelopeXdrBase64();

            var response = PostResult(tx);

            Console.WriteLine(response.ReasonPhrase);
        }
Exemplo n.º 3
0
        public static Asset FromXDR(Generated.Asset asset)
        {
            switch (asset.Discriminant.InnerValue)
            {
            case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_NATIVE:
                return(new Asset());

            case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4:
                return(new Asset(Encoding.ASCII.GetString(asset.AlphaNum4.AssetCode), KeyPair.FromXdrPublicKey(asset.AlphaNum4.Issuer.InnerValue)));

            case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12:
                return(new Asset(Encoding.ASCII.GetString(asset.AlphaNum12.AssetCode), KeyPair.FromXdrPublicKey(asset.AlphaNum12.Issuer.InnerValue)));

            default:
                throw new ArgumentException("Invalid asset.");
            }
        }
Exemplo n.º 4
0
 public Builder(KeyPair destination, Generated.Asset asset, long amount)
 {
     this.Destination = CheckNotNull(destination, "destination cannot be null.");
     this.Asset       = CheckNotNull(asset, "asset cannot be null.");
     this.Amount      = amount;
 }
Exemplo n.º 5
0
 private PaymentOperation(KeyPair destination, Generated.Asset asset, long amount)
 {
     this.Destination = CheckNotNull(destination, "destination cannot be null.");
     this.Asset       = CheckNotNull(asset, "asset cannot be null.");
     this.Amount      = amount;
 }
 public Builder(Generated.Asset asset, long limit)
 {
     Asset = CheckNotNull(asset, "asset cannot be null.");
     Limit = CheckNotNull(limit, "limit cannot be null.");
 }
 private ChangeTrustOperation(Generated.Asset asset, long limit)
 {
     Asset = CheckNotNull(asset, "asset cannot be null.");
     Limit = CheckNotNull(limit, "limit cannot be null.");
 }