Will ripple automagically use the ordebook when finding a path? I have a question regarding this scenario.





A (test-gateway)


28000 XRP in balance

B (user1)


trust line with A for 1000 USD
400 XRP in balance

C (user2)


trust line with bitstamp for 100 BTC
400 XRP in balance






A issues 100 USD/A to B


B now holds 100 USD/A in the balance

A open a trade giving 10 XRP for 1 USD/A
B wants to send 0.1 BTC/bitstamp to C using his USD/A IOUs as source.




Will ripple do this?
  USD/A => XRP => BTC/bitstamp

Because i can't make it work.

C has a trust line to bitstamp.
B has no trust line with bitstamp, should it have one?

(there's a lot liquidity XRP&lt;=>BTC/bitstamp in the order book)
There is a missing piece in your picture, the trade offers selling BTC/Bitstamp for XRP. The values you give won't work currently since the best offers in the order book are in the range of 8300 XRP/BTC or 830 XRP for the 0.1 BTC you mention.

If the values you give were adjusted or if we assumed an alternate reality where 10 XRP could buy 0.1 BTC/Bitstamp then the following should (see note at bottom*) be what a user would see if they were to go to the client's "send" page (sorry no picture):

Recipient: C
Recipient will receive: 0.1 BTC
You can send:
    10.000 XRP  &lt;Send XRP button&gt;
    1.00 USD    &lt;Send USD button&gt;


Since User B has no BTC there is no BTC option given. If the user selects "Send XRP" then a payment path such as the following would be used:

User B 10.000 XRP
   --&gt; trade offer for 10XRP to 0.1 BTC/Bitstamp
   --&gt; Bitstamp
   --&gt; User C


User B's balance goes down by 10.000 XRP. The unknown person making the trade offer has their balance go up by 10 XRP and down by 0.1 BTC/Bitstamp. Bitstamp's balances are adjusted so that 0.1 BTC less is "owed" to the trader and 0.1 BTC more is "owed" to User C. User C's balance goes up by 0.1 BTC/Bitstamp.

If instead User A selects "Send USD" then a payment path such as the following would be used:

User B 1.00 USD/A
    --&gt; User A's offer giving 10.000 XRP for 1.00 USD
    [then as above]
   --&gt; trade offer for 10XRP to 0.1 BTC/Bitstamp
   --&gt; Bitstamp
   --&gt; User C


User B's balance goes down by 1.00 USD/A. User A's balance goes up by 1.00 USD/A (they owe one less USD to User B) and User A's balance goes down by 10.000 XRP. Then it's as in the previous case: The unknown person making the trade offer has their balance go up by 10 XRP and down by 0.1 BTC/Bitstamp. Bitstamp's balances are adjusted so that 0.1 BTC less is "owed" to the trader and 0.1 BTC more is "owed" to User C. User C's balance goes up by 0.1 BTC/Bitstamp.

In both cases User C considers the payment from User A complete by ending up with a larger balance with Bitstamp. All of these balance changes happen atomically within a single transaction, either all the balances change or none of them do (e.g. if the transaction fails because a required trade offer is consumed or canceled before this transaction can be processed). User B never ends up holding something they didn't want to hold (e.g. BTC/Bitstamp).


Note that path finding in Ripple is not exhaustive, not all valid paths are found. As David Schwartz says above, pathfinding is an area they are constantly improving. If the option to pay with USD as shown above is not presented currently then it's likely it will be as the pathfinding is improved.