chaintopology: fix crash if bcli doesn't include errmsg.

Interestingly, we required that "sendrawtx" include "errmsg" field even
on success, otherwise we crashed in broadcast_remainder.

We only actually insist on an "errmsg" if success is false.  And this
logic here is weird (the !success) was added by darosior in
947f5ddde1, which makes the msg checks redundant.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-01-06 16:32:04 +10:30 committed by Christian Decker
parent fd7d1a1cc0
commit 11a4d46c44

View file

@ -136,10 +136,7 @@ static void broadcast_remainder(struct bitcoind *bitcoind,
bool success, const char *msg, bool success, const char *msg,
struct txs_to_broadcast *txs) struct txs_to_broadcast *txs)
{ {
/* These are expected. */ if (!success)
if (strstr(msg, "txn-mempool-conflict")
|| strstr(msg, "transaction already in block chain")
|| !success)
log_debug(bitcoind->log, log_debug(bitcoind->log,
"Expected error broadcasting tx %s: %s", "Expected error broadcasting tx %s: %s",
txs->txs[txs->cursor], msg); txs->txs[txs->cursor], msg);