bolt12: export DecodeOffer - #11199
usefahmed07 wants to merge 2 commits into
Conversation
🟡 PR Severity: MEDIUM
🟡 Medium (1 file)
🟢 Low (2 files)
AnalysisThis PR exports To override, add a |
Lrifton92
left a comment
There was a problem hiding this comment.
The export itself is consistent with DecodeInvoice/DecodeInvoiceRequest, and keeping the permissive-decode doc comment (with the ValidateOfferRead note) is the right call for a fuzz entry point.
One issue though: the rename looks incomplete. After decodeOffer becomes DecodeOffer, there are still call sites referencing the old unexported name, so go test ./bolt12 won't compile (undefined: decodeOffer):
bolt12/offer_test.go:71bolt12/offer_test.go:90bolt12/decode_test.go:44bolt12/validate_test.go:3027bolt12/validate_test.go:3135
The diff only updates offer_test.go:42 and invoice_request_test.go:155. A quick grep -rn 'decodeOffer(' bolt12/ should catch the remaining five. Worth running go build ./... && go test ./bolt12 -run x -count=1 locally before the CI check — since this is test-only code, the compile break is invisible in go build ./... alone.
|
@Lrifton92 Good catch! Fixed in 74bb3b2, tests pass now. |
Lrifton92
left a comment
There was a problem hiding this comment.
Marking this as request-changes: as noted in my earlier comment, the rename is incomplete — five call sites still reference the now-removed decodeOffer, so go test ./bolt12 fails to compile (undefined: decodeOffer):
bolt12/offer_test.go:71bolt12/offer_test.go:90bolt12/decode_test.go:44bolt12/validate_test.go:3027bolt12/validate_test.go:3135
grep -rn 'decodeOffer(' bolt12/ catches all of them. Happy to re-approve once the package builds.
Lrifton92
left a comment
There was a problem hiding this comment.
Verified on the updated head (74bb3b2): all five call sites now use DecodeOffer, and go test ./bolt12/ -run '^$' -count=1 compiles and links the package cleanly (including the _test.go files where the breakage was), returning ok ... [no tests to run]. The earlier compile break is resolved. Thanks for the quick turnaround — LGTM.
|
This PR (#11191) redefines some of the exports to keep bolt12's package interface minimal ( |
|
Thanks @bitromortac, agreed: DecodeOfferString on master covers the path the fuzz target needs, so decodeOffer doesn't need to be exported. I switched the bitcoinfuzz target to it (bitcoinfuzz/bitcoinfuzz#655), so I'm closing this PR. |
Description
Exports
bolt12.decodeOfferasbolt12.DecodeOffer, mirroring theexisting exported decode functions for the other BOLT 12 messages
(
DecodeInvoice,DecodeInvoiceRequest,DecodeInvoiceError).Currently
decodeOfferis unexported and only referenced from thepackage's own tests, so there is no public entry point to parse a raw
BOLT 12 offer TLV stream from outside the
bolt12package.Motivation
bitcoinfuzz, a
differential fuzzing project for Bitcoin/Lightning implementations,
has an open issue to add LND to its
deserialize_offerfuzz target(bitcoinfuzz/bitcoinfuzz#586), which references this work
(#10736). That target needs a public decode
function to call from outside the package, exactly like the ones
already exported for Invoice/InvoiceRequest/InvoiceError.
Changes
bolt12/offer.go: renamedecodeOffer->DecodeOffer(doc commentupdated accordingly).
bolt12/offer_test.go,bolt12/invoice_request_test.go: update thetwo internal call-sites to use the new exported name.
No behavioral change - this is a pure rename/export, decoding logic is
untouched. As noted in the function's doc comment, callers that need a
valid offer (not just a syntactically decodable one) should still run
ValidateOfferReadafterwards.