-
Notifications
You must be signed in to change notification settings - Fork 3
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
Mdavis/kt uma invoice #54
Conversation
uma-sdk/src/commonMain/kotlin/me/uma/protocol/CounterPartyData.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely seems to be heading down the right path!
uma-sdk/src/commonMain/kotlin/me/uma/protocol/CounterPartyData.kt
Outdated
Show resolved
Hide resolved
val encoded = serialFormat.encodeToString(invoiceCurrency) | ||
println(encoded) | ||
println("decoded object ${serialFormat.decodeFromString<InvoiceCurrency>(encoded)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to pull out test vectors from some of the tests that @zhenlu wrote for other sdks just as a sanity check that they spit out the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/uma-universal-money-address/uma-go-sdk/blob/main/uma/test/protocol_test.go#L273
There's one trick part is that to serialize integers, different language might make a different size integer type so it won't fully align. (I had this problem in python)
} | ||
|
||
|
||
fun ByteArray.getNumber(offset: Int): Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the offset here meant to be a byte offset or value index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a starting index of the read value in the byte array. most of the methods for accessing byte arrays refer to this as offset, but here's it's being used as the starting index of the value being read . I'm fine switching the parameter names to "valueIndex" for readability if that's preferred
fun toBech32(): String = Bech32.encode(Bech32.Encoding.BECH32, UMA_BECH32_PREFIX, this.toTLV()) | ||
|
||
companion object { | ||
fun fromTLV(bytes: ByteArray): Invoice { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a non-optional field is not presented, we should throw an error here.
… remove bitcoinj dependency
@@ -43,7 +43,7 @@ class UmaTests { | |||
validateInvoice(invoice, result) | |||
} | |||
|
|||
@Ignore("bech32 not complete") | |||
// @Ignore("bech32 not complete") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove when you're ready.
.idea/other.xml
Outdated
@@ -0,0 +1,252 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this file, assuming we don't want it in the repo
Add UMA Invoice for kotlin, complete w/ bech32 encoding
https://linear.app/lightsparkdev/issue/LIG-6113/[uma-invoice]-kotlin-sdk-implementation
design:
This PR creates Invoice & InvoiceCurrency classes, which are serializable to TVL format
This is accomplished with custom serializers that convert the objects to ByteArrays, recursively encoding other TLV or byte codeable members.