eclair icon indicating copy to clipboard operation
eclair copied to clipboard

RPC: parse BOLT12 invoices and offers

Open rorp opened this issue 1 year ago • 4 comments

This PR adds the ability to parse BOLT12 invoices to parseinvoice RPC call, and introduces parseoffer RPC call, that parses BOLT12 offers.

rorp avatar Mar 28 '24 16:03 rorp

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.00%. Comparing base (c8184b3) to head (6d01eee).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2843      +/-   ##
==========================================
+ Coverage   85.96%   86.00%   +0.03%     
==========================================
  Files         219      219              
  Lines       18441    18442       +1     
  Branches      762      731      -31     
==========================================
+ Hits        15853    15861       +8     
+ Misses       2588     2581       -7     
Files Coverage Δ
...n/scala/fr/acinq/eclair/json/JsonSerializers.scala 96.42% <ø> (ø)
...la/fr/acinq/eclair/payment/send/OfferPayment.scala 72.91% <100.00%> (+0.57%) :arrow_up:

... and 5 files with indirect coverage changes

codecov-commenter avatar Mar 29 '24 09:03 codecov-commenter

You seem to be doing more than just adding a parseoffer API in this PR, you're also adding support for Bolt 12 invoices which is arguably not a good idea...

Not at all. Only parseinvoice was changed to support Bolt 12 invoices. The changes in other RPCs were made just to prevent MatchError exceptions and avoid compiler errors.

rorp avatar Mar 29 '24 14:03 rorp

Only parseinvoice was changed to support Bolt 12 invoices.

This is what threw me off, I don't think we should do this. But I may be wrong, @thomash-acinq do you think this would be useful?

t-bast avatar Mar 29 '24 16:03 t-bast

If there was an explicit decision to hide Bolt 12 invoices from the user (I didn't realize it was removed from the spec), then we shouldn't expose them.

If it's only for debugging purposes, what I usually do is run this test:

test("show invoice"){
  val encodedInvoice = "lni1qqgds4gw..."
  val invoice = Bolt12Invoice.fromString(encodedInvoice).get
  invoice.records.records.foreach(println)
}

thomash-acinq avatar Mar 29 '24 16:03 thomash-acinq

Shelving this for now, as Bolt 12 invoices aren't supposed to be exposed yet. We can reopen this in the future when concrete use-cases need it.

t-bast avatar Sep 18 '24 13:09 t-bast