mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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.
This commit is contained in:
@@ -91,7 +91,8 @@ COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) \
|
|||||||
common/json_command.h \
|
common/json_command.h \
|
||||||
common/jsonrpc_errors.h \
|
common/jsonrpc_errors.h \
|
||||||
common/overflows.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_GEN := common/gen_htlc_state_names.h common/status_wiregen.h common/peer_status_wiregen.h
|
||||||
|
|
||||||
COMMON_HEADERS := $(COMMON_HEADERS_GEN) $(COMMON_HEADERS_NOGEN)
|
COMMON_HEADERS := $(COMMON_HEADERS_GEN) $(COMMON_HEADERS_NOGEN)
|
||||||
|
|||||||
12
common/tx_roles.h
Normal file
12
common/tx_roles.h
Normal file
@@ -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 */
|
||||||
@@ -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 */
|
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
* new and improved, two-party opening protocol, which allows bother peers to
|
* new and improved, two-party opening protocol, which allows bother peers to
|
||||||
* contribute inputs to the transaction
|
* contribute inputs to the transaction
|
||||||
*/
|
*/
|
||||||
#include "dual_fund_roles.h"
|
|
||||||
#include <bitcoin/feerate.h>
|
#include <bitcoin/feerate.h>
|
||||||
#include <bitcoin/privkey.h>
|
#include <bitcoin/privkey.h>
|
||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
@@ -44,6 +43,7 @@
|
|||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/subdaemon.h>
|
#include <common/subdaemon.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
|
#include <common/tx_roles.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
@@ -97,7 +97,7 @@ struct state {
|
|||||||
u32 tx_locktime;
|
u32 tx_locktime;
|
||||||
|
|
||||||
struct sha256 opening_podle_h2;
|
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_funding;
|
||||||
u32 feerate_per_kw;
|
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)) {
|
else if (fromwire_dual_open_psbt_changed(state, msg, &unused, &updated_psbt)) {
|
||||||
/* Does our PSBT meet requirements? */
|
/* Does our PSBT meet requirements? */
|
||||||
if (!check_balances(state, updated_psbt,
|
if (!check_balances(state, updated_psbt,
|
||||||
state->our_role == OPENER,
|
state->our_role == TX_INITIATOR,
|
||||||
false, /* peers input/outputs not complete */
|
false, /* peers input/outputs not complete */
|
||||||
state->feerate_per_kw_funding))
|
state->feerate_per_kw_funding))
|
||||||
status_failed(STATUS_FAIL_MASTER_IO,
|
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;
|
struct amount_sat total;
|
||||||
enum dualopend_wire msg_type;
|
enum dualopend_wire msg_type;
|
||||||
|
|
||||||
state->our_role = ACCEPTER;
|
state->our_role = TX_ACCEPTER;
|
||||||
open_tlv = tlv_opening_tlvs_new(tmpctx);
|
open_tlv = tlv_opening_tlvs_new(tmpctx);
|
||||||
|
|
||||||
if (!fromwire_open_channel2(oc2_msg, &chain_hash,
|
if (!fromwire_open_channel2(oc2_msg, &chain_hash,
|
||||||
|
|||||||
Reference in New Issue
Block a user