| 250 | } |
| 251 | |
| 252 | static struct command_result *listsendpays_done(struct command *cmd, |
| 253 | const char *method UNNEEDED, |
| 254 | const char *buf, |
| 255 | const jsmntok_t *result, |
| 256 | struct createproof_state *state) |
| 257 | { |
| 258 | const jsmntok_t *arr, *t; |
| 259 | size_t i; |
| 260 | |
| 261 | arr = json_get_member(buf, result, "payments"); |
| 262 | if (!arr || arr->type != JSMN_ARRAY) |
| 263 | return command_fail(cmd, LIGHTNINGD, |
| 264 | "Unexpected listsendpays result"); |
| 265 | |
| 266 | state->proofs = tal_arr(state, struct one_proof *, 0); |
| 267 | |
| 268 | json_for_each_arr(i, t, arr) { |
| 269 | const jsmntok_t *statustok, *b12tok, *preimagetok; |
| 270 | const char *b12str; |
| 271 | struct tlv_invoice *inv; |
| 272 | struct preimage preimage; |
| 273 | const char *fail; |
| 274 | struct one_proof *proof; |
| 275 | struct sha256 mroot; |
| 276 | struct out_req *req; |
| 277 | |
| 278 | statustok = json_get_member(buf, t, "status"); |
| 279 | if (!statustok || !json_tok_streq(buf, statustok, "complete")) |
| 280 | continue; |
| 281 | |
| 282 | preimagetok = json_get_member(buf, t, "payment_preimage"); |
| 283 | if (!preimagetok) |
| 284 | continue; |
| 285 | if (!json_to_preimage(buf, preimagetok, &preimage)) |
| 286 | continue; |
| 287 | |
| 288 | b12tok = json_get_member(buf, t, "bolt12"); |
| 289 | if (!b12tok) |
| 290 | continue; |
| 291 | |
| 292 | b12str = json_strdup(tmpctx, buf, b12tok); |
| 293 | inv = invoice_decode(tmpctx, b12str, strlen(b12str), |
| 294 | NULL, chainparams, &fail); |
| 295 | if (!inv) |
| 296 | continue; |
| 297 | |
| 298 | switch (state->invinfo->type) { |
| 299 | case INVTYPE_OFFER: { |
| 300 | /* offer_id matching means invoice is for this offer */ |
| 301 | struct sha256 inv_offer_id; |
| 302 | invoice_offer_id(inv, &inv_offer_id); |
| 303 | if (!sha256_eq(&state->invinfo->offer_id, &inv_offer_id)) |
| 304 | continue; |
| 305 | break; |
| 306 | } |
| 307 | case INVTYPE_BIP353: |
| 308 | if (!inv->invreq_bip_353_name) |
| 309 | continue; |
nothing calls this directly
no test coverage detected