From 7d1137c45ebb9e966cf1efb22e407b983d1678e3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 7 Nov 2016 22:58:02 +1030 Subject: [PATCH] bitcoind_sendrawtx: tie the sending of the transaction to the particular peer. Not important just yet, but it will be soon. Signed-off-by: Rusty Russell --- daemon/bitcoind.c | 5 +++-- daemon/bitcoind.h | 7 ++++--- daemon/chaintopology.c | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/daemon/bitcoind.c b/daemon/bitcoind.c index 3e610ce60..3b029fd0a 100644 --- a/daemon/bitcoind.c +++ b/daemon/bitcoind.c @@ -282,13 +282,14 @@ static void process_sendrawtx(struct bitcoin_cli *bcli) cb(bcli->dstate, msg, bcli->cb_arg); } -void bitcoind_sendrawtx_(struct lightningd_state *dstate, +void bitcoind_sendrawtx_(struct peer *peer, + struct lightningd_state *dstate, const char *hextx, void (*cb)(struct lightningd_state *dstate, const char *msg, void *), void *arg) { - start_bitcoin_cli(dstate, NULL, process_sendrawtx, true, cb, arg, + start_bitcoin_cli(dstate, peer, process_sendrawtx, true, cb, arg, "sendrawtransaction", hextx, NULL); } diff --git a/daemon/bitcoind.h b/daemon/bitcoind.h index cafe912ac..5f9208eb2 100644 --- a/daemon/bitcoind.h +++ b/daemon/bitcoind.h @@ -27,14 +27,15 @@ void bitcoind_estimate_fee_(struct lightningd_state *dstate, u64), \ (arg)) -void bitcoind_sendrawtx_(struct lightningd_state *dstate, +void bitcoind_sendrawtx_(struct peer *peer, + struct lightningd_state *dstate, const char *hextx, void (*cb)(struct lightningd_state *dstate, const char *msg, void *), void *arg); -#define bitcoind_sendrawtx(dstate, hextx, cb, arg) \ - bitcoind_sendrawtx_((dstate), (hextx), \ +#define bitcoind_sendrawtx(peer_, dstate, hextx, cb, arg) \ + bitcoind_sendrawtx_((peer_), (dstate), (hextx), \ typesafe_cb_preargs(void, void *, \ (cb), (arg), \ struct lightningd_state *, \ diff --git a/daemon/chaintopology.c b/daemon/chaintopology.c index 880832994..697ef0bc3 100644 --- a/daemon/chaintopology.c +++ b/daemon/chaintopology.c @@ -237,7 +237,7 @@ static void try_broadcast(struct lightningd_state *dstate, this_tx = txs[num_txs-1]; tal_resize(&txs, num_txs-1); - bitcoind_sendrawtx(dstate, this_tx, try_broadcast, txs); + bitcoind_sendrawtx(NULL, dstate, this_tx, try_broadcast, txs); } /* FIXME: This is dumb. We can group txs and avoid bothering bitcoind @@ -266,7 +266,8 @@ static void rebroadcast_txs(struct lightningd_state *dstate) } if (num_txs) - bitcoind_sendrawtx(dstate, txs[num_txs-1], try_broadcast, txs); + bitcoind_sendrawtx(NULL, dstate, txs[num_txs-1], + try_broadcast, txs); else tal_free(txs); } @@ -291,7 +292,7 @@ void broadcast_tx(struct peer *peer, const struct bitcoin_tx *tx) rawtx = linearize_tx(txs, otx->tx); txs[0] = tal_hexstr(txs, rawtx, tal_count(rawtx)); - bitcoind_sendrawtx(peer->dstate, txs[0], try_broadcast, txs); + bitcoind_sendrawtx(peer, peer->dstate, txs[0], try_broadcast, txs); } static void free_blocks(struct lightningd_state *dstate, struct block *b)