MCPcopy Create free account
hub / github.com/ElementsProject/lightning / sendrawtx_callback

Function sendrawtx_callback

lightningd/bitcoind.c:357–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355};
356
357static void sendrawtx_callback(const char *buf, const jsmntok_t *toks,
358 const jsmntok_t *idtok,
359 struct sendrawtx_call *call)
360{
361 const jsmntok_t *resulttok;
362 const char *err;
363 const char *errmsg = NULL;
364 bool success = false;
365
366 resulttok = get_bitcoin_result(call->bitcoind, buf, toks, "sendrawtransaction");
367
368 err = json_scan(tmpctx, buf, resulttok, "{success:%}",
369 JSON_SCAN(json_to_bool, &success));
370 if (err) {
371 bitcoin_plugin_error(call->bitcoind, buf, resulttok,
372 "sendrawtransaction",
373 "bad 'result' field: %s", err);
374 } else if (!success) {
375 err = json_scan(tmpctx, buf, resulttok, "{errmsg:%}",
376 JSON_SCAN_TAL(tmpctx, json_strdup, &errmsg));
377 if (err)
378 bitcoin_plugin_error(call->bitcoind, buf, resulttok,
379 "sendrawtransaction",
380 "bad 'errmsg' field: %s",
381 err);
382 }
383
384 /* In case they don't free it, we will. */
385 tal_steal(tmpctx, call);
386 call->cb(call->bitcoind, success, errmsg, call->cb_arg);
387}
388
389void bitcoind_sendrawtx_(const tal_t *ctx,
390 struct bitcoind *bitcoind,

Callers

nothing calls this directly

Calls 3

get_bitcoin_resultFunction · 0.85
bitcoin_plugin_errorFunction · 0.85
json_scanFunction · 0.50

Tested by

no test coverage detected