pull down to refresh

Ideating on this a bit since it's becoming a common request... wanted to run this possible extension by you...

CLINK debits does seem like the obvious place for balance info, but there's a catch...

CLINK debit connections don't necessarily have a balance of their own since debit requests can be either manually approved or have rolling auto-approved budgets that can reset based on time.

We could expose the remaining CLINK Debit budget as something like available_sats, either as added payload with each successful payment response, to a poll, or both.

Two edgecases with that for you:

  • If a user has it set to manual approval, available_sats would show 0, and SN would have to try anyway expecting the user approves the request manually.
    • Potential mitigation here is instead of showing 0 we flag it as either manual or exhausted
  • If a user has it set to auto approve, but blows their budget, the last availabe_sats you see in a success response may be out of date.
    • Mitigation would be to re-poll for available_sats if the amount is lesser than the forthcoming request.
      • Users using SN on multiple devices could throw this amount off too, so might need a re-poll anyway unless the available_sats state is cached to cross clients by SN's service level storage

Beyond that, a non-CLINK way, would be the SN Client just using the full ShockWallet RPC and becoming another interface for Lightning.Pub. That could get a little heavy on your end given it's nsec based keyring, but does open an interesting design surface.

35 sats \ 1 reply \ @k00b 21 Jul

We implement getBalance as an independent periodic poll to the wallet/node provider/endpoint. Supporting other patterns is not something we'll likely pursue anytime soon. Regardless, at worst, a wallet/provider without a getBalance-like RPC to poll will just show balance unavailable. Not ideal, but also not that bad either.

  • If a user has it set to manual approval, available_sats would show 0, and SN would have to try anyway expecting the user approves the request manually.

We don't gate payment attempts by balance showing a sufficient amount. We attempt payment then process responses very carefully and conservatively (ie to not invite double pays). Balances are for human eyeballs only so that customers can determine in advance if a payment will succeed or not.

reply

Sounds good, we can just add a shape then for available_sats without an actual debit that you can use to populate UI when you fire getBalance

reply