Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decimal field in InvoiceCurrency #44

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions uma/protocol/invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type InvoiceCurrency struct {

// Symbol is the symbol of the currency (eg. $ for USD).
Symbol string `tlv:"2"`

// Decimals is the number of digits after the decimal point for display on the sender side
Decimals uint8 `tlv:"3"`
}

func (c *InvoiceCurrency) MarshalTLV() ([]byte, error) {
Expand Down
9 changes: 5 additions & 4 deletions uma/test/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ func TestUMAInvoiceTLVAndBech32(t *testing.T) {
InvoiceUUID: "c7c07fec-cf00-431c-916f-6c13fc4b69f9",
Amount: 1000,
ReceivingCurrency: umaprotocol.InvoiceCurrency{
Code: "USD",
Name: "US Dollar",
Symbol: "$",
Code: "USD",
Name: "US Dollar",
Symbol: "$",
Decimals: 2,
},
Expiration: 1000000,
IsSubjectToTravelRule: true,
Expand Down Expand Up @@ -308,7 +309,7 @@ func TestUMAInvoiceTLVAndBech32(t *testing.T) {

bech32String, err := invoice2.ToBech32String()
require.NoError(t, err)
require.Equal(t, "uma1qqxzgen0daqxyctj9e3k7mgpy33nwcesxanx2cedvdnrqvpdxsenzced8ycnve3dxe3nzvmxvv6xyd3evcusypp3xqcrqqcnqqp4256yqyy425eqg3hkcmrpwgpqzfqyqucnqvpsxqcrqpgpqyrpkcm0d4cxc6tpde3k2w3393jk6ctfdsarqtrwv9kk2w3squpnqt3npvy9v32jf9ryj32ypswxsar5wpen5te0v4uxzmtsd3jjucm0d5hkxctvd33xzcmtvsyhx6t8deshgatjv5sjy5ff", bech32String)
require.Equal(t, "uma1qqxzgen0daqxyctj9e3k7mgpy33nwcesxanx2cedvdnrqvpdxsenzced8ycnve3dxe3nzvmxvv6xyd3evcusypp3xqcrqqckqqp4256yqyy425eqg3hkcmrpwgpqzfqrqyeqgpe3xqcrqvpsxqzszqgxrd3k7mtsd35kzmnrv5arztr9d4skjmp6xqkxuctdv5arqpcrxqhrxzcg2ez4yj2xf9z5grqudp68gurn8ghj7etcv9khqmr99e3k7mf0vdskcmrzv93kkeqfwd5kwmnpw36hyegy0tgay", bech32String)

invoice3, err := umaprotocol.FromBech32String(bech32String)
require.NoError(t, err)
Expand Down
7 changes: 4 additions & 3 deletions uma/test/uma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,10 @@ func TestUMAInvoice(t *testing.T) {
"[email protected]",
100000,
umaprotocol.InvoiceCurrency{
Code: "USD",
Name: "US Dollar",
Symbol: "$",
Code: "USD",
Name: "US Dollar",
Symbol: "$",
Decimals: 2,
},
1721081249,
"https://vasp2.com/api/lnurl/payreq/$foo",
Expand Down
Loading