Browse Source

tx_roles: pull up roles, rename

We're going to use these elsewhere/more widely so having them in common
and using a more generic name is a obvious place to start.
travis-experimental
niftynei 4 years ago
committed by Rusty Russell
parent
commit
2618ef10c3
  1. 3
      common/Makefile
  2. 12
      common/tx_roles.h
  3. 10
      openingd/dual_fund_roles.h
  4. 8
      openingd/dualopend.c

3
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)

12
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 */

10
openingd/dual_fund_roles.h

@ -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 */

8
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 <bitcoin/feerate.h>
#include <bitcoin/privkey.h>
#include <bitcoin/script.h>
@ -44,6 +43,7 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/type_to_string.h>
#include <common/tx_roles.h>
#include <common/utils.h>
#include <common/version.h>
#include <common/wire_error.h>
@ -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,

Loading…
Cancel
Save