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

Function connect_ok

plugins/spender/multifundchannel.c:1596–1638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1594
1595
1596static struct command_result *
1597connect_ok(struct command *cmd,
1598 const char *buf,
1599 const jsmntok_t *result,
1600 struct multifundchannel_destination *dest)
1601{
1602 struct multifundchannel_command *mfc = dest->mfc;
1603 const jsmntok_t *features_tok;
1604
1605 plugin_log(mfc->cmd->plugin, LOG_DBG,
1606 "mfc %"PRIu64", dest %u: connect done.",
1607 mfc->id, dest->index);
1608
1609 features_tok = json_get_member(buf, result, "features");
1610 if (!features_tok)
1611 plugin_err(cmd->plugin,
1612 "'connect' did not return 'features'? %.*s",
1613 json_tok_full_len(result),
1614 json_tok_full(buf, result));
1615 dest->their_features = json_tok_bin_from_hex(mfc, buf, features_tok);
1616 if (!dest->their_features)
1617 plugin_err(cmd->plugin,
1618 "'connect' has unparesable 'features'? %.*s",
1619 json_tok_full_len(features_tok),
1620 json_tok_full(buf, features_tok));
1621
1622 dest->state = MULTIFUNDCHANNEL_CONNECTED;
1623
1624 /* Set the open protocol to use now */
1625 if (feature_negotiated(plugin_feature_set(mfc->cmd->plugin),
1626 dest->their_features,
1627 OPT_DUAL_FUND))
1628 dest->protocol = OPEN_CHANNEL;
1629 else if (!amount_sat_zero(dest->request_amt) || !(!dest->rates))
1630 /* Return an error */
1631 fail_destination_msg(dest, FUNDING_V2_NOT_SUPPORTED,
1632 "Tried to buy a liquidity ad"
1633 " but we(?) don't have"
1634 " experimental-dual-fund"
1635 " enabled");
1636
1637 return connect_done(dest);
1638}
1639
1640static struct command_result *
1641connect_err(struct command *cmd,

Callers

nothing calls this directly

Calls 11

plugin_feature_setFunction · 0.85
amount_sat_zeroFunction · 0.85
fail_destination_msgFunction · 0.85
connect_doneFunction · 0.85
plugin_logFunction · 0.50
json_get_memberFunction · 0.50
plugin_errFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_tok_bin_from_hexFunction · 0.50
feature_negotiatedFunction · 0.50

Tested by

no test coverage detected