I am working on a script to automate opening/closing channels in an Electrum wallet and my head is spinning trying to figure out how much Electrum considers reasonable to spend when opening a channel. I have dug through the code to the extent I can to figure out how this works.
There's some things I need to know to calculate the channel opening amount:
- How much electrum keeps in the channel reserve in the channel (looks to be the larger of 1% of channel size or the dust limit)
- What the dust limit is (546 is the highest hardcoded value I could see in bitcoin.py)
- Minimum channel size (appears to be 60,000 sats but can be configured to a lower 20,000 sats if you have an electrum daemon like self.electrum.lnutil.MIN_FUNDING_SAT)
What I can't figure out is:
- How much electrum insists on having in on-chain funds to make the channel, cover fees, and have enough left over (aside from the channel amount itself). Testing on some wallets, it seems to be a little over 10,000 sats. Is this in total? Per channel? I don't know. Is there a way to lower this number? 10,000 sats seems a little high, we haven't had a tx fee like that in years. Given the large size, I am assuming this isn't dynamically calculated from the fee rate but I could be wrong.
- Is there some way to modify these values including MIN_FUNDING_SAT via the JSON-RPC API? Or otherwise? The only way I've found to modify them so far is to run electrum directly as a python library, but I'd rather not have to do that.
I am also confused by this. I have a channel and in the channel info window I see :
Local balance: 200,000 sats
Remote balance: 0 sats
Can send: 191,512 sat
Local reserve: 2000 sat
Remote reserve: 2000 sat
Local dust limit: 546 sat
Remote dust limit: 354 sat
No matter how I combine these numbers, I can't seem to get the 191,512 sat number shown in the "Can send" field. What am I missing? How do I calculate that number? It doesn't appear in list_channels() when using the console/API.
Thank you anybody who can help