mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +01:00
bitcoind_sendrawtx: hand error code to callback.
So it can determine success or failure. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
4cbe9785a8
commit
89131444b3
3 changed files with 13 additions and 11 deletions
|
@ -272,20 +272,21 @@ void bitcoind_estimate_fee_(struct lightningd_state *dstate,
|
||||||
static void process_sendrawtx(struct bitcoin_cli *bcli)
|
static void process_sendrawtx(struct bitcoin_cli *bcli)
|
||||||
{
|
{
|
||||||
void (*cb)(struct lightningd_state *dstate,
|
void (*cb)(struct lightningd_state *dstate,
|
||||||
const char *msg, void *) = bcli->cb;
|
int, const char *msg, void *) = bcli->cb;
|
||||||
const char *msg = tal_strndup(bcli, (char *)bcli->output,
|
const char *msg = tal_strndup(bcli, (char *)bcli->output,
|
||||||
bcli->output_bytes);
|
bcli->output_bytes);
|
||||||
|
|
||||||
log_debug(bcli->dstate->base_log, "sendrawtx exit %u, gave %s",
|
log_debug(bcli->dstate->base_log, "sendrawtx exit %u, gave %s",
|
||||||
*bcli->exitstatus, msg);
|
*bcli->exitstatus, msg);
|
||||||
|
|
||||||
cb(bcli->dstate, msg, bcli->cb_arg);
|
cb(bcli->dstate, *bcli->exitstatus, msg, bcli->cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitcoind_sendrawtx_(struct peer *peer,struct lightningd_state *dstate,
|
void bitcoind_sendrawtx_(struct peer *peer,
|
||||||
|
struct lightningd_state *dstate,
|
||||||
const char *hextx,
|
const char *hextx,
|
||||||
void (*cb)(struct lightningd_state *dstate,
|
void (*cb)(struct lightningd_state *dstate,
|
||||||
const char *msg, void *),
|
int exitstatus, const char *msg, void *),
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
start_bitcoin_cli(dstate, NULL, process_sendrawtx, true, cb, arg,
|
start_bitcoin_cli(dstate, NULL, process_sendrawtx, true, cb, arg,
|
||||||
|
|
|
@ -31,7 +31,7 @@ void bitcoind_sendrawtx_(struct peer *peer,
|
||||||
struct lightningd_state *dstate,
|
struct lightningd_state *dstate,
|
||||||
const char *hextx,
|
const char *hextx,
|
||||||
void (*cb)(struct lightningd_state *dstate,
|
void (*cb)(struct lightningd_state *dstate,
|
||||||
const char *msg, void *),
|
int exitstatus, const char *msg, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
#define bitcoind_sendrawtx(peer_, dstate, hextx, cb, arg) \
|
#define bitcoind_sendrawtx(peer_, dstate, hextx, cb, arg) \
|
||||||
|
@ -39,7 +39,7 @@ void bitcoind_sendrawtx_(struct peer *peer,
|
||||||
typesafe_cb_preargs(void, void *, \
|
typesafe_cb_preargs(void, void *, \
|
||||||
(cb), (arg), \
|
(cb), (arg), \
|
||||||
struct lightningd_state *, \
|
struct lightningd_state *, \
|
||||||
const char *), \
|
int, const char *), \
|
||||||
(arg))
|
(arg))
|
||||||
|
|
||||||
void bitcoind_get_chaintip_(struct lightningd_state *dstate,
|
void bitcoind_get_chaintip_(struct lightningd_state *dstate,
|
||||||
|
|
|
@ -214,7 +214,7 @@ size_t get_tx_depth(struct lightningd_state *dstate,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void broadcast_remainder(struct lightningd_state *dstate,
|
static void broadcast_remainder(struct lightningd_state *dstate,
|
||||||
const char *msg, char **txs)
|
int exitstatus, const char *msg, char **txs)
|
||||||
{
|
{
|
||||||
size_t num_txs = tal_count(txs);
|
size_t num_txs = tal_count(txs);
|
||||||
const char *this_tx;
|
const char *this_tx;
|
||||||
|
@ -225,9 +225,9 @@ static void broadcast_remainder(struct lightningd_state *dstate,
|
||||||
log_debug(dstate->base_log,
|
log_debug(dstate->base_log,
|
||||||
"Expected error broadcasting tx %s: %s",
|
"Expected error broadcasting tx %s: %s",
|
||||||
txs[num_txs-1], msg);
|
txs[num_txs-1], msg);
|
||||||
else
|
else if (exitstatus)
|
||||||
log_unusual(dstate->base_log, "Broadcasting tx %s: %s",
|
log_unusual(dstate->base_log, "Broadcasting tx %s: %i %s",
|
||||||
txs[num_txs-1], msg);
|
txs[num_txs-1], exitstatus, msg);
|
||||||
|
|
||||||
if (num_txs == 1) {
|
if (num_txs == 1) {
|
||||||
tal_free(txs);
|
tal_free(txs);
|
||||||
|
@ -276,7 +276,8 @@ static void destroy_outgoing_tx(struct outgoing_tx *otx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void broadcast_done(struct lightningd_state *dstate,
|
static void broadcast_done(struct lightningd_state *dstate,
|
||||||
const char *msg, struct outgoing_tx *otx)
|
int exitstatus, const char *msg,
|
||||||
|
struct outgoing_tx *otx)
|
||||||
{
|
{
|
||||||
/* For continual rebroadcasting */
|
/* For continual rebroadcasting */
|
||||||
list_add_tail(&otx->peer->outgoing_txs, &otx->list);
|
list_add_tail(&otx->peer->outgoing_txs, &otx->list);
|
||||||
|
|
Loading…
Add table
Reference in a new issue