Browse Source

mfc-df: track destination's openchannel version

Plus method to help count/tabulate how many of each we've got
around still.
fix-mocks
niftynei 4 years ago
committed by neil saitug
parent
commit
991ae65e9e
  1. 13
      plugins/spender/multifundchannel.c
  2. 20
      plugins/spender/multifundchannel.h

13
plugins/spender/multifundchannel.c

@ -39,6 +39,17 @@ static bool has_all(const struct multifundchannel_command *mfc)
return false;
}
size_t dest_count(const struct multifundchannel_command *mfc,
enum channel_protocol protocol)
{
size_t count = 0, i;
for (i = 0; i < tal_count(mfc->destinations); i++) {
if (mfc->destinations[i].protocol == protocol)
count++;
}
return count;
}
/*-----------------------------------------------------------------------------
Command Cleanup
-----------------------------------------------------------------------------*/
@ -380,6 +391,7 @@ param_destinations_array(struct command *cmd, const char *name,
dest->error = NULL;
dest->psbt = NULL;
dest->updated_psbt = NULL;
dest->protocol = FUND_CHANNEL;
/* Only one destination can have "all" indicator. */
if (dest->all) {
@ -946,6 +958,7 @@ perform_channel_start(struct multifundchannel_command *mfc)
if (feature_negotiated(plugin_feature_set(mfc->cmd->plugin),
mfc->destinations[i].their_features,
OPT_DUAL_FUND)) {
mfc->destinations[i].protocol = OPEN_CHANNEL;
openchannel_init_dest(&mfc->destinations[i]);
} else
#endif /* EXPERIMENTAL_FEATURES */

20
plugins/spender/multifundchannel.h

@ -9,6 +9,13 @@
extern const struct plugin_command multifundchannel_commands[];
extern const size_t num_multifundchannel_commands;
/* Which protocol this channel open is using.
* OPEN_CHANNEL implies opt_dual_fund */
enum channel_protocol {
FUND_CHANNEL,
OPEN_CHANNEL,
};
/* Current state of the funding process. */
enum multifundchannel_state {
/* We have not yet performed `fundchannel_start`. */
@ -114,9 +121,16 @@ struct multifundchannel_destination {
const char *error;
errcode_t code;
/* yarr v2, ahoy! */
/* what channel protocol this destination is using */
enum channel_protocol protocol;
/* PSBT for the inflight channel open (OPEN_CHANNEL) */
struct wally_psbt *psbt;
/* PSBT for the inflight channel open, updated (OPEN_CHANNEL) */
struct wally_psbt *updated_psbt;
/* serial of the funding output for this channel (OPEN_CHANNEL) */
u64 funding_serial;
};
@ -221,6 +235,10 @@ mfc_forward_error(struct command *cmd,
void fail_destination(struct multifundchannel_destination *dest,
char *error TAKES);
/* dest_count - Returns count of destinations using given protocol version */
size_t dest_count(const struct multifundchannel_command *mfc,
enum channel_protocol);
/* Use this instead of command_finished. */
struct command_result *
mfc_finished(struct multifundchannel_command *, struct json_stream *response);

Loading…
Cancel
Save