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

Function sendrawtransaction

plugins/bcli.c:637–678  ·  view source on GitHub ↗

Send a transaction to the Bitcoin network. * Calls `sendrawtransaction` using the first parameter as the raw tx. */

Source from the content-addressed store, hash-verified

635 * Calls `sendrawtransaction` using the first parameter as the raw tx.
636 */
637static struct command_result *sendrawtransaction(struct command *cmd,
638 const char *buf,
639 const jsmntok_t *toks)
640{
641 const char *tx, *highfeesarg;
642 bool *allowhighfees;
643 struct bcli_result *res;
644 struct json_stream *response;
645
646 /* bitcoin-cli wants strings. */
647 if (!param(cmd, buf, toks,
648 p_req("tx", param_string, &tx),
649 p_req("allowhighfees", param_bool, &allowhighfees),
650 NULL))
651 return command_param_failed();
652
653 if (*allowhighfees) {
654 highfeesarg = "0";
655 } else
656 highfeesarg = NULL;
657
658 res = run_bitcoin_cli(cmd, cmd->plugin,
659 "sendrawtransaction", tx, highfeesarg, NULL);
660
661 /* This is useful for functional tests. */
662 plugin_log(cmd->plugin, LOG_DBG,
663 "sendrawtx exit %i (%s) %.*s",
664 res->exitstatus, res->args,
665 res->exitstatus ? (int)res->output_len : 0,
666 res->output);
667
668 response = jsonrpc_stream_success(cmd);
669 json_add_bool(response, "success",
670 res->exitstatus == 0 ||
671 res->exitstatus == RPC_TRANSACTION_ALREADY_IN_CHAIN);
672 json_add_string(response, "errmsg",
673 res->exitstatus ?
674 tal_strndup(cmd, res->output, res->output_len)
675 : "");
676
677 return command_finished(cmd, response);
678}
679
680static struct command_result *getutxout(struct command *cmd,
681 const char *buf,

Callers

nothing calls this directly

Calls 8

run_bitcoin_cliFunction · 0.85
json_add_boolFunction · 0.85
command_param_failedFunction · 0.70
plugin_logFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
paramFunction · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected