Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
9f6fbd6
feat: pay contacts through pubky swaps
ovitrif Oct 30, 2026
c32983d
docs: add the paykit swap route journey
ovitrif Oct 30, 2026
82f2bb1
chore: add changelog fragment
ovitrif Oct 30, 2026
2ca81e4
chore: move to bitkit-core 0.8.0-swaps.3
ovitrif Nov 2, 2026
4677e4f
feat: pay on-chain contacts from spark
ovitrif Nov 2, 2026
38e8239
chore: add changelog fragment
ovitrif Nov 2, 2026
438d6ae
docs: add the paykit spark route journey
ovitrif Nov 2, 2026
59f6ff5
chore: merge feat/breez-spark-lightning
ovitrif Nov 5, 2026
8a75ad7
chore: merge feat/breez-spark-lightning
ovitrif Nov 5, 2026
f0bcc7e
fix: spark route reads the withdrawal txid on sdk 0.28
ovitrif Nov 5, 2026
7cf79e3
chore: merge feat/breez-spark-lightning
ovitrif Nov 6, 2026
c603363
chore: merge feat/breez-spark-lightning
ovitrif Nov 6, 2026
49b360c
chore: merge feat/breez-spark-lightning
ovitrif Nov 6, 2026
9075526
chore: merge feat/breez-spark-lightning
ovitrif Nov 6, 2026
db34878
feat: route every contact payment through the paykit router
ovitrif Nov 6, 2026
53a7648
chore: merge feat/breez-spark-lightning
ovitrif Nov 6, 2026
525004a
chore: translate the paykit no-route copy
ovitrif Nov 7, 2026
771b250
feat: pay paykit requests through the router and spark
ovitrif Nov 7, 2026
0a47cc8
fix: charge the spark leg its broadcast fee and keep it a send
ovitrif Nov 7, 2026
4521e56
fix: keep spark contact withdrawals recoverable
ovitrif Nov 7, 2026
a2a3400
fix: settle spark contact withdrawals only after a fresh sync
ovitrif Nov 7, 2026
8fcb3cc
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
54a0ff1
fix: keep contact payments off the spark transfer list
ovitrif Nov 9, 2026
0b5b531
fix: keep the swipe off when confirm's reroute is refused
ovitrif Nov 9, 2026
d7c88bd
fix: give back the private list when a spark withdrawal never sent
ovitrif Nov 9, 2026
45e9be7
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
bbcc069
fix: keep the spark withdrawal journal until its proof is released
ovitrif Nov 9, 2026
d7883b0
fix: count spark-routed requests in the allowance ledger
ovitrif Nov 9, 2026
e88af97
fix: show an unresolved spark send as pending
ovitrif Nov 9, 2026
7db039f
fix: settle a spark send's allowance attempt from its journal
ovitrif Nov 9, 2026
2dcd538
fix: end a spark withdrawal spark returns as failed as a failure
ovitrif Nov 9, 2026
54c0e0d
fix: price a spark-funded request at its on-chain endpoint
ovitrif Nov 9, 2026
4c73571
fix: settle a pending spark send from its journal
ovitrif Nov 9, 2026
97280c2
fix: keep a pending spark send off the node's on-chain attempts
ovitrif Nov 9, 2026
bda656f
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
3a310c4
fix: write the spark journal before its request proof starts
ovitrif Nov 9, 2026
609be76
fix: drop a paykit route that returns after its payment changed
ovitrif Nov 9, 2026
11f7433
test: run the spending confirm check on the main actor
ovitrif Nov 9, 2026
d20530e
fix: keep an unselected lnurl's price and minimum off a spark leg
ovitrif Nov 9, 2026
8de0a46
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
775f644
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
921c3f8
fix: close only a spark journal's own proof and allowance attempt
ovitrif Nov 9, 2026
2555a90
fix: give back a request's private list when its spark proof never st…
ovitrif Nov 9, 2026
86d02ce
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
2a91662
fix: clear a spark withdrawal journal only while it is still open
ovitrif Nov 9, 2026
cd03aec
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 9, 2026
724ec71
chore: log private payment list publication
ovitrif Nov 9, 2026
e7a2492
fix: keep a dismissed payment request from popping up again
ovitrif Nov 10, 2026
2b6bf07
fix: offer spending on confirm while spark can pay an on-chain request
ovitrif Nov 10, 2026
c5f9f61
fix: publish a spark withdrawal's resolution only when its journal cl…
ovitrif Nov 10, 2026
8f5e15f
fix: keep a stale spark withdrawal settle off a retry's proof and all…
ovitrif Nov 10, 2026
e2f9a36
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 10, 2026
be2c540
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 10, 2026
5c9179b
fix: check the quote deadline right before a spark withdrawal sends
ovitrif Nov 10, 2026
6bb6134
fix: keep the funding source switchable on a spark route
ovitrif Nov 10, 2026
76a1aee
test: pin the funding source control on a spark route
ovitrif Nov 10, 2026
2eea8e5
fix: keep a failed spark withdrawal open after a sync that never reac…
ovitrif Nov 10, 2026
a21a20d
fix: drop a paykit route quote once its source or amount changed
ovitrif Nov 10, 2026
6957828
fix: settle an unsent spark withdrawal's allowance before dropping it…
ovitrif Nov 10, 2026
803edb2
chore: merge feat/breez-spark-lightning into feat/paykit-spark-route
ovitrif Nov 10, 2026
e6678ae
chore: merge feat/breez-spark-lightning into feat/paykit-spark-route
ovitrif Nov 11, 2026
88fb385
fix: hide boost on a pending spark withdrawal
ovitrif Nov 11, 2026
b96e53e
fix: restore the endpoint a paykit reroute picks
ovitrif Nov 11, 2026
4ea41b6
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 11, 2026
daec38b
fix: validate a spark withdrawal against its debit and spark's balance
ovitrif Nov 11, 2026
ec8daf9
fix: check a rerouted lnurl's minimum before confirm
ovitrif Nov 11, 2026
f0f06df
fix: check a rerouted lnurl's maximum before confirm
ovitrif Nov 11, 2026
238abe5
fix: settle pending spark withdrawals and guard contact routing
ovitrif Nov 11, 2026
412ddd7
fix: offer the spark leg when lightning pays the lnurl minimum
ovitrif Nov 11, 2026
9f7afa9
fix: skip the spark quote when lightning pays a contact
ovitrif Nov 11, 2026
8f66a5d
fix: name the lnurl limit when no route pays a contact
ovitrif Nov 11, 2026
a2d84a7
fix: hold a pending spark withdrawal until spark completes it
ovitrif Nov 11, 2026
b261472
fix: route a mixed bitcoin contact through spark when no endpoint pays
ovitrif Nov 11, 2026
33236e6
Merge branch 'feat/breez-spark-lightning' into feat/paykit-spark-route
ovitrif Nov 11, 2026
32b3379
fix: show the balance copy when spark's fee takes a contact payment p…
ovitrif Nov 11, 2026
aedeee5
fix: leave an open contact withdrawal off spark's transfers to savings
ovitrif Nov 11, 2026
1a3a179
fix: close a contact withdrawal spark refuses for a fee rise at once
ovitrif Nov 11, 2026
e24e37c
fix: refuse a spark contact leg while an earlier withdrawal settles
ovitrif Nov 11, 2026
da90a39
fix: keep confirm's first route refusal and block its payment
ovitrif Nov 11, 2026
8354e2b
Merge remote-tracking branch 'origin/feat/breez-spark-lightning' into…
ovitrif Nov 11, 2026
d1efd4f
fix: re-route when the source changes on confirm
ovitrif Nov 11, 2026
313c683
fix: confirm a spark withdrawal from the chain
ovitrif Nov 11, 2026
46ccee9
fix: resolve an lnurl the router picks
ovitrif Nov 11, 2026
c8d16ff
fix: show the request note on a spark leg
ovitrif Nov 11, 2026
c2346f3
fix: match a spark withdrawal by its idempotency key
ovitrif Nov 11, 2026
3a772cc
Merge commit '18946a0f0' into HEAD
ovitrif Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@
repositoryURL = "https://github.com/synonymdev/bitkit-core";
requirement = {
kind = exactVersion;
version = "0.8.0-rc11";
version = "0.8.0-spark.3";
};
};
96E493A22C942FD1000E8BC2 /* XCRemoteSwiftPackageReference "swift-secp256k1" */ = {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

646 changes: 643 additions & 3 deletions Bitkit/Managers/SparkManager.swift

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,9 @@
"wallet__send_sync_long_title" = "مشاكل\n<accent>الاتصال</accent>";
"wallet__send_sync_long_description" = "يبدو أنك غير متصل. يرجى التحقق من اتصالك. سيحاول Bitkit إعادة الاتصال كل بضع ثوانٍ.";
"wallet__send_to" = "إلى";
"wallet__send_swap_route" = "المسار";
"wallet__send_paykit_no_route__title" = "تعذّر الدفع لجهة الاتصال هذه";
"wallet__send_paykit_no_route__description" = "ليس لدى جهة الاتصال هذه طريقة دفع يمكن لـ Bitkit استخدامها حاليًا.";
"wallet__recipient_contact" = "جهة الاتصال";
"wallet__recipient_invoice" = "لصق فاتورة";
"wallet__recipient_manual" = "إدخال يدوي";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,9 @@
"wallet__send_sync_long_title" = "Problemes de\n<accent>connexió</accent>";
"wallet__send_sync_long_description" = "Sembla que estàs desconnectat. Comprova la connexió. Bitkit intentarà tornar a connectar-se cada pocs segons.";
"wallet__send_to" = "A";
"wallet__send_swap_route" = "Ruta";
"wallet__send_paykit_no_route__title" = "No es pot pagar aquest contacte";
"wallet__send_paykit_no_route__description" = "Aquest contacte no té cap mètode de pagament que Bitkit pugui fer servir ara mateix.";
"wallet__recipient_contact" = "Contacte";
"wallet__recipient_invoice" = "Enganxa factura";
"wallet__recipient_manual" = "Introdueix manualment";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@
"wallet__send_sync_long_title" = "<accent>Problémy</accent>\ns připojením";
"wallet__send_sync_long_description" = "Zdá se, že jste odpojeni. Zkontrolujte prosím připojení. Bitkit se bude každých několik sekund pokoušet znovu připojit.";
"wallet__send_to" = "Komu";
"wallet__send_swap_route" = "Trasa";
"wallet__send_paykit_no_route__title" = "Tomuto kontaktu nelze zaplatit";
"wallet__send_paykit_no_route__description" = "Tento kontakt teď nemá žádný platební způsob, který by Bitkit mohl použít.";
"wallet__recipient_contact" = "Kontakt";
"wallet__recipient_invoice" = "Vložit fakturu";
"wallet__recipient_manual" = "Zadat ručně";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,9 @@
"wallet__send_sync_long_title" = "<accent>Verbindungs-</accent>\nprobleme";
"wallet__send_sync_long_description" = "Anscheinend bist du nicht verbunden. Bitte überprüfe deine Verbindung. Bitkit versucht alle paar Sekunden, sich erneut zu verbinden.";
"wallet__send_to" = "An";
"wallet__send_swap_route" = "Route";
"wallet__send_paykit_no_route__title" = "Zahlung an diesen Kontakt nicht möglich";
"wallet__send_paykit_no_route__description" = "Dieser Kontakt hat derzeit keine Zahlungsmethode, die Bitkit nutzen kann.";
"wallet__recipient_contact" = "Kontakt";
"wallet__recipient_invoice" = "Rechnung einfügen";
"wallet__recipient_manual" = "Manuell eingeben";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,9 @@
"wallet__send_sync_long_title" = "<accent>Προβλήματα</accent>\nσύνδεσης";
"wallet__send_sync_long_description" = "Φαίνεται ότι είστε αποσυνδεδεμένοι. Ελέγξτε τη σύνδεσή σας. Το Bitkit θα προσπαθεί να επανασυνδεθεί κάθε λίγα δευτερόλεπτα.";
"wallet__send_to" = "Προς";
"wallet__send_swap_route" = "Διαδρομή";
"wallet__send_paykit_no_route__title" = "Δεν είναι δυνατή η πληρωμή αυτής της επαφής";
"wallet__send_paykit_no_route__description" = "Αυτή η επαφή δεν έχει αυτή τη στιγμή κάποια μέθοδο πληρωμής που μπορεί να χρησιμοποιήσει το Bitkit.";
"wallet__recipient_contact" = "Επαφή";
"wallet__recipient_invoice" = "Επικόλληση Τιμολογίου";
"wallet__recipient_manual" = "Χειροκίνητη Εισαγωγή";
Expand Down
4 changes: 4 additions & 0 deletions Bitkit/Resources/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,10 @@
"wallet__send_sync_long_title" = "<accent>Connection</accent>\nissues";
"wallet__send_sync_long_description" = "It appears you’re disconnected. Please check your connection. Bitkit will try to reconnect every few seconds.";
"wallet__send_to" = "To";
"wallet__send_swap_route" = "Route";
"wallet__send_paykit_no_route__title" = "Can't pay this contact";
"wallet__send_paykit_no_route__description" = "This contact has no payment method Bitkit can use right now.";
"wallet__send_paykit_withdrawal_settling__description" = "An earlier withdrawal from your spending balance is still settling. Try again once it completes.";
Comment thread
ovitrif marked this conversation as resolved.
Resolved
Comment thread
ovitrif marked this conversation as resolved.
Resolved
"wallet__recipient_contact" = "Contact";
"wallet__recipient_invoice" = "Paste Invoice";
"wallet__recipient_manual" = "Enter Manually";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,9 @@
"wallet__send_sync_long_title" = "Problemas de\n<accent>conexión</accent>";
"wallet__send_sync_long_description" = "Parece que está desconectado. Revise su conexión. Bitkit intentará reconectarse cada pocos segundos.";
"wallet__send_to" = "Para";
"wallet__send_swap_route" = "Ruta";
"wallet__send_paykit_no_route__title" = "No se puede pagar a este contacto";
"wallet__send_paykit_no_route__description" = "Este contacto no tiene ningún método de pago que Bitkit pueda usar en este momento.";
"wallet__recipient_contact" = "Contacto";
"wallet__recipient_invoice" = "Pegar factura";
"wallet__recipient_manual" = "Introducir manualmente";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,9 @@
"wallet__send_sync_long_title" = "Problemas de\n<accent>conexión</accent>";
"wallet__send_sync_long_description" = "Parece que está desconectado. Compruebe su conexión. Bitkit intentará reconectarse cada pocos segundos.";
"wallet__send_to" = "Para";
"wallet__send_swap_route" = "Ruta";
"wallet__send_paykit_no_route__title" = "No se puede pagar a este contacto";
"wallet__send_paykit_no_route__description" = "Este contacto no tiene ningún método de pago que Bitkit pueda usar ahora mismo.";
"wallet__recipient_contact" = "Contactar";
"wallet__recipient_invoice" = "Pegar factura";
"wallet__recipient_manual" = "Introducir manualmente";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,9 @@
"wallet__send_sync_long_title" = "Problèmes de\n<accent>connexion</accent>";
"wallet__send_sync_long_description" = "Il semble que vous soyez déconnecté. Veuillez vérifier votre connexion. Bitkit tentera de se reconnecter toutes les quelques secondes.";
"wallet__send_to" = "Pour";
"wallet__send_swap_route" = "Itinéraire";
"wallet__send_paykit_no_route__title" = "Impossible de payer ce contact";
"wallet__send_paykit_no_route__description" = "Ce contact n’a actuellement aucun moyen de paiement que Bitkit peut utiliser.";
"wallet__recipient_contact" = "Contact";
"wallet__recipient_invoice" = "Coller la facture";
"wallet__recipient_manual" = "Entrer manuellement";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,9 @@
"wallet__send_sync_long_title" = "Problemi di\n<accent>connessione</accent>";
"wallet__send_sync_long_description" = "Sembra che tu sia disconnesso. Controlla la connessione. Bitkit proverà a riconnettersi ogni pochi secondi.";
"wallet__send_to" = "A";
"wallet__send_swap_route" = "Percorso";
"wallet__send_paykit_no_route__title" = "Impossibile pagare questo contatto";
"wallet__send_paykit_no_route__description" = "Al momento questo contatto non ha un metodo di pagamento che Bitkit possa usare.";
"wallet__recipient_contact" = "Contatto";
"wallet__recipient_invoice" = "Incolla fattura";
"wallet__recipient_manual" = "Inserisci Manualmente";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,9 @@
"wallet__send_sync_long_title" = "<accent>Verbindings</accent>\nproblemen";
"wallet__send_sync_long_description" = "Het lijkt erop dat u niet verbonden bent. Controleer uw verbinding. Bitkit probeert om de paar seconden opnieuw verbinding te maken.";
"wallet__send_to" = "Naar";
"wallet__send_swap_route" = "Route";
"wallet__send_paykit_no_route__title" = "Kan dit contact niet betalen";
"wallet__send_paykit_no_route__description" = "Dit contact heeft op dit moment geen betaalmethode die Bitkit kan gebruiken.";
"wallet__recipient_contact" = "Contact";
"wallet__recipient_invoice" = "Factuur Plakken";
"wallet__recipient_manual" = "Handmatig Invoeren";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,9 @@
"wallet__send_sync_long_title" = "<accent>Problemy</accent>\nz połączeniem";
"wallet__send_sync_long_description" = "Wygląda na to, że nie masz połączenia. Sprawdź połączenie. Bitkit będzie próbował połączyć się ponownie co kilka sekund.";
"wallet__send_to" = "Do";
"wallet__send_swap_route" = "Trasa";
"wallet__send_paykit_no_route__title" = "Nie można zapłacić temu kontaktowi";
"wallet__send_paykit_no_route__description" = "Ten kontakt nie ma obecnie żadnej metody płatności, której Bitkit może użyć.";
"wallet__recipient_contact" = "Kontakt";
"wallet__recipient_invoice" = "Wklej fakturę";
"wallet__recipient_manual" = "Wprowadź ręcznie";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,9 @@
"wallet__send_sync_long_title" = "Problemas de\n<accent>conexão</accent>";
"wallet__send_sync_long_description" = "Parece que você está desconectado. Verifique sua conexão. A Bitkit tentará se reconectar a cada poucos segundos.";
"wallet__send_to" = "Para";
"wallet__send_swap_route" = "Rota";
"wallet__send_paykit_no_route__title" = "Não é possível pagar este contato";
"wallet__send_paykit_no_route__description" = "Este contato não tem nenhum método de pagamento que o Bitkit possa usar agora.";
"wallet__recipient_contact" = "Contato";
"wallet__recipient_invoice" = "Colar Invoice";
"wallet__recipient_manual" = "Inserir Manualmente";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/pt.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,9 @@
"wallet__send_sync_long_title" = "Problemas\n<accent>de ligação</accent>";
"wallet__send_sync_long_description" = "Parece que está desligado. Verifique a sua ligação. A Bitkit vai tentar voltar a ligar a cada poucos segundos.";
"wallet__send_to" = "Para";
"wallet__send_swap_route" = "Rota";
"wallet__send_paykit_no_route__title" = "Não é possível pagar a este contacto";
"wallet__send_paykit_no_route__description" = "Este contacto não tem neste momento nenhum método de pagamento que a Bitkit possa usar.";
"wallet__recipient_contact" = "Contato";
"wallet__recipient_invoice" = "Colar Invoice";
"wallet__recipient_manual" = "Inserir Manualmente";
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/Resources/Localization/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,9 @@
"wallet__send_sync_long_title" = "<accent>Проблемы</accent>\nс подключением";
"wallet__send_sync_long_description" = "Похоже, вы отключены. Проверьте подключение. Bitkit будет пытаться переподключиться каждые несколько секунд.";
"wallet__send_to" = "Кому";
"wallet__send_swap_route" = "Маршрут";
"wallet__send_paykit_no_route__title" = "Не удаётся оплатить этому контакту";
"wallet__send_paykit_no_route__description" = "У этого контакта сейчас нет способа оплаты, который может использовать Bitkit.";
"wallet__recipient_contact" = "Контакт";
"wallet__recipient_invoice" = "Вставить Инвойс";
"wallet__recipient_manual" = "Ввести Вручную";
Expand Down
18 changes: 18 additions & 0 deletions Bitkit/Services/CoreService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,24 @@ class ActivityService {
}
}

/// Marks a sent on-chain activity the node doesn't watch, such as a Spark withdrawal to a contact, as confirmed once
/// its sender reports it complete.
func markOnchainActivityAsConfirmed(txId: String) async {
do {
try await ServiceQueue.background(.core) {
guard let existing = try BitkitCore.getActivityByTxId(walletId: WalletScope.default, txId: txId),
!existing.confirmed
else { return }
var updated = existing
updated.confirmed = true
try updateActivity(activityId: existing.id, activity: .onchain(updated))
self.activitiesChangedSubject.send()
}
} catch {
Logger.error("Failed to mark activity as confirmed for \(txId): \(error)", context: "ActivityService")
}
}

/// Marks the on-chain activity for `txId` as a transfer between Savings and Spending that has no channel,
/// such as a Spark deposit or withdrawal. No-op until the activity exists or once it is marked.
func markOnchainActivityAsTransfer(txId: String) async {
Expand Down
21 changes: 19 additions & 2 deletions Bitkit/Services/PaykitAllowanceExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,10 @@ actor PaykitAllowanceExecutor {
setStage(.sending, attemptId: attemptId, identity: identity)
}

func finishManualPayment(attemptId: String, outcome: Paykit.PaymentOutcome, transactionId: String? = nil) async {
guard let identity = activeIdentity else { return }
/// Returns whether the outcome was recorded.
@discardableResult
func finishManualPayment(attemptId: String, outcome: Paykit.PaymentOutcome, transactionId: String? = nil) async -> Bool {
guard let identity = activeIdentity else { return false }
if let transactionId {
updateLocalState(identity: identity) { state in
guard let index = state.journal.firstIndex(where: { $0.attemptId == attemptId }) else { return }
Expand All @@ -1368,11 +1370,26 @@ actor PaykitAllowanceExecutor {
}
do {
try await record(attemptId: attemptId, outcome: outcome, identity: identity)
return true
} catch {
Logger.warn("Failed to record a manual payment outcome: \(error)", context: "PaykitAllowance")
return false
}
}

/// Settles the manual attempt still open for a request once its outcome is learned later, as a Spark withdrawal's
/// journal learns it, so an unsent send no longer blocks the request on the ledger.
/// Returns whether no attempt is left open for the request.
@discardableResult
func settleManualPayment(requestId: PaykitPaymentRequest.ID, outcome: Paykit.PaymentOutcome, transactionId: String? = nil) async -> Bool {
guard let identity = activeIdentity else { return false }
guard let entry = localState(identity: identity).journal.last(where: {
!$0.isAutomatic && $0.requestId == requestId && !$0.stage.isTerminal
})
else { return true }
return await finishManualPayment(attemptId: entry.attemptId, outcome: outcome, transactionId: transactionId)
}

// MARK: Helpers

private func checks(_ request: PaykitPaymentRequest, endpointIdentifier: String, trustedTime: String) throws -> Paykit.PaymentExecutionChecks {
Expand Down
Loading
Loading