Skip to content

Commit a9ed072

Browse files
authored
Merge pull request #37 from SatoshiPortal/develop
v0.2.0
2 parents 9d94924 + 57ae41b commit a9ed072

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4774
-9402
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
.history
1010
.svn/
1111

12-
# IntelliJ related
12+
# Code Editor related
1313
*.iml
1414
*.ipr
1515
*.iws
1616
.idea/
17-
17+
.vscode/
1818
# The .vscode folder contains launch configuration and tasks you configure in
1919
# VS Code which you may wish to be included in version control, so this line
2020
# is commented out by default.

.vscode/launch.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@
2222
- boltz-0.3.0: Updated fees
2323
- dep(update): using latest boltz-rust. added description to decoded invoice
2424
- fix: lock boltz-client version
25+
26+
# 0.2.0
27+
- upgrade: frb 2.9.0 (breaking)
28+
- fix: added into() for submarine limits.
29+
- Added lnurl freezed. Updated generated files
30+
- feat: claim/refund sizes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Currently we do not use precompiled binaries with cargokit. So as the end user,
4040
# install rust
4141
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
4242
# install tools
43-
cargo install flutter_rust_bridge_codegen --version 2.0.0
43+
cargo install flutter_rust_bridge_codegen --version 2.9.0
4444
cargo install cargo-ndk
4545
cargo install cargo-lipo
4646
```

flutter_rust_bridge.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ dart_output: lib/src/generated/
33
full_dep: true
44
c_output: ios/Classes/frb_generated.h
55
duplicated_c_output: [macos/Classes/frb_generated.h]
6-
dart_entrypoint_class_name: BoltzCore
6+
dart_entrypoint_class_name: BoltzCore
7+
stop_on_error: true
8+
web: false
9+
dart3: true

ios/Classes/frb_generated.h

Lines changed: 100 additions & 67 deletions
Large diffs are not rendered by default.

lib/boltz.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export './src/generated/api/chain_swap.dart';
77
export './src/generated/api/error.dart';
88
export './src/generated/api/types.dart';
99
export './src/generated/api/fees.dart';
10+
export './src/generated/api/lnurl.dart';
11+
1012
export './src/root.dart';
1113
export './src/utils/loader.dart';
1214
export './src/utils/stream.dart';

lib/src/generated/api/btc_ln.dart

Lines changed: 75 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
// This file is automatically generated, so please do not edit it.
2-
// Generated by `flutter_rust_bridge`@ 2.0.0.
2+
// @generated by `flutter_rust_bridge`@ 2.9.0.
33

44
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
55

66
import '../frb_generated.dart';
77
import 'error.dart';
88
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
9-
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
109
import 'types.dart';
11-
part 'btc_ln.freezed.dart';
1210

1311
// These functions are ignored because they are not marked as `pub`: `extract_id`
1412
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_receiver_is_total_eq`, `clone`, `eq`
1513

1614
/// Bitcoin-Lightning Swap Class
17-
@freezed
18-
class BtcLnSwap with _$BtcLnSwap {
19-
const BtcLnSwap._();
20-
const factory BtcLnSwap({
21-
required String id,
22-
required SwapType kind,
23-
required Chain network,
24-
required KeyPair keys,
25-
required BigInt keyIndex,
26-
required PreImage preimage,
27-
required BtcSwapScriptStr swapScript,
28-
required String invoice,
29-
required String scriptAddress,
30-
required BigInt outAmount,
31-
required String electrumUrl,
32-
required String boltzUrl,
33-
String? referralId,
34-
}) = _BtcLnSwap;
15+
class BtcLnSwap {
16+
final String id;
17+
final SwapType kind;
18+
final Chain network;
19+
final KeyPair keys;
20+
final BigInt keyIndex;
21+
final PreImage preimage;
22+
final BtcSwapScriptStr swapScript;
23+
final String invoice;
24+
final String scriptAddress;
25+
final BigInt outAmount;
26+
final String electrumUrl;
27+
final String boltzUrl;
28+
final String? referralId;
29+
30+
const BtcLnSwap({
31+
required this.id,
32+
required this.kind,
33+
required this.network,
34+
required this.keys,
35+
required this.keyIndex,
36+
required this.preimage,
37+
required this.swapScript,
38+
required this.invoice,
39+
required this.scriptAddress,
40+
required this.outAmount,
41+
required this.electrumUrl,
42+
required this.boltzUrl,
43+
this.referralId,
44+
});
3545

3646
/// Broadcast using boltz's electrum server
3747
Future<String> broadcastBoltz({required String signedHex}) => BoltzCore
@@ -54,6 +64,11 @@ class BtcLnSwap with _$BtcLnSwap {
5464
minerFee: minerFee,
5565
tryCooperate: tryCooperate);
5666

67+
/// Get the size of the claim transaction. Can be used to estimate the absolute miner fees required, given a fee rate.
68+
Future<BigInt> claimTxSize({required bool isCooperative}) =>
69+
BoltzCore.instance.api.crateApiBtcLnBtcLnSwapClaimTxSize(
70+
that: this, isCooperative: isCooperative);
71+
5772
/// After boltz completes a submarine swap, call this function to close the swap cooperatively using Musig.
5873
/// If this function is not called within ~1 hour, the swap will be closed via the script path.
5974
/// The benefit of a cooperative close is that the onchain footprint is smaller and makes the transaction look like a single sig tx, while the script path spend is clearly a swap tx.
@@ -162,13 +177,49 @@ class BtcLnSwap with _$BtcLnSwap {
162177
minerFee: minerFee,
163178
tryCooperate: tryCooperate);
164179

180+
/// Get the size of the refund transaction. Can be used to estimate the absolute miner fees required, given a fee rate.
181+
Future<BigInt> refundTxSize({required bool isCooperative}) =>
182+
BoltzCore.instance.api.crateApiBtcLnBtcLnSwapRefundTxSize(
183+
that: this, isCooperative: isCooperative);
184+
165185
/// Convert instance to a JSON string.
166186
Future<String> toJson() =>
167187
BoltzCore.instance.api.crateApiBtcLnBtcLnSwapToJson(
168188
that: this,
169189
);
170190

171-
/// Get the size of the transaction. Can be used to estimate the absolute miner fees required, given a fee rate.
172-
Future<BigInt> txSize({required bool isCooperative}) => BoltzCore.instance.api
173-
.crateApiBtcLnBtcLnSwapTxSize(that: this, isCooperative: isCooperative);
191+
@override
192+
int get hashCode =>
193+
id.hashCode ^
194+
kind.hashCode ^
195+
network.hashCode ^
196+
keys.hashCode ^
197+
keyIndex.hashCode ^
198+
preimage.hashCode ^
199+
swapScript.hashCode ^
200+
invoice.hashCode ^
201+
scriptAddress.hashCode ^
202+
outAmount.hashCode ^
203+
electrumUrl.hashCode ^
204+
boltzUrl.hashCode ^
205+
referralId.hashCode;
206+
207+
@override
208+
bool operator ==(Object other) =>
209+
identical(this, other) ||
210+
other is BtcLnSwap &&
211+
runtimeType == other.runtimeType &&
212+
id == other.id &&
213+
kind == other.kind &&
214+
network == other.network &&
215+
keys == other.keys &&
216+
keyIndex == other.keyIndex &&
217+
preimage == other.preimage &&
218+
swapScript == other.swapScript &&
219+
invoice == other.invoice &&
220+
scriptAddress == other.scriptAddress &&
221+
outAmount == other.outAmount &&
222+
electrumUrl == other.electrumUrl &&
223+
boltzUrl == other.boltzUrl &&
224+
referralId == other.referralId;
174225
}

0 commit comments

Comments
 (0)