Skip to content

Commit

Permalink
Merge release/lightspark-sdk-v0.15.0 into main (#187)
Browse files Browse the repository at this point in the history
* lnurlp fallback

* annotation and tests

* fallback sender side

* fix serialization

* unused import

* comments

* fixes

* Try to fix docs publish job my running on main

* [gha] Use environment for doc-publish

* Fix sender vasp utxo callback

* Switch to a full 64bit nonce

* Use json for parsing in demo vasp (#163)

* Update the demo VASP's SDK version to 0.8.0

* Update the demo VASP's SDK version to 0.8.1

* Accept gzip responses, compress request with deflate (#172)

Install `ContentEncoding` plugin to handle gzip responses. Compress
requests larger than 1K using `Deflater`. Change
`addSigningDataIfNeeded()` to return serialised bytes so that we only
serialise once.

* Regenerate SDK (#173)

* Regenerate SDK

* no op vls

* Update macos environment version (#175)

* Uma data visibility (#174)

* fix typo (#176)

* encode hex (#177)

* Bump lightspark-sdk to version 0.14.0

* Load signing key

* Revert "Merge release/lightspark-sdk-v0.14.0 into develop" (#181)

* Bump lightspark-sdk to version 0.14.0

* update readme (#184)

* Update invoice creator (#185)

* Bump lightspark-sdk to version 0.15.0

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: shreyav <[email protected]>
Co-authored-by: Jeremy Klein <[email protected]>
Co-authored-by: Michael Gorven <[email protected]>
Co-authored-by: Michael Gorven <[email protected]>
Co-authored-by: runner <[email protected]>
Co-authored-by: runner <[email protected]>
Co-authored-by: runner <[email protected]>
  • Loading branch information
8 people authored Jul 16, 2024
1 parent 104c0c5 commit 9e0ceae
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 11 deletions.
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ For example, to cut a release branch for version `1.0.0` of the `wallet-sdk` mod
the following from the `develop` branch:

```bash
git checkout -b release/wallet-sdk-1.0.0
git push -u origin release/wallet-sdk-1.0.0
git checkout -b release/wallet-sdk-v1.0.0
git push -u origin release/wallet-sdk-v1.0.0
```

Alternatively, you can create the new branch from the github UI.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ktlint = "11.3.1"
ktor = "2.3.7"
lightsparkCore = "0.6.0"
lightsparkCrypto = "0.6.0"
uma = "1.1.1"
uma = "1.2.1"
mavenPublish = "0.25.2"
mockitoCore = "5.5.0"
taskTree = "2.1.1"
Expand Down
4 changes: 2 additions & 2 deletions lightspark-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Start by installing the SDK from maven:
**build.gradle:**
```groovy
dependencies {
implementation "com.lightspark:lightspark-sdk:0.14.0"
implementation "com.lightspark:lightspark-sdk:0.15.0"
}
```

or with **build.gradle.kts:**
```kotlin
dependencies {
implementation("com.lightspark:lightspark-sdk:0.14.0")
implementation("com.lightspark:lightspark-sdk:0.15.0")
}
```

Expand Down
2 changes: 1 addition & 1 deletion lightspark-sdk/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GROUP=com.lightspark
POM_ARTIFACT_ID=lightspark-sdk
# Don't bump this manually. Run `scripts/versions.main.kt <new_version>` to bump the version instead.
VERSION_NAME=0.14.0
VERSION_NAME=0.15.0

POM_DESCRIPTION=The Lightspark API SDK for Kotlin and Java.
POM_INCEPTION_YEAR=2023
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,54 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.future.future
import me.uma.UmaInvoiceCreator

class LightsparkClientUmaInvoiceCreator(
/**
* Creates UMA invoices using the Lightspark client.
*
* @constructor Creates an instance of [LightsparkClientUmaInvoiceCreator].
*
* @param client The [LightsparkCoroutinesClient] used to create invoices.
* @param nodeId The ID of the node for which to create the invoice.
* @param expirySecs The number of seconds before the invoice expires.
* @param enableUmaAnalytics A flag indicating whether UMA analytics should be enabled. If `true`,
* the receiver identifier will be hashed using a monthly-rotated seed and used for anonymized
* analysis.
* @param signingPrivateKey Optional, the receiver's signing private key. Used to hash the receiver
* identifier if UMA analytics is enabled.
*/
class LightsparkClientUmaInvoiceCreator @JvmOverloads constructor(
private val client: LightsparkCoroutinesClient,
private val nodeId: String,
private val expirySecs: Int,
private val enableUmaAnalytics: Boolean = false,
private val signingPrivateKey: ByteArray? = null,
) : UmaInvoiceCreator {
private val coroutineScope = CoroutineScope(Dispatchers.IO)

constructor(apiClientId: String, apiClientSecret: String, nodeId: String, expirySecs: Int) : this(
@JvmOverloads
constructor(
apiClientId: String,
apiClientSecret: String,
nodeId: String,
expirySecs: Int,
enableUmaAnalytics: Boolean = false,
signingPrivateKey: ByteArray? = null,
) : this(
LightsparkCoroutinesClient(
ClientConfig(
authProvider = AccountApiTokenAuthProvider(apiClientId, apiClientSecret),
),
),
nodeId,
expirySecs,
enableUmaAnalytics,
signingPrivateKey,
)

override fun createUmaInvoice(amountMsats: Long, metadata: String) = coroutineScope.future {
client.createUmaInvoice(nodeId, amountMsats, metadata, expirySecs).data.encodedPaymentRequest
override fun createUmaInvoice(amountMsats: Long, metadata: String, receiverIdentifier: String?) = coroutineScope.future {
if (enableUmaAnalytics && signingPrivateKey != null) {
client.createUmaInvoice(nodeId, amountMsats, metadata, expirySecs, signingPrivateKey, receiverIdentifier)
} else {
client.createUmaInvoice(nodeId, amountMsats, metadata, expirySecs)
}.data.encodedPaymentRequest
}
}
8 changes: 7 additions & 1 deletion umaserverdemo/src/main/kotlin/com/lightspark/Vasp2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,13 @@ class Vasp2(
val response = try {
uma.getPayReqResponse(
query = request,
invoiceCreator = LightsparkClientUmaInvoiceCreator(client, config.nodeID, expirySecs),
invoiceCreator = LightsparkClientUmaInvoiceCreator(
client = client,
nodeId = config.nodeID,
expirySecs = expirySecs,
enableUmaAnalytics = true,
signingPrivateKey = config.umaSigningPrivKey,
),
metadata = getEncodedMetadata(),
receivingCurrencyCode = receivingCurrency.code,
receivingCurrencyDecimals = receivingCurrency.decimals,
Expand Down

0 comments on commit 9e0ceae

Please sign in to comment.