Skip to content

Commit 711ada1

Browse files
authored
Merge pull request #40 from SatoshiPortal/develop
v0.2.1
2 parents 7e32607 + d04909b commit 711ada1

File tree

14 files changed

+35
-119
lines changed

14 files changed

+35
-119
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
- fix: added into() for submarine limits.
2929
- Added lnurl freezed. Updated generated files
3030
- feat: claim/refund sizes
31+
32+
# 0.2.1
33+
- fix: do not build swap tx for chain claim and coop close
34+
- fix: Update to latest boltz-rust commit

ios/Classes/frb_generated.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ void frbgen_boltz_wire__crate__api__chain_swap__chain_swap_broadcast_local(int64
302302
void frbgen_boltz_wire__crate__api__chain_swap__chain_swap_claim(int64_t port_,
303303
struct wire_cst_chain_swap *that,
304304
struct wire_cst_list_prim_u_8_strict *out_address,
305-
struct wire_cst_list_prim_u_8_strict *refund_address,
306305
struct wire_cst_tx_fee *miner_fee,
307306
bool try_cooperate);
308307

lib/src/generated/api/btc_ln.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'types.dart';
1111
// These functions are ignored because they are not marked as `pub`: `extract_id`
1212
// 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`
1313

14-
/// Bitcoin-Lightning Swap Class
1514
class BtcLnSwap {
1615
final String id;
1716
final SwapType kind;

lib/src/generated/api/chain_swap.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ class ChainSwap {
6666
/// Claim a successful swap
6767
Future<String> claim(
6868
{required String outAddress,
69-
required String refundAddress,
7069
required TxFee minerFee,
7170
required bool tryCooperate}) =>
7271
BoltzCore.instance.api.crateApiChainSwapChainSwapClaim(
7372
that: this,
7473
outAddress: outAddress,
75-
refundAddress: refundAddress,
7674
minerFee: minerFee,
7775
tryCooperate: tryCooperate);
7876

lib/src/generated/frb_generated.dart

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ abstract class BoltzCoreApi extends BaseApi {
182182
Future<String> crateApiChainSwapChainSwapClaim(
183183
{required ChainSwap that,
184184
required String outAddress,
185-
required String refundAddress,
186185
required TxFee minerFee,
187186
required bool tryCooperate});
188187

@@ -1014,39 +1013,31 @@ class BoltzCoreApiImpl extends BoltzCoreApiImplPlatform
10141013
Future<String> crateApiChainSwapChainSwapClaim(
10151014
{required ChainSwap that,
10161015
required String outAddress,
1017-
required String refundAddress,
10181016
required TxFee minerFee,
10191017
required bool tryCooperate}) {
10201018
return handler.executeNormal(NormalTask(
10211019
callFfi: (port_) {
10221020
var arg0 = cst_encode_box_autoadd_chain_swap(that);
10231021
var arg1 = cst_encode_String(outAddress);
1024-
var arg2 = cst_encode_String(refundAddress);
1025-
var arg3 = cst_encode_box_autoadd_tx_fee(minerFee);
1026-
var arg4 = cst_encode_bool(tryCooperate);
1022+
var arg2 = cst_encode_box_autoadd_tx_fee(minerFee);
1023+
var arg3 = cst_encode_bool(tryCooperate);
10271024
return wire.wire__crate__api__chain_swap__chain_swap_claim(
1028-
port_, arg0, arg1, arg2, arg3, arg4);
1025+
port_, arg0, arg1, arg2, arg3);
10291026
},
10301027
codec: DcoCodec(
10311028
decodeSuccessData: dco_decode_String,
10321029
decodeErrorData: dco_decode_boltz_error,
10331030
),
10341031
constMeta: kCrateApiChainSwapChainSwapClaimConstMeta,
1035-
argValues: [that, outAddress, refundAddress, minerFee, tryCooperate],
1032+
argValues: [that, outAddress, minerFee, tryCooperate],
10361033
apiImpl: this,
10371034
));
10381035
}
10391036

10401037
TaskConstMeta get kCrateApiChainSwapChainSwapClaimConstMeta =>
10411038
const TaskConstMeta(
10421039
debugName: "chain_swap_claim",
1043-
argNames: [
1044-
"that",
1045-
"outAddress",
1046-
"refundAddress",
1047-
"minerFee",
1048-
"tryCooperate"
1049-
],
1040+
argNames: ["that", "outAddress", "minerFee", "tryCooperate"],
10501041
);
10511042

10521043
@override

lib/src/generated/frb_generated.io.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,15 +1544,13 @@ class BoltzCoreWire implements BaseWire {
15441544
int port_,
15451545
ffi.Pointer<wire_cst_chain_swap> that,
15461546
ffi.Pointer<wire_cst_list_prim_u_8_strict> out_address,
1547-
ffi.Pointer<wire_cst_list_prim_u_8_strict> refund_address,
15481547
ffi.Pointer<wire_cst_tx_fee> miner_fee,
15491548
bool try_cooperate,
15501549
) {
15511550
return _wire__crate__api__chain_swap__chain_swap_claim(
15521551
port_,
15531552
that,
15541553
out_address,
1555-
refund_address,
15561554
miner_fee,
15571555
try_cooperate,
15581556
);
@@ -1564,7 +1562,6 @@ class BoltzCoreWire implements BaseWire {
15641562
ffi.Int64,
15651563
ffi.Pointer<wire_cst_chain_swap>,
15661564
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
1567-
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
15681565
ffi.Pointer<wire_cst_tx_fee>,
15691566
ffi.Bool)>>(
15701567
'frbgen_boltz_wire__crate__api__chain_swap__chain_swap_claim');
@@ -1574,7 +1571,6 @@ class BoltzCoreWire implements BaseWire {
15741571
int,
15751572
ffi.Pointer<wire_cst_chain_swap>,
15761573
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
1577-
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
15781574
ffi.Pointer<wire_cst_tx_fee>,
15791575
bool)>();
15801576

macos/Classes/frb_generated.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ void frbgen_boltz_wire__crate__api__chain_swap__chain_swap_broadcast_local(int64
302302
void frbgen_boltz_wire__crate__api__chain_swap__chain_swap_claim(int64_t port_,
303303
struct wire_cst_chain_swap *that,
304304
struct wire_cst_list_prim_u_8_strict *out_address,
305-
struct wire_cst_list_prim_u_8_strict *refund_address,
306305
struct wire_cst_tx_fee *miner_fee,
307306
bool try_cooperate);
308307

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: boltz
22
description: A dart/flutter library for boltz swaps
3-
version: 0.2.0
3+
version: 0.2.1
44
homepage: https://github.com/SatoshiPortal/boltz-dart
55

66
environment:

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
crate-type = ["staticlib", "cdylib"]
1313

1414
[dependencies]
15-
boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust.git", ref = "d0f5e29278e9b267d87799ecfa3ca1df10308ff7", features = ["lnurl", "electrum"] }
15+
boltz-client = { git = "https://github.com/SatoshiPortal/boltz-rust.git", ref = "ced38e7a60ee96fa8b480015271f1ad2ff194884", features = ["lnurl", "electrum"] }
1616
flutter_rust_bridge = "=2.9.0"
1717
anyhow = "1.0.68"
1818
serde = { version = "1.0.0", features = ["derive"] }

rust/src/api/btc_ln.rs

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ use boltz_client::{
1111
},
1212
boltz::Cooperative,
1313
network::{electrum::ElectrumBitcoinClient, BitcoinClient, Chain as AllChains},
14-
swaps::{boltz::BoltzApiClientV2, magic_routing},
14+
swaps::{boltz::BoltzApiClientV2, magic_routing, SwapScriptCommon},
1515
util::secrets::Preimage,
1616
BtcSwapScript, BtcSwapTx, Keypair, PublicKey, ToHex,
1717
};
1818
use serde::{Deserialize, Serialize};
1919
use serde_json::Value;
2020

21-
/// Bitcoin-Lightning Swap Class
21+
// / Bitcoin-Lightning Swap Class
2222
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
2323
pub struct BtcLnSwap {
2424
pub id: String,
@@ -162,38 +162,13 @@ impl BtcLnSwap {
162162
/// If this function is not called within ~1 hour, the swap will be closed via the script path.
163163
/// 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.
164164
pub async fn coop_close_submarine(&self) -> Result<(), BoltzError> {
165-
let all_chains: AllChains = self.network.into();
166-
let bitcoin_chain = match all_chains {
167-
AllChains::Bitcoin(inner_chain) => inner_chain,
168-
_ => {
169-
return Err(BoltzError::new(
170-
"ChainType".to_string(),
171-
"Expected Bitcoin chain but got Liquid chain".to_string(),
172-
))
173-
}
174-
};
175-
let network_config =
176-
ElectrumBitcoinClient::new(bitcoin_chain, &self.electrum_url, true, true, 10)?;
177165
let boltz_client = BoltzApiClientV2::new(ensure_http_prefix(&self.boltz_url), None);
178166
let swap_script: BtcSwapScript = self.swap_script.clone().try_into()?;
179-
// WE SHOULD NOT NEED TO MAKE A TX, JUST A SCRIPT
180-
let tx = match BtcSwapTx::new_refund(
181-
swap_script,
182-
&self.script_address,
183-
&network_config,
184-
&boltz_client,
185-
self.id.clone(),
186-
)
187-
.await
188-
{
189-
Ok(result) => result,
190-
Err(e) => return Err(e.into()),
191-
};
192167
let ckp: Keypair = self.keys.clone().try_into()?;
193168
let claim_tx_response = boltz_client
194169
.get_submarine_claim_tx_details(&self.id)
195170
.await?;
196-
let (partial_sig, pub_nonce) = tx.partial_sign(
171+
let (partial_sig, pub_nonce) = swap_script.partial_sign(
197172
&ckp,
198173
&claim_tx_response.pub_nonce,
199174
&claim_tx_response.transaction_hash,
@@ -245,31 +220,33 @@ impl BtcLnSwap {
245220
let create_reverse_req = if out_address.is_some() {
246221
let address = out_address.unwrap();
247222
boltz_client::swaps::boltz::CreateReverseRequest {
248-
invoice_amount: out_amount as u64,
223+
invoice_amount: Some(out_amount as u64),
249224
from: "BTC".to_string(),
250225
to: "BTC".to_string(),
251-
preimage_hash: preimage.sha256,
226+
preimage_hash: Some(preimage.sha256),
252227
claim_public_key,
253228
referral_id: referral_id.clone(),
254229
address: Some(address.clone()),
255230
address_signature: Some(magic_routing::sign_address(&address, &ckp)?.to_string()),
256231
webhook: None,
257232
description: description,
258233
description_hash: None,
234+
invoice: None,
259235
}
260236
} else {
261237
boltz_client::swaps::boltz::CreateReverseRequest {
262-
invoice_amount: out_amount,
238+
invoice_amount: Some(out_amount),
263239
from: "BTC".to_string(),
264240
to: "BTC".to_string(),
265-
preimage_hash: preimage.sha256,
241+
preimage_hash: Some(preimage.sha256),
266242
claim_public_key,
267243
referral_id: referral_id.clone(),
268244
address: None,
269245
address_signature: None,
270246
description: None,
271247
description_hash: None,
272248
webhook: None,
249+
invoice: None,
273250
}
274251
};
275252
let all_chains: AllChains = network.into();
@@ -295,7 +272,7 @@ impl BtcLnSwap {
295272
index,
296273
preimage.into(),
297274
swap_script.into(),
298-
create_swap_response.invoice,
275+
create_swap_response.invoice.unwrap_or_default(),
299276
script_address,
300277
out_amount,
301278
strip_tcp_prefix(&electrum_url),

0 commit comments

Comments
 (0)