Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bolt11: Don't push the size of the witness program for v1+ scripts #6435

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions common/bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ static const char *decode_f(struct bolt11 *b11,
"f: witness v0 bad length %zu",
tal_count(f));
}
if (version == 1 && tal_count(f) != 32) {
return tal_fmt(b11,
"f: witness v1 bad length %zu",
tal_count(f));
}
if (tal_count(f) > 40) {
return tal_fmt(b11,
"f: witness v%ld bad length %zu",
version,
tal_count(f));
}
Comment on lines +415 to +425
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can avoid the {....} here

fallback = scriptpubkey_witness_raw(b11, version,
f, tal_count(f));
} else {
Expand Down Expand Up @@ -1129,12 +1140,12 @@ static void encode_f(u5 **data, const u8 *fallback)
push_fallback_addr(data, 0, &pkh, sizeof(pkh));
} else if (is_p2wsh(fallback, &wsh)) {
push_fallback_addr(data, 0, &wsh, sizeof(wsh));
} else if (tal_count(fallback)
} else if (tal_count(fallback) > 1
&& fallback[0] >= 0x50
&& fallback[0] < (0x50+16)) {
/* Other (future) witness versions: turn OP_N into N */
push_fallback_addr(data, fallback[0] - 0x50, fallback + 1,
tal_count(fallback) - 1);
push_fallback_addr(data, fallback[0] - 0x50, fallback + 2,
tal_count(fallback) - 2);
} else {
/* Copy raw. */
push_field(data, 'f',
Expand Down