Skip to content

Commit

Permalink
Merge pull request #9 from uma-universal-money-address/feat/payrespde…
Browse files Browse the repository at this point in the history
…cimals

Add the decimals field to payreq paymentinfo for convenience
  • Loading branch information
jklein24 authored Dec 21, 2023
2 parents c927021 + 6a893ab commit 03f56a5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions javatest/src/test/java/me/uma/javatest/UmaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void testGetPayReqResponseSync() throws Exception {
new TestUmaInvoiceCreator(),
"metadata",
"USD",
2,
12345L,
0L,
List.of(),
Expand All @@ -134,6 +135,7 @@ public void testGetPayReqResponseFuture() throws Exception {
new TestUmaInvoiceCreator(),
"metadata",
"USD",
2,
12345L,
0L,
List.of(),
Expand Down
15 changes: 15 additions & 0 deletions uma-sdk/src/commonMain/kotlin/me/uma/UmaProtocolHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ class UmaProtocolHelper @JvmOverloads constructor(
* @param invoiceCreator The [UmaInvoiceCreator] that will be used to create the invoice.
* @param metadata The metadata that will be added to the invoice's metadata hash field.
* @param currencyCode The code of the currency that the receiver will receive for this payment.
* @param currencyDecimals The number of digits after the decimal point for the receiving currency. For example,
* USD has 2 decimal places. This should align with the `decimals` field returned for the chosen currency in the
* LNURLP response.
* @param conversionRate The conversion rate. It is the numer of milli-satoshis per the smallest unit of the
* specified currency (for example: cents in USD). This rate is committed to by the receiving VASP until the
* invoice expires.
Expand All @@ -377,6 +380,7 @@ class UmaProtocolHelper @JvmOverloads constructor(
invoiceCreator: UmaInvoiceCreator,
metadata: String,
currencyCode: String,
currencyDecimals: Int,
conversionRate: Double,
receiverFeesMillisats: Long,
receiverChannelUtxos: List<String>,
Expand All @@ -388,6 +392,7 @@ class UmaProtocolHelper @JvmOverloads constructor(
invoiceCreator,
metadata,
currencyCode,
currencyDecimals,
conversionRate,
receiverFeesMillisats,
receiverChannelUtxos,
Expand All @@ -406,6 +411,9 @@ class UmaProtocolHelper @JvmOverloads constructor(
* @param invoiceCreator The [UmaInvoiceCreator] that will be used to create the invoice.
* @param metadata The metadata that will be added to the invoice's metadata hash field.
* @param currencyCode The code of the currency that the receiver will receive for this payment.
* @param currencyDecimals The number of digits after the decimal point for the receiving currency. For example,
* USD has 2 decimal places. This should align with the `decimals` field returned for the chosen currency in the
* LNURLP response.
* @param conversionRate The conversion rate. It is the number of milli-satoshis per the smallest unit of the
* specified currency (for example: cents in USD). This rate is committed to by the receiving VASP until the
* invoice expires.
Expand All @@ -424,6 +432,7 @@ class UmaProtocolHelper @JvmOverloads constructor(
invoiceCreator: UmaInvoiceCreator,
metadata: String,
currencyCode: String,
currencyDecimals: Int,
conversionRate: Double,
receiverFeesMillisats: Long,
receiverChannelUtxos: List<String>,
Expand All @@ -435,6 +444,7 @@ class UmaProtocolHelper @JvmOverloads constructor(
invoiceCreator,
metadata,
currencyCode,
currencyDecimals,
conversionRate,
receiverFeesMillisats,
receiverChannelUtxos,
Expand All @@ -450,6 +460,9 @@ class UmaProtocolHelper @JvmOverloads constructor(
* @param invoiceCreator The [UmaInvoiceCreator] that will be used to create the invoice.
* @param metadata The metadata that will be added to the invoice's metadata hash field.
* @param currencyCode The code of the currency that the receiver will receive for this payment.
* @param currencyDecimals The number of digits after the decimal point for the receiving currency. For example,
* USD has 2 decimal places. This should align with the `decimals` field returned for the chosen currency in the
* LNURLP response.
* @param conversionRate The conversion rate. It is the numer of milli-satoshis per the smallest unit of the
* specified currency (for example: cents in USD). This rate is committed to by the receiving VASP until the
* invoice expires.
Expand All @@ -468,6 +481,7 @@ class UmaProtocolHelper @JvmOverloads constructor(
invoiceCreator: UmaInvoiceCreator,
metadata: String,
currencyCode: String,
currencyDecimals: Int,
conversionRate: Double,
receiverFeesMillisats: Long,
receiverChannelUtxos: List<String>,
Expand All @@ -489,6 +503,7 @@ class UmaProtocolHelper @JvmOverloads constructor(
),
paymentInfo = PayReqResponsePaymentInfo(
currencyCode = currencyCode,
decimals = currencyDecimals,
multiplier = conversionRate,
exchangeFeesMillisatoshi = receiverFeesMillisats,
),
Expand Down
2 changes: 1 addition & 1 deletion uma-sdk/src/commonMain/kotlin/me/uma/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlinx.serialization.json.encodeToJsonElement
import kotlinx.serialization.json.put

const val MAJOR_VERSION = 0
const val MINOR_VERSION = 2
const val MINOR_VERSION = 3
const val UMA_VERSION_STRING = "$MAJOR_VERSION.$MINOR_VERSION"

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ data class PayReqResponseCompliance(
* The payment info from the receiver.
*
* @property currencyCode The currency code that the receiver will receive for this payment.
* @property decimals Number of digits after the decimal point for the receiving currency. For example, in USD, by
* convention, there are 2 digits for cents - $5.95. In this case, `decimals` would be 2. This should align with
* the currency's `decimals` field in the LNURLP response. It is included here for convenience. See
* [UMAD-04](https://github.com/uma-universal-money-address/protocol/blob/main/umad-04-lnurlp-response.md) for
* details, edge cases, and examples.
* @property multiplier The conversion rate. It is the number of millisatoshis that the receiver will receive for 1
* unit of the specified currency (eg: cents in USD). In this context, this is just for convenience. The conversion
* rate is also baked into the invoice amount itself. Specifically:
Expand All @@ -69,6 +74,7 @@ data class PayReqResponseCompliance(
@Serializable
data class PayReqResponsePaymentInfo(
val currencyCode: String,
val decimals: Int,
val multiplier: Double,
val exchangeFeesMillisatoshi: Long,
)

0 comments on commit 03f56a5

Please sign in to comment.