feat: add real-time sync service (#629)

* feat(rt-sync): add persistency layer (#555)

* feat(rt-sync): add pull and merge (#556)

* feat(rt-sync): add push logic and run method (#568)

* feat(rt-sync): integrate rt-sync with the sdk

fix: add formatting command to build

feat: add secondary trigger to sync

deps: add tonic tls-webpki-roots

feat: prevent double claiming on status stream handlers

fix: add tx commit to chain swap update (#588)

fix: ensure we pull records before prepare_send

fix: fmt and tests

* fix: set initial pulled state to `Recoverable`

* feat(rt-sync): add `last_derivation_index` to sync service

* Single chain source

* Handle Recoverable state

* fix(rt-sync): chain recovery integration (#590)

Co-authored-by: yse <hydra_yse@proton.me>

* feat(rt-sync): add `pair_fees_json`

* fix(rt-sync): clean already persisted incoming records

* feat: cache wallet info (#591)

* log: add status-stream logging for non-local swaps

* Sync improvements (#598)

* Full sync on new Bitcoin block

* Track the last unconfirmed refund tx

* Trigger synced event on partial sync

* fix: remove `REPLACE` clause from swap insert/update

* fix(rt-sync): update chain swap payer/receiver amount (#604)

* Fix syncing last derivation index

* fix: update bindings and lockfile

* remove logs

* fix(rt-sync): avoid reuse of derivation index update logic (#608)

* Add 5 index buffer to full scan

* Fix storing claim_address (#609)

* Filter incoming MRH txs by swap timestamp

* fix liquid panding timestamp

* persist tx data timestamp

* Update unconfirmed transactions

* feat: add API key (#618)

* Use configured lazy connect channel in sync service

* fix: set lower-case header (#624)

* fix error message

* Store & Sync LNURL info (#617)

* Persist and decrypt LNURL info

* Update Notification Plugin

* Sync payment details

* Update list payments to include chain swaps with only user lockup (#620)

* Update payments query to include chain swaps without txs

* Allow emitting a payment event without tx_id

* fix: bindings

---------

Co-authored-by: Ross Savage <hello@satimoto.com>
Co-authored-by: Ross Savage <551697+dangeross@users.noreply.github.com>
Co-authored-by: Roei Erez <roeierez@gmail.com>
This commit is contained in:
yse
2024-12-24 10:39:43 +01:00
committed by GitHub
parent b0b88b8f1c
commit 6782e8beef
61 changed files with 8566 additions and 3043 deletions

View File

@@ -134,6 +134,9 @@ class Config {
/// Zero-conf minimum accepted fee-rate in millisatoshis per vbyte
final int zeroConfMinFeeRateMsat;
/// The url of the real-time sync service
final String syncServiceUrl;
/// Maximum amount in satoshi to accept zero-conf payments with
/// Defaults to [DEFAULT_ZERO_CONF_MAX_SAT]
final BigInt? zeroConfMaxAmountSat;
@@ -160,6 +163,7 @@ class Config {
required this.network,
required this.paymentTimeoutSec,
required this.zeroConfMinFeeRateMsat,
required this.syncServiceUrl,
this.zeroConfMaxAmountSat,
this.breezApiKey,
this.externalInputParsers,
@@ -176,6 +180,7 @@ class Config {
network.hashCode ^
paymentTimeoutSec.hashCode ^
zeroConfMinFeeRateMsat.hashCode ^
syncServiceUrl.hashCode ^
zeroConfMaxAmountSat.hashCode ^
breezApiKey.hashCode ^
externalInputParsers.hashCode ^
@@ -194,6 +199,7 @@ class Config {
network == other.network &&
paymentTimeoutSec == other.paymentTimeoutSec &&
zeroConfMinFeeRateMsat == other.zeroConfMinFeeRateMsat &&
syncServiceUrl == other.syncServiceUrl &&
zeroConfMaxAmountSat == other.zeroConfMaxAmountSat &&
breezApiKey == other.breezApiKey &&
externalInputParsers == other.externalInputParsers &&
@@ -356,6 +362,7 @@ sealed class ListPaymentDetails with _$ListPaymentDetails {
/// An argument when calling [crate::sdk::LiquidSdk::list_payments].
class ListPaymentsRequest {
final List<PaymentType>? filters;
final List<PaymentState>? states;
/// Epoch time, in seconds
final PlatformInt64? fromTimestamp;
@@ -368,6 +375,7 @@ class ListPaymentsRequest {
const ListPaymentsRequest({
this.filters,
this.states,
this.fromTimestamp,
this.toTimestamp,
this.offset,
@@ -378,6 +386,7 @@ class ListPaymentsRequest {
@override
int get hashCode =>
filters.hashCode ^
states.hashCode ^
fromTimestamp.hashCode ^
toTimestamp.hashCode ^
offset.hashCode ^
@@ -390,6 +399,7 @@ class ListPaymentsRequest {
other is ListPaymentsRequest &&
runtimeType == other.runtimeType &&
filters == other.filters &&
states == other.states &&
fromTimestamp == other.fromTimestamp &&
toTimestamp == other.toTimestamp &&
offset == other.offset &&
@@ -397,6 +407,50 @@ class ListPaymentsRequest {
details == other.details;
}
/// Represents the payment LNURL info
class LnUrlInfo {
final String? lnAddress;
final String? lnurlPayComment;
final String? lnurlPayDomain;
final String? lnurlPayMetadata;
final SuccessActionProcessed? lnurlPaySuccessAction;
final SuccessAction? lnurlPayUnprocessedSuccessAction;
final String? lnurlWithdrawEndpoint;
const LnUrlInfo({
this.lnAddress,
this.lnurlPayComment,
this.lnurlPayDomain,
this.lnurlPayMetadata,
this.lnurlPaySuccessAction,
this.lnurlPayUnprocessedSuccessAction,
this.lnurlWithdrawEndpoint,
});
@override
int get hashCode =>
lnAddress.hashCode ^
lnurlPayComment.hashCode ^
lnurlPayDomain.hashCode ^
lnurlPayMetadata.hashCode ^
lnurlPaySuccessAction.hashCode ^
lnurlPayUnprocessedSuccessAction.hashCode ^
lnurlWithdrawEndpoint.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LnUrlInfo &&
runtimeType == other.runtimeType &&
lnAddress == other.lnAddress &&
lnurlPayComment == other.lnurlPayComment &&
lnurlPayDomain == other.lnurlPayDomain &&
lnurlPayMetadata == other.lnurlPayMetadata &&
lnurlPaySuccessAction == other.lnurlPaySuccessAction &&
lnurlPayUnprocessedSuccessAction == other.lnurlPayUnprocessedSuccessAction &&
lnurlWithdrawEndpoint == other.lnurlWithdrawEndpoint;
}
/// An argument when calling [crate::sdk::LiquidSdk::lnurl_pay].
class LnUrlPayRequest {
/// The response from calling [crate::sdk::LiquidSdk::prepare_lnurl_pay]
@@ -649,6 +703,9 @@ sealed class PaymentDetails with _$PaymentDetails {
/// The payment hash of the invoice
String? paymentHash,
/// The payment LNURL info
LnUrlInfo? lnurlInfo,
/// For a Send swap which was refunded, this is the refund tx id
String? refundTxId,
@@ -854,6 +911,12 @@ class PrepareLnUrlPayResponse {
/// The fees in satoshis to send the payment
final BigInt feesSat;
/// The [LnUrlPayRequestData] returned by [crate::input_parser::parse]
final LnUrlPayRequestData data;
/// An optional comment for this payment
final String? comment;
/// The unprocessed LUD-09 success action. This will be processed and decrypted if
/// needed after calling [crate::sdk::LiquidSdk::lnurl_pay]
final SuccessAction? successAction;
@@ -861,11 +924,14 @@ class PrepareLnUrlPayResponse {
const PrepareLnUrlPayResponse({
required this.destination,
required this.feesSat,
required this.data,
this.comment,
this.successAction,
});
@override
int get hashCode => destination.hashCode ^ feesSat.hashCode ^ successAction.hashCode;
int get hashCode =>
destination.hashCode ^ feesSat.hashCode ^ data.hashCode ^ comment.hashCode ^ successAction.hashCode;
@override
bool operator ==(Object other) =>
@@ -874,6 +940,8 @@ class PrepareLnUrlPayResponse {
runtimeType == other.runtimeType &&
destination == other.destination &&
feesSat == other.feesSat &&
data == other.data &&
comment == other.comment &&
successAction == other.successAction;
}