- Assume I created address#1 and address#2 under same wallet. How to transfer funds? Should I open a channel to do that?
You seem to confuse bitcoin addresses and lightning network ids. If you have a lightning node you have a node pubkey
(called the node_id
). Of course there is a corresponding private key / secret. From this you can derive bitcoin addresses in your bitcoin wallet that is attached to the lightning node. Those addresses are used to fund your node or to claim funds from channels that for some reason hit the chain.
- Is it possible to send funds from address in lightning network to simple bitcoin address?
As from the first part of the answer. once the channels hit the chain they are in the bitcon network and can be send to any other bitcoin address. There are exchange
-services that allow and atomic on/off-chain swap. means you pay in invoice on lightning so that onchain bitcoin arrive at some address and vice versa.
- Are there any ways to choose sender address (in case users created thousands different addresses and user wants to send satoshis on behalf of himself)
If I understand your question correctly I would say it is possible. In the current setting people who offer a custodial wallet service seem to sign all invoices with the node ID of the lightningnode that is powering the custodial wallet. There speaks nothing against giving every user their own secrete and their own node id / bitcoin keys. You could even have virtual payment channels between the exchanges lightning network node that you maintain an run and between the "virtual" nodes of your customers which are basically private and suggest in the routing hints of the invoice to use the lightning node of your service.
In order to do these kinds of tricks you might want to switch to c-lightning as with their plugin infrastructure have an API that allow easier customization for such features.