Commit Graph

44 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
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
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
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
yse
be3120c935 feat: remove PrepareSendResponse fields
feat: add `PrepareSendRequest` object

fix: rename to `claim_tx_feerate`

fix: fix reverse submarine test

feat: improve prepare_send and prepare_receive interfaces

fix: use v2 to broadcast lowball tx

feat: finalize prepare_send and prepare_receive

feat: remove manual BTC pair from response

fix: remove `pair_hash` from PrepareReceive

rebasing

updating Cargo.lock

fix: update lbtc pair method names

fixing bindings

fix: re-add uniffi_macros

add comment to elements dependency

fix: switch back to v1 fee calculation

fix: revert to v1 pair hash

fix: simplify migrations

fix: rename `FeesExpired` to `InvalidOrExpiredFees`

Log error when list_ongoing_swaps() fails

Log swap ID when list_ongoing_swaps() succeeds

Migrations: add missing ongoing_receive_swaps field

Clarify swap type (reverse vs submarine) in logs
2024-05-09 11:26:10 +03:00
ok300
8a1508ab07 Rename wallet to SDK or LiquidSdk (#157)
* Rename global instance in bindings.rs

* Rename wallet to SDK or LiquidSdk

* Rename BindingWallet to BindingLiquidSdk

* Rename wallet to lwk_wollet, signer to lwk_signer

* Rename LsSdkError to LiquidSdkError

* Cargo fmt

* Rename LsSdkError in RN generator

---------

Co-authored-by: Ross Savage <hello@satimoto.com>
2024-05-03 13:53:37 +00:00
ok300
708a3526c7 Add request, response to API methods (#153)
* Add request, response to get_info()

* Add request, response to prepare_send_payment()

* Add request, response to restore()

* Add request, response to connect()

* Update lib/bindings/src/breez_liquid_sdk.udl

Co-authored-by: Ross Savage <551697+dangeross@users.noreply.github.com>

* Update lib/bindings/src/breez_liquid_sdk.udl

Co-authored-by: Ross Savage <551697+dangeross@users.noreply.github.com>

* Update lib/core/src/bindings.rs

Co-authored-by: Ross Savage <551697+dangeross@users.noreply.github.com>

* Fix bindings.rs call

* Update connect to handle ConnectRequest

---------

Co-authored-by: Ross Savage <551697+dangeross@users.noreply.github.com>
Co-authored-by: Ross Savage <hello@satimoto.com>
2024-05-03 08:48:03 +00:00
ok300
3df6a5c3d4 CLI: Allow choosing custom network (#151)
* CLI: Allow choosing custom network

* Cargo fmt
2024-05-02 18:27:31 +00:00
ok300
080698c2d1 Update receive to support only payer amount (#131) 2024-05-02 06:00:56 +00:00
ok300
cb7e753c95 Rename project: Rust, uniffi (#133)
* Rename rust crates, uniffi bindings

* Rename uniffi tests

* Rename uniffi UDL file
2024-05-02 05:44:47 +00:00
Erdem Yerebasmaz
3b94544b89 Apply frb's file structure changes to cli 2024-04-29 18:41:37 +03:00
ok300
522bdaea5c Rename init() to connect() (#119)
* Rename init() to connect()

* Shorten commit ID for secp256k1-zkp dependency

* Update RN bindings

* Rename the manually coded init function to connect

* Update RN example app

---------

Co-authored-by: Ross Savage <hello@satimoto.com>
Co-authored-by: Ross Savage <551697+dangeross@users.noreply.github.com>
2024-04-29 15:25:48 +00:00
yse
857db3cc33 fix: change log write mode to append (#110) 2024-04-26 19:40:45 +02:00
yse
1d3ed4b00c feat: add fee calculation to payment receive (#101) 2024-04-25 10:56:21 +02:00
yse
ecc211e090 feat: add backup and restore functionality (#65) 2024-04-25 09:40:32 +02:00
yse
8f35cee0a1 fix: remove receive options from cli (#100) 2024-04-24 19:09:15 +02:00
yse
2929d668cf feat: add fee persistence to payments (#83) 2024-04-18 11:24:04 +02:00
ok300
7443a8717a Address uniffi feedback (#90)
* Replace invoice_amount_sat with payer_amount_sat

* Replace onchain_amount_sat with receiver_amount_sat
2024-04-17 20:57:51 +00:00
ok300
fa0cde18d6 Use a different DB file per network (#91)
* Use DEFAULT_DATA_DIR instead of hardcoded string in CLI

* Use a different DB file per network
2024-04-17 17:28:03 +00:00
ok300
5e190a9a5d CLI: Use qrcode-rs instead of qr2term (#88) 2024-04-16 23:07:11 +02:00
yse
3efbdb97cb cli: add log file (#87) 2024-04-16 21:28:40 +02:00
ok300
e2ace48b48 Add uniffi bindings (#59)
* Rename CLI and lib projects

* Place lib in a workspace

* Add uniffi package

* Bump uniffi version

* Add uniffi.toml config file to customize lib names

* Add makefile for kotlin, python, swift bindings

* Add missing PaymentError variant

* Rename BoltzGeneric error variant
2024-04-15 15:32:16 +00:00
yse
85e8a6d1a3 feat: persist invoice rather than amount (#66)
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-04-12 15:51:16 +02:00
yse
efc970d1e0 feat: add json responses to cli (#81) 2024-04-09 21:30:02 +02:00
yse
04d0c5b790 feat: add transaction persistence to lwk instance (#70) 2024-04-09 00:12:25 +02:00
yse
2a2317001b feat: add qr code to receive command (#71) 2024-04-08 10:58:48 +02:00
yse
21f6d7068a feat: add support for pending send (#48) 2024-03-27 16:16:08 +01:00
ok300
16a13efd72 Make network a mandatory arg of init() (#53) 2024-03-26 06:00:25 +01:00
ok300
e6a8a84050 Consolidate constants and default init values (#52) 2024-03-26 05:58:30 +01:00
ok300
baabf39811 Default to a 12-word mnemonic (#51)
* Change to blinding variant slip77

* Simplify init arg

* Default to a 12-word mnemonic
2024-03-26 05:55:37 +01:00
ok300
402a712b9b Simplify init arg (#50)
* Change to blinding variant slip77

* Simplify init arg
2024-03-26 05:54:41 +01:00
ok300
4e3536f67f Derive Debug for relevant structs (#45) 2024-03-21 19:53:33 +00:00
ok300
a55b496f27 Remove unused dependency: tokio (#46) 2024-03-21 19:52:41 +00:00
yse
a123d32651 feat: added onchain_amount_sat field to received swaps (#41) 2024-03-21 19:42:21 +01:00
yse
03c2c3918a feat: add invoice_amount_sat field to swaps (#33)
* fix: rebasing and updating cargo.lock

* feat: add `requested-amount-sat` field to pending swaps

* lint

* feat: added list-payments method

* linting

* feat: adding pending transactions to list-payments

* fix: rename received_amount to invoice_amount

* fix: renaming Pending to PendingReceive

* fix: remove expect from preimage unwrapping
2024-03-21 15:05:08 +01:00
ok300
516f95a685 Consolidate wallet initialization (#30)
* Consolidate wallet initialization
2024-03-19 12:39:08 +00:00
yse
21335d73aa feat: add primary methods for ongoing swaps (#28)
* Fix receive-payment by increasing claim absolute_fee

* feat: added sqlite methods for ongoing swaps

* fix: create specific error type when persisting swaps

---------
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-03-19 13:13:33 +01:00
yse
72835423cb feat: add get_info method to wallet (#12)
* feat: initial `get_info` wallet method
* feat: add current active address to info
2024-03-18 10:41:41 +01:00
ok300
69363c662f Add support for logging 2024-03-15 12:50:17 +01:00
yse
c17bbc9c4f chore: splitting models and renaming wallet (#11)
* chore: split code and rename wallet
* chore: removing `wait_for_tx`
2024-03-13 10:27:57 +01:00
yse
ffadce402e feat: adding initial methods (#2)
Note that the structure is still experimental and subject to change, refer to breez-sdk-liquid#2 for more details
2024-03-13 09:10:26 +01:00