Ihilda Documentation

Download Now

Install

Start Up

Keys

Trust

  • Account Currencies
  • Account Info
  • Account Offers
  • Account Transactions
  • BIP39 Mnemonics
  • book_offers
  • Ledger Tracker
  • Network
  • Offer Create
  • Path Find
  • Payment
  • Ping
  • Server Info
  • Server State
  • Subscribe
  • Trustline
  • Transaction Types
  • Transaction Look up

Payments

  • Trading

    RippleLibSharp Path Find Example


    Import the necessary libraries
    using System.Threading;

    using System.Threading.Tasks;

    using RippleLibSharp.Commands.Accounts;

    using RippleLibSharp.Commands.Stipulate;

    using RippleLibSharp.Keys;

    using RippleLibSharp.Network;

    using RippleLibSharp.Result;

    using RippleLibSharp.Transactions;

    using RippleLibSharp.Transactions.TxTypes;

    Connect to the xrp ledger
    var tokenSource = new CancellationTokenSource();
    
    var token = tokenSource.Token;
    
    ConnectionSettings connectInfo = new ConnectionSettings
    {
    
        // list of server url's in prefered order.
        ServerUrls = new string[] { "wss://s1.ripple.com:443", "wss://s2.ripple.com:443" },
    
    
        LocalUrl = "localhost",
        UserAgent = "optional spoof browser user agent",
        Reconnect = true
    };
    
    
    NetworkInterface network = new NetworkInterface(connectInfo);
    bool didConnect = network.Connect();
    
    if (!didConnect) {
        return;
    }
    
    Retrieve a list of possible paths for a payment
    string address = "";
    string destination = "";
    
    RippleCurrency recieve_amount = new RippleCurrency(1.0m);
    
    var task = PathFind.GetResult(
        address,
        destination,
        recieve_amount,
        network,
        token
    );
    
    task.Wait();
    
    var resp = task.Result;
    
    PathFindResult path_result = resp.result;
    
    RipplePaymentTransaction tx = new RipplePaymentTransaction
      {
          Destination = path_result.destination_account,
          Account = path_result.source_account,
          Amount = path_result.destination_amount,
          Paths = usersChoice.paths_computed,
          SendMax = usersChoice.source_amount
      };
    
    
    
    Sign and submit the transaction
    tx.AutoRequestFee(
        network,
        token);
    
    tx.AutoRequestSequence(
        address,
        network,
        token);
    
    RippleIdentifier secret = new RippleSeedAddress("the secret");
    
    //RippleIdentifier secret = new RipplePrivateKey("");
    
    // Sign with rippled // rippled must be installed and running
    tx.SignLocalRippled(secret);
    
    // Or sigh with
    tx.SignRippleDotNet(secret);
    
    // Or sign with
    // Currently broken !!
    tx.SignRippleLibSharp(secret);
    
    Response<RippleSubmitTxResult> submitTask = tx.Submit(network, token);
    
    var outcome = submitTask.result;
    
    Console.WriteLine(
        outcome.engine_result );