|
1 | 1 | use crate::lnurlauth::AuthManager; |
2 | 2 | use crate::logging::LOGGING_KEY; |
3 | 3 | use crate::multiesplora::MultiEsploraClient; |
| 4 | +use crate::payjoin::PayjoinStorage; |
4 | 5 | use crate::redshift::{RedshiftManager, RedshiftStatus, RedshiftStorage}; |
5 | 6 | use crate::storage::{MutinyStorage, DEVICE_ID_KEY, KEYCHAIN_STORE_KEY, NEED_FULL_SYNC_KEY}; |
6 | 7 | use crate::utils::{sleep, spawn}; |
@@ -844,6 +845,14 @@ impl<S: MutinyStorage> NodeManager<S> { |
844 | 845 | /// Starts a background tasks to poll payjoin directory to attempt receiving. |
845 | 846 | pub(crate) fn start_payjoins(nm: Arc<NodeManager<S>>) { |
846 | 847 | let all = nm.storage.get_payjoins().unwrap_or_default(); |
| 848 | + for payjoin in all { |
| 849 | + let wallet = nm.wallet.clone(); |
| 850 | + let stop = nm.stop.clone(); |
| 851 | + utils::spawn(async move { |
| 852 | + let pj_txid = Self::receive_payjoin(wallet, stop, payjoin).await.unwrap(); |
| 853 | + log::info!("Received payjoin txid: {}", pj_txid); |
| 854 | + }); |
| 855 | + } |
847 | 856 | } |
848 | 857 |
|
849 | 858 | /// Starts a background tasks to poll redshifts until they are ready and then start attempting payments. |
@@ -1078,6 +1087,7 @@ impl<S: MutinyStorage> NodeManager<S> { |
1078 | 1087 | .process_res(ohttp_response.as_ref(), context) |
1079 | 1088 | .map_err(|e| anyhow!("parse error {}", e)) |
1080 | 1089 | .unwrap(); |
| 1090 | + self.storage.persist_payjoin(enrolled.clone()).unwrap(); |
1081 | 1091 | let pj_uri = enrolled.fallback_target(); |
1082 | 1092 | log_debug!(self.logger, "{pj_uri}"); |
1083 | 1093 | // run await payjoin task in the background as it'll keep polling the relay |
|
0 commit comments