C-Otto / rebalance-lnd

A script that can be used to balance lightning channels of a lnd node
MIT License
343 stars 82 forks source link

adding --ignore-missed-fee argument #337

Closed zapomatic closed 3 months ago

zapomatic commented 3 months ago

Testing now. Just sending over PR for review. If you don't want to merge this, at least it will be linked as a note for issue #217 cheers.

C-Otto commented 3 months ago

That's actually quite neat. Let me know if it works as expected!

zapomatic commented 3 months ago

Adjusted docs and handling for fees_too_high function as well. Now also omitting log showing missed fee. Sample run without flag:

Sending 10,000 satoshis from channel 914049305013780490 with 1sats.com⚡️lsp.flashsats.xyz.

Trying route #1 (fee 560 mSAT, 55ppm)
914049305013780490 to 1sats.com⚡️lsp.flashsats.xyz      (free, we usually charge 899ppm)
887499397714214913 to OneKey                            (fee      560 mSAT,    56ppm)
907729312178634768 to Zap-O-Matic                       (fee        0 mSAT,     0ppm)

Increased outbound liquidity on OneKey (1,233ppm) by 10,000 sat
Increased inbound liquidity on 1sats.com⚡️lsp.flashsats.xyz (899ppm configured for outbound)
Fee: 0 sats (560 mSAT, 55ppm)

Successful route:
914049305013780490 to 1sats.com⚡️lsp.flashsats.xyz      (free, we usually charge 899ppm)
887499397714214913 to OneKey                            (fee      560 mSAT,    56ppm)
907729312178634768 to Zap-O-Matic                       (fee        0 mSAT,     0ppm)
    12,330 mSAT: expected future fee income for inbound channel (with OneKey)
-      560 mSAT: rebalance transaction fees
-    8,990 mSAT: missing out on future fees for outbound channel (with 1sats.com⚡️lsp.flashsats.xyz)
=    2,780 mSAT: potential profit!

and running with --ignore-missed-fee

Ignoring missed fee!
Sending 10,000 satoshis from channel 914049305013780490 with 1sats.com⚡️lsp.flashsats.xyz.

Trying route #1 (fee 560 mSAT, 55ppm)
914049305013780490 to 1sats.com⚡️lsp.flashsats.xyz      (free, we usually charge 899ppm)
887499397714214913 to OneKey                            (fee      560 mSAT,    56ppm)
907729312178634768 to Zap-O-Matic                       (fee        0 mSAT,     0ppm)

Increased outbound liquidity on OneKey (1,233ppm) by 10,000 sat
Increased inbound liquidity on 1sats.com⚡️lsp.flashsats.xyz (899ppm configured for outbound)
Fee: 0 sats (560 mSAT, 55ppm)

Successful route:
914049305013780490 to 1sats.com⚡️lsp.flashsats.xyz      (free, we usually charge 899ppm)
887499397714214913 to OneKey                            (fee      560 mSAT,    56ppm)
907729312178634768 to Zap-O-Matic                       (fee        0 mSAT,     0ppm)
    12,330 mSAT: expected future fee income for inbound channel (with OneKey)
-      560 mSAT: rebalance transaction fees
=   11,770 mSAT: potential profit!

This looks like a good way to possibly push some sats around after initially opening a channel and not yet finding the right fee point as it slowly drops from 2000 to possibly 0 :)

C-Otto commented 3 months ago

I'm not a big fan of adding more special cases into the code, and "Ignoring missed fee!" might raise more questions - but I also see the advantage of having this feature. Thanks a lot for the contribution!