Skip to content

Commit

Permalink
psbt: Allow doubly-present but matching fields when combining exclusi…
Browse files Browse the repository at this point in the history
…ve fields
  • Loading branch information
jgriffiths committed Sep 13, 2020
1 parent afab6f7 commit 5d8d667
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2005,12 +2005,17 @@ int wally_psbt_to_base64(const struct wally_psbt *psbt, uint32_t flags, char **o
return ret;
}

#define COMBINE_BYTES(typ, member, ALLOW_DUPS) do { \
if (!dst->member && src->member) { \
if (!ALLOW_DUPS) return WALLY_EINVAL; \
ret = wally_psbt_ ## typ ## _set_ ## member(dst, src->member, src->member ## _len); \
if (ret != WALLY_OK) \
return ret; \
#define COMBINE_BYTES(TYP, MEMBER, ALLOW_DUPS) do { \
if (src->MEMBER) { \
if (dst->MEMBER && !ALLOW_DUPS) { \
if (dst->MEMBER ## _len != src->MEMBER ## _len || \
memcmp(dst->MEMBER, src->MEMBER, dst->MEMBER ## _len) != 0) \
return WALLY_EINVAL; \
} else if (!dst->MEMBER) { \
ret = wally_psbt_ ## TYP ## _set_ ## MEMBER(dst, src->MEMBER, src->MEMBER ## _len); \
if (ret != WALLY_OK) \
return ret; \
} \
} } while (0)

static int combine_txs(struct wally_tx **dst, struct wally_tx *src)
Expand Down

0 comments on commit 5d8d667

Please sign in to comment.