Commit Graph

50 Commits

Author SHA1 Message Date
Roei Erez
c093d54cac extractd out receive swap handling logic 2024-06-06 13:02:38 +03:00
Roei Erez
f7b7149187 Abstract swapper stream as part of swapper trait 2024-06-03 13:57:20 +03:00
ok300
1cc06cef74 Bump lwk-wollet to fix InsufficientFunds error (#268)
* Bump lwk-wollet to fix InsufficientFunds error

* Re-add swap tracking on Send

* Track Send swap even on re-connect
2024-06-01 11:53:35 +00: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
Ross Savage
e986f75605 Convert the ws handling to async (#234) 2024-05-28 14:20:12 +02: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
9d2f6f0839 Fix cooperative refund and improve keypair generation (#223)
* feat: add random keypair generation

* Encapsulate decode_keypair in SendSwap::get_refund_keypair()

* Add refund_tx_id and refund_tx_amount_sat to Payment

* fix: remove blocking on refund

* fix: change `refund_private_key` order

* fix: rebasing

* fix: set `next_unused_address` as refund output

* Handle refunds in `get_info`, `list_payments` (#226)

* Exclude refund txs from payment list

* Adjust balance calculation to account for refunds

* fix: revert boltz changes and fix locktime

* Replace subquery with LEFT JOIN to get refund data

* Rewrite locktime check for more clarity

* Rewrite locktime check for more clarity

* Fix select_payment_query in case of refunds

* Include boltz-client fixes (handling of unwraps for failed broadcasts)

* Cargo.toml: Use boltz-client branch instead of commit

---------

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-05-28 08:07:29 +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
ec88a9fb6a Pin security-framework dependencies in Cargo.toml 2024-05-24 11:48:25 +02:00
Ross Savage
e421b95bef Lock security-framework version 2024-05-24 11:22:49 +02:00
ok300
c7b46314f4 Send: Retrieve and store preimage for non-cooperative claim (#222)
* Bump LWK dependencies to v0.5.1

* Send: Retrieve and store preimage for non-cooperative claim

* Remove branch that could have not succeeded
2024-05-24 06:16:41 +00: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
Ross Savage
7787267275 Build android fixes
Signed-off-by: Ross Savage <hello@satimoto.com>
2024-05-21 12:31:59 +02:00
yse
5a9dc1d5ce feat: fix fee calculation issues 2024-05-14 13:05:55 +02:00
yse
55804e88c5 feat: add double lockup checks and resolve on claim details 2024-05-14 13:05:55 +02:00
yse
a92e83a446 feat: improve send and refund 2024-05-14 13:05:54 +02:00
yse
28d4f264eb feat: add refund and improve send flow 2024-05-14 13:05:27 +02:00
ok300
6b58682a91 Receive: broadcast claim tx when lockup tx in mempool 2024-05-12 18:34:44 +02:00
ok300
fb7190032a Bump boltz-rust client to latest patch level 2024-05-09 21:22:57 +02:00
ok300
d67756bf43 Migrate receive-payment to V2 API, use WS to get status 2024-05-09 16:09:12 +00:00
yse
18257dbc91 feat: migrate send_payment to v2 (#171) 2024-05-09 15:47:23 +03: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
Erdem Yerebasmaz
05689299f0 Update flutter_rust_bridge to 2.0.0-dev.33
Update dependencies to latest & increase the supported range
2024-05-06 14:58:31 +03:00
Ross Savage
267819bb08 Change secp256k1-zkp dependency git source 2024-05-03 15:15:49 +02:00
ok300
33815fac05 Integrate ureq fix from Boltz Client (#148) 2024-05-02 18:29:45 +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
811f99f348 Update Cargo.lock 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
ok300
47a8dde47d Integrate boltz-client fix for swapstatus (#111) 2024-04-29 11:01:34 +00:00
ok300
1accd632fc Bump boltz-client (#108)
* Bump boltz-client

* Include swap ID in errors
2024-04-26 12:46:09 +02:00
Ross Savage
567b077717 Add building of android bindings and swift bindings for iOS 2024-04-25 13:42:53 +02:00
yse
ecc211e090 feat: add backup and restore functionality (#65) 2024-04-25 09:40:32 +02: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
efc970d1e0 feat: add json responses to cli (#81) 2024-04-09 21:30:02 +02:00
yse
2a2317001b feat: add qr code to receive command (#71) 2024-04-08 10:58:48 +02:00
ok300
091c0ced8b Bump boltz-client, fix fee calculation (#68)
* Bump boltz-client, fix fee calculation

* Cargo fmt
2024-04-04 14:01:33 +00:00
yse
aec000f0fd fix: remove Boltz internal txid logging (#64) 2024-03-29 02:49:23 +01:00
ok300
076badca32 Bump boltz-client (#62)
* Bump boltz-client to the latest commit

* Fix error types

* Consolidate boltz_client Errors into one type
2024-03-26 19:42:35 +00:00
ok300
3ba213fa92 Bump lwk to v0.3.0 (#61) 2024-03-26 19:39:54 +00:00
ok300
a55b496f27 Remove unused dependency: tokio (#46) 2024-03-21 19:52:41 +00: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
865733c0a9 Simplify cargo dependencies (#35)
* Arrange dependencies alphabetically

* Reduce tokio feature set to minimum

* CLI: remove lwk dependencies

* lib: remove lightning dependency

* lib: remove rusqlite features
2024-03-21 07:30:17 +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
ok300
865a2d6cf4 Simplify workspace layout 2024-03-18 14:07:56 +01:00
ok300
69363c662f Add support for logging 2024-03-15 12:50:17 +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