Commit Graph

17 Commits

Author SHA1 Message Date
Ross Savage
5d9a8f18a3 Add Config (#267)
* Add config

* Add rustdocs to Config, send_payment (#271)

---------

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-06-01 06:32:45 +02:00
ok300
f6082f2aa5 Add global SDK logger (#242)
* Add SDK global logger

* Add bindings

* Fix path to internal uniffi log

* Exclude "set_log_stream" from generated RN methods

* Move logger-specific structs to a separate module

* Delegate init_logging to method in logger.rs

* Rename uniffi BindingLogger to UniffiBindingLogger

* Add set_log_stream for dart bindings

* Add SDK logger to Dart bindings

* Rename dart binding logger to DartBindingLogger

* Add rustdocs

* RN bindings: Add manual handling for setLogStream()

* Re-generate dart bindings

* Re-generate RN bindings

* Remove LOG_INIT cell

* Set global maximum log level once on initialization

Return a LiquidSdkError::Generic instead of Anyhow error when initializing log stream on Dart bindings

* Do not panic when initializing binding loggers

* Rename LogStream to Logger

---------

Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>
2024-05-31 18:01:39 +00:00
Erdem Yerebasmaz
e0322c39d6 Remove tokio runtime (#239)
* Remove obsolete Tokio runtime dependency on bindings

* Apply changes on example app

* Update "Getting Started" on README

* Update pubspec.lock
2024-05-30 17:04:58 +03:00
ok300
e5dba1043e Add ability to parse an invoice (#240)
* Add ability to parse an invoice

* Simplify LNInvoice initialization

* Add missing LNInvoice fields

* Cargo fmt

* Re-generate bindings after merging main branch

* Explicitly check the invoice signature

* Remove redundant signature check

* Strip potential lightning: prefix before parsing bolt11
2024-05-30 13:26:00 +00:00
ok300
434fb80d49 Add shutdown signal (#238)
* Add shutdown signal handling

Revert periodic sync interval change

Revert keep-alive interval change

CLI: Add disconnect command

SDK: Add scaffolding for is_started, shutdown()

Simplify instance init

* Rebase on savage-async-ws branch

* Avoid waiting when shutdown signal is received in the sync loop

* Directly use shutdown signal in background threads

* Acquire is_started lock at the very beginning of start()

* Fix cargo clippy warnings

* Update RN generator (kt): set bindingLiquidSdk to null on disconnect()

* Update RN generator (swift): set bindingLiquidSdk to nil on disconnect()

* Startup: only run foreground sync() if this could be the first run

* Start a sync() in background, before regular sync() loop

* Remove ensure_started check from start()

* Add bindings for disconnect()

* Remove foreground sync condition from startup

* Simplify background sync loop
2024-05-30 08:04:30 +00:00
Erdem Yerebasmaz
608f54ea69 Bump flutter_rust_bridge_codegen to 2.0.0-dev.36 and generate bindings (#237) 2024-05-28 14:41:47 +03:00
yse
2fcefee45e Add option to specify backup path (#228)
* feat: add backup_path to backup method

* Re-generate bindings with flutter_rust_bridge`@ 2.0.0-dev.35

* Rebased on main

* Update backup path description

---------

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-05-27 19:01:49 +00:00
Ross Savage
06b848a8f3 SDK events framework (#193)
* Add events framework

* Adapt RN codegen and add synced event

* Only use get_connection internally
2024-05-25 06:20:14 +02:00
Erdem Yerebasmaz
7b1b78a2d9 Update example app on Flutter plugin (#220)
* Update example app on Flutter plugin

* Expose `empty_wallet_cache` through Dart bindings (#224)
2024-05-24 12:12:29 +03:00
Erdem Yerebasmaz
a9cc69743d Expose sync through Dart bindings (#221)
Reformat build_other.dart
2024-05-23 17:59:01 +03:00
Erdem Yerebasmaz
a861011952 Generate Bindings
- Fix list_payments API on bindings
2024-05-23 10:12:53 +03:00
Erdem Yerebasmaz
1fe5bb353c Stop using singleton instance on Dart bindings
Apply changes to test cases on Dart plugin
2024-05-23 10:10:42 +03:00
ok300
c975da5b3c Payment lifecycle (#184)
* Rename swap tables: remove ongoing_ prefix

* Add swap status enums and filtering

* Swap-in: add claim_txid

* Swap-out: add claim_txid

* resolve_swap: Don't remove swap when complete

* Fixups after rebase

* Remove unused method

* Consider payment as pending based on confirmations

An onchain payment with no confirmations is considered
pending. The previous logic of converting pending swaps
into pending payments is removed, since we may have
pending swaps that should not result in pending
payments (for example on Receive, before the invoice
is paid).

* Fix swap-in query

* GetInfoResponse: fix balance, include pending

* Remove unused method

* Re-generate flutter bridge files

* Re-generate RN bindings

* Fix payment_type detection in list_payments

* Send: persist to DB when claim tx is seen

* Receive: fix occasional error when broadcasting claim

* Remove fixed TODO

* Receive: only rescan on testnet, where Electrum is used to broadcast

* Log more details when broadcasting fails

* Improve AlreadyClaimed error detection and handling

* Rename SubmarineSwapStatus::Initial to Created

* Split pending payment types into separate field status

* Rename swap status enums

* Fix INSERT query

* Bump lwk libraries

* Simplify Receive try_handle_reverse_swap_status loop

* Change resolve_swap to insert_or_update_payment

* Refactor payment data persistence

* Remove unused dependency

* Bump LWK dependencies

* Rename reconcile_payments_with_onchain

* Rename try_claim_v2

* Rename address() to next_unused_address()

* Move all claim persistence writes in try_claim

* Flatten Payment struct

* Re-generate bindings

* Expose sync() in service interface

* Set Send ws stream as nonblocking, use singleton stream

* Send_payment: sync() before handling new state

* Sync() on sdk.connect()

* Remove unused args from list_payments()

* Receive: rename DB field redeem_script to response JSON

* Convert to and from internal structs to persist CreateResponse JSON

* De-duplicate internal CreateResponse structs to prevent storing same field twice

* Schedule a periodic sync() thread on startup

* Persist swap states and add methods to transition between them

* Handle unwrap() when subscribing for WS updates

* Status Stream: handle remaining unwraps() and TODOs

* Consolidate status transitions into two SDK methods

* Status Stream: reconnect and resume tracking on disconnect

* Remove superfluous TODO

* Send swaps: correctly transition to Complete even if app killed during send_payment()

* State transitions: Move SQL queries to persistence layer

* Send: handle edge TransactionClaimed edge-case

* Send: mark as Complete after we check the preimage

* Send: remove marking as Complete on TransactionClaimed
2024-05-22 20:00:38 +00:00
ok300
177127d376 Update flutter bindings 2024-05-15 09:41:06 +02:00
Erdem Yerebasmaz
4dc16e565a Run dart format -l 110 2024-05-08 01:19:46 +03:00
Erdem Yerebasmaz
3071c36486 Generate Dart/Flutter bindings 2024-05-06 14:50:20 +03:00
Erdem Yerebasmaz
5d966fc856 Move dart & flutter packages to packages folder on root 2024-05-03 16:05:39 +03:00