When a payment is pending, then times out, the app needs to be online and connected to the peer to negotiate the payment failure. If the app goes off while a payment is pending, and then does not connect once it times out, the peer is forced after a while to unilaterally close the channel.
This issue is already taken care thanks to the silent push notifications sent by the peer that will "wake up" Phoenix remotely, so that it can settle these pending payments. However, this does not work all the time and there still may be force closures.
This PR schedules a task that runs when the app is in the background/off and there are in-flight payments.
This task consists in simply starting the node, which connects to the peer and wait for any pending payments ready to be finalised to be finalised. Once all payments are settled, or after 30s (iOS) or 2 minutes (Android) the task aborts.
This tasks runs on both the iOS and the Android app (although on iOS, the task is merged with the watchtower, since the OS allows us to schedule only 1 BGAppRefreshTask).
On Android, we also display a badge in the home screen that counts in-flight payments to make the user aware that a payment is in-flight.
When a payment is pending, then times out, the app needs to be online and connected to the peer to negotiate the payment failure. If the app goes off while a payment is pending, and then does not connect once it times out, the peer is forced after a while to unilaterally close the channel.
This issue is already taken care thanks to the silent push notifications sent by the peer that will "wake up" Phoenix remotely, so that it can settle these pending payments. However, this does not work all the time and there still may be force closures.
This PR schedules a task that runs when the app is in the background/off and there are in-flight payments.
This task consists in simply starting the node, which connects to the peer and wait for any pending payments ready to be finalised to be finalised. Once all payments are settled, or after 30s (iOS) or 2 minutes (Android) the task aborts.
This tasks runs on both the iOS and the Android app (although on iOS, the task is merged with the watchtower, since the OS allows us to schedule only 1
BGAppRefreshTask
).On Android, we also display a badge in the home screen that counts in-flight payments to make the user aware that a payment is in-flight.