mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
channel_states: fold all the ONCHAIND states into one.
The billboard is now far more useful to tell what's going on, and this gets us closer to a state == owner mapping. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
866ba00445
commit
cccdb53bec
24
README.md
24
README.md
@@ -111,16 +111,22 @@ You can check the status of the channel using `cli/lightning-cli listpeers`, whi
|
|||||||
|
|
||||||
### Different states
|
### Different states
|
||||||
|
|
||||||
States starting with `ONCHAIND` mean that the channel has been closed and an onchain transaction exists reflecting the resulting balances
|
* `GOSSIPING` means that you are connected to a peer but there is no
|
||||||
* `ONCHAIND_OUR_UNILATERAL` > Closed by you without cooperation of the counterparty
|
payment channel yet.
|
||||||
* `ONCHAIND_THEIR_UNILATERAL` > Closed by the counterparty without your cooperation
|
* `OPENINGD` means that `lightning_openingd` is negotiating channel opening.
|
||||||
* `ONCHAIND_MUTUAL` > Negotiated closing by both sides
|
* `CHANNELD_AWAITING_LOCKIN` means that `lightning_channeld` is waiting until
|
||||||
|
the minimum number of confirmation on the channel funding transaction.
|
||||||
|
* `CHANNELD_NORMAL` means your channel is operating normally.
|
||||||
|
* `CHANNELD_SHUTTING_DOWN` means one or both sides have asked to shut down the
|
||||||
|
channel, and we're waiting for existing HTLCs to clear.
|
||||||
|
* `CLOSINGD_SIGEXCHANGE` means we're trying to negotiate the fee for the mutual close transaction.
|
||||||
|
* `CLOSINGD_COMPLETE` means we've broadcast our mutual close
|
||||||
|
transaction (which spends the funding transaction) , but haven't seen it in a block yet.
|
||||||
|
* `FUNDING_SPEND_SEEN` means we've seen the funding transaction spent.
|
||||||
|
* `ONCHAIN` means that the `lightning_onchaind` is tracking the onchain closing of the channel.
|
||||||
|
|
||||||
States starting with `CHANNELD` mean that funds are not available onchain, and from that moment they can only be moved offchain, this is, through the Lightning Network
|
All these states have more information about what's going on in the
|
||||||
* `CHANNELD_AWAITING_LOCKIN` > Waiting for confirmation of the channel funding transaction
|
`status` field in `listpeers`.
|
||||||
* `CHANNELD_NORMAL` > Channel is active
|
|
||||||
|
|
||||||
The `GOSSIPING` state means that you are connected to a peer but there is no payment channel yet.
|
|
||||||
|
|
||||||
### Sending and receiving payments
|
### Sending and receiving payments
|
||||||
|
|
||||||
|
|||||||
@@ -171,20 +171,9 @@ static inline bool channel_fees_can_change(const struct channel *channel)
|
|||||||
|| channel->state == CHANNELD_SHUTTING_DOWN;
|
|| channel->state == CHANNELD_SHUTTING_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool channel_can_remove_htlc(const struct channel *channel)
|
|
||||||
{
|
|
||||||
return channel->state == CHANNELD_NORMAL
|
|
||||||
|| channel->state == CHANNELD_SHUTTING_DOWN
|
|
||||||
|| channel->state == ONCHAIND_THEIR_UNILATERAL
|
|
||||||
|| channel->state == ONCHAIND_OUR_UNILATERAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool channel_state_on_chain(enum channel_state state)
|
static inline bool channel_state_on_chain(enum channel_state state)
|
||||||
{
|
{
|
||||||
return state == ONCHAIND_CHEATED
|
return state == ONCHAIN;
|
||||||
|| state == ONCHAIND_THEIR_UNILATERAL
|
|
||||||
|| state == ONCHAIND_OUR_UNILATERAL
|
|
||||||
|| state == ONCHAIND_MUTUAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool channel_on_chain(const struct channel *channel)
|
static inline bool channel_on_chain(const struct channel *channel)
|
||||||
|
|||||||
@@ -22,12 +22,9 @@ enum channel_state {
|
|||||||
/* We've seen the funding spent, we're waiting for onchaind. */
|
/* We've seen the funding spent, we're waiting for onchaind. */
|
||||||
FUNDING_SPEND_SEEN,
|
FUNDING_SPEND_SEEN,
|
||||||
|
|
||||||
/* Various onchain states. */
|
/* On chain */
|
||||||
ONCHAIND_CHEATED,
|
ONCHAIN
|
||||||
ONCHAIND_THEIR_UNILATERAL,
|
|
||||||
ONCHAIND_OUR_UNILATERAL,
|
|
||||||
ONCHAIND_MUTUAL
|
|
||||||
};
|
};
|
||||||
#define CHANNEL_STATE_MAX ONCHAIND_MUTUAL
|
#define CHANNEL_STATE_MAX ONCHAIN
|
||||||
|
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_STATE_H */
|
#endif /* LIGHTNING_LIGHTNINGD_CHANNEL_STATE_H */
|
||||||
|
|||||||
@@ -48,21 +48,8 @@ static void onchaind_tell_fulfill(struct channel *channel)
|
|||||||
|
|
||||||
static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
|
static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
|
||||||
{
|
{
|
||||||
u8 state;
|
/* FIXME: We may already be ONCHAIN state when we implement restart! */
|
||||||
|
channel_set_state(channel, FUNDING_SPEND_SEEN, ONCHAIN);
|
||||||
if (!fromwire_onchain_init_reply(msg, &state)) {
|
|
||||||
channel_internal_error(channel, "Invalid onchain_init_reply");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!channel_state_on_chain(state)) {
|
|
||||||
channel_internal_error(channel,
|
|
||||||
"Invalid onchain_init_reply state %u (%s)",
|
|
||||||
state, channel_state_str(state));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
channel_set_state(channel, FUNDING_SPEND_SEEN, state);
|
|
||||||
|
|
||||||
/* Tell it about any preimages we know. */
|
/* Tell it about any preimages we know. */
|
||||||
onchaind_tell_fulfill(channel);
|
onchaind_tell_fulfill(channel);
|
||||||
|
|||||||
@@ -344,11 +344,8 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (channel->state) {
|
switch (channel->state) {
|
||||||
case ONCHAIND_CHEATED:
|
case ONCHAIN:
|
||||||
case ONCHAIND_THEIR_UNILATERAL:
|
|
||||||
case ONCHAIND_OUR_UNILATERAL:
|
|
||||||
case FUNDING_SPEND_SEEN:
|
case FUNDING_SPEND_SEEN:
|
||||||
case ONCHAIND_MUTUAL:
|
|
||||||
case CLOSINGD_COMPLETE:
|
case CLOSINGD_COMPLETE:
|
||||||
/* Channel is active! */
|
/* Channel is active! */
|
||||||
abort();
|
abort();
|
||||||
|
|||||||
@@ -1051,16 +1051,16 @@ static void wait_for_resolved(struct tracked_output **outs)
|
|||||||
take(towire_onchain_all_irrevocably_resolved(outs)));
|
take(towire_onchain_all_irrevocably_resolved(outs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_state(enum channel_state state)
|
static void init_reply(const char *what)
|
||||||
{
|
{
|
||||||
wire_sync_write(REQ_FD, take(towire_onchain_init_reply(NULL, state)));
|
peer_billboard(true, what);
|
||||||
|
wire_sync_write(REQ_FD, take(towire_onchain_init_reply(NULL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_mutual_close(const struct bitcoin_txid *txid,
|
static void handle_mutual_close(const struct bitcoin_txid *txid,
|
||||||
struct tracked_output **outs)
|
struct tracked_output **outs)
|
||||||
{
|
{
|
||||||
set_state(ONCHAIND_MUTUAL);
|
init_reply("Tracking mutual close transaction");
|
||||||
peer_billboard(true, "Tracking mutual close transaction");
|
|
||||||
|
|
||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
*
|
*
|
||||||
@@ -1269,8 +1269,7 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
|||||||
struct keyset *ks;
|
struct keyset *ks;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
set_state(ONCHAIND_OUR_UNILATERAL);
|
init_reply("Tracking our own unilateral close");
|
||||||
peer_billboard(true, "Tracking our own unilateral close");
|
|
||||||
|
|
||||||
init_feerate_range(outs[0]->satoshi, tx);
|
init_feerate_range(outs[0]->satoshi, tx);
|
||||||
|
|
||||||
@@ -1571,8 +1570,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
|||||||
struct privkey per_commitment_privkey;
|
struct privkey per_commitment_privkey;
|
||||||
struct pubkey per_commitment_point;
|
struct pubkey per_commitment_point;
|
||||||
|
|
||||||
set_state(ONCHAIND_CHEATED);
|
init_reply("Tracking their illegal close: taking all funds");
|
||||||
peer_billboard(true, "Tracking their illegal close: taking all funds");
|
|
||||||
|
|
||||||
init_feerate_range(outs[0]->satoshi, tx);
|
init_feerate_range(outs[0]->satoshi, tx);
|
||||||
|
|
||||||
@@ -1832,8 +1830,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
|||||||
struct keyset *ks;
|
struct keyset *ks;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
set_state(ONCHAIND_THEIR_UNILATERAL);
|
init_reply("Tracking their unilateral close");
|
||||||
peer_billboard(true, "Tracking their unilateral close");
|
|
||||||
|
|
||||||
init_feerate_range(outs[0]->satoshi, tx);
|
init_feerate_range(outs[0]->satoshi, tx);
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,8 @@ onchain_htlc,,htlc,struct htlc_stub
|
|||||||
onchain_htlc,,tell_if_missing,bool
|
onchain_htlc,,tell_if_missing,bool
|
||||||
onchain_htlc,,tell_immediately,bool
|
onchain_htlc,,tell_immediately,bool
|
||||||
|
|
||||||
# This sets what the state is, depending on tx.
|
# This says we're ready; give us preimages.
|
||||||
onchain_init_reply,5101
|
onchain_init_reply,5101
|
||||||
onchain_init_reply,,state,u8
|
|
||||||
|
|
||||||
# onchaind->master: Send out a tx.
|
# onchaind->master: Send out a tx.
|
||||||
onchain_broadcast_tx,5003
|
onchain_broadcast_tx,5003
|
||||||
|
|||||||
|
@@ -1052,10 +1052,10 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
assert closetxid in set([o['txid'] for o in l1.rpc.listfunds()['outputs']])
|
assert closetxid in set([o['txid'] for o in l1.rpc.listfunds()['outputs']])
|
||||||
assert closetxid in set([o['txid'] for o in l2.rpc.listfunds()['outputs']])
|
assert closetxid in set([o['txid'] for o in l2.rpc.listfunds()['outputs']])
|
||||||
|
|
||||||
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status'] == ['CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 5430 satoshi', 'ONCHAIND_MUTUAL:Tracking mutual close transaction', 'ONCHAIND_MUTUAL:All outputs resolved: waiting 99 more blocks before forgetting channel'])
|
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status'] == ['CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 5430 satoshi', 'ONCHAIND:Tracking mutual close transaction', 'ONCHAIND_MUTUAL:All outputs resolved: waiting 99 more blocks before forgetting channel'])
|
||||||
|
|
||||||
l1.bitcoin.rpc.generate(9)
|
l1.bitcoin.rpc.generate(9)
|
||||||
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status'] == ['CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 5430 satoshi', 'ONCHAIND_MUTUAL:Tracking mutual close transaction', 'ONCHAIND_MUTUAL:All outputs resolved: waiting 90 more blocks before forgetting channel'])
|
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status'] == ['CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 5430 satoshi', 'ONCHAIND:Tracking mutual close transaction', 'ONCHAIND_MUTUAL:All outputs resolved: waiting 90 more blocks before forgetting channel'])
|
||||||
|
|
||||||
# Make sure both have forgotten about it
|
# Make sure both have forgotten about it
|
||||||
l1.bitcoin.rpc.generate(90)
|
l1.bitcoin.rpc.generate(90)
|
||||||
@@ -1131,9 +1131,9 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
|
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
for p in peers:
|
for p in peers:
|
||||||
p.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
|
p.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
wait_for(lambda: p.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status'][1] == 'ONCHAIND:Tracking mutual close transaction')
|
||||||
l1.daemon.wait_for_logs([' to ONCHAIND_MUTUAL'] * num_peers)
|
l1.daemon.wait_for_logs([' to ONCHAIN'] * num_peers)
|
||||||
|
|
||||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
||||||
def test_permfail(self):
|
def test_permfail(self):
|
||||||
@@ -1166,19 +1166,19 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET (.*) in 5 blocks')
|
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET (.*) in 5 blocks')
|
||||||
|
|
||||||
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status']
|
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]['status']
|
||||||
== ['CHANNELD_NORMAL:Received error from peer: channel ALL: Internal error: Failing due to dev-fail command',
|
== ['CHANNELD_NORMAL:Received error from peer: channel ALL: Internal error: Failing due to dev-fail command',
|
||||||
'ONCHAIND_THEIR_UNILATERAL:Tracking their unilateral close',
|
'ONCHAIND:Tracking their unilateral close',
|
||||||
'ONCHAIND_THEIR_UNILATERAL:All outputs resolved: waiting 99 more blocks before forgetting channel'])
|
'ONCHAIND:All outputs resolved: waiting 99 more blocks before forgetting channel'])
|
||||||
|
|
||||||
billboard = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status']
|
billboard = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status']
|
||||||
assert len(billboard) == 2
|
assert len(billboard) == 2
|
||||||
assert billboard[0] == 'ONCHAIND_OUR_UNILATERAL:Tracking our own unilateral close'
|
assert billboard[0] == 'ONCHAIND:Tracking our own unilateral close'
|
||||||
assert re.fullmatch('ONCHAIND_OUR_UNILATERAL:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1])
|
assert re.fullmatch('ONCHAIND:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1])
|
||||||
|
|
||||||
# Now, mine 4 blocks so it sends out the spending tx.
|
# Now, mine 4 blocks so it sends out the spending tx.
|
||||||
bitcoind.generate_block(4)
|
bitcoind.generate_block(4)
|
||||||
@@ -1191,7 +1191,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.generate_block(95)
|
bitcoind.generate_block(95)
|
||||||
wait_forget_channels(l1)
|
wait_forget_channels(l1)
|
||||||
|
|
||||||
wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status'] == ['ONCHAIND_OUR_UNILATERAL:Tracking our own unilateral close', 'ONCHAIND_OUR_UNILATERAL:All outputs resolved: waiting 5 more blocks before forgetting channel'], timeout=1)
|
wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status'] == ['ONCHAIND:Tracking our own unilateral close', 'ONCHAIND:All outputs resolved: waiting 5 more blocks before forgetting channel'], timeout=1)
|
||||||
|
|
||||||
# Now, 100 blocks l2 should be done.
|
# Now, 100 blocks l2 should be done.
|
||||||
bitcoind.generate_block(5)
|
bitcoind.generate_block(5)
|
||||||
@@ -1226,8 +1226,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
# 10 later, l1 should collect its to-self payment.
|
# 10 later, l1 should collect its to-self payment.
|
||||||
bitcoind.generate_block(10)
|
bitcoind.generate_block(10)
|
||||||
@@ -1255,8 +1255,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
|
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
# 10 later, l1 should collect its to-self payment.
|
# 10 later, l1 should collect its to-self payment.
|
||||||
bitcoind.generate_block(10)
|
bitcoind.generate_block(10)
|
||||||
@@ -1316,8 +1316,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
# We use 3 blocks for "reasonable depth"
|
# We use 3 blocks for "reasonable depth"
|
||||||
bitcoind.generate_block(3)
|
bitcoind.generate_block(3)
|
||||||
@@ -1369,8 +1369,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
# Wait for timeout.
|
# Wait for timeout.
|
||||||
l1.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET .* in 5 blocks')
|
l1.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET .* in 5 blocks')
|
||||||
@@ -1448,8 +1448,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
# l2 will drop to chain.
|
# l2 will drop to chain.
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log('OUR_UNILATERAL/THEIR_HTLC')
|
l2.daemon.wait_for_log('OUR_UNILATERAL/THEIR_HTLC')
|
||||||
|
|
||||||
# l2 should fulfill HTLC onchain, and spend to-us (any order)
|
# l2 should fulfill HTLC onchain, and spend to-us (any order)
|
||||||
@@ -1524,7 +1524,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.rpc.sendrawtransaction(tx)
|
bitcoind.rpc.sendrawtransaction(tx)
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_CHEATED')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
# FIXME: l1 should try to stumble along!
|
# FIXME: l1 should try to stumble along!
|
||||||
wait_for(lambda: len(l2.getactivechannels()) == 0)
|
wait_for(lambda: len(l2.getactivechannels()) == 0)
|
||||||
|
|
||||||
@@ -1587,7 +1587,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.rpc.sendrawtransaction(tx)
|
bitcoind.rpc.sendrawtransaction(tx)
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_CHEATED')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
# FIXME: l1 should try to stumble along!
|
# FIXME: l1 should try to stumble along!
|
||||||
|
|
||||||
# l2 should spend all of the outputs (except to-us).
|
# l2 should spend all of the outputs (except to-us).
|
||||||
@@ -1623,8 +1623,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, new commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, new commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/THEIR_HTLC by THEIR_HTLC_TIMEOUT_TO_THEM \\(IGNORING\\) in 5 blocks')
|
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/THEIR_HTLC by THEIR_HTLC_TIMEOUT_TO_THEM \\(IGNORING\\) in 5 blocks')
|
||||||
l1.daemon.wait_for_log('Propose handling THEIR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TO_US (.*) in 5 blocks')
|
l1.daemon.wait_for_log('Propose handling THEIR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TO_US (.*) in 5 blocks')
|
||||||
|
|
||||||
@@ -1659,8 +1659,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/THEIR_HTLC by THEIR_HTLC_TIMEOUT_TO_THEM \\(IGNORING\\) in 5 blocks')
|
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/THEIR_HTLC by THEIR_HTLC_TIMEOUT_TO_THEM \\(IGNORING\\) in 5 blocks')
|
||||||
l1.daemon.wait_for_log('Propose handling THEIR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TO_US (.*) in 5 blocks')
|
l1.daemon.wait_for_log('Propose handling THEIR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TO_US (.*) in 5 blocks')
|
||||||
# l2 then gets preimage, uses it instead of ignoring
|
# l2 then gets preimage, uses it instead of ignoring
|
||||||
@@ -1701,8 +1701,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_logs(['Propose handling OUR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TX \\(.*\\) in 5 blocks',
|
l2.daemon.wait_for_logs(['Propose handling OUR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TX \\(.*\\) in 5 blocks',
|
||||||
'Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET .* in 5 blocks'])
|
'Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET .* in 5 blocks'])
|
||||||
|
|
||||||
@@ -2277,8 +2277,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l1.daemon.wait_for_log('Offered HTLC 0 SENT_ADD_ACK_REVOCATION cltv .* hit deadline')
|
l1.daemon.wait_for_log('Offered HTLC 0 SENT_ADD_ACK_REVOCATION cltv .* hit deadline')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
# L1 will timeout HTLC immediately
|
# L1 will timeout HTLC immediately
|
||||||
l1.daemon.wait_for_logs(['Propose handling OUR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TX .* in 0 blocks',
|
l1.daemon.wait_for_logs(['Propose handling OUR_UNILATERAL/OUR_HTLC by OUR_HTLC_TIMEOUT_TX .* in 0 blocks',
|
||||||
@@ -2332,8 +2332,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l2.daemon.wait_for_log('Fulfilled HTLC 0 SENT_REMOVE_COMMIT cltv .* hit deadline')
|
l2.daemon.wait_for_log('Fulfilled HTLC 0 SENT_REMOVE_COMMIT cltv .* hit deadline')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l2.bitcoin.generate_block(1)
|
l2.bitcoin.generate_block(1)
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
# L2 will collect HTLC
|
# L2 will collect HTLC
|
||||||
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/THEIR_HTLC by OUR_HTLC_SUCCESS_TX .* in 0 blocks')
|
l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/THEIR_HTLC by OUR_HTLC_SUCCESS_TX .* in 0 blocks')
|
||||||
@@ -3016,7 +3016,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
# L1 must notice.
|
# L1 must notice.
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
||||||
def test_payment_success_persistence(self):
|
def test_payment_success_persistence(self):
|
||||||
@@ -3294,8 +3294,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
|
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
bitcoind.generate_block(99)
|
bitcoind.generate_block(99)
|
||||||
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||||
@@ -3410,8 +3410,8 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
|
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
|
|
||||||
bitcoind.generate_block(99)
|
bitcoind.generate_block(99)
|
||||||
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
l1.daemon.wait_for_log('onchaind complete, forgetting peer')
|
||||||
|
|||||||
@@ -198,6 +198,8 @@ char *dbmigrations[] = {
|
|||||||
"CREATE TABLE db_upgrades (upgrade_from INTEGER, lightning_version TEXT);",
|
"CREATE TABLE db_upgrades (upgrade_from INTEGER, lightning_version TEXT);",
|
||||||
/* We used not to clean up peers when their channels were gone. */
|
/* We used not to clean up peers when their channels were gone. */
|
||||||
"DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);",
|
"DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);",
|
||||||
|
/* The ONCHAIND_CHEATED/THEIR_UNILATERAL/OUR_UNILATERAL/MUTUAL are now one */
|
||||||
|
"UPDATE channels SET STATE = 8 WHERE state > 8;",
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user