forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
splice.h
63 lines (57 loc) · 2.22 KB
/
splice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef LIGHTNING_CHANNELD_SPLICE_H
#define LIGHTNING_CHANNELD_SPLICE_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
#include <channeld/inflight.h>
#include <common/amount.h>
#include <common/htlc.h>
/* The channel's general splice state for tracking splice candidates */
struct splice_state {
/* The active inflights */
struct inflight **inflights;
/* The pending short channel id for a splice. Set when mutual lock. */
struct short_channel_id short_channel_id;
/* Set to old short channel id when mutual lock occurs. */
struct short_channel_id last_short_channel_id;
/* Tally of which sides are locked, or not */
bool locked_ready[NUM_SIDES];
/* Set to true when commitment cycle completes successfully */
bool await_commitment_succcess;
/* The txid of which splice inflight was confirmed */
struct bitcoin_txid locked_txid;
/* The number of splices that have been signed & committed */
u32 committed_count;
/* the number of splices that have been revoke_and_ack'ed */
u32 revoked_count;
/* The number of splices that are active (awaiting confirmation) */
u32 count;
};
/* Sets `splice_state` items to default values */
struct splice_state *splice_state_new(const tal_t *ctx);
/* An active splice negotiation. Born when splice beings and dies when a splice
* negotation has finished */
struct splicing {
/* The opener side's relative balance change */
s64 opener_relative;
/* The accepter side's relative balance change */
s64 accepter_relative;
/* The feerate for the splice (on set for the initiator) */
u32 feerate_per_kw;
/* If the feerate is higher than max, don't abort the splice */
bool force_feerate;
/* Make our side sign first */
bool force_sign_first;
/* After `splice` and `splice_ack` occur, we are in splice mode */
bool mode;
/* Track how many of each tx collab msg we receive */
u16 tx_add_input_count, tx_add_output_count;
/* Current negoitated psbt */
struct wally_psbt *current_psbt;
/* If, in the last splice_update, was tx_complete was received */
bool received_tx_complete;
/* If, in the last splice_update, we sent tx_complete */
bool sent_tx_complete;
};
/* Sets `splice` items to default values */
struct splicing *splicing_new(const tal_t *ctx);
#endif /* LIGHTNING_CHANNELD_SPLICE_H */