MCPcopy Create free account
hub / github.com/ElementsProject/lightning / offer_decode

Function offer_decode

common/bolt12.c:164–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164struct tlv_offer *offer_decode(const tal_t *ctx,
165 const char *b12, size_t b12len,
166 const struct feature_set *our_features,
167 const struct chainparams *must_be_chain,
168 char **fail)
169{
170 struct tlv_offer *offer;
171 const u8 *data;
172 size_t dlen;
173
174 data = string_to_data(tmpctx, b12, b12len, "lno", &dlen, fail);
175 if (!data)
176 return NULL;;
177
178 offer = fromwire_tlv_offer(ctx, &data, &dlen);
179 if (!offer) {
180 *fail = tal_fmt(ctx, "invalid offer data");
181 return NULL;
182 }
183
184 *fail = check_features_and_chain(ctx,
185 our_features, must_be_chain,
186 offer->features,
187 offer->chains,
188 tal_count(offer->chains));
189 if (*fail)
190 return tal_free(offer);
191
192 /* BOLT-offers #12:
193 * - if `signature` is present, but is not a valid signature using
194 * `node_id` as described in [Signature Calculation](#signature-calculation):
195 * - MUST NOT respond to the offer.
196 */
197 if (offer->signature) {
198 *fail = check_signature(ctx, offer->fields,
199 "offer", "signature",
200 offer->node_id, offer->signature);
201 if (*fail)
202 return tal_free(offer);
203 }
204
205 return offer;
206}
207
208char *invrequest_encode(const tal_t *ctx, const struct tlv_invoice_request *invrequest_tlv)
209{

Callers 8

param_b12_offerFunction · 0.85
offer_str_nosigFunction · 0.85
mainFunction · 0.85
listoffers_doneFunction · 0.85
param_offerFunction · 0.85
listoffers_doneFunction · 0.85
param_decodableFunction · 0.85
mainFunction · 0.85

Calls 5

string_to_dataFunction · 0.85
check_features_and_chainFunction · 0.85
tal_freeFunction · 0.85
check_signatureFunction · 0.85
fromwire_tlv_offerFunction · 0.50

Tested by 1

mainFunction · 0.68