ACINQ / phoenix

Phoenix is a self-custodial Bitcoin wallet using Lightning to send/receive payments.
https://phoenix.acinq.co
Apache License 2.0
624 stars 93 forks source link

(ios) Keep-alive integration #472

Closed robbiehanson closed 7 months ago

robbiehanson commented 7 months ago

This integrates the keep-alive mechanism from lightning-kmp #550.

Each call uses a unique identifier that is extracted from the parameters in TaskStarted/TaskEnded. So if these events are broadcast multiple times, the system can easily ignore them.

In addition, iOS will "punish" our app if we abuse the longLivedTask system. That is, if we always ask for background execution time. Which would happen if the lightning-kmp library didn't always emit a TaskEnded in every situation. So to protect against this we've also added a backup call to endLongLivedTask that will be executed automatically after a timeout.

This updated architecture is now also used for payments, which are driven by the PeerEvent's: PaymentProgress, PaymentSent, PaymentNotSent.