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

Function json_close

lightningd/closing_control.c:609–885  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609static struct command_result *json_close(struct command *cmd,
610 const char *buffer,
611 const jsmntok_t *obj UNNEEDED,
612 const jsmntok_t *params)
613{
614 struct channel *channel;
615 unsigned int *timeout;
616 const u8 *close_to_script = NULL;
617 u32 *final_index;
618 u32 index_val;
619 bool close_script_set, wrong_funding_changed, *force_lease_close;
620 const char *fee_negotiation_step_str;
621 struct bitcoin_outpoint *wrong_funding;
622 u32 *feerate_range;
623 char* end;
624 bool anysegwit;
625 struct some_channel *sc = talz(tmpctx, struct some_channel);
626
627 if (!param(cmd, buffer, params,
628 p_req("id", param_channel_or_peer, &sc),
629 p_opt_def("unilateraltimeout", param_number, &timeout,
630 48 * 3600),
631 p_opt("destination", param_bitcoin_address, &close_to_script),
632 p_opt("fee_negotiation_step", param_string,
633 &fee_negotiation_step_str),
634 p_opt("wrong_funding", param_outpoint, &wrong_funding),
635 p_opt_def("force_lease_closed", param_bool,
636 &force_lease_close, false),
637 p_opt("feerange", param_feerate_range, &feerate_range),
638 NULL))
639 return command_param_failed();
640
641 /* Easy cases: peer can simply be forgotten. */
642 if (sc->uc) {
643 kill_uncommitted_channel(sc->uc, "close command called");
644 goto discard_unopened;
645 }
646
647 if (sc->unsaved_channel) {
648 channel_unsaved_close_conn(sc->unsaved_channel,
649 "close command called");
650 goto discard_unopened;
651 }
652
653 channel = sc->channel;
654 assert(channel);
655
656 if (!*force_lease_close && sc->channel->opener != LOCAL
657 && get_block_height(cmd->ld->topology) < channel->lease_expiry)
658 return command_fail(cmd, LIGHTNINGD,
659 "Peer leased this channel from us, we"
660 " shouldn't close until lease has expired"
661 " (lease expires block %u,"
662 " current block %u)",
663 channel->lease_expiry,
664 get_block_height(cmd->ld->topology));
665
666 /* Set the wallet index to the default value; it is updated

Callers

nothing calls this directly

Calls 15

memeqFunction · 0.85
p2wpkh_for_keyidxFunction · 0.85
tal_hexFunction · 0.85
tal_freeFunction · 0.85
wallet_can_spendFunction · 0.85
channel_set_stateFunction · 0.85
register_close_commandFunction · 0.85
command_param_failedFunction · 0.70
kill_uncommitted_channelFunction · 0.70
get_block_heightFunction · 0.70

Tested by

no test coverage detected