common: add tal_arr_eq helper.

We do `memeq(a, tal_bytelen(a), b, tal_bytelen(b))` remarkably often...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-02-14 20:08:33 +10:30
committed by Christian Decker
parent b6cc0ce425
commit df44431f8c
50 changed files with 98 additions and 178 deletions

View File

@@ -205,8 +205,7 @@ int main(int argc, char *argv[])
wscript = bitcoin_redeem_2of2(ctx, &local_fundingkey, &remote_fundingkey);
expect_scriptpubkey = scriptpubkey_p2wsh(ctx, wscript);
if (!memeq(expect_scriptpubkey, tal_bytelen(expect_scriptpubkey),
scriptpubkey, tal_bytelen(scriptpubkey))) {
if (!tal_arr_eq(expect_scriptpubkey, scriptpubkey)) {
printf("*** FATAL *** outscript %s should be %s\n",
tal_hex(ctx, scriptpubkey),
tal_hex(ctx, expect_scriptpubkey));