Commit Graph

66 Commits

Author SHA1 Message Date
ok300
fe1dc30917 Add support for paying to BOLT12 (#549)
Add support for paying to BOLT12
2024-11-19 13:08:50 +00:00
Ross Savage
802e9eece7 Configurable cache dir (#567)
* Add a configurable cache dir

* Fix UDL field position
2024-11-18 13:36:38 +01:00
Ross Savage
4da57e3fe2 Liquid/Lightning drain (#553)
* Attempt drain using liquid or lightning payment

* Optimize estimation handling, use address in drain estimation

* Add drain option to PrepareSendRequest

* Block draining while there are pending payments

* Apply suggestions from code review

* Rename PayOnchainAmount to PayAmount
2024-11-11 21:50:18 +01:00
Ross Savage
b78d53b436 Add swift framework plists (#536)
* Add a Info.plist per framework

* Update dart bindings
2024-10-24 16:58:55 +02:00
Roei Erez
c999cedaa3 Implement flutter bindings 2024-10-18 11:25:06 +02:00
ok300
cbe835b565 GetInfoResponse: add fingerprint (#532)
* GetInfoResponse: add fingerprint

* Re-generate dart ffi with `just ffigen`

* Re-generate dart ffi with `just gen`
2024-10-17 14:36:33 +00:00
Ross Savage
0884106159 Add prepare_lnurl_pay (#524)
* Add prepare_lnurl_pay

* Move fields into prepare response
2024-10-14 10:06:14 +02:00
Ross Savage
3867fa91da Get Payment (#476)
* Get payment by destination

* CI fixes

* Remove claim_address from query

* Add PaymentDestination enum

* Add payment hash as a payment query option

* Bump Flutter dependencies

* Move destination/address queries to list_payments

* Apply suggestions from code review

Co-authored-by: yse <70684173+hydra-yse@users.noreply.github.com>

---------

Co-authored-by: yse <70684173+hydra-yse@users.noreply.github.com>
2024-10-10 17:44:32 +02:00
yse
42f4ca0129 feat: require Breez API key globally on mainnet (#520) 2024-10-08 16:17:34 +02:00
Erdem Yerebasmaz
f6fa503cb9 Flutter uniFFI (#510)
* Flutter uniffi

* Set on-demand resources

* Do not build non-uniffi libraries

* Change iosLibName

* Add BreezSDKLiquid as on demand resources

* Use downloaded framework

* Add Sources to published flutter package

* Set OTHER_LDFLAGS

* Add logging

* Refactor library initialization logic and throw an error if initialization fails

* Do not statically link framework on production

* Use uniFFI headers to generate FlutterBreezLiquidBindings

* Re add frb header

* Correct the library name

* Remove static_framework

* Move source header files

* Copy iOS podspecs to macOS folder

* Update version of macOS podspecs

* Remove Windows & Linux support

* Remove CMake scripts

* Remove breez_sdk_liquid.podspec from version script

* Cleanup older build scripts used by melos & just recipes

* Remove softlink & copy recipes

Add recipe descriptions

* Rename link-uniffi recipe to link-headers

Make sure headers are linked after uniffi is built
  - Remove just gen recipe
Add recipe descriptions

* Set package versions on production files as well when publishing

* Include bindings project on melos script hooks

* Flutter uniffi

* Set on-demand resources

* Do not build non-uniffi libraries

* Change iosLibName

* Add BreezSDKLiquid as on demand resources

* Use downloaded framework

* Add Sources to published flutter package

* Set OTHER_LDFLAGS

* Add logging

* Refactor library initialization logic and throw an error if initialization fails

* Do not statically link framework on production

* Use uniFFI headers to generate FlutterBreezLiquidBindings

* Re add frb header

* Correct the library name

* Remove static_framework

* Move source header files

* Copy iOS podspecs to macOS folder

* Update version of macOS podspecs

* Remove Windows & Linux support

* Remove CMake scripts

* Remove breez_sdk_liquid.podspec from version script

* Cleanup older build scripts used by melos & just recipes

* Remove softlink & copy recipes

Add recipe descriptions

* Rename link-uniffi recipe to link-headers

Make sure headers are linked after uniffi is built
  - Remove just gen recipe
Add recipe descriptions

* Set package versions on production files as well when publishing

* Include bindings project on melos script hooks

* chore: just version

* fix: remove unused files on "Set package version" step

* copy FFI header files

* [WIP] Add macOS support

* remove example app on Flutter plugin

* Link headers before running ffigen on CI workflow

* macOS: add macos/Sources folder to .gitignore

.

* macOS: Copy iOS sources to macOS sources after downloading bindings

* macOS: copy sources & framework file to macos folder on build-uniffi-swift script

* import breez_sdk_liquidFFI header on plugin file

Update flutter_breez_liquid.c

* cleanup header file artifacts

---------

Co-authored-by: Ross Savage <hello@satimoto.com>
2024-10-01 10:59:11 +03:00
Ross Savage
9c0e469ad1 Fix pay onchain claim fee (#499)
* Fix pay onchain claim fee

* Bump flutter example dependencies
2024-09-25 10:44:33 +02:00
yse
783c5ac450 feat: refactor refund logic and support lowball broadcasts (#407) 2024-09-20 15:57:54 +02:00
yse
189e257f89 feat: add lowball broadcast support with API key for all transaction types (#489) 2024-09-20 13:04:49 +02:00
ok300
e8cd66f81f prepare-pay-onchain: add option for drain (#464)
* prepare-pay-onchain: add option for drain in req

* Fix clippy

* ChainSwapStateHandler: gracefully handle building both drain and non-drain lockups

* Send Chain swap: use standard feerate when estimating lockup tx fee

* UDL: move new drain field above the last PreparePayOnchainRequest optional field

* UDL: move new drain field optional

* prepare-pay-onchain: treat normal payment as drain if receiver amount is high enough

If the receiver amount is as high as it would be in case of drain, treat the current prepare-pay-onchain as drain, even if the drain flag is not set.

* build_drain_tx: add optional amount validation

* Add PayOnchainAmount enum to cover amount types (drain, receiver)

* Add ability to find max_receiver_amount_sat for non-drain sends

* Revert "Add ability to find max_receiver_amount_sat for non-drain sends"

This reverts commit 60ee1c768021810f72bc64a8ada69d35b638185e.

* prepare_pay_onchain: treat drain and non-drain cases separately

If the non-drain case is chosen with a receiver_amount equivalent to what drain would have calculated, it results in an error. For drain, the caller has to explicitly choose PayOnchainAmount::Drain.

* CLI: send-onchain-payment accepts optional amount

* CLI: add docs for send-onchain-payment drain arg

* SDK: expand docs for prepare_pay_onchain

* Re-generate RN bindings

* Re-generate flutter bindings
2024-09-11 15:52:56 +00:00
Ross Savage
c141d8e0a4 Change short_channel_id to string (#484)
* Change short_channel_id to string

* Bump sdk-common
2024-09-11 12:54:39 +02:00
yse
2dc3d57309 fix: set PaymentDetails as mandatory, default to LiquidAddress (#474) 2024-09-09 13:00:22 +02:00
Ross Savage
6b78919df8 Add sign_message and check_message (#443)
* Add sign and check message methods

* Use lightning message_signing module to verify the message signature

* Use hash engine
2024-08-29 08:42:16 +02:00
Ross Savage
deb9ed1b09 Add description hash to receive payment (#440)
* Add option to hash description

* Fix Flutter gen

* Switch to upstream boltz-rust

* Address feedback
2024-08-29 08:17:10 +02:00
Ross Savage
34774647bf Integrate webhooks (#410)
* Integrate webhooks

* Make hash_swap_id optional

* Hash and store the swap id

* Add webhook status include lists

* Remove superfluous webhook statuses

* Verify and fetch user_lockup_tx_id if missing

* Fix tests

* Use bitcoin sha256

* Fix flutter CI
2024-08-29 08:03:50 +02:00
yse
1a89bcd6c1 feat: add BIP21 support (#414)
Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-08-22 12:23:36 +02:00
Erdem Yerebasmaz
5248dfc235 Depend on sdk-common with liquid feature (#452)
* Add copy script to packages/react-native makefile
  * Reorder scripts
* Depend on sdk-common with liquid feature
  * chore: cargo update
* Generate Dart bindings
* Generate UniFFI bindings
* Simplify import resolution by using prelude::*
  * Applies changes from https://github.com/breez/breez-sdk-greenlight/pull/1078
2024-08-20 18:50:27 +03:00
Ross Savage
baa8096852 Update boltz-rust and add receive payment description (#409)
* Update boltz-rust

* Store description and add to Payment struct

* Fix examples
2024-07-25 12:46:40 +02:00
Ross Savage
bfeb785221 Buy Bitcoin (#398)
* Add fiat on-ramp service

* Use sdk-common MoonpayProvider

* Bump flutter qr dependency

* Bump sdk-common dependency
2024-07-19 14:57:51 +02:00
Ross Savage
a3eb4caaf2 Add validate url success action param (#395) 2024-07-16 10:08:30 +02:00
Ross Savage
0da35259fe Allow custom pay_onchain claim fees (#391)
* Allow optional fee rate for pay onchain BTC claim

* Add recommended_fees method

* Fix example Config

* Address review comments
2024-07-15 17:38:10 +02:00
Ross Savage
143993fd3a List payments filtering and paging (#369)
* List payments in reverse chonological order

* Add payment filtering and paging

* Fix examples

* Apply suggestions from code review

Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>

* Set timestamp for pseudo payments

* Filter by the first non-null timestamp from the join query

---------

Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>
2024-07-10 17:50:53 +02:00
Ross Savage
da43f7ff78 Rename namespace (#345)
* Rename namespace

* Fix flutter build

* Fix kotlin-multiplatform CI

* Rename repositories
2024-07-09 17:25:05 +02:00
Ross Savage
05507063f0 Change Config param to zero_conf_min_fee_rate_msat (#374)
* Change Config param to zero_conf_min_fee_rate_msat

* Fix Flutter example
2024-07-09 14:13:42 +02:00
yse
50be093230 fix: refund InsufficientFunds error when calculating broadcast fee (#360)
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-07-08 17:30:17 +02:00
ok300
08b2e5a6e2 Add fetch_onchain_limits service method (#343)
* Add pay_onchain_limits service method

* Add receive_onchain_limits service method

* Merge pay/receive_onchain_limits

* Update field names

* Split swapper method in get_chain_pair and get_chain_pairs

* Fix test

* Introduce and re-use Limits model

* Add fetch_lightning_limits SDK method

* Fix CI: propagate latest sdk-common changes
2024-07-03 09:22:29 +00:00
Erdem Yerebasmaz
381c09b93f Expose duplicates of "external structs that cannot be mirrored" through Dart/Flutter plugin (#348)
Generate Dart bindings
2024-07-01 11:01:50 +03:00
Ross Savage
e7844473cd Monitor chain swap addresses (#322)
* Check chain swap addresses for unspent outputs

* Monitoring expired swaps up to 4320 blocks after expiration

* Refactor chain swap monitoring

* Handle the error to prevent the loop exiting

* Add RefundPending state

* Check if RefundPendingbefore setting to Refundable

* Use script_get_balance to determine spent state

* Use unconfirmed balance to check if RefundPending should be reset to Refundable
2024-06-26 16:53:41 +02:00
ok300
ef5cd28fa5 Add FiatAPI methods to Liquid SDK (#331)
* Add FiatAPI methods to Liquid SDK

* Add mirrored structs of fiat crate on Dart bindings

* Re-generate bindings

* Fix sdk-common imports

* Avoid using hardcoded Breez Server URL, re-use sdk-common constant

* Update Cargo.lock

---------

Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>
2024-06-26 13:55:44 +00:00
ok300
7bd9b6ddb2 Use swapper proxy to extract referral ID (#329)
* Use swapper proxy to extract referral ID

* Derive swapper API base URL from proxy URL

* Update RN bindings

* Remove referral_id from Config, move proxy_url parsing to swapper

* Fix tests

* Cache swapper proxy URL

* Move boltz_url from Config to swapper

* Silently fail when fetching proxy swapper URLs

* Update RN bindings

* Fix sdk-common dependency

* Fix dependency issues
2024-06-25 17:19:02 +00:00
Ross Savage
9da16fba78 Receive Chain Swaps (#310)
* Implement Chain Swaps for receiving

* Send: validate if we have sufficient funds (#321)

* Implement Chain Swaps for receiving

* Fix rebase of flutter_rust_bridge version

* Send: validate if we have sufficient funds

* Re-generate FRB

---------

Co-authored-by: Ross Savage <hello@satimoto.com>

* Chaim swap claim: remove refund_tx arg (#328)

---------

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-06-25 17:33:38 +02:00
ok300
bcb4743260 Integrate sdk-common (#308)
* Rename Network to LiquidSdkNetwork to avoid naming conflicts with sdk-common

* Integrate sdk-common: re-use parse_invoice

* Fix UDL bindings tests

* Add input parser support

* CLI: Add input parser support

* Integrate lnurl-pay

* Cargo format, re-generate FRB and RN bindings

* Duplicate LnUrlPayError, update FRB/UniFFI bindings

* Move duplicate LnUrlPayError to FRB bindings.rs

* Add support for lnurl-withdraw

* Lnurl-withdraw: convert units, incorporate fees

* Bump sdk-common, rename InputType::LnUrlError

* Bump sdk-common, remove Wrapped prefix from LnUrlPaySuccessData, LnUrlPayResult

* LNURL-withdraw: add missing UDL mappings

* Add support for LNURL-auth

* Move LNURL structs into models.rs

* Rename LiquidSdkNetwork to LiquidNetwork

* Fix binding tests

* Fix tests

* Move FRB mirroring structs to bindings.rs

* Remove TODO

* Bump sdk-common, remove sdk-common dependency on rusqlite

* Propagate LiquidNetwork rename into flutter example app

* CI: install protobuf before running clippy

* CI: add rust cache, protobuf for remaining rust steps
2024-06-20 16:18:50 +00:00
Ross Savage
428d69729b Implement Chain Swaps for sending (#298) 2024-06-19 12:48:13 +02:00
yse
4e76e94d26 feat: invoice details to Payment (#309) 2024-06-18 17:32:51 +02:00
yse
bcf84fe8cd feat: add zero-conf checks when receive lockup is in the mempool (#292) 2024-06-13 10:22:05 +02:00
yse
2b64708e36 Receive: Switch payment to pending state when lockup is in the mempool (#301)
* feat: switch to pending state when receive lockup is in the mempool

* rebasing

* fix: move socket update logic to sub-crate

* Update payments query, to avoid duplicate Receive Swaps

This can happen if the app is stopped before the temporary lockup tx is removed from the DB. The Receive Swap would then forever result in two payments in list_payments.

* Add comments to clarify use of temp lockup txid

* Re-generate flutter bridge bindings

* feat: set Payment `tx_id` as optional and change `list_payments` logic

* fix: debug typo

* fix: undo `remove_temporary_tx` changes

* fix: switch to full join rather than manual filtering

* fix: bindings

* fix: improve error handling when tx data is not present

* fix: RN bindings

* fix: exclude Created receives from the list

* fix: fixing nits

* Re-generate FRB bindings

---------

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2024-06-12 20:44:31 +00:00
ok300
31e2ab44af get_info: remove with_scan argument (#306)
* get_info: remove with_scan argument

* Fix binding tests

* Update dart test and kotlin example app

* Update RN example app
2024-06-12 13:23:32 +00:00
Erdem Yerebasmaz
5e2a4fe342 Bump flutter_rust_bridge to 2.0.0-dev.38 (#304)
* Generate Dart bindings
* flutter_rust_bridge has relative path issues with this new approach introduced in 2.0.0-dev.38, we'll be using the default rust_output path until it's addressed.
2024-06-10 14:51:42 +03:00
ok300
7276346a5f Cleanup, fix typos (#299)
* Fix typo in PaymentSucceeded event name

* Remove fixed todo

* Organize imports

* Fix log typos

* Re-generate flutter bindings

* Re-generate RN bindings

* Fix "Unhandled msg" logs for WS pings

* Hide ureq debug logs, showing raw HTTP headers for Boltz calls
2024-06-07 04:53:14 +00:00
ok300
2928e0fa58 Add magic routing hint support (#265)
* Receive: Add magic routing hint support

* Send: add MRH support

* Filter out and reject self-transfers

* Extract self-transfer validation in own fn

* PrepareSendResponse: use onchain fee as fees_sat if MRH present

* Use onchain tx fee as payment fee, if MRH used for direct onchain tx

* Fix swap fee calculation when MRH is used

* Apply boltz-client patch that aborts send if tx broadcast fails

* Send with MRH: return pending payment

* Receive with MRH: validate BIP21 amount, address

* Emit remaining events for MRH Send, Receive

* Sync: update swap info and emit events after new tx data is persisted

* Extract MRH send into its own send_payment_via_mrh()

* Pending Send via swap: store tx fees for pseudo-tx

* Fix clippy
2024-06-07 00:40:42 +00:00
yse
054b8c6d3b feat: add checks for TimedOut payments (#266) 2024-06-06 17:03:01 +02:00
Erdem Yerebasmaz
564d75d59d Mark default_config && parse_invoice as sync functions on Dart bindings (#280)
- Generate Dart bindings
2024-06-03 11:53:34 +03:00
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