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