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

Function sendrawtx_callback

lightningd/bitcoind.c:270–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268};
269
270static 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
301void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
302 const char *id_prefix,

Callers

nothing calls this directly

Calls 4

bitcoin_plugin_errorFunction · 0.85
tal_freeFunction · 0.85
json_scanFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected