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>
@ -111,16 +111,22 @@ You can check the status of the channel using `cli/lightning-cli listpeers`, whi
### Different states
States starting with `ONCHAIND` mean that the channel has been closed and an onchain transaction exists reflecting the resulting balances
* `ONCHAIND_OUR_UNILATERAL` > Closed by you without cooperation of the counterparty
* `ONCHAIND_THEIR_UNILATERAL` > Closed by the counterparty without your cooperation
* `ONCHAIND_MUTUAL` > Negotiated closing by both sides
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
* `CHANNELD_AWAITING_LOCKIN` > Waiting for confirmation of the channel funding transaction
* `CHANNELD_NORMAL` > Channel is active
The `GOSSIPING` state means that you are connected to a peer but there is no payment channel yet.
* `GOSSIPING` means that you are connected to a peer but there is no
payment channel yet.
* `OPENINGD` means that `lightning_openingd` is negotiating channel opening.
* `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.
All these states have more information about what's going on in the
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)
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
l1.bitcoin.rpc.generate(90)
@ -1131,9 +1131,9 @@ class LightningDTests(BaseLightningDTests):
bitcoind.generate_block(1)
forpinpeers:
p.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
l1.daemon.wait_for_logs([' to ONCHAIND_MUTUAL']*num_peers)
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 ONCHAIN']*num_peers)
assertbillboard[0]=='ONCHAIND_OUR_UNILATERAL:Tracking our own unilateral close'
assertre.fullmatch('ONCHAIND_OUR_UNILATERAL:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET',billboard[1])
assertbillboard[0]=='ONCHAIND:Tracking our own unilateral close'
assertre.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.
bitcoind.generate_block(4)
@ -1191,7 +1191,7 @@ class LightningDTests(BaseLightningDTests):
bitcoind.generate_block(95)
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.
bitcoind.generate_block(5)
@ -1226,8 +1226,8 @@ class LightningDTests(BaseLightningDTests):
l1.daemon.wait_for_log('permfail')
l1.daemon.wait_for_log('sendrawtx exit 0')
l1.bitcoin.generate_block(1)
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
l1.daemon.wait_for_log(' to ONCHAIN')
l2.daemon.wait_for_log(' to ONCHAIN')
# 10 later, l1 should collect its to-self payment.
bitcoind.generate_block(10)
@ -1255,8 +1255,8 @@ class LightningDTests(BaseLightningDTests):
l1.daemon.wait_for_log('sendrawtx exit 0')
l1.bitcoin.generate_block(1)
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
l1.daemon.wait_for_log(' to ONCHAIN')
l2.daemon.wait_for_log(' to ONCHAIN')
# 10 later, l1 should collect its to-self payment.
bitcoind.generate_block(10)
@ -1316,8 +1316,8 @@ class LightningDTests(BaseLightningDTests):
l1.daemon.wait_for_log('permfail')
l1.daemon.wait_for_log('sendrawtx exit 0')
l1.bitcoin.generate_block(1)
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
l1.daemon.wait_for_log(' to ONCHAIN')
l2.daemon.wait_for_log(' to ONCHAIN')
# We use 3 blocks for "reasonable depth"
bitcoind.generate_block(3)
@ -1369,8 +1369,8 @@ class LightningDTests(BaseLightningDTests):
l1.daemon.wait_for_log('permfail')
l1.daemon.wait_for_log('sendrawtx exit 0')
l1.bitcoin.generate_block(1)
l1.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
l2.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')
l1.daemon.wait_for_log(' to ONCHAIN')
l2.daemon.wait_for_log(' to ONCHAIN')
# 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')
@ -1448,8 +1448,8 @@ class LightningDTests(BaseLightningDTests):
# l2 will drop to chain.
l2.daemon.wait_for_log('sendrawtx exit 0')
l1.bitcoin.generate_block(1)
l2.daemon.wait_for_log(' to ONCHAIND_OUR_UNILATERAL')
l1.daemon.wait_for_log(' to ONCHAIND_THEIR_UNILATERAL')