mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-02-20 21:44:29 +01:00
Implement flutter bindings
This commit is contained in:
@@ -447,8 +447,8 @@ typedef struct wire_cst_config {
|
||||
} wire_cst_config;
|
||||
|
||||
typedef struct wire_cst_connect_request {
|
||||
struct wire_cst_list_prim_u_8_strict *mnemonic;
|
||||
struct wire_cst_config config;
|
||||
struct wire_cst_list_prim_u_8_strict *mnemonic;
|
||||
} wire_cst_connect_request;
|
||||
|
||||
typedef struct wire_cst_aes_success_action_data_decrypted {
|
||||
|
||||
@@ -320,10 +320,14 @@ enum LiquidNetwork {
|
||||
};
|
||||
|
||||
dictionary ConnectRequest {
|
||||
Config config;
|
||||
Config config;
|
||||
string mnemonic;
|
||||
};
|
||||
|
||||
dictionary ConnectWithSignerRequest {
|
||||
Config config;
|
||||
};
|
||||
|
||||
dictionary GetInfoResponse {
|
||||
u64 balance_sat;
|
||||
u64 pending_send_sat;
|
||||
@@ -601,6 +605,9 @@ namespace breez_sdk_liquid {
|
||||
[Throws=SdkError]
|
||||
BindingLiquidSdk connect(ConnectRequest req);
|
||||
|
||||
[Throws=SdkError]
|
||||
BindingLiquidSdk connect_with_signer(ConnectWithSignerRequest req, Signer signer);
|
||||
|
||||
[Throws=SdkError]
|
||||
void set_logger(Logger logger);
|
||||
|
||||
@@ -614,6 +621,31 @@ namespace breez_sdk_liquid {
|
||||
LNInvoice parse_invoice(string input);
|
||||
};
|
||||
|
||||
[Error]
|
||||
interface SignerError {
|
||||
Generic(string err);
|
||||
};
|
||||
|
||||
callback interface Signer {
|
||||
[Throws=SignerError]
|
||||
sequence<u8> xpub();
|
||||
|
||||
[Throws=SignerError]
|
||||
sequence<u8> derive_xpub(string derivation_path);
|
||||
|
||||
[Throws=SignerError]
|
||||
sequence<u8> sign_ecdsa(sequence<u8> msg, string derivation_path);
|
||||
|
||||
[Throws=SignerError]
|
||||
sequence<u8> sign_ecdsa_recoverable(sequence<u8> msg);
|
||||
|
||||
[Throws=SignerError]
|
||||
sequence<u8> slip77_master_blinding_key();
|
||||
|
||||
[Throws=SignerError]
|
||||
sequence<u8> hmac_sha256(sequence<u8> msg, string derivation_path);
|
||||
};
|
||||
|
||||
interface BindingLiquidSdk {
|
||||
[Throws=SdkError]
|
||||
string add_event_listener(EventListener listener);
|
||||
|
||||
@@ -54,6 +54,16 @@ pub fn connect(req: ConnectRequest) -> Result<Arc<BindingLiquidSdk>, SdkError> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn connect_with_signer(
|
||||
req: ConnectWithSignerRequest,
|
||||
signer: Box<dyn Signer>,
|
||||
) -> Result<Arc<BindingLiquidSdk>, SdkError> {
|
||||
rt().block_on(async {
|
||||
let sdk = LiquidSdk::connect_with_signer(req, signer).await?;
|
||||
Ok(Arc::from(BindingLiquidSdk { sdk }))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn default_config(
|
||||
network: LiquidNetwork,
|
||||
breez_api_key: Option<String>,
|
||||
|
||||
@@ -1666,8 +1666,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
|
||||
return ConnectRequest(
|
||||
mnemonic: dco_decode_String(arr[0]),
|
||||
config: dco_decode_config(arr[1]),
|
||||
config: dco_decode_config(arr[0]),
|
||||
mnemonic: dco_decode_String(arr[1]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3442,9 +3442,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
@protected
|
||||
ConnectRequest sse_decode_connect_request(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
var var_mnemonic = sse_decode_String(deserializer);
|
||||
var var_config = sse_decode_config(deserializer);
|
||||
return ConnectRequest(mnemonic: var_mnemonic, config: var_config);
|
||||
var var_mnemonic = sse_decode_String(deserializer);
|
||||
return ConnectRequest(config: var_config, mnemonic: var_mnemonic);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -5330,8 +5330,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
@protected
|
||||
void sse_encode_connect_request(ConnectRequest self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
sse_encode_String(self.mnemonic, serializer);
|
||||
sse_encode_config(self.config, serializer);
|
||||
sse_encode_String(self.mnemonic, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
|
||||
@@ -2003,8 +2003,8 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_connect_request(ConnectRequest apiObj, wire_cst_connect_request wireObj) {
|
||||
wireObj.mnemonic = cst_encode_String(apiObj.mnemonic);
|
||||
cst_api_fill_to_wire_config(apiObj.config, wireObj.config);
|
||||
wireObj.mnemonic = cst_encode_String(apiObj.mnemonic);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -5580,9 +5580,9 @@ final class wire_cst_config extends ffi.Struct {
|
||||
}
|
||||
|
||||
final class wire_cst_connect_request extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> mnemonic;
|
||||
|
||||
external wire_cst_config config;
|
||||
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> mnemonic;
|
||||
}
|
||||
|
||||
final class wire_cst_aes_success_action_data_decrypted extends ffi.Struct {
|
||||
|
||||
10
packages/dart/lib/src/lib.dart
Normal file
10
packages/dart/lib/src/lib.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
// This file is automatically generated, so please do not edit it.
|
||||
// @generated by `flutter_rust_bridge`@ 2.4.0.
|
||||
|
||||
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
|
||||
|
||||
import 'frb_generated.dart';
|
||||
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
||||
|
||||
// Rust type: RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<Arc < Box < dyn Signer > >>>
|
||||
abstract class ArcBoxSigner implements RustOpaqueInterface {}
|
||||
@@ -180,24 +180,24 @@ class Config {
|
||||
|
||||
/// An argument when calling [crate::sdk::LiquidSdk::connect].
|
||||
class ConnectRequest {
|
||||
final String mnemonic;
|
||||
final Config config;
|
||||
final String mnemonic;
|
||||
|
||||
const ConnectRequest({
|
||||
required this.mnemonic,
|
||||
required this.config,
|
||||
required this.mnemonic,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => mnemonic.hashCode ^ config.hashCode;
|
||||
int get hashCode => config.hashCode ^ mnemonic.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ConnectRequest &&
|
||||
runtimeType == other.runtimeType &&
|
||||
mnemonic == other.mnemonic &&
|
||||
config == other.config;
|
||||
config == other.config &&
|
||||
mnemonic == other.mnemonic;
|
||||
}
|
||||
|
||||
/// Returned when calling [crate::sdk::LiquidSdk::get_info].
|
||||
|
||||
@@ -4267,9 +4267,9 @@ final class wire_cst_config extends ffi.Struct {
|
||||
}
|
||||
|
||||
final class wire_cst_connect_request extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> mnemonic;
|
||||
|
||||
external wire_cst_config config;
|
||||
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> mnemonic;
|
||||
}
|
||||
|
||||
final class wire_cst_aes_success_action_data_decrypted extends ffi.Struct {
|
||||
|
||||
Reference in New Issue
Block a user