diff --git a/common/Makefile b/common/Makefile index 33f2caf68..771834c81 100644 --- a/common/Makefile +++ b/common/Makefile @@ -91,7 +91,8 @@ COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) \ common/json_command.h \ common/jsonrpc_errors.h \ common/overflows.h \ - common/status_levels.h + common/status_levels.h \ + common/tx_roles.h COMMON_HEADERS_GEN := common/gen_htlc_state_names.h common/status_wiregen.h common/peer_status_wiregen.h COMMON_HEADERS := $(COMMON_HEADERS_GEN) $(COMMON_HEADERS_NOGEN) diff --git a/common/tx_roles.h b/common/tx_roles.h new file mode 100644 index 000000000..5a65dbc10 --- /dev/null +++ b/common/tx_roles.h @@ -0,0 +1,12 @@ +#ifndef LIGHTNING_COMMON_TX_ROLES_H +#define LIGHTNING_COMMON_TX_ROLES_H + +#include "config.h" + +#define NUM_TX_ROLES (TX_ACCEPTER + 1) +enum tx_role { + TX_INITIATOR, + TX_ACCEPTER, +}; + +#endif /* LIGHTNING_COMMON_TX_ROLES_H */ diff --git a/openingd/dual_fund_roles.h b/openingd/dual_fund_roles.h deleted file mode 100644 index f2e3b7a30..000000000 --- a/openingd/dual_fund_roles.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef LIGHTNING_OPENINGD_DUAL_FUND_ROLES_H -#define LIGHTNING_OPENINGD_DUAL_FUND_ROLES_H - -#define NUM_DF_RULES (OPENER + 1) -enum dual_fund_roles { - ACCEPTER, - OPENER, -}; - -#endif /* LIGHTNING_OPENINGD_DUAL_FUND_ROLES_H */ diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 5357cdb34..2d56c8d87 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -11,7 +11,6 @@ * new and improved, two-party opening protocol, which allows bother peers to * contribute inputs to the transaction */ -#include "dual_fund_roles.h" #include #include #include @@ -44,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -97,7 +97,7 @@ struct state { u32 tx_locktime; struct sha256 opening_podle_h2; - enum dual_fund_roles our_role; + enum tx_role our_role; u32 feerate_per_kw_funding; u32 feerate_per_kw; @@ -390,7 +390,7 @@ fetch_psbt_changes(struct state *state, const struct wally_psbt *psbt) else if (fromwire_dual_open_psbt_changed(state, msg, &unused, &updated_psbt)) { /* Does our PSBT meet requirements? */ if (!check_balances(state, updated_psbt, - state->our_role == OPENER, + state->our_role == TX_INITIATOR, false, /* peers input/outputs not complete */ state->feerate_per_kw_funding)) status_failed(STATUS_FAIL_MASTER_IO, @@ -856,7 +856,7 @@ static u8 *accepter_start(struct state *state, const u8 *oc2_msg) struct amount_sat total; enum dualopend_wire msg_type; - state->our_role = ACCEPTER; + state->our_role = TX_ACCEPTER; open_tlv = tlv_opening_tlvs_new(tmpctx); if (!fromwire_open_channel2(oc2_msg, &chain_hash,