| 268 | }; |
| 269 | |
| 270 | static void sendrawtx_callback(const char *buf, const jsmntok_t *toks, |
| 271 | const jsmntok_t *idtok, |
| 272 | struct sendrawtx_call *call) |
| 273 | { |
| 274 | const char *err; |
| 275 | const char *errmsg = NULL; |
| 276 | bool success = false; |
| 277 | |
| 278 | err = json_scan(tmpctx, buf, toks, "{result:{success:%}}", |
| 279 | JSON_SCAN(json_to_bool, &success)); |
| 280 | if (err) { |
| 281 | bitcoin_plugin_error(call->bitcoind, buf, toks, |
| 282 | "sendrawtransaction", |
| 283 | "bad 'result' field: %s", err); |
| 284 | } else if (!success) { |
| 285 | err = json_scan(tmpctx, buf, toks, "{result:{errmsg:%}}", |
| 286 | JSON_SCAN_TAL(tmpctx, json_strdup, &errmsg)); |
| 287 | if (err) |
| 288 | bitcoin_plugin_error(call->bitcoind, buf, toks, |
| 289 | "sendrawtransaction", |
| 290 | "bad 'errmsg' field: %s", |
| 291 | err); |
| 292 | } |
| 293 | |
| 294 | db_begin_transaction(call->bitcoind->ld->wallet->db); |
| 295 | call->cb(call->bitcoind, success, errmsg, call->cb_arg); |
| 296 | db_commit_transaction(call->bitcoind->ld->wallet->db); |
| 297 | |
| 298 | tal_free(call); |
| 299 | } |
| 300 | |
| 301 | void bitcoind_sendrawtx_(struct bitcoind *bitcoind, |
| 302 | const char *id_prefix, |
nothing calls this directly
no test coverage detected