From 5e93cf821949967682c4c0693d55ad23a9a9964a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 17 Aug 2017 14:53:13 +1000 Subject: [PATCH] Cope gracefully with lack of default_witness_commitment despite rules supporting segwit. --- src/stratifier.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index d1468a2b..566ea90d 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1449,8 +1449,11 @@ retry: witnessdata_check = json_string_value(json_object_get(wb->json, "default_witness_commitment")); gbt_witness_data(wb, txn_array); // Verify against the pre-calculated value if it exists. Skip the size/OP_RETURN bytes. - if (wb->insert_witness && witnessdata_check[0] && safecmp(witnessdata_check + 4, wb->witnessdata) != 0) - LOGERR("Witness from btcd: %s. Calculated Witness: %s", witnessdata_check + 4, wb->witnessdata); + if (likely(witnessdata_check)) { + if (wb->insert_witness && witnessdata_check[0] && safecmp(witnessdata_check + 4, wb->witnessdata) != 0) + LOGERR("Witness from btcd: %s. Calculated Witness: %s", witnessdata_check + 4, wb->witnessdata); + } else + LOGNOTICE("Segwit rules returned but no default_witness_commitment to check witness data"); break; } }