-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Hi, I am running breez-sdk-spark v0.2.1 and I noticed that sometimes, when I use the lightning address registered with the seed to fund the wallet, the balance does not increase, see video:
2025-09-29.22-13-47.mp4
bolt11: lnbc1u1p5d469qpp5qy80day0z5qley6dusrs4ea8mhfehzpetl93us2dcchcrnxynsvssp5rntevgxke2dm0ltt9s932y4ypf9wl85e0t8mdjcw36s8w65c8n2sxq9z0rgqnp4qvyndeaqzman7h898jxm98dzkm0mlrsx36s93smrur7h0azyyuxc5rzjq25carzepgd4vqsyn44jrk85ezrpju92xyrk9apw4cdjh6yrwt5jgqqqqrt49lmtcqqqqqqqqqqq86qq9qrzjqwghf7zxvfkxq5a6sr65g0gdkv768p83mhsnt0msszapamzx2qvuxqqqqrt49lmtcqqqqqqqqqqq86qq9qcqzpghp568tju29a20nhd5gr8z7sqf5umsecw5xxq8ahvanlqy5w0v9rzd8s9qyyssqh8pfun99tjdtz743mcpttp8qgt7zy5ezms9rwa6nva2euheekwey26fkqrk4ygm09axy7sgufj0eav53cv8hx2r2cjkqx9tyl9pvpusqdm57qd`
payment hash: 010ef6f48f1501fc934de4070ae7a7ddd39b88395fcb1e414dc62f81ccc49c19
preimage: b880aeb9b57e58ecaf5808936686f99cfbc101b4612770ca160c5a42706c824d
(As you can see, I also encountered a RuntimeError: unreachable error. I got this error for the first time since I used initLogging, so maybe related, maybe not.)
Here is the code I am running in this video. When I click 'next' in the first form, testSendPayment is called:
import init, { initLogging, defaultConfig, connect } from '@breeztech/breez-sdk-spark'
export const name = 'BREEZ_SPARK'
class SdkLogger {
log = (l) => {
console.log(`[${l.level}]: ${l.line}`)
}
}
async function withSdk (mnemonic, cb) {
await init()
initLogging(new SdkLogger())
const config = defaultConfig('mainnet')
// this API key should be kept a secret on a best effort basis
config.apiKey = process.env.NEXT_PUBLIC_BREEZ_SDK_API_KEY
config.lnurlDomain = 'breez.tips'
const sdk = await connect({
config,
seed: { type: 'mnemonic', mnemonic, passphrase: undefined },
// the SDK will create a IndexedDB with this name to store data
storageDir: 'breez-sdk-spark'
})
const info = await sdk.getInfo({})
console.log(info)
const result = await cb(sdk)
sdk.disconnect()
return result
}
export async function testSendPayment ({ mnemonic }, { signal }) {
return await withSdk(
mnemonic,
async sdk => {
const { paymentRequest: sparkAddress } = await sdk.receivePayment({
// this will always return the same spark address for the same seed
paymentMethod: { type: 'sparkAddress' }
})
const username = getUsername(sparkAddress)
const available = await sdk.checkLightningAddressAvailable({ username })
if (available) {
await sdk.registerLightningAddress({ username, description: 'Running Spark SDK' })
}
return { username }
}
)
}
function getIdentityPublicKey (sparkAddress) {
const decoded = bech32m.decode(sparkAddress)
const pubkey = Buffer.from(bech32m.fromWords(decoded.words)).toString('hex').slice(4)
return pubkey
}
function getUsername (sparkAddress) {
const identityPublicKey = getIdentityPublicKey(sparkAddress)
// max lnurl username length is 64 characters
// https://github.com/breez/spark-sdk/blob/71b8cb097d2bc846be427599b1bf44eae897786f/crates/breez-sdk/lnurl/src/routes.rs#L326
return identityPublicKey.slice(0, 64)
}The code can also be found here: stackernews/stacker.news#2575 (wallets/client/protocols/breezSpark.js)
See video for logs.