Skip to content

Commit f2dab0c

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

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

wallets/client/protocols/spark.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import init, { defaultConfig, connect } from '@breeztech/breez-sdk-spark'
2-
import { WalletValidationError } from '@/wallets/client/errors'
32
import { getUsername } from '@/wallets/lib/protocols/spark'
43

54
export const name = 'SPARK'
@@ -28,17 +27,15 @@ export async function testSendPayment ({ mnemonic }, { signal }) {
2827
paymentMethod: { type: 'sparkAddress' }
2928
})
3029

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

35-
// TODO(spark): don't check lightning address again if we already registered it
3635
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')
36+
if (available) {
37+
await sdk.registerLightningAddress({ username, description: 'Running Spark SDK' })
4038
}
41-
await sdk.registerLightningAddress({ username, description: 'Running Spark SDK' })
4239

4340
sdk.disconnect()
4441

0 commit comments

Comments
 (0)