| 507 | } |
| 508 | |
| 509 | static bool wally_map_set_unknown(const tal_t *ctx, |
| 510 | struct wally_map *map, |
| 511 | const u8 *key, |
| 512 | const void *value, |
| 513 | size_t value_len) |
| 514 | { |
| 515 | size_t exists_at; |
| 516 | struct wally_map_item *item; |
| 517 | |
| 518 | assert(value_len != 0); |
| 519 | if (wally_map_find(map, key, tal_bytelen(key), &exists_at) != WALLY_OK) |
| 520 | return false; |
| 521 | |
| 522 | /* If not exists, add */ |
| 523 | if (exists_at == 0) { |
| 524 | bool ok; |
| 525 | tal_wally_start(); |
| 526 | ok = wally_map_add(map, key, tal_bytelen(key), |
| 527 | (unsigned char *) memcheck(value, value_len), value_len) |
| 528 | == WALLY_OK; |
| 529 | tal_wally_end(ctx); |
| 530 | return ok; |
| 531 | } |
| 532 | |
| 533 | /* Already in map, update entry */ |
| 534 | item = &map->items[exists_at - 1]; |
| 535 | tal_resize(&item->value, value_len); |
| 536 | memcpy(item->value, memcheck(value, value_len), value_len); |
| 537 | item->value_len = value_len; |
| 538 | |
| 539 | return true; |
| 540 | } |
| 541 | |
| 542 | void psbt_input_set_unknown(const tal_t *ctx, |
| 543 | struct wally_psbt_input *in, |
no test coverage detected