From 66fe3382901a5cbfa150b911c18200be02e0b899 Mon Sep 17 00:00:00 2001 From: Dusty Daemon Date: Mon, 11 Nov 2024 11:00:43 +1030 Subject: [PATCH] psbt: Add ability to set global PSBT values Changelog-None --- bitcoin/psbt.c | 11 +++++++++++ bitcoin/psbt.h | 13 +++++++++++++ 2 files changed, 24 insertions(+) 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