lnbits / watchonly

MIT License
1 stars 2 forks source link

Get Next Unused Address #13

Open dadofsambonzuki opened 5 months ago

dadofsambonzuki commented 5 months ago

We (BTC Map) are currently using api_fresh_address_watchonly to generate new bitcoin addresses for donations.

We are currently getting large gaps between addresses as we get a new address on each page load of the support us page.

It would be good to get the next unused address instead via a getNextUnusedAddress call.

motorina0 commented 5 months ago

Just a short background on how the onchain extension works:

So if you are using the API to get the Next Receive address it will work fine, but if the front-end is not used to check the balance then the back-end cannot know which addresses have funds and which not.

motorina0 commented 5 months ago

Also you might want to check the TipJar extension. The TipJar via Satspay will update the balance of the address (back-end call)

secondl1ght commented 5 months ago

I have some questions about this:

  1. Why does this use the mempool.space API instead of the bitcoin core node that the lightning node is connected to in order to query the address balances?
  2. Are you saying that the TipJar extension will achieve the desired behaviour of only returning the next unused address and that we should use it instead of this extension?
motorina0 commented 5 months ago
  1. The user can have a LSP as a funding source, so it has no access to either a Lighting Node or a Bitcoin Node. The mempool.space API is used in order to quickly allow users to set-up their wallet without requiring complex configurations.

  2. TipJar generates an address at the moment the user wants to make a donation. On the back-end the server will watch for funds reaching this address. You can give it a spin on the demo server. It works for both Lightning and Onchain donations.