@@ -208,6 +208,42 @@ convert from mSAT to asset units as follows:
208208 ` price_in_asset `
209209 * ` Y ` is the number of asset units per BTC, specified by ` price_out_asset `
210210
211+ ### Price oracle interaction
212+
213+ ``` mermaid
214+ sequenceDiagram
215+ actor User
216+ box Seller (user)
217+ participant NodeA as Node A
218+ participant OracleA as Price Oracle A
219+ end
220+ box Buyer (edge node)
221+ participant NodeB as Node B
222+ participant OracleB as Price Oracle B
223+ end
224+
225+ User->>+NodeA: SendPayment
226+
227+ NodeA->>+NodeA: AddAssetSellOrder
228+
229+ NodeA->>+OracleA: Get price rate hint<br/>(QueryAssetRate[type=SALE,intent=PAY_INVOICE_HINT,peer=NodeB])
230+ OracleA-->>-NodeA: Price rate hint
231+
232+ NodeA->>+NodeB: Send sell request with price<br/>rate hint over p2p
233+
234+ NodeB->>+OracleB: Determine actual price<br/>rate using suggested price<br/>(QueryAssetRate[type=PURCHASE,intent=PAY_INVOICE,peer=NodeA])
235+ OracleB-->>-NodeB: Actual price rate
236+
237+ NodeB-->>-NodeA: Return actual price rate
238+
239+ NodeA->>+OracleA: Validate actual price rate<br/>(QueryAssetRate[type=SALE,intent=PAY_INVOICE_QUALIFY,peer=NodeB])
240+ OracleA-->>-NodeA: Approve actual price rate
241+
242+ NodeA->>-NodeA: Send payment over LN using approved actual price rate
243+
244+ NodeA->>-User: Payment result
245+ ```
246+
211247## Buy Order (Receiving via an Invoice)
212248
213249The buy order covers the second user story: The user wants to get paid, they
@@ -245,6 +281,43 @@ node as:
245281 * ` M ` is the number of mSAT in a BTC (100,000,000,000), specified by
246282 ` price_in_asset `
247283
284+ ### Price oracle interaction
285+
286+ ``` mermaid
287+ sequenceDiagram
288+ actor User
289+ box Buyer (user)
290+ participant NodeA as Node A
291+ participant OracleA as Price Oracle A
292+ end
293+ box Seller (edge node)
294+ participant NodeB as Node B
295+ participant OracleB as Price Oracle B
296+ end
297+
298+ User->>+NodeA: AddInvoice
299+
300+ NodeA->>+NodeA: AddAssetBuyOrder
301+
302+ NodeA->>+OracleA: Get price rate hint<br/>(QueryAssetRate[type=PURCHASE,intent=RECV_PAYMENT_HINT,peer=NodeB])
303+ OracleA-->>-NodeA: Price rate hint
304+
305+ NodeA->>+NodeB: Send buy request with price<br/>rate hint over p2p
306+
307+ NodeB->>+OracleB: Determine actual price<br/>rate using suggested price<br/>(QueryAssetRate[type=SALE,intent=RECV_PAYMENT,peer=NodeA])
308+ OracleB-->>-NodeB: Actual price rate
309+
310+ NodeB-->>-NodeA: Return actual price rate
311+
312+ NodeA->>+OracleA: Validate actual price rate<br/>(QueryAssetRate[type=PURCHASE,intent=RECV_PAYMENT_QUALIFY,peer=NodeB])
313+ OracleA-->>-NodeA: Approve actual price rate
314+
315+ NodeA->>-NodeA: Create invoice using actual price rate
316+
317+ NodeA->>-User: Invoice
318+ ```
319+
320+
248321## Examples
249322
250323See ` TestFindDecimalDisplayBoundaries ` and ` TestUsdToJpy ` in
0 commit comments