Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"easier" fee output to be parsed by external scripts #226

Open
GordianLN opened this issue Oct 16, 2021 · 2 comments
Open

"easier" fee output to be parsed by external scripts #226

GordianLN opened this issue Oct 16, 2021 · 2 comments

Comments

@GordianLN
Copy link

GordianLN commented Oct 16, 2021

This is the current output of a successful rebalance:

Successful route:
17142485788721152 to 5-0221b5a1c10bc1ae                 (free, we usually charge 499ppm)
16104546812166144 to HelloJessica                       (fee   14,621 mSAT,   514ppm)
16104546812100608 to 4-0287a94a1c9be067                 (fee    1,028 mSAT,    36ppm)
17185366742269953 to Links🗡️                             (fee    1,028 mSAT,    36ppm)

In case I am compiling a database with all rebalance expenses, I would have to build a boring regex to extract the trunc of each "fee" and then sum them, with the risk of the output layout changing in the future for any reason.
Would it be possible to add a final line (literally last line of the output, maybe enabled with a switch on the commandline) where the parameters are reported in json format? Like "inchannel"=>"XXXXXXX", "outchannel"=>"YYYYYYYYY", "amount" => "ZZZZZZ", "fee"=>"FFFFFFFF" plus any other thing that might come to mind?

@C-Otto
Copy link
Owner

C-Otto commented Oct 16, 2021

I could do that, you could do that yourself, and I certainly see the point of this. But why don't you ask lnd about the details? The output fix is only shown once, whereas lnd keeps the underlying information in a database you can access at any time.

lnd already gives you access to all invoices and payments via lncli listinvoices and lncli listpayments. Rebalances are payments to an invoice you created yourself, and the r_hash of your invoice needs to match the payment_hash of your payment.

The payment details provide information about the route in htlcs.route.hops, where the first chan_id is your "outchannel", and the last chan_id is your "inchannel". You could check the invoice's memo: "Rebalance of channel with ID X" indicates that you explicitly invoked it for channel X, so that you can infer if it was a -f invocation for the first hop, or rather a -t invocation for the last hop - in case this detail is of any interest to you.

Last but not least, the fee is in htlcs.route.total_fees_msat, and the amount is in htlcs.route.total_amt_msat. You even get information about the fees/amounts sent along the route, i.e. you can see how much nodes get paid for your rebalance transactions.

@GordianLN
Copy link
Author

Thanks for the superfast reply! It is a trove of information that alas goes beyond my skill level, as my experience is only with PHP, basically I'd rather parse the stdout instead as at least that's something I know how to do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants