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

Function connect_ok

plugins/spender/multifundchannel.c:1542–1585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1540
1541
1542static struct command_result *
1543connect_ok(struct command *cmd,
1544 const char *method,
1545 const char *buf,
1546 const jsmntok_t *result,
1547 struct multifundchannel_destination *dest)
1548{
1549 struct multifundchannel_command *mfc = dest->mfc;
1550 const jsmntok_t *features_tok;
1551
1552 plugin_log(mfc->cmd->plugin, LOG_DBG,
1553 "mfc %"PRIu64", dest %u: connect done.",
1554 mfc->id, dest->index);
1555
1556 features_tok = json_get_member(buf, result, "features");
1557 if (!features_tok)
1558 plugin_err(cmd->plugin,
1559 "'connect' did not return 'features'? %.*s",
1560 json_tok_full_len(result),
1561 json_tok_full(buf, result));
1562 dest->their_features = json_tok_bin_from_hex(mfc, buf, features_tok);
1563 if (!dest->their_features)
1564 plugin_err(cmd->plugin,
1565 "'connect' has unparesable 'features'? %.*s",
1566 json_tok_full_len(features_tok),
1567 json_tok_full(buf, features_tok));
1568
1569 dest->state = MULTIFUNDCHANNEL_CONNECTED;
1570
1571 /* Set the open protocol to use now */
1572 if (feature_negotiated(plugin_feature_set(mfc->cmd->plugin),
1573 dest->their_features,
1574 OPT_DUAL_FUND))
1575 dest->protocol = OPEN_CHANNEL;
1576 else if (!amount_sat_is_zero(dest->request_amt) || !(!dest->rates))
1577 /* Return an error */
1578 fail_destination_msg(dest, FUNDING_V2_NOT_SUPPORTED,
1579 "Tried to buy a liquidity ad"
1580 " but we(?) don't have"
1581 " experimental-dual-fund"
1582 " enabled");
1583
1584 return connect_done(dest);
1585}
1586
1587static struct command_result *
1588connect_err(struct command *cmd,

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected