From ae031420020592860cf7b0422cc4de36d2eb73fa Mon Sep 17 00:00:00 2001 From: i5hi Date: Sat, 3 Feb 2024 12:09:19 +0530 Subject: [PATCH] Updated latest binaries --- README.md | 12 +- lib/src/generated/bindings.dart | 448 ++++++++++++++-------- lib/src/generated/bridge_definitions.dart | 28 +- rust/compress.sh | 6 + rust/makefile | 12 +- rust/src/bridge_generated.rs | 407 +------------------- 6 files changed, 338 insertions(+), 575 deletions(-) diff --git a/README.md b/README.md index e99ac76..2a5e5d5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ The top level directory of this project is a dart/flutter pub library. The `rust` folder containers the core code which uses the `boltz-rust` crate internally to expose an abstracted API to manage boltz swaps. ## Dependencies +Docker is required for linux builds. ```bash cargo install flutter_rust_bridge_codegen @@ -27,11 +28,18 @@ types.rs structures and enums are also re-exported via api.rs # in the project root directory ./compile.native.sh # build for your native platform (linux/macos). adds binary to dart test folder. -./compile.android.sh # build for android (workds on linux and macos hosts) -./compile.ios.sh # build for ios (can only build on macos hosts) ``` +## MacOS as host + +macos as the host machine can build binaries for all platforms using: + +```bash +# requires dockerd running +./compile.all.sh +``` + Compile will first build native binaries of the rust code and move them to the dart test folder. It will then run flutter_rust_bridge_codegen and generate ffi code in rust and dart. diff --git a/lib/src/generated/bindings.dart b/lib/src/generated/bindings.dart index c9acdcb..4696dc0 100644 --- a/lib/src/generated/bindings.dart +++ b/lib/src/generated/bindings.dart @@ -19,16 +19,20 @@ import 'dart:ffi' as ffi; class BoltzDartImpl implements BoltzDart { final BoltzDartPlatform _platform; - factory BoltzDartImpl(ExternalLibrary dylib) => BoltzDartImpl.raw(BoltzDartPlatform(dylib)); + factory BoltzDartImpl(ExternalLibrary dylib) => + BoltzDartImpl.raw(BoltzDartPlatform(dylib)); /// Only valid on web/WASM platforms. - factory BoltzDartImpl.wasm(FutureOr module) => BoltzDartImpl(module as ExternalLibrary); + factory BoltzDartImpl.wasm(FutureOr module) => + BoltzDartImpl(module as ExternalLibrary); BoltzDartImpl.raw(this._platform); - Future swapFeesStaticMethodApi({required String boltzUrl, required int outputAmount, dynamic hint}) { + Future swapFeesStaticMethodApi( + {required String boltzUrl, required int outputAmount, dynamic hint}) { var arg0 = _platform.api2wire_String(boltzUrl); var arg1 = _platform.api2wire_u64(outputAmount); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_swap_fees__static_method__Api(port_, arg0, arg1), + callFfi: (port_) => + _platform.inner.wire_swap_fees__static_method__Api(port_, arg0, arg1), parseSuccessData: _wire2api_all_fees, parseErrorData: _wire2api_boltz_error, constMeta: kSwapFeesStaticMethodApiConstMeta, @@ -37,7 +41,8 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kSwapFeesStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kSwapFeesStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( debugName: "swap_fees__static_method__Api", argNames: ["boltzUrl", "outputAmount"], ); @@ -57,8 +62,9 @@ class BoltzDartImpl implements BoltzDart { var arg4 = _platform.api2wire_String(electrumUrl); var arg5 = _platform.api2wire_String(boltzUrl); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_new_btc_ln_submarine__static_method__Api(port_, arg0, arg1, arg2, arg3, arg4, arg5), + callFfi: (port_) => _platform.inner + .wire_new_btc_ln_submarine__static_method__Api( + port_, arg0, arg1, arg2, arg3, arg4, arg5), parseSuccessData: _wire2api_btc_ln_swap, parseErrorData: _wire2api_boltz_error, constMeta: kNewBtcLnSubmarineStaticMethodApiConstMeta, @@ -67,10 +73,19 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kNewBtcLnSubmarineStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "new_btc_ln_submarine__static_method__Api", - argNames: ["mnemonic", "index", "invoice", "network", "electrumUrl", "boltzUrl"], - ); + FlutterRustBridgeTaskConstMeta + get kNewBtcLnSubmarineStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "new_btc_ln_submarine__static_method__Api", + argNames: [ + "mnemonic", + "index", + "invoice", + "network", + "electrumUrl", + "boltzUrl" + ], + ); Future newBtcLnReverseStaticMethodApi( {required String mnemonic, @@ -87,8 +102,9 @@ class BoltzDartImpl implements BoltzDart { var arg4 = _platform.api2wire_String(electrumUrl); var arg5 = _platform.api2wire_String(boltzUrl); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_new_btc_ln_reverse__static_method__Api(port_, arg0, arg1, arg2, arg3, arg4, arg5), + callFfi: (port_) => _platform.inner + .wire_new_btc_ln_reverse__static_method__Api( + port_, arg0, arg1, arg2, arg3, arg4, arg5), parseSuccessData: _wire2api_btc_ln_swap, parseErrorData: _wire2api_boltz_error, constMeta: kNewBtcLnReverseStaticMethodApiConstMeta, @@ -97,15 +113,25 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kNewBtcLnReverseStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kNewBtcLnReverseStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( debugName: "new_btc_ln_reverse__static_method__Api", - argNames: ["mnemonic", "index", "outAmount", "network", "electrumUrl", "boltzUrl"], + argNames: [ + "mnemonic", + "index", + "outAmount", + "network", + "electrumUrl", + "boltzUrl" + ], ); - Future btcLnTxSizeStaticMethodApi({required BtcLnSwap swap, dynamic hint}) { + Future btcLnTxSizeStaticMethodApi( + {required BtcLnSwap swap, dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_btc_ln_swap(swap); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_btc_ln_tx_size__static_method__Api(port_, arg0), + callFfi: (port_) => + _platform.inner.wire_btc_ln_tx_size__static_method__Api(port_, arg0), parseSuccessData: _wire2api_usize, parseErrorData: _wire2api_boltz_error, constMeta: kBtcLnTxSizeStaticMethodApiConstMeta, @@ -114,18 +140,24 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kBtcLnTxSizeStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kBtcLnTxSizeStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( debugName: "btc_ln_tx_size__static_method__Api", argNames: ["swap"], ); Future btcLnReverseClaimStaticMethodApi( - {required BtcLnSwap swap, required String outAddress, required int absFee, dynamic hint}) { + {required BtcLnSwap swap, + required String outAddress, + required int absFee, + dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_btc_ln_swap(swap); var arg1 = _platform.api2wire_String(outAddress); var arg2 = _platform.api2wire_u64(absFee); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_btc_ln_reverse_claim__static_method__Api(port_, arg0, arg1, arg2), + callFfi: (port_) => _platform.inner + .wire_btc_ln_reverse_claim__static_method__Api( + port_, arg0, arg1, arg2), parseSuccessData: _wire2api_String, parseErrorData: _wire2api_boltz_error, constMeta: kBtcLnReverseClaimStaticMethodApiConstMeta, @@ -134,10 +166,12 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kBtcLnReverseClaimStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "btc_ln_reverse_claim__static_method__Api", - argNames: ["swap", "outAddress", "absFee"], - ); + FlutterRustBridgeTaskConstMeta + get kBtcLnReverseClaimStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "btc_ln_reverse_claim__static_method__Api", + argNames: ["swap", "outAddress", "absFee"], + ); Future newLbtcLnSubmarineStaticMethodApi( {required String mnemonic, @@ -154,8 +188,9 @@ class BoltzDartImpl implements BoltzDart { var arg4 = _platform.api2wire_String(electrumUrl); var arg5 = _platform.api2wire_String(boltzUrl); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_new_lbtc_ln_submarine__static_method__Api(port_, arg0, arg1, arg2, arg3, arg4, arg5), + callFfi: (port_) => _platform.inner + .wire_new_lbtc_ln_submarine__static_method__Api( + port_, arg0, arg1, arg2, arg3, arg4, arg5), parseSuccessData: _wire2api_lbtc_ln_swap, parseErrorData: _wire2api_boltz_error, constMeta: kNewLbtcLnSubmarineStaticMethodApiConstMeta, @@ -164,11 +199,19 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kNewLbtcLnSubmarineStaticMethodApiConstMeta => - const FlutterRustBridgeTaskConstMeta( - debugName: "new_lbtc_ln_submarine__static_method__Api", - argNames: ["mnemonic", "index", "invoice", "network", "electrumUrl", "boltzUrl"], - ); + FlutterRustBridgeTaskConstMeta + get kNewLbtcLnSubmarineStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "new_lbtc_ln_submarine__static_method__Api", + argNames: [ + "mnemonic", + "index", + "invoice", + "network", + "electrumUrl", + "boltzUrl" + ], + ); Future newLbtcLnReverseStaticMethodApi( {required String mnemonic, @@ -185,8 +228,9 @@ class BoltzDartImpl implements BoltzDart { var arg4 = _platform.api2wire_String(electrumUrl); var arg5 = _platform.api2wire_String(boltzUrl); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_new_lbtc_ln_reverse__static_method__Api(port_, arg0, arg1, arg2, arg3, arg4, arg5), + callFfi: (port_) => _platform.inner + .wire_new_lbtc_ln_reverse__static_method__Api( + port_, arg0, arg1, arg2, arg3, arg4, arg5), parseSuccessData: _wire2api_lbtc_ln_swap, parseErrorData: _wire2api_boltz_error, constMeta: kNewLbtcLnReverseStaticMethodApiConstMeta, @@ -195,15 +239,26 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kNewLbtcLnReverseStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "new_lbtc_ln_reverse__static_method__Api", - argNames: ["mnemonic", "index", "outAmount", "network", "electrumUrl", "boltzUrl"], - ); - - Future lbtcLnTxSizeStaticMethodApi({required LbtcLnSwap swap, dynamic hint}) { + FlutterRustBridgeTaskConstMeta + get kNewLbtcLnReverseStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "new_lbtc_ln_reverse__static_method__Api", + argNames: [ + "mnemonic", + "index", + "outAmount", + "network", + "electrumUrl", + "boltzUrl" + ], + ); + + Future lbtcLnTxSizeStaticMethodApi( + {required LbtcLnSwap swap, dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_lbtc_ln_swap(swap); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_lbtc_ln_tx_size__static_method__Api(port_, arg0), + callFfi: (port_) => + _platform.inner.wire_lbtc_ln_tx_size__static_method__Api(port_, arg0), parseSuccessData: _wire2api_usize, parseErrorData: _wire2api_boltz_error, constMeta: kLbtcLnTxSizeStaticMethodApiConstMeta, @@ -212,18 +267,24 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kLbtcLnTxSizeStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kLbtcLnTxSizeStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( debugName: "lbtc_ln_tx_size__static_method__Api", argNames: ["swap"], ); Future lbtcLnReverseClaimStaticMethodApi( - {required LbtcLnSwap swap, required String outAddress, required int absFee, dynamic hint}) { + {required LbtcLnSwap swap, + required String outAddress, + required int absFee, + dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_lbtc_ln_swap(swap); var arg1 = _platform.api2wire_String(outAddress); var arg2 = _platform.api2wire_u64(absFee); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_lbtc_ln_reverse_claim__static_method__Api(port_, arg0, arg1, arg2), + callFfi: (port_) => _platform.inner + .wire_lbtc_ln_reverse_claim__static_method__Api( + port_, arg0, arg1, arg2), parseSuccessData: _wire2api_String, parseErrorData: _wire2api_boltz_error, constMeta: kLbtcLnReverseClaimStaticMethodApiConstMeta, @@ -232,17 +293,20 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kLbtcLnReverseClaimStaticMethodApiConstMeta => - const FlutterRustBridgeTaskConstMeta( - debugName: "lbtc_ln_reverse_claim__static_method__Api", - argNames: ["swap", "outAddress", "absFee"], - ); + FlutterRustBridgeTaskConstMeta + get kLbtcLnReverseClaimStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "lbtc_ln_reverse_claim__static_method__Api", + argNames: ["swap", "outAddress", "absFee"], + ); - Future swapStatusStaticMethodApi({required String boltzUrl, required String id, dynamic hint}) { + Future swapStatusStaticMethodApi( + {required String boltzUrl, required String id, dynamic hint}) { var arg0 = _platform.api2wire_String(boltzUrl); var arg1 = _platform.api2wire_String(id); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_swap_status__static_method__Api(port_, arg0, arg1), + callFfi: (port_) => _platform.inner + .wire_swap_status__static_method__Api(port_, arg0, arg1), parseSuccessData: _wire2api_String, parseErrorData: _wire2api_boltz_error, constMeta: kSwapStatusStaticMethodApiConstMeta, @@ -251,7 +315,8 @@ class BoltzDartImpl implements BoltzDart { )); } - FlutterRustBridgeTaskConstMeta get kSwapStatusStaticMethodApiConstMeta => const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kSwapStatusStaticMethodApiConstMeta => + const FlutterRustBridgeTaskConstMeta( debugName: "swap_status__static_method__Api", argNames: ["boltzUrl", "id"], ); @@ -267,7 +332,8 @@ class BoltzDartImpl implements BoltzDart { AllFees _wire2api_all_fees(dynamic raw) { final arr = raw as List; - if (arr.length != 6) throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + if (arr.length != 6) + throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); return AllFees( btcLimits: _wire2api_limits(arr[0]), lbtcLimits: _wire2api_limits(arr[1]), @@ -280,7 +346,8 @@ class BoltzDartImpl implements BoltzDart { BoltzError _wire2api_boltz_error(dynamic raw) { final arr = raw as List; - if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return BoltzError( kind: _wire2api_String(arr[0]), message: _wire2api_String(arr[1]), @@ -289,7 +356,8 @@ class BoltzDartImpl implements BoltzDart { BtcLnSwap _wire2api_btc_ln_swap(dynamic raw) { final arr = raw as List; - if (arr.length != 11) throw Exception('unexpected arr length: expect 11 but see ${arr.length}'); + if (arr.length != 11) + throw Exception('unexpected arr length: expect 11 but see ${arr.length}'); return BtcLnSwap( id: _wire2api_String(arr[0]), kind: _wire2api_swap_type(arr[1]), @@ -315,7 +383,8 @@ class BoltzDartImpl implements BoltzDart { KeyPair _wire2api_key_pair(dynamic raw) { final arr = raw as List; - if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return KeyPair( secretKey: _wire2api_String(arr[0]), publicKey: _wire2api_String(arr[1]), @@ -324,7 +393,8 @@ class BoltzDartImpl implements BoltzDart { LbtcLnSwap _wire2api_lbtc_ln_swap(dynamic raw) { final arr = raw as List; - if (arr.length != 12) throw Exception('unexpected arr length: expect 12 but see ${arr.length}'); + if (arr.length != 12) + throw Exception('unexpected arr length: expect 12 but see ${arr.length}'); return LbtcLnSwap( id: _wire2api_String(arr[0]), kind: _wire2api_swap_type(arr[1]), @@ -343,7 +413,8 @@ class BoltzDartImpl implements BoltzDart { Limits _wire2api_limits(dynamic raw) { final arr = raw as List; - if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return Limits( minimal: _wire2api_u64(arr[0]), maximal: _wire2api_u64(arr[1]), @@ -352,7 +423,8 @@ class BoltzDartImpl implements BoltzDart { PreImage _wire2api_pre_image(dynamic raw) { final arr = raw as List; - if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); return PreImage( value: _wire2api_String(arr[0]), sha256: _wire2api_String(arr[1]), @@ -362,7 +434,8 @@ class BoltzDartImpl implements BoltzDart { ReverseSwapFees _wire2api_reverse_swap_fees(dynamic raw) { final arr = raw as List; - if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); return ReverseSwapFees( boltzFees: _wire2api_u64(arr[0]), lockupFees: _wire2api_u64(arr[1]), @@ -372,7 +445,8 @@ class BoltzDartImpl implements BoltzDart { SubmarineSwapFees _wire2api_submarine_swap_fees(dynamic raw) { final arr = raw as List; - if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); return SubmarineSwapFees( boltzFees: _wire2api_u64(arr[0]), claimFees: _wire2api_u64(arr[1]), @@ -443,7 +517,8 @@ class BoltzDartPlatform extends FlutterRustBridgeBase { } @protected - ffi.Pointer api2wire_box_autoadd_lbtc_ln_swap(LbtcLnSwap raw) { + ffi.Pointer api2wire_box_autoadd_lbtc_ln_swap( + LbtcLnSwap raw) { final ptr = inner.new_box_autoadd_lbtc_ln_swap_0(); _api_fill_to_wire_lbtc_ln_swap(raw, ptr.ref); return ptr; @@ -464,11 +539,13 @@ class BoltzDartPlatform extends FlutterRustBridgeBase { // Section: api_fill_to_wire - void _api_fill_to_wire_box_autoadd_btc_ln_swap(BtcLnSwap apiObj, ffi.Pointer wireObj) { + void _api_fill_to_wire_box_autoadd_btc_ln_swap( + BtcLnSwap apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_btc_ln_swap(apiObj, wireObj.ref); } - void _api_fill_to_wire_box_autoadd_lbtc_ln_swap(LbtcLnSwap apiObj, ffi.Pointer wireObj) { + void _api_fill_to_wire_box_autoadd_lbtc_ln_swap( + LbtcLnSwap apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_lbtc_ln_swap(apiObj, wireObj.ref); } @@ -491,7 +568,8 @@ class BoltzDartPlatform extends FlutterRustBridgeBase { wireObj.public_key = api2wire_String(apiObj.publicKey); } - void _api_fill_to_wire_lbtc_ln_swap(LbtcLnSwap apiObj, wire_LbtcLnSwap wireObj) { + void _api_fill_to_wire_lbtc_ln_swap( + LbtcLnSwap apiObj, wire_LbtcLnSwap wireObj) { wireObj.id = api2wire_String(apiObj.id); wireObj.kind = api2wire_swap_type(apiObj.kind); wireObj.network = api2wire_chain(apiObj.network); @@ -526,13 +604,17 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { late final dartApi = DartApiDl(init_frb_dart_api_dl); /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; + final ffi.Pointer Function(String symbolName) + _lookup; /// The symbols are looked up in [dynamicLibrary]. - BoltzDartWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + BoltzDartWire(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - BoltzDartWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) + BoltzDartWire.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) : _lookup = lookup; void store_dart_post_cobject( @@ -544,8 +626,10 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _store_dart_post_cobjectPtr = - _lookup>('store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); + _lookup>( + 'store_dart_post_cobject'); + late final _store_dart_post_cobject = _store_dart_post_cobjectPtr + .asFunction(); Object get_dart_object( int ptr, @@ -555,8 +639,11 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _get_dart_objectPtr = _lookup>('get_dart_object'); - late final _get_dart_object = _get_dart_objectPtr.asFunction(); + late final _get_dart_objectPtr = + _lookup>( + 'get_dart_object'); + late final _get_dart_object = + _get_dart_objectPtr.asFunction(); void drop_dart_object( int ptr, @@ -566,8 +653,11 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); - late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); + late final _drop_dart_objectPtr = + _lookup>( + 'drop_dart_object'); + late final _drop_dart_object = + _drop_dart_objectPtr.asFunction(); int new_dart_opaque( Object handle, @@ -577,8 +667,11 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); - late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); + late final _new_dart_opaquePtr = + _lookup>( + 'new_dart_opaque'); + late final _new_dart_opaque = + _new_dart_opaquePtr.asFunction(); int init_frb_dart_api_dl( ffi.Pointer obj, @@ -589,8 +682,10 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _init_frb_dart_api_dlPtr = - _lookup)>>('init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); + _lookup)>>( + 'init_frb_dart_api_dl'); + late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr + .asFunction)>(); void wire_swap_fees__static_method__Api( int port_, @@ -604,11 +699,13 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _wire_swap_fees__static_method__ApiPtr = - _lookup, ffi.Uint64)>>( - 'wire_swap_fees__static_method__Api'); + late final _wire_swap_fees__static_method__ApiPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, + ffi.Uint64)>>('wire_swap_fees__static_method__Api'); late final _wire_swap_fees__static_method__Api = - _wire_swap_fees__static_method__ApiPtr.asFunction, int)>(); + _wire_swap_fees__static_method__ApiPtr + .asFunction, int)>(); void wire_new_btc_ln_submarine__static_method__Api( int port_, @@ -631,19 +728,26 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _wire_new_btc_ln_submarine__static_method__ApiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Int32, + ffi.Pointer, + ffi.Pointer)>>( + 'wire_new_btc_ln_submarine__static_method__Api'); + late final _wire_new_btc_ln_submarine__static_method__Api = + _wire_new_btc_ln_submarine__static_method__ApiPtr.asFunction< + void Function( + int, ffi.Pointer, - ffi.Uint64, + int, ffi.Pointer, - ffi.Int32, + int, ffi.Pointer, - ffi.Pointer)>>('wire_new_btc_ln_submarine__static_method__Api'); - late final _wire_new_btc_ln_submarine__static_method__Api = - _wire_new_btc_ln_submarine__static_method__ApiPtr.asFunction< - void Function(int, ffi.Pointer, int, ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer)>(); void wire_new_btc_ln_reverse__static_method__Api( int port_, @@ -666,18 +770,20 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _wire_new_btc_ln_reverse__static_method__ApiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Uint64, - ffi.Uint64, - ffi.Int32, - ffi.Pointer, - ffi.Pointer)>>('wire_new_btc_ln_reverse__static_method__Api'); - late final _wire_new_btc_ln_reverse__static_method__Api = _wire_new_btc_ln_reverse__static_method__ApiPtr.asFunction< - void Function(int, ffi.Pointer, int, int, int, ffi.Pointer, - ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Uint64, + ffi.Uint64, + ffi.Int32, + ffi.Pointer, + ffi.Pointer)>>( + 'wire_new_btc_ln_reverse__static_method__Api'); + late final _wire_new_btc_ln_reverse__static_method__Api = + _wire_new_btc_ln_reverse__static_method__ApiPtr.asFunction< + void Function(int, ffi.Pointer, int, int, int, + ffi.Pointer, ffi.Pointer)>(); void wire_btc_ln_tx_size__static_method__Api( int port_, @@ -689,11 +795,13 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _wire_btc_ln_tx_size__static_method__ApiPtr = - _lookup)>>( - 'wire_btc_ln_tx_size__static_method__Api'); + late final _wire_btc_ln_tx_size__static_method__ApiPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer)>>( + 'wire_btc_ln_tx_size__static_method__Api'); late final _wire_btc_ln_tx_size__static_method__Api = - _wire_btc_ln_tx_size__static_method__ApiPtr.asFunction)>(); + _wire_btc_ln_tx_size__static_method__ApiPtr + .asFunction)>(); void wire_btc_ln_reverse_claim__static_method__Api( int port_, @@ -711,10 +819,15 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { late final _wire_btc_ln_reverse_claim__static_method__ApiPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer, ffi.Uint64)>>('wire_btc_ln_reverse_claim__static_method__Api'); - late final _wire_btc_ln_reverse_claim__static_method__Api = _wire_btc_ln_reverse_claim__static_method__ApiPtr - .asFunction, ffi.Pointer, int)>(); + late final _wire_btc_ln_reverse_claim__static_method__Api = + _wire_btc_ln_reverse_claim__static_method__ApiPtr.asFunction< + void Function(int, ffi.Pointer, + ffi.Pointer, int)>(); void wire_new_lbtc_ln_submarine__static_method__Api( int port_, @@ -737,19 +850,26 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _wire_new_lbtc_ln_submarine__static_method__ApiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Int32, + ffi.Pointer, + ffi.Pointer)>>( + 'wire_new_lbtc_ln_submarine__static_method__Api'); + late final _wire_new_lbtc_ln_submarine__static_method__Api = + _wire_new_lbtc_ln_submarine__static_method__ApiPtr.asFunction< + void Function( + int, ffi.Pointer, - ffi.Uint64, + int, ffi.Pointer, - ffi.Int32, + int, ffi.Pointer, - ffi.Pointer)>>('wire_new_lbtc_ln_submarine__static_method__Api'); - late final _wire_new_lbtc_ln_submarine__static_method__Api = - _wire_new_lbtc_ln_submarine__static_method__ApiPtr.asFunction< - void Function(int, ffi.Pointer, int, ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer)>(); void wire_new_lbtc_ln_reverse__static_method__Api( int port_, @@ -772,19 +892,20 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _wire_new_lbtc_ln_reverse__static_method__ApiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Uint64, - ffi.Uint64, - ffi.Int32, - ffi.Pointer, - ffi.Pointer)>>('wire_new_lbtc_ln_reverse__static_method__Api'); + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Uint64, + ffi.Uint64, + ffi.Int32, + ffi.Pointer, + ffi.Pointer)>>( + 'wire_new_lbtc_ln_reverse__static_method__Api'); late final _wire_new_lbtc_ln_reverse__static_method__Api = _wire_new_lbtc_ln_reverse__static_method__ApiPtr.asFunction< - void Function(int, ffi.Pointer, int, int, int, ffi.Pointer, - ffi.Pointer)>(); + void Function(int, ffi.Pointer, int, int, int, + ffi.Pointer, ffi.Pointer)>(); void wire_lbtc_ln_tx_size__static_method__Api( int port_, @@ -796,11 +917,13 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _wire_lbtc_ln_tx_size__static_method__ApiPtr = - _lookup)>>( - 'wire_lbtc_ln_tx_size__static_method__Api'); + late final _wire_lbtc_ln_tx_size__static_method__ApiPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer)>>( + 'wire_lbtc_ln_tx_size__static_method__Api'); late final _wire_lbtc_ln_tx_size__static_method__Api = - _wire_lbtc_ln_tx_size__static_method__ApiPtr.asFunction)>(); + _wire_lbtc_ln_tx_size__static_method__ApiPtr + .asFunction)>(); void wire_lbtc_ln_reverse_claim__static_method__Api( int port_, @@ -818,10 +941,15 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { late final _wire_lbtc_ln_reverse_claim__static_method__ApiPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer, ffi.Uint64)>>('wire_lbtc_ln_reverse_claim__static_method__Api'); - late final _wire_lbtc_ln_reverse_claim__static_method__Api = _wire_lbtc_ln_reverse_claim__static_method__ApiPtr - .asFunction, ffi.Pointer, int)>(); + late final _wire_lbtc_ln_reverse_claim__static_method__Api = + _wire_lbtc_ln_reverse_claim__static_method__ApiPtr.asFunction< + void Function(int, ffi.Pointer, + ffi.Pointer, int)>(); void wire_swap_status__static_method__Api( int port_, @@ -836,29 +964,35 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _wire_swap_status__static_method__ApiPtr = _lookup< - ffi - .NativeFunction, ffi.Pointer)>>( + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, + ffi.Pointer)>>( 'wire_swap_status__static_method__Api'); - late final _wire_swap_status__static_method__Api = _wire_swap_status__static_method__ApiPtr - .asFunction, ffi.Pointer)>(); + late final _wire_swap_status__static_method__Api = + _wire_swap_status__static_method__ApiPtr.asFunction< + void Function(int, ffi.Pointer, + ffi.Pointer)>(); ffi.Pointer new_box_autoadd_btc_ln_swap_0() { return _new_box_autoadd_btc_ln_swap_0(); } late final _new_box_autoadd_btc_ln_swap_0Ptr = - _lookup Function()>>('new_box_autoadd_btc_ln_swap_0'); - late final _new_box_autoadd_btc_ln_swap_0 = - _new_box_autoadd_btc_ln_swap_0Ptr.asFunction Function()>(); + _lookup Function()>>( + 'new_box_autoadd_btc_ln_swap_0'); + late final _new_box_autoadd_btc_ln_swap_0 = _new_box_autoadd_btc_ln_swap_0Ptr + .asFunction Function()>(); ffi.Pointer new_box_autoadd_lbtc_ln_swap_0() { return _new_box_autoadd_lbtc_ln_swap_0(); } late final _new_box_autoadd_lbtc_ln_swap_0Ptr = - _lookup Function()>>('new_box_autoadd_lbtc_ln_swap_0'); + _lookup Function()>>( + 'new_box_autoadd_lbtc_ln_swap_0'); late final _new_box_autoadd_lbtc_ln_swap_0 = - _new_box_autoadd_lbtc_ln_swap_0Ptr.asFunction Function()>(); + _new_box_autoadd_lbtc_ln_swap_0Ptr + .asFunction Function()>(); ffi.Pointer new_uint_8_list_0( int len, @@ -868,9 +1002,12 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { ); } - late final _new_uint_8_list_0Ptr = - _lookup Function(ffi.Int32)>>('new_uint_8_list_0'); - late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr.asFunction Function(int)>(); + late final _new_uint_8_list_0Ptr = _lookup< + ffi + .NativeFunction Function(ffi.Int32)>>( + 'new_uint_8_list_0'); + late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr + .asFunction Function(int)>(); void free_WireSyncReturn( WireSyncReturn ptr, @@ -881,8 +1018,10 @@ class BoltzDartWire implements FlutterRustBridgeWireBase { } late final _free_WireSyncReturnPtr = - _lookup>('free_WireSyncReturn'); - late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); + _lookup>( + 'free_WireSyncReturn'); + late final _free_WireSyncReturn = + _free_WireSyncReturnPtr.asFunction(); } final class _Dart_Handle extends ffi.Opaque {} @@ -964,6 +1103,7 @@ final class wire_LbtcLnSwap extends ffi.Struct { external ffi.Pointer boltz_url; } -typedef DartPostCObjectFnType - = ffi.Pointer message)>>; +typedef DartPostCObjectFnType = ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(DartPort port_id, ffi.Pointer message)>>; typedef DartPort = ffi.Int64; diff --git a/lib/src/generated/bridge_definitions.dart b/lib/src/generated/bridge_definitions.dart index 910ad96..d1387ad 100644 --- a/lib/src/generated/bridge_definitions.dart +++ b/lib/src/generated/bridge_definitions.dart @@ -9,7 +9,8 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; import 'package:uuid/uuid.dart'; abstract class BoltzDart { - Future swapFeesStaticMethodApi({required String boltzUrl, required int outputAmount, dynamic hint}); + Future swapFeesStaticMethodApi( + {required String boltzUrl, required int outputAmount, dynamic hint}); FlutterRustBridgeTaskConstMeta get kSwapFeesStaticMethodApiConstMeta; @@ -35,12 +36,16 @@ abstract class BoltzDart { FlutterRustBridgeTaskConstMeta get kNewBtcLnReverseStaticMethodApiConstMeta; - Future btcLnTxSizeStaticMethodApi({required BtcLnSwap swap, dynamic hint}); + Future btcLnTxSizeStaticMethodApi( + {required BtcLnSwap swap, dynamic hint}); FlutterRustBridgeTaskConstMeta get kBtcLnTxSizeStaticMethodApiConstMeta; Future btcLnReverseClaimStaticMethodApi( - {required BtcLnSwap swap, required String outAddress, required int absFee, dynamic hint}); + {required BtcLnSwap swap, + required String outAddress, + required int absFee, + dynamic hint}); FlutterRustBridgeTaskConstMeta get kBtcLnReverseClaimStaticMethodApiConstMeta; @@ -53,7 +58,8 @@ abstract class BoltzDart { required String boltzUrl, dynamic hint}); - FlutterRustBridgeTaskConstMeta get kNewLbtcLnSubmarineStaticMethodApiConstMeta; + FlutterRustBridgeTaskConstMeta + get kNewLbtcLnSubmarineStaticMethodApiConstMeta; Future newLbtcLnReverseStaticMethodApi( {required String mnemonic, @@ -66,16 +72,22 @@ abstract class BoltzDart { FlutterRustBridgeTaskConstMeta get kNewLbtcLnReverseStaticMethodApiConstMeta; - Future lbtcLnTxSizeStaticMethodApi({required LbtcLnSwap swap, dynamic hint}); + Future lbtcLnTxSizeStaticMethodApi( + {required LbtcLnSwap swap, dynamic hint}); FlutterRustBridgeTaskConstMeta get kLbtcLnTxSizeStaticMethodApiConstMeta; Future lbtcLnReverseClaimStaticMethodApi( - {required LbtcLnSwap swap, required String outAddress, required int absFee, dynamic hint}); + {required LbtcLnSwap swap, + required String outAddress, + required int absFee, + dynamic hint}); - FlutterRustBridgeTaskConstMeta get kLbtcLnReverseClaimStaticMethodApiConstMeta; + FlutterRustBridgeTaskConstMeta + get kLbtcLnReverseClaimStaticMethodApiConstMeta; - Future swapStatusStaticMethodApi({required String boltzUrl, required String id, dynamic hint}); + Future swapStatusStaticMethodApi( + {required String boltzUrl, required String id, dynamic hint}); FlutterRustBridgeTaskConstMeta get kSwapStatusStaticMethodApiConstMeta; } diff --git a/rust/compress.sh b/rust/compress.sh index a9bf588..4de6465 100644 --- a/rust/compress.sh +++ b/rust/compress.sh @@ -1 +1,7 @@ #!/bin/bash +ROOT="target" +VERSION=$1 +NAME="libboltz" +LIB=$ROOT/$NAME.$VERSION + +zip -r $LIB.zip $LIB \ No newline at end of file diff --git a/rust/makefile b/rust/makefile index 8dcb448..715daf8 100644 --- a/rust/makefile +++ b/rust/makefile @@ -19,8 +19,8 @@ init: @if [ $$(uname) == "Darwin" ] ; then cargo install cargo-lipo ; fi ## : -## all: Compile iOS, Android and bindings targets -all: init jnilib xcframework linux +## all: Compile iOS, Android & Linux binaries +all: init jnilib xcframework zip linux: @echo "[Creating linux binary ...] $@" @@ -39,10 +39,10 @@ xcframework: sh darwin.sh $(VERSION) @echo "[Done ✅]" -# compress-build: -# @echo "[COMPRESSING BINARIES TO FLUTTER PACKAGE ...] $@" -# sh compress.sh -# @echo "[Done ✅]" +zip: + @echo "[COMPRESSING BINARIES TO FLUTTER PACKAGE ...] $@" + sh compress.sh $(VERSION) + @echo "[Done ✅]" # copy-build: # @echo "[COPYING BINARIES TO FLUTTER PACKAGE ...] $@" diff --git a/rust/src/bridge_generated.rs b/rust/src/bridge_generated.rs index 11aeca8..b40843b 100644 --- a/rust/src/bridge_generated.rs +++ b/rust/src/bridge_generated.rs @@ -551,410 +551,7 @@ support::lazy_static! { } #[cfg(not(target_family = "wasm"))] -mod io { - use super::*; - // Section: wire functions - - #[no_mangle] - pub extern "C" fn wire_swap_fees__static_method__Api( - port_: i64, - boltz_url: *mut wire_uint_8_list, - output_amount: u64, - ) { - wire_swap_fees__static_method__Api_impl(port_, boltz_url, output_amount) - } - - #[no_mangle] - pub extern "C" fn wire_new_btc_ln_submarine__static_method__Api( - port_: i64, - mnemonic: *mut wire_uint_8_list, - index: u64, - invoice: *mut wire_uint_8_list, - network: i32, - electrum_url: *mut wire_uint_8_list, - boltz_url: *mut wire_uint_8_list, - ) { - wire_new_btc_ln_submarine__static_method__Api_impl( - port_, - mnemonic, - index, - invoice, - network, - electrum_url, - boltz_url, - ) - } - - #[no_mangle] - pub extern "C" fn wire_new_btc_ln_reverse__static_method__Api( - port_: i64, - mnemonic: *mut wire_uint_8_list, - index: u64, - out_amount: u64, - network: i32, - electrum_url: *mut wire_uint_8_list, - boltz_url: *mut wire_uint_8_list, - ) { - wire_new_btc_ln_reverse__static_method__Api_impl( - port_, - mnemonic, - index, - out_amount, - network, - electrum_url, - boltz_url, - ) - } - - #[no_mangle] - pub extern "C" fn wire_btc_ln_tx_size__static_method__Api( - port_: i64, - swap: *mut wire_BtcLnSwap, - ) { - wire_btc_ln_tx_size__static_method__Api_impl(port_, swap) - } - - #[no_mangle] - pub extern "C" fn wire_btc_ln_reverse_claim__static_method__Api( - port_: i64, - swap: *mut wire_BtcLnSwap, - out_address: *mut wire_uint_8_list, - abs_fee: u64, - ) { - wire_btc_ln_reverse_claim__static_method__Api_impl(port_, swap, out_address, abs_fee) - } - - #[no_mangle] - pub extern "C" fn wire_new_lbtc_ln_submarine__static_method__Api( - port_: i64, - mnemonic: *mut wire_uint_8_list, - index: u64, - invoice: *mut wire_uint_8_list, - network: i32, - electrum_url: *mut wire_uint_8_list, - boltz_url: *mut wire_uint_8_list, - ) { - wire_new_lbtc_ln_submarine__static_method__Api_impl( - port_, - mnemonic, - index, - invoice, - network, - electrum_url, - boltz_url, - ) - } - - #[no_mangle] - pub extern "C" fn wire_new_lbtc_ln_reverse__static_method__Api( - port_: i64, - mnemonic: *mut wire_uint_8_list, - index: u64, - out_amount: u64, - network: i32, - electrum_url: *mut wire_uint_8_list, - boltz_url: *mut wire_uint_8_list, - ) { - wire_new_lbtc_ln_reverse__static_method__Api_impl( - port_, - mnemonic, - index, - out_amount, - network, - electrum_url, - boltz_url, - ) - } - - #[no_mangle] - pub extern "C" fn wire_lbtc_ln_tx_size__static_method__Api( - port_: i64, - swap: *mut wire_LbtcLnSwap, - ) { - wire_lbtc_ln_tx_size__static_method__Api_impl(port_, swap) - } - - #[no_mangle] - pub extern "C" fn wire_lbtc_ln_reverse_claim__static_method__Api( - port_: i64, - swap: *mut wire_LbtcLnSwap, - out_address: *mut wire_uint_8_list, - abs_fee: u64, - ) { - wire_lbtc_ln_reverse_claim__static_method__Api_impl(port_, swap, out_address, abs_fee) - } - - #[no_mangle] - pub extern "C" fn wire_swap_status__static_method__Api( - port_: i64, - boltz_url: *mut wire_uint_8_list, - id: *mut wire_uint_8_list, - ) { - wire_swap_status__static_method__Api_impl(port_, boltz_url, id) - } - - // Section: allocate functions - - #[no_mangle] - pub extern "C" fn new_box_autoadd_btc_ln_swap_0() -> *mut wire_BtcLnSwap { - support::new_leak_box_ptr(wire_BtcLnSwap::new_with_null_ptr()) - } - - #[no_mangle] - pub extern "C" fn new_box_autoadd_lbtc_ln_swap_0() -> *mut wire_LbtcLnSwap { - support::new_leak_box_ptr(wire_LbtcLnSwap::new_with_null_ptr()) - } - - #[no_mangle] - pub extern "C" fn new_uint_8_list_0(len: i32) -> *mut wire_uint_8_list { - let ans = wire_uint_8_list { - ptr: support::new_leak_vec_ptr(Default::default(), len), - len, - }; - support::new_leak_box_ptr(ans) - } - - // Section: related functions - - // Section: impl Wire2Api - - impl Wire2Api for *mut wire_uint_8_list { - fn wire2api(self) -> String { - let vec: Vec = self.wire2api(); - String::from_utf8_lossy(&vec).into_owned() - } - } - impl Wire2Api for *mut wire_BtcLnSwap { - fn wire2api(self) -> BtcLnSwap { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - Wire2Api::::wire2api(*wrap).into() - } - } - impl Wire2Api for *mut wire_LbtcLnSwap { - fn wire2api(self) -> LbtcLnSwap { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - Wire2Api::::wire2api(*wrap).into() - } - } - impl Wire2Api for wire_BtcLnSwap { - fn wire2api(self) -> BtcLnSwap { - BtcLnSwap { - id: self.id.wire2api(), - kind: self.kind.wire2api(), - network: self.network.wire2api(), - keys: self.keys.wire2api(), - preimage: self.preimage.wire2api(), - redeem_script: self.redeem_script.wire2api(), - invoice: self.invoice.wire2api(), - script_address: self.script_address.wire2api(), - out_amount: self.out_amount.wire2api(), - electrum_url: self.electrum_url.wire2api(), - boltz_url: self.boltz_url.wire2api(), - } - } - } - - impl Wire2Api for wire_KeyPair { - fn wire2api(self) -> KeyPair { - KeyPair { - secret_key: self.secret_key.wire2api(), - public_key: self.public_key.wire2api(), - } - } - } - impl Wire2Api for wire_LbtcLnSwap { - fn wire2api(self) -> LbtcLnSwap { - LbtcLnSwap { - id: self.id.wire2api(), - kind: self.kind.wire2api(), - network: self.network.wire2api(), - keys: self.keys.wire2api(), - preimage: self.preimage.wire2api(), - redeem_script: self.redeem_script.wire2api(), - invoice: self.invoice.wire2api(), - out_amount: self.out_amount.wire2api(), - script_address: self.script_address.wire2api(), - blinding_key: self.blinding_key.wire2api(), - electrum_url: self.electrum_url.wire2api(), - boltz_url: self.boltz_url.wire2api(), - } - } - } - impl Wire2Api for wire_PreImage { - fn wire2api(self) -> PreImage { - PreImage { - value: self.value.wire2api(), - sha256: self.sha256.wire2api(), - hash160: self.hash160.wire2api(), - } - } - } - - impl Wire2Api> for *mut wire_uint_8_list { - fn wire2api(self) -> Vec { - unsafe { - let wrap = support::box_from_leak_ptr(self); - support::vec_from_leak_ptr(wrap.ptr, wrap.len) - } - } - } - // Section: wire structs - - #[repr(C)] - #[derive(Clone)] - pub struct wire_BtcLnSwap { - id: *mut wire_uint_8_list, - kind: i32, - network: i32, - keys: wire_KeyPair, - preimage: wire_PreImage, - redeem_script: *mut wire_uint_8_list, - invoice: *mut wire_uint_8_list, - script_address: *mut wire_uint_8_list, - out_amount: u64, - electrum_url: *mut wire_uint_8_list, - boltz_url: *mut wire_uint_8_list, - } - - #[repr(C)] - #[derive(Clone)] - pub struct wire_KeyPair { - secret_key: *mut wire_uint_8_list, - public_key: *mut wire_uint_8_list, - } - - #[repr(C)] - #[derive(Clone)] - pub struct wire_LbtcLnSwap { - id: *mut wire_uint_8_list, - kind: i32, - network: i32, - keys: wire_KeyPair, - preimage: wire_PreImage, - redeem_script: *mut wire_uint_8_list, - invoice: *mut wire_uint_8_list, - out_amount: u64, - script_address: *mut wire_uint_8_list, - blinding_key: *mut wire_uint_8_list, - electrum_url: *mut wire_uint_8_list, - boltz_url: *mut wire_uint_8_list, - } - - #[repr(C)] - #[derive(Clone)] - pub struct wire_PreImage { - value: *mut wire_uint_8_list, - sha256: *mut wire_uint_8_list, - hash160: *mut wire_uint_8_list, - } - - #[repr(C)] - #[derive(Clone)] - pub struct wire_uint_8_list { - ptr: *mut u8, - len: i32, - } - - // Section: impl NewWithNullPtr - - pub trait NewWithNullPtr { - fn new_with_null_ptr() -> Self; - } - - impl NewWithNullPtr for *mut T { - fn new_with_null_ptr() -> Self { - std::ptr::null_mut() - } - } - - impl NewWithNullPtr for wire_BtcLnSwap { - fn new_with_null_ptr() -> Self { - Self { - id: core::ptr::null_mut(), - kind: Default::default(), - network: Default::default(), - keys: Default::default(), - preimage: Default::default(), - redeem_script: core::ptr::null_mut(), - invoice: core::ptr::null_mut(), - script_address: core::ptr::null_mut(), - out_amount: Default::default(), - electrum_url: core::ptr::null_mut(), - boltz_url: core::ptr::null_mut(), - } - } - } - - impl Default for wire_BtcLnSwap { - fn default() -> Self { - Self::new_with_null_ptr() - } - } - - impl NewWithNullPtr for wire_KeyPair { - fn new_with_null_ptr() -> Self { - Self { - secret_key: core::ptr::null_mut(), - public_key: core::ptr::null_mut(), - } - } - } - - impl Default for wire_KeyPair { - fn default() -> Self { - Self::new_with_null_ptr() - } - } - - impl NewWithNullPtr for wire_LbtcLnSwap { - fn new_with_null_ptr() -> Self { - Self { - id: core::ptr::null_mut(), - kind: Default::default(), - network: Default::default(), - keys: Default::default(), - preimage: Default::default(), - redeem_script: core::ptr::null_mut(), - invoice: core::ptr::null_mut(), - out_amount: Default::default(), - script_address: core::ptr::null_mut(), - blinding_key: core::ptr::null_mut(), - electrum_url: core::ptr::null_mut(), - boltz_url: core::ptr::null_mut(), - } - } - } - - impl Default for wire_LbtcLnSwap { - fn default() -> Self { - Self::new_with_null_ptr() - } - } - - impl NewWithNullPtr for wire_PreImage { - fn new_with_null_ptr() -> Self { - Self { - value: core::ptr::null_mut(), - sha256: core::ptr::null_mut(), - hash160: core::ptr::null_mut(), - } - } - } - - impl Default for wire_PreImage { - fn default() -> Self { - Self::new_with_null_ptr() - } - } - - // Section: sync execution mode utility - - #[no_mangle] - pub extern "C" fn free_WireSyncReturn(ptr: support::WireSyncReturn) { - unsafe { - let _ = support::box_from_leak_ptr(ptr); - }; - } -} +#[path = "bridge_generated.io.rs"] +mod io; #[cfg(not(target_family = "wasm"))] pub use self::io::*;