Skip to content

Commit 3aa4e55

Browse files
Added Paths to the XRPL Payment Transaction (#25)
* Added `Paths` to the `XrplPaymentTransaction`. * Added extension to convert the string representation of XRP drops to a decimal.
1 parent 6bf64f8 commit 3aa4e55

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/XUMM.NET.SDK/Extensions/CurrencyExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,15 @@ public static string XrpToDropsString(this decimal value)
9696

9797
return Math.Truncate(value * XrpDrops).ToString();
9898
}
99+
100+
/// <summary>
101+
/// Convert XRP Drops to the decimal value
102+
/// </summary>
103+
/// <param name="value">Value in drops</param>
104+
/// <returns>Returns the decimal value of the XRP in drops.</returns>
105+
public static decimal XrpDropsToDecimal(this string value)
106+
{
107+
var decimalValue = value.XrplStringNumberToDecimal();
108+
return decimalValue / XrpDrops;
109+
}
99110
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Text.Json.Serialization;
3+
4+
namespace XUMM.NET.SDK.Models.Payload.XRPL
5+
{
6+
public class XrplPaymentPathSpecification
7+
{
8+
/// <summary>
9+
/// (Optional) If present, this path step represents rippling through the specified address. MUST NOT be provided if this step specifies the currency or issuer fields.
10+
/// </summary>
11+
[JsonPropertyName("account")]
12+
public string? Account { get; set; }
13+
14+
/// <summary>
15+
/// (Optional) If present, this path step represents changing currencies through an order book. The currency specified indicates the new currency. MUST NOT be provided if this step specifies the account field.
16+
/// </summary>
17+
[JsonPropertyName("currency")]
18+
public string? Currency { get; set; }
19+
20+
/// <summary>
21+
/// (Optional) If present, this path step represents changing currencies and this address defines the issuer of the new currency.
22+
/// If omitted in a step with a non-XRP currency, a previous step of the path defines the issuer. If present when currency is omitted,
23+
/// indicates a path step that uses an order book between same-named currencies with different issuers. MUST be omitted if the currency is XRP.
24+
/// MUST NOT be provided if this step specifies the account field.
25+
/// </summary>
26+
[JsonPropertyName("issuer")]
27+
public string? Issuer { get; set; }
28+
29+
/// <summary>
30+
/// DEPRECATED (Optional) An indicator of which other fields are present.
31+
/// </summary>
32+
[Obsolete]
33+
[JsonPropertyName("type")]
34+
public int? Type { get; set; }
35+
36+
/// <summary>
37+
/// DEPRECATED: (Optional) A hexadecimal representation of the type field.
38+
/// </summary>
39+
[Obsolete]
40+
[JsonPropertyName("type_hex")]
41+
public string? TypeHex { get; set; }
42+
}
43+
}

src/XUMM.NET.SDK/Models/Payload/XRPL/XrplPaymentTransaction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public XrplPaymentTransaction()
4747
[JsonPropertyName("InvoiceID")]
4848
public string? InvoiceId { get; set; }
4949

50+
/// <summary>
51+
/// (Optional, auto-fillable) Array of payment paths to be used for this transaction. Must be omitted for XRP-to-XRP transactions.
52+
/// </summary>
53+
[JsonPropertyName("Paths")]
54+
public XrplPaymentPathSpecification[][]? Paths { get; set; }
55+
5056
/// <summary>
5157
/// The amount of currency to deliver. For non-XRP amounts, the nested field names MUST be lower-case. If the
5258
/// tfPartialPayment flag is set, deliver up to this amount instead.

0 commit comments

Comments
 (0)