Skip to content

Commit b648893

Browse files
committed
Only register lightning address if available
1 parent d331bc5 commit b648893

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

wallets/client/protocols/spark.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ export async function testSendPayment ({ mnemonic }, { signal }) {
2828
paymentMethod: { type: 'sparkAddress' }
2929
})
3030

31-
// check and register lightning address here so we can test it in the next step
31+
// check and register lightning address here
32+
// if we haven't already so we can test it in the next step
3233
// https://sdk-doc-spark.breez.technology/guide/receive_lnurl_pay.html
3334
const username = getUsername(sparkAddress)
3435

35-
// TODO(spark): don't check lightning address again if we already registered it
3636
const available = await sdk.checkLightningAddressAvailable({ username })
37-
if (!available) {
38-
// TODO(spark): better error message for user? but this should never happen with randomly generated mnemonics, right?
39-
throw new WalletValidationError('lightning address unavailable')
37+
if (available) {
38+
await sdk.registerLightningAddress({ username, description: 'Running Spark SDK' })
4039
}
41-
await sdk.registerLightningAddress({ username, description: 'Running Spark SDK' })
4240

4341
sdk.disconnect()
4442

0 commit comments

Comments
 (0)