Send a transaction to the Bitcoin network. * Calls `sendrawtransaction` using the first parameter as the raw tx. */
| 635 | * Calls `sendrawtransaction` using the first parameter as the raw tx. |
| 636 | */ |
| 637 | static 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 | |
| 680 | static struct command_result *getutxout(struct command *cmd, |
| 681 | const char *buf, |
nothing calls this directly
no test coverage detected