Skip to content

Commit

Permalink
Merge pull request #77 from lightsparkdev/feat/newLUD21
Browse files Browse the repository at this point in the history
Switch to the new LUD-21 spec
  • Loading branch information
jklein24 authored Mar 1, 2024
2 parents 7387e4b + 09f9832 commit 691f29e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/uma-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/google/uuid v1.3.1
github.com/lightsparkdev/go-sdk v0.10.0
// Run go get github.com/uma-universal-money-address/uma-go-sdk@release/v1.0 to update:
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240223211106-661bd445f2fd
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240301061227-c82cc51dc509
)

require (
Expand Down
2 changes: 2 additions & 0 deletions examples/uma-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240223210406-edde99
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240223210406-edde992528b1/go.mod h1:OimSKjRNT7Wm2lA0Q9C0DmxsMvqBickucUjtQmB8Cl8=
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240223211106-661bd445f2fd h1:aqqu5emV4DpEjBBqaAu1vDxVpYE7ejnL/JqEDCsVhWs=
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240223211106-661bd445f2fd/go.mod h1:OimSKjRNT7Wm2lA0Q9C0DmxsMvqBickucUjtQmB8Cl8=
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240301061227-c82cc51dc509 h1:rfS4bg6ov5V602mikSQTCU3FcWDjCNrViW+ft5Q3Zb8=
github.com/uma-universal-money-address/uma-go-sdk v0.6.3-0.20240301061227-c82cc51dc509/go.mod h1:OimSKjRNT7Wm2lA0Q9C0DmxsMvqBickucUjtQmB8Cl8=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI=
Expand Down
16 changes: 10 additions & 6 deletions examples/uma-server/vasp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (v *Vasp1) handleClientPayReq(context *gin.Context) {
})
return
}
isAmountInMsats := strings.ToLower(context.Query("isAmountInMsats")) == "true"
vasp2EncryptionPubKey, err := vasp2PubKeys.EncryptionPubKey()
if err != nil {
context.JSON(http.StatusInternalServerError, gin.H{
Expand All @@ -308,6 +309,7 @@ func (v *Vasp1) handleClientPayReq(context *gin.Context) {
vasp2EncryptionPubKey,
umaSigningPrivateKey,
currencyCode,
!isAmountInMsats,
amountInt64,
payerInfo.Identifier,
payerInfo.Name,
Expand Down Expand Up @@ -402,12 +404,14 @@ func (v *Vasp1) handleClientPayReq(context *gin.Context) {
)

context.JSON(http.StatusOK, gin.H{
"encodedInvoice": payreqResponse.EncodedInvoice,
"callbackUuid": callbackUuid,
"amount": invoiceData.Amount,
"conversionRate": payreqResponse.PaymentInfo.Multiplier,
"currencyCode": payreqResponse.PaymentInfo.CurrencyCode,
"expiresAt": invoiceData.ExpiresAt.Unix(),
"encodedInvoice": payreqResponse.EncodedInvoice,
"callbackUuid": callbackUuid,
"amountMsats": invoiceData.Amount,
"amountReceivingCurrency": payreqResponse.PaymentInfo.Amount,
"conversionRate": payreqResponse.PaymentInfo.Multiplier,
"currencyCode": payreqResponse.PaymentInfo.CurrencyCode,
"exchangeFeesMsats": payreqResponse.PaymentInfo.ExchangeFeesMillisatoshi,
"expiresAt": invoiceData.ExpiresAt.Unix(),
})
}

Expand Down
22 changes: 13 additions & 9 deletions examples/uma-server/vasp2.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,22 @@ func (v *Vasp2) parseUmaQueryData(context *gin.Context) ([]byte, bool) {
Name: "US Dollars",
Symbol: "$",
MillisatoshiPerUnit: MillisatoshiPerUsd,
MinSendable: 1,
MaxSendable: 1_000,
Decimals: 2,
Convertible: uma.ConvertibleCurrency{
MinSendable: 1,
MaxSendable: 1_000,
},
Decimals: 2,
},
{
Code: "SAT",
Name: "Satoshis",
Symbol: "SAT",
MillisatoshiPerUnit: 1000,
MinSendable: 1,
MaxSendable: 100_000_000,
Decimals: 0,
Convertible: uma.ConvertibleCurrency{
MinSendable: 1,
MaxSendable: 100_000_000,
},
Decimals: 0,
},
},
uma.KycStatusVerified,
Expand Down Expand Up @@ -370,7 +374,7 @@ func (v *Vasp2) handleUmaPayreq(context *gin.Context) {
}

conversionRate := 1000.0
if request.CurrencyCode == "USD" {
if request.ReceivingCurrencyCode == "USD" {
conversionRate = MillisatoshiPerUsd
}
exchangeFees := int64(100_000)
Expand All @@ -394,7 +398,7 @@ func (v *Vasp2) handleUmaPayreq(context *gin.Context) {
}

decimals := 0
if request.CurrencyCode == "USD" {
if request.ReceivingCurrencyCode == "USD" {
decimals = 2
}
receiverUma := "$" + v.config.Username + "@" + v.getVaspDomain(context)
Expand All @@ -411,7 +415,7 @@ func (v *Vasp2) handleUmaPayreq(context *gin.Context) {
request,
invoiceCreator,
metadata,
request.CurrencyCode,
request.ReceivingCurrencyCode,
decimals,
conversionRate,
exchangeFees,
Expand Down

0 comments on commit 691f29e

Please sign in to comment.