<p>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.</p>

<p>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 <em>should</em> (see note at bottom*) be what a user would see if they were to go to the client's "send" page (sorry no picture):</p>

<pre><code>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;
</code></pre>

<p>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:</p>

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

<p>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.</p>

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

<pre><code>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
</code></pre>

<p>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.</p>

<p>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).</p>

<ul>
<li>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.</li>
</ul>

CC BY-SA 3.0
2013-05-17T20:32:09.440Z
Also note that I omitted Bitstamp's 0.2% transfer fee for simplicity. The above values would work for sending 1/1.002 =~ 0.998 BTC at a cost of 0.1 BTC/Bitstamp==10 XRP
dchapes
CC BY-SA 3.0
2013-05-17T20:35:29.183Z
Oh and I also neglected the 0.000010 XRP transaction fee that will be subtracted from User B's balance when the transaction is confirmed and submitted (even if the transaction fails as described above; in that case the only balance changed will be the XRP balance of User A and only by the tx fee amount).
dchapes
CC BY-SA 3.0
2013-05-17T20:29:26.693Z
2013-05-17T20:29:26.693Z
dchapes
<p>Short answer is: Yes. For longer detailed explanation please see <a href="http://ripple.com/wiki" rel="nofollow">http://ripple.com/wiki</a></p>

CC BY-SA 3.0
2013-05-16T15:12:41.983Z
It's also not clear what article on the wiki we're supposed to be looking at.
Nick ODell
CC BY-SA 3.0
2013-05-17T02:17:13.450Z
Pathfinding is an area we are constantly improving.
David Schwartz
CC BY-SA 3.0
2013-05-17T07:07:28.287Z
@DavidSchwartz theoretically the answer is correct? Maybe is not working for some reason?
ElMato
CC BY-SA 3.0
2013-05-17T07:14:15.380Z
@Matu: Possibly. I'm not quite sure I completely follow your scenario. For example, it's not clear which party is extending trust.
David Schwartz
CC BY-SA 3.0
2013-05-17T18:21:39.497Z
@DavidSchwartz i have added an image to clarify the scenario
ElMato
CC BY-SA 3.0
2013-05-16T09:53:47.957Z
2013-05-16T09:53:47.957Z
Alex Kravets
<pre><code>I have a question regarding this scenario.
</code></pre>

<p><img src="https://i.sstatic.net/6Ebsm.png" alt="scenario"></p>

<ul>
<li><p>A (test-gateway)</p>

<ul>
<li>28000 XRP in balance</li>
</ul></li>
<li><p>B (user1)</p>

<ul>
<li>trust line with A for 1000 USD</li>
<li>400 XRP in balance</li>
</ul></li>
<li><p>C (user2)</p>

<ul>
<li>trust line with bitstamp for 100 BTC</li>
<li>400 XRP in balance</li>
</ul></li>
</ul>

<hr>

<ul>
<li><p>A issues 100 USD/A to B</p>

<ul>
<li>B now holds 100 USD/A in the balance</li>
</ul></li>
<li><p>A open a trade giving 10 XRP for 1 USD/A</p></li>
<li><p>B wants to send 0.1 BTC/bitstamp to C using his USD/A IOUs as source.</p></li>
</ul>

<hr>

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

<p>Because i can't make it work.</p>

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

<p>(there's a lot liquidity XRP&lt;=>BTC/bitstamp in the order book)</p>

<ripple><trade>
Will ripple automagically use the ordebook when finding a path?
ElMato
# Will ripple automagically use the ordebook when finding a path?

(Asked by: username_0 on 2013-05-16)

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<=>BTC/bitstamp in the order book)

**Tags:** ripple, trade


---

## 2 answers

### Answer by username_1 on 2013-05-17. Score: 2 | Accepted answer

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  
    1.00 USD    

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
   --> trade offer for 10XRP to 0.1 BTC/Bitstamp
   --> Bitstamp
   --> 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
    --> User A's offer giving 10.000 XRP for 1.00 USD
    [then as above]
   --> trade offer for 10XRP to 0.1 BTC/Bitstamp
   --> Bitstamp
   --> 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 username_4 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.

> **Comments:**
> **username_1**: Also note that I omitted Bitstamp's 0.2% transfer fee for simplicity. The above values would work for sending 1/1.002 =~ 0.998 BTC at a cost of 0.1 BTC/Bitstamp==10 XRP  
> **username_1**: Oh and I also neglected the 0.000010 XRP transaction fee that will be subtracted from User B's balance when the transaction is confirmed and submitted (even if the transaction fails as described above; in that case the only balance changed will be the XRP balance of User A and only by the tx fee amount).  

---

### Answer by username_2 on 2013-05-16. Score: -1

Short answer is: Yes. For longer detailed explanation please see <http://ripple.com/wiki>

> **Comments:**
> **username_3**: It's also not clear what article on the wiki we're supposed to be looking at.  
> **username_4**: Pathfinding is an area we are constantly improving.  
> **username_0**: @DavidSchwartz theoretically the answer is correct? Maybe is not working for some reason?  
> **username_4**: @Matu: Possibly. I'm not quite sure I completely follow your scenario. For example, it's not clear which party is extending trust.  
> **username_0**: @DavidSchwartz i have added an image to clarify the scenario  

---

