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

Function sendrawtransaction

plugins/bcli.c:644–685  ·  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

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