diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index 7afb5a4fe..dfe4f8e53 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -641,6 +641,17 @@ void *psbt_get_lightning(const struct wally_map *map, return item->value; } +void psbt_set_lightning(const tal_t *ctx, + struct wally_map *map, + const u8 proprietary_type, + const void *value, + size_t val_len) +{ + u8 *key = psbt_make_key(NULL, proprietary_type, NULL); + map_replace(ctx, map, key, value, val_len); + tal_free(key); +} + void psbt_output_set_unknown(const tal_t *ctx, struct wally_psbt_output *out, const u8 *key, diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index 8d9eda2a0..b313cc028 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -220,6 +220,19 @@ void *psbt_get_lightning(const struct wally_map *map, const u8 proprietary_type, size_t *val_len); +/* psbt_set_lightning - Set a propreitary lightning value on the given map + * + * @map - map of unknowns to set the value + * @proprietary_type - type no. to set + * @value - the value to be set + * @val_len - length of value + */ +void psbt_set_lightning(const tal_t *ctx, + struct wally_map *map, + const u8 proprietary_type, + const void *value, + size_t val_len); + /* psbt_output_set_unknown - Set the given Key-Value in the psbt's output keymap * * @ctx - tal context for allocations