diff --git a/ios/Classes/frb_generated.h b/ios/Classes/frb_generated.h index 4b9b2aa..ffd8533 100644 --- a/ios/Classes/frb_generated.h +++ b/ios/Classes/frb_generated.h @@ -155,7 +155,7 @@ typedef struct wire_cst_ffi_request_context { } wire_cst_ffi_request_context; typedef struct wire_cst_ffi_pj_uri_builder { - uintptr_t field0; + uintptr_t internal; } wire_cst_ffi_pj_uri_builder; typedef struct wire_cst_ffi_uri { @@ -298,19 +298,16 @@ void frbgen_payjoin_flutter_wire__crate__api__io__fetch_ohttp_keys(int64_t port_ void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_extract_req(int64_t port_, struct wire_cst_ffi_active_session *ptr); -void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_uri_builder(int64_t port_, - struct wire_cst_ffi_active_session *ptr); +WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_uri_builder(struct wire_cst_ffi_active_session *ptr); -void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url(int64_t port_, - struct wire_cst_ffi_active_session *ptr); +WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url(struct wire_cst_ffi_active_session *ptr); void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_process_res(int64_t port_, struct wire_cst_ffi_active_session *that, struct wire_cst_list_prim_u_8_loose *body, struct wire_cst_ffi_client_response *ctx); -void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_public_key(int64_t port_, - struct wire_cst_ffi_active_session *that); +WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_public_key(struct wire_cst_ffi_active_session *that); void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_maybe_inputs_owned_check_inputs_not_owned(int64_t port_, struct wire_cst_ffi_maybe_inputs_owned *ptr, @@ -367,7 +364,7 @@ void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_session_initializer_e void frbgen_payjoin_flutter_wire__crate__api__receive__ffi_session_initializer_new(int64_t port_, struct wire_cst_list_prim_u_8_strict *address, - uint64_t expire_after, + uint64_t *expire_after, int32_t network, struct wire_cst_ffi_url *directory, struct wire_cst_ffi_ohttp_keys *ohttp_keys, @@ -521,16 +518,18 @@ WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_bu WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_build(struct wire_cst_ffi_pj_uri_builder *that); +void frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_create(int64_t port_, + struct wire_cst_list_prim_u_8_strict *address, + struct wire_cst_ffi_url *pj, + struct wire_cst_ffi_ohttp_keys *ohttp_keys, + uint64_t *expiry); + WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_label(struct wire_cst_ffi_pj_uri_builder *that, struct wire_cst_list_prim_u_8_strict *label); WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_message(struct wire_cst_ffi_pj_uri_builder *that, struct wire_cst_list_prim_u_8_strict *message); -WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_new(struct wire_cst_list_prim_u_8_strict *address, - struct wire_cst_ffi_url *pj, - struct wire_cst_ffi_ohttp_keys *ohttp_keys); - WireSyncRust2DartDco frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_pjos(struct wire_cst_ffi_pj_uri_builder *that, bool pjos); @@ -884,9 +883,9 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_as_string); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_amount); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_build); + dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_create); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_label); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_message); - dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_new); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_pjos); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_address); dummy_var ^= ((int64_t) (void*) frbgen_payjoin_flutter_wire__crate__api__uri__ffi_uri_amount); diff --git a/lib/receive/v2.dart b/lib/receive/v2.dart index 5829f08..f7f7472 100644 --- a/lib/receive/v2.dart +++ b/lib/receive/v2.dart @@ -6,7 +6,6 @@ import '../common.dart'; import '../src/exceptions.dart'; import '../src/generated/api/receive.dart'; import '../src/generated/utils/error.dart' as error; -import '../uri.dart' as uri; import '../uri.dart'; class SessionInitializer extends FfiSessionInitializer { @@ -47,7 +46,7 @@ class SessionInitializer extends FfiSessionInitializer { try { final res = await FfiSessionInitializer.extractReq(ptr: this); final request = - Request(await uri.Url.fromString(res.$1.$1.query()!), res.$1.$2); + Request(await Url.fromString(res.$1.$1.query()!), res.$1.$2); return (request, ClientResponse._(field0: res.$2.field0)); } on error.PayjoinError catch (e) { throw mapPayjoinError(e); @@ -61,7 +60,7 @@ class ActiveSession extends FfiActiveSession { try { final res = await FfiActiveSession.extractReq(ptr: this); final request = - Request(await uri.Url.fromString(res.$1.$1.query()!), res.$1.$2); + Request(await Url.fromString(res.$1.$1.query()!), res.$1.$2); return (request, ClientResponse._(field0: res.$2.field0)); } on error.PayjoinError catch (e) { throw mapPayjoinError(e); @@ -81,15 +80,18 @@ class ActiveSession extends FfiActiveSession { throw mapPayjoinError(e); } } - // - // @override - // Future fallbackTarget({dynamic hint}) { - // try { - // return super.fallbackTarget(); - // } on error.PayjoinError catch (e) { - // throw mapPayjoinError(e); - // } - // } + + /// The contents of the `&pj=` query parameter including the base64url-encoded public key receiver subdirectory. + /// This identifies a session at the payjoin directory server. + Future pjUrl() { + final res = FfiActiveSession.pjUrl(ptr: super); + return Url.fromString(res.asString()); + } + + PjUriBuilder pjUriBuilder() { + final res = FfiActiveSession.pjUriBuilder(ptr: super); + return PjUriBuilder(internal: res.internal); + } } class UncheckedProposal extends FfiV2UncheckedProposal { @@ -295,7 +297,7 @@ class PayjoinProposal extends FfiV2PayjoinProposal { try { final res = await FfiV2PayjoinProposal.extractV2Req(ptr: this); final request = - Request(await uri.Url.fromString(res.$1.$1.toString()), res.$1.$2); + Request(await Url.fromString(res.$1.$1.toString()), res.$1.$2); return (request, ClientResponse._(field0: res.$2.field0)); } on error.PayjoinError catch (e) { throw mapPayjoinError(e); diff --git a/lib/src/generated/api/receive.dart b/lib/src/generated/api/receive.dart index 3cedfb9..90cc2f3 100644 --- a/lib/src/generated/api/receive.dart +++ b/lib/src/generated/api/receive.dart @@ -24,11 +24,10 @@ class FfiActiveSession { {required FfiActiveSession ptr}) => core.instance.api.crateApiReceiveFfiActiveSessionExtractReq(ptr: ptr); - static Future pjUriBuilder( - {required FfiActiveSession ptr}) => + static FfiPjUriBuilder pjUriBuilder({required FfiActiveSession ptr}) => core.instance.api.crateApiReceiveFfiActiveSessionPjUriBuilder(ptr: ptr); - static Future pjUrl({required FfiActiveSession ptr}) => + static FfiUrl pjUrl({required FfiActiveSession ptr}) => core.instance.api.crateApiReceiveFfiActiveSessionPjUrl(ptr: ptr); Future processRes( @@ -36,7 +35,8 @@ class FfiActiveSession { core.instance.api.crateApiReceiveFfiActiveSessionProcessRes( that: this, body: body, ctx: ctx); - Future publicKey() => + ///The per-session public key to use as an identifier + String publicKey() => core.instance.api.crateApiReceiveFfiActiveSessionPublicKey( that: this, ); @@ -271,7 +271,7 @@ class FfiSessionInitializer { // HINT: Make it `#[frb(sync)]` to let it become the default constructor of Dart class. static Future newInstance( {required String address, - required BigInt expireAfter, + BigInt? expireAfter, required Network network, required FfiUrl directory, required FfiOhttpKeys ohttpKeys, diff --git a/lib/src/generated/api/uri.dart b/lib/src/generated/api/uri.dart index b9db22b..9d8f767 100644 --- a/lib/src/generated/api/uri.dart +++ b/lib/src/generated/api/uri.dart @@ -63,12 +63,13 @@ class FfiPjUri { } class FfiPjUriBuilder { - final PjUriBuilder field0; + final PjUriBuilder internal; - const FfiPjUriBuilder.raw({ - required this.field0, + const FfiPjUriBuilder({ + required this.internal, }); + ///Accepts the amount you want to receive in sats and sets it in btc. FfiPjUriBuilder amount({required BigInt amount}) => core.instance.api .crateApiUriFfiPjUriBuilderAmount(that: this, amount: amount); @@ -77,6 +78,14 @@ class FfiPjUriBuilder { that: this, ); + static Future create( + {required String address, + required FfiUrl pj, + FfiOhttpKeys? ohttpKeys, + BigInt? expiry}) => + core.instance.api.crateApiUriFfiPjUriBuilderCreate( + address: address, pj: pj, ohttpKeys: ohttpKeys, expiry: expiry); + ///Set the label. FfiPjUriBuilder label({required String label}) => core.instance.api .crateApiUriFfiPjUriBuilderLabel(that: this, label: label); @@ -85,25 +94,19 @@ class FfiPjUriBuilder { FfiPjUriBuilder message({required String message}) => core.instance.api .crateApiUriFfiPjUriBuilderMessage(that: this, message: message); - factory FfiPjUriBuilder( - {required String address, - required FfiUrl pj, - FfiOhttpKeys? ohttpKeys}) => - core.instance.api.crateApiUriFfiPjUriBuilderNew( - address: address, pj: pj, ohttpKeys: ohttpKeys); - + ///Set whether payjoin output substitution is allowed. FfiPjUriBuilder pjos({required bool pjos}) => core.instance.api.crateApiUriFfiPjUriBuilderPjos(that: this, pjos: pjos); @override - int get hashCode => field0.hashCode; + int get hashCode => internal.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is FfiPjUriBuilder && runtimeType == other.runtimeType && - field0 == other.field0; + internal == other.internal; } class FfiUri { diff --git a/lib/src/generated/frb_generated.dart b/lib/src/generated/frb_generated.dart index 323a286..0ce72f7 100644 --- a/lib/src/generated/frb_generated.dart +++ b/lib/src/generated/frb_generated.dart @@ -61,7 +61,7 @@ class core extends BaseEntrypoint { String get codegenVersion => '2.0.0'; @override - int get rustContentHash => 1145331695; + int get rustContentHash => -1575278373; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -81,18 +81,17 @@ abstract class coreApi extends BaseApi { crateApiReceiveFfiActiveSessionExtractReq( {required FfiActiveSession ptr}); - Future crateApiReceiveFfiActiveSessionPjUriBuilder( + FfiPjUriBuilder crateApiReceiveFfiActiveSessionPjUriBuilder( {required FfiActiveSession ptr}); - Future crateApiReceiveFfiActiveSessionPjUrl( - {required FfiActiveSession ptr}); + FfiUrl crateApiReceiveFfiActiveSessionPjUrl({required FfiActiveSession ptr}); Future crateApiReceiveFfiActiveSessionProcessRes( {required FfiActiveSession that, required List body, required FfiClientResponse ctx}); - Future crateApiReceiveFfiActiveSessionPublicKey( + String crateApiReceiveFfiActiveSessionPublicKey( {required FfiActiveSession that}); Future @@ -156,7 +155,7 @@ abstract class coreApi extends BaseApi { Future crateApiReceiveFfiSessionInitializerNew( {required String address, - required BigInt expireAfter, + BigInt? expireAfter, required Network network, required FfiUrl directory, required FfiOhttpKeys ohttpKeys, @@ -318,15 +317,18 @@ abstract class coreApi extends BaseApi { FfiPjUri crateApiUriFfiPjUriBuilderBuild({required FfiPjUriBuilder that}); + Future crateApiUriFfiPjUriBuilderCreate( + {required String address, + required FfiUrl pj, + FfiOhttpKeys? ohttpKeys, + BigInt? expiry}); + FfiPjUriBuilder crateApiUriFfiPjUriBuilderLabel( {required FfiPjUriBuilder that, required String label}); FfiPjUriBuilder crateApiUriFfiPjUriBuilderMessage( {required FfiPjUriBuilder that, required String message}); - FfiPjUriBuilder crateApiUriFfiPjUriBuilderNew( - {required String address, required FfiUrl pj, FfiOhttpKeys? ohttpKeys}); - FfiPjUriBuilder crateApiUriFfiPjUriBuilderPjos( {required FfiPjUriBuilder that, required bool pjos}); @@ -632,14 +634,13 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { ); @override - Future crateApiReceiveFfiActiveSessionPjUriBuilder( + FfiPjUriBuilder crateApiReceiveFfiActiveSessionPjUriBuilder( {required FfiActiveSession ptr}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { + return handler.executeSync(SyncTask( + callFfi: () { var arg0 = cst_encode_box_autoadd_ffi_active_session(ptr); return wire - .wire__crate__api__receive__ffi_active_session_pj_uri_builder( - port_, arg0); + .wire__crate__api__receive__ffi_active_session_pj_uri_builder(arg0); }, codec: DcoCodec( decodeSuccessData: dco_decode_ffi_pj_uri_builder, @@ -658,13 +659,11 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { ); @override - Future crateApiReceiveFfiActiveSessionPjUrl( - {required FfiActiveSession ptr}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { + FfiUrl crateApiReceiveFfiActiveSessionPjUrl({required FfiActiveSession ptr}) { + return handler.executeSync(SyncTask( + callFfi: () { var arg0 = cst_encode_box_autoadd_ffi_active_session(ptr); - return wire.wire__crate__api__receive__ffi_active_session_pj_url( - port_, arg0); + return wire.wire__crate__api__receive__ffi_active_session_pj_url(arg0); }, codec: DcoCodec( decodeSuccessData: dco_decode_ffi_url, @@ -713,13 +712,13 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { ); @override - Future crateApiReceiveFfiActiveSessionPublicKey( + String crateApiReceiveFfiActiveSessionPublicKey( {required FfiActiveSession that}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { + return handler.executeSync(SyncTask( + callFfi: () { var arg0 = cst_encode_box_autoadd_ffi_active_session(that); - return wire.wire__crate__api__receive__ffi_active_session_public_key( - port_, arg0); + return wire + .wire__crate__api__receive__ffi_active_session_public_key(arg0); }, codec: DcoCodec( decodeSuccessData: dco_decode_String, @@ -1164,7 +1163,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { @override Future crateApiReceiveFfiSessionInitializerNew( {required String address, - required BigInt expireAfter, + BigInt? expireAfter, required Network network, required FfiUrl directory, required FfiOhttpKeys ohttpKeys, @@ -1172,7 +1171,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { return handler.executeNormal(NormalTask( callFfi: (port_) { var arg0 = cst_encode_String(address); - var arg1 = cst_encode_u_64(expireAfter); + var arg1 = cst_encode_opt_box_autoadd_u_64(expireAfter); var arg2 = cst_encode_network(network); var arg3 = cst_encode_box_autoadd_ffi_url(directory); var arg4 = cst_encode_box_autoadd_ffi_ohttp_keys(ohttpKeys); @@ -2375,6 +2374,37 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { argNames: ["that"], ); + @override + Future crateApiUriFfiPjUriBuilderCreate( + {required String address, + required FfiUrl pj, + FfiOhttpKeys? ohttpKeys, + BigInt? expiry}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + var arg0 = cst_encode_String(address); + var arg1 = cst_encode_box_autoadd_ffi_url(pj); + var arg2 = cst_encode_opt_box_autoadd_ffi_ohttp_keys(ohttpKeys); + var arg3 = cst_encode_opt_box_autoadd_u_64(expiry); + return wire.wire__crate__api__uri__ffi_pj_uri_builder_create( + port_, arg0, arg1, arg2, arg3); + }, + codec: DcoCodec( + decodeSuccessData: dco_decode_ffi_pj_uri_builder, + decodeErrorData: dco_decode_payjoin_error, + ), + constMeta: kCrateApiUriFfiPjUriBuilderCreateConstMeta, + argValues: [address, pj, ohttpKeys, expiry], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiUriFfiPjUriBuilderCreateConstMeta => + const TaskConstMeta( + debugName: "ffi_pj_uri_builder_create", + argNames: ["address", "pj", "ohttpKeys", "expiry"], + ); + @override FfiPjUriBuilder crateApiUriFfiPjUriBuilderLabel( {required FfiPjUriBuilder that, required String label}) { @@ -2426,33 +2456,6 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { argNames: ["that", "message"], ); - @override - FfiPjUriBuilder crateApiUriFfiPjUriBuilderNew( - {required String address, required FfiUrl pj, FfiOhttpKeys? ohttpKeys}) { - return handler.executeSync(SyncTask( - callFfi: () { - var arg0 = cst_encode_String(address); - var arg1 = cst_encode_box_autoadd_ffi_url(pj); - var arg2 = cst_encode_opt_box_autoadd_ffi_ohttp_keys(ohttpKeys); - return wire.wire__crate__api__uri__ffi_pj_uri_builder_new( - arg0, arg1, arg2); - }, - codec: DcoCodec( - decodeSuccessData: dco_decode_ffi_pj_uri_builder, - decodeErrorData: dco_decode_payjoin_error, - ), - constMeta: kCrateApiUriFfiPjUriBuilderNewConstMeta, - argValues: [address, pj, ohttpKeys], - apiImpl: this, - )); - } - - TaskConstMeta get kCrateApiUriFfiPjUriBuilderNewConstMeta => - const TaskConstMeta( - debugName: "ffi_pj_uri_builder_new", - argNames: ["address", "pj", "ohttpKeys"], - ); - @override FfiPjUriBuilder crateApiUriFfiPjUriBuilderPjos( {required FfiPjUriBuilder that, required bool pjos}) { @@ -3590,8 +3593,8 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { final arr = raw as List; if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return FfiPjUriBuilder.raw( - field0: dco_decode_RustOpaque_payjoin_ffiuriPjUriBuilder(arr[0]), + return FfiPjUriBuilder( + internal: dco_decode_RustOpaque_payjoin_ffiuriPjUriBuilder(arr[0]), ); } @@ -4655,9 +4658,9 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { @protected FfiPjUriBuilder sse_decode_ffi_pj_uri_builder(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs - var var_field0 = + var var_internal = sse_decode_RustOpaque_payjoin_ffiuriPjUriBuilder(deserializer); - return FfiPjUriBuilder.raw(field0: var_field0); + return FfiPjUriBuilder(internal: var_internal); } @protected @@ -6013,7 +6016,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { void sse_encode_ffi_pj_uri_builder( FfiPjUriBuilder self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_RustOpaque_payjoin_ffiuriPjUriBuilder(self.field0, serializer); + sse_encode_RustOpaque_payjoin_ffiuriPjUriBuilder(self.internal, serializer); } @protected diff --git a/lib/src/generated/frb_generated.io.dart b/lib/src/generated/frb_generated.io.dart index b5dd5ad..853e2bf 100644 --- a/lib/src/generated/frb_generated.io.dart +++ b/lib/src/generated/frb_generated.io.dart @@ -1698,8 +1698,8 @@ abstract class coreApiImplPlatform extends BaseApiImpl { @protected void cst_api_fill_to_wire_ffi_pj_uri_builder( FfiPjUriBuilder apiObj, wire_cst_ffi_pj_uri_builder wireObj) { - wireObj.field0 = - cst_encode_RustOpaque_payjoin_ffiuriPjUriBuilder(apiObj.field0); + wireObj.internal = + cst_encode_RustOpaque_payjoin_ffiuriPjUriBuilder(apiObj.internal); } @protected @@ -2684,12 +2684,11 @@ class coreWire implements BaseWire { _wire__crate__api__receive__ffi_active_session_extract_reqPtr.asFunction< void Function(int, ffi.Pointer)>(); - void wire__crate__api__receive__ffi_active_session_pj_uri_builder( - int port_, + WireSyncRust2DartDco + wire__crate__api__receive__ffi_active_session_pj_uri_builder( ffi.Pointer ptr, ) { return _wire__crate__api__receive__ffi_active_session_pj_uri_builder( - port_, ptr, ); } @@ -2697,32 +2696,32 @@ class coreWire implements BaseWire { late final _wire__crate__api__receive__ffi_active_session_pj_uri_builderPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( + WireSyncRust2DartDco Function( + ffi.Pointer)>>( 'frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_uri_builder'); late final _wire__crate__api__receive__ffi_active_session_pj_uri_builder = _wire__crate__api__receive__ffi_active_session_pj_uri_builderPtr .asFunction< - void Function(int, ffi.Pointer)>(); + WireSyncRust2DartDco Function( + ffi.Pointer)>(); - void wire__crate__api__receive__ffi_active_session_pj_url( - int port_, + WireSyncRust2DartDco wire__crate__api__receive__ffi_active_session_pj_url( ffi.Pointer ptr, ) { return _wire__crate__api__receive__ffi_active_session_pj_url( - port_, ptr, ); } late final _wire__crate__api__receive__ffi_active_session_pj_urlPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( + WireSyncRust2DartDco Function( + ffi.Pointer)>>( 'frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url'); late final _wire__crate__api__receive__ffi_active_session_pj_url = _wire__crate__api__receive__ffi_active_session_pj_urlPtr.asFunction< - void Function(int, ffi.Pointer)>(); + WireSyncRust2DartDco Function( + ffi.Pointer)>(); void wire__crate__api__receive__ffi_active_session_process_res( int port_, @@ -2755,24 +2754,23 @@ class coreWire implements BaseWire { ffi.Pointer, ffi.Pointer)>(); - void wire__crate__api__receive__ffi_active_session_public_key( - int port_, + WireSyncRust2DartDco wire__crate__api__receive__ffi_active_session_public_key( ffi.Pointer that, ) { return _wire__crate__api__receive__ffi_active_session_public_key( - port_, that, ); } late final _wire__crate__api__receive__ffi_active_session_public_keyPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>( + WireSyncRust2DartDco Function( + ffi.Pointer)>>( 'frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_public_key'); late final _wire__crate__api__receive__ffi_active_session_public_key = _wire__crate__api__receive__ffi_active_session_public_keyPtr.asFunction< - void Function(int, ffi.Pointer)>(); + WireSyncRust2DartDco Function( + ffi.Pointer)>(); void wire__crate__api__receive__ffi_maybe_inputs_owned_check_inputs_not_owned( int port_, @@ -3133,7 +3131,7 @@ class coreWire implements BaseWire { void wire__crate__api__receive__ffi_session_initializer_new( int port_, ffi.Pointer address, - int expire_after, + ffi.Pointer expire_after, int network, ffi.Pointer directory, ffi.Pointer ohttp_keys, @@ -3155,7 +3153,7 @@ class coreWire implements BaseWire { ffi.Void Function( ffi.Int64, ffi.Pointer, - ffi.Uint64, + ffi.Pointer, ffi.Int32, ffi.Pointer, ffi.Pointer, @@ -3166,7 +3164,7 @@ class coreWire implements BaseWire { void Function( int, ffi.Pointer, - int, + ffi.Pointer, int, ffi.Pointer, ffi.Pointer, @@ -4173,6 +4171,40 @@ class coreWire implements BaseWire { WireSyncRust2DartDco Function( ffi.Pointer)>(); + void wire__crate__api__uri__ffi_pj_uri_builder_create( + int port_, + ffi.Pointer address, + ffi.Pointer pj, + ffi.Pointer ohttp_keys, + ffi.Pointer expiry, + ) { + return _wire__crate__api__uri__ffi_pj_uri_builder_create( + port_, + address, + pj, + ohttp_keys, + expiry, + ); + } + + late final _wire__crate__api__uri__ffi_pj_uri_builder_createPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>( + 'frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_create'); + late final _wire__crate__api__uri__ffi_pj_uri_builder_create = + _wire__crate__api__uri__ffi_pj_uri_builder_createPtr.asFunction< + void Function( + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + WireSyncRust2DartDco wire__crate__api__uri__ffi_pj_uri_builder_label( ffi.Pointer that, ffi.Pointer label, @@ -4217,32 +4249,6 @@ class coreWire implements BaseWire { ffi.Pointer, ffi.Pointer)>(); - WireSyncRust2DartDco wire__crate__api__uri__ffi_pj_uri_builder_new( - ffi.Pointer address, - ffi.Pointer pj, - ffi.Pointer ohttp_keys, - ) { - return _wire__crate__api__uri__ffi_pj_uri_builder_new( - address, - pj, - ohttp_keys, - ); - } - - late final _wire__crate__api__uri__ffi_pj_uri_builder_newPtr = _lookup< - ffi.NativeFunction< - WireSyncRust2DartDco Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>( - 'frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_new'); - late final _wire__crate__api__uri__ffi_pj_uri_builder_new = - _wire__crate__api__uri__ffi_pj_uri_builder_newPtr.asFunction< - WireSyncRust2DartDco Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); - WireSyncRust2DartDco wire__crate__api__uri__ffi_pj_uri_builder_pjos( ffi.Pointer that, bool pjos, @@ -5905,7 +5911,7 @@ final class wire_cst_ffi_request_context extends ffi.Struct { final class wire_cst_ffi_pj_uri_builder extends ffi.Struct { @ffi.UintPtr() - external int field0; + external int internal; } final class wire_cst_ffi_uri extends ffi.Struct { diff --git a/lib/uri.dart b/lib/uri.dart index e666566..ea19416 100644 --- a/lib/uri.dart +++ b/lib/uri.dart @@ -5,6 +5,30 @@ import 'src/generated/api/io.dart' as io; import 'src/generated/api/uri.dart'; import 'src/generated/utils/error.dart' as error; +class PjUriBuilder extends FfiPjUriBuilder { + PjUriBuilder({required super.internal}); + + ///Create a new PjUriBuilder with required parameters. + /// Parameters + /// address: Represents a bitcoin address. + /// ohttpKeys: Optional OHTTP keys for v2. + /// expiry: Optional non-default duration_since epoch expiry for the `payjoin` session. + static Future create( + {required String address, + required FfiUrl pj, + FfiOhttpKeys? ohttpKeys, + BigInt? expiry}) async { + try { + await PConfig.initializeApp(); + final res = await FfiPjUriBuilder.create( + address: address, pj: pj, ohttpKeys: ohttpKeys, expiry: expiry); + return PjUriBuilder(internal: res.internal); + } on error.PayjoinError catch (e) { + throw mapPayjoinError(e); + } + } +} + class Uri extends FfiUri { Uri._({required super.field0}); @@ -132,7 +156,7 @@ class OhttpKeys extends FfiOhttpKeys { /// * `payjoinDirectory`: The payjoin directory from which to fetch the ohttp keys. This /// directory stores and forwards payjoin client payloads. /// -/// * `cert_der` (optional): The DER-encoded certificate to use for local HTTPS connections. This +/// * `certDer` (optional): The DER-encoded certificate to use for local HTTPS connections. This /// parameter is only available when the "danger-local-https" feature is enabled. Future fetchOhttpKeys( {required Url ohttpRelay, diff --git a/rust/Cargo.lock b/rust/Cargo.lock index ed3b27f..429c554 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1774,7 +1774,7 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "payjoin" version = "0.18.0" -source = "git+https://github.com/LtbLightning/rust-payjoin?branch=clone-pj-uri-builder#cd02a360127ecc080f46ee8ea961bc17000ccbca" +source = "git+https://github.com/LtbLightning/rust-payjoin?branch=clone-pj-uri-builder#3b5bda95fc8ce63f506538f0ff9daed885810488" dependencies = [ "bhttp", "bip21", @@ -1783,7 +1783,6 @@ dependencies = [ "http", "log", "ohttp", - "percent-encoding-rfc3986", "reqwest", "rustls 0.22.4", "serde", @@ -1794,7 +1793,7 @@ dependencies = [ [[package]] name = "payjoin_ffi" version = "0.18.0" -source = "git+https://github.com/LtbLightning/payjoin-ffi.git?branch=v0.18.0#e43ea781fda2a141eb3db8761503f1ea3bd5ecec" +source = "git+https://github.com/LtbLightning/payjoin-ffi?branch=upgrade-v18.0#610aed9239c6e1e28cc56118e9b94b5000ae6052" dependencies = [ "base64 0.22.1", "hex", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2f0b17e..05de0e5 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -12,7 +12,7 @@ bitcoincore-rpc = "0.19.0" anyhow = "1.0.68" [dependencies] ohttp = { version = "0.5.1" } -payjoin_ffi = {git = "https://github.com/LtbLightning/payjoin-ffi.git", branch="v0.18.0"} +payjoin_ffi = {git = "https://github.com/LtbLightning/payjoin-ffi", branch="upgrade-v18.0"} flutter_rust_bridge = "=2.0.0" anyhow = "1.0.68" tokio = "1.36.0" diff --git a/rust/src/api/io.rs b/rust/src/api/io.rs index ca5e16a..5461c5d 100644 --- a/rust/src/api/io.rs +++ b/rust/src/api/io.rs @@ -17,8 +17,12 @@ pub async fn fetch_ohttp_keys( payjoin_directory: FfiUrl, cert_der: Vec, ) -> Result { - payjoin_ffi::io::fetch_ohttp_keys((*ohttp_relay.0).clone(), (*payjoin_directory.0).clone(), cert_der) - .await - .map(|e| e.into()) - .map_err(|e| e.into()) -} \ No newline at end of file + payjoin_ffi::io::fetch_ohttp_keys( + (*ohttp_relay.0).clone(), + (*payjoin_directory.0).clone(), + cert_der, + ) + .await + .map(|e| e.into()) + .map_err(|e| e.into()) +} diff --git a/rust/src/api/mod.rs b/rust/src/api/mod.rs index 0f841a8..860a805 100644 --- a/rust/src/api/mod.rs +++ b/rust/src/api/mod.rs @@ -1,3 +1,4 @@ +pub mod io; pub mod receive; pub mod send; pub mod uri; diff --git a/rust/src/api/receive.rs b/rust/src/api/receive.rs index 9aec1d8..ca927d2 100644 --- a/rust/src/api/receive.rs +++ b/rust/src/api/receive.rs @@ -2,7 +2,7 @@ use crate::api::uri::{FfiOhttpKeys, FfiPjUriBuilder, FfiUrl}; use crate::frb_generated::RustOpaque; pub use crate::utils::error::PayjoinError; use crate::utils::types::{Headers, OutPoint, TxOut}; -use flutter_rust_bridge::DartFnFuture; +use flutter_rust_bridge::{frb, DartFnFuture}; use std::collections::HashMap; pub use std::sync::Arc; @@ -131,9 +131,7 @@ impl FfiOutputsUnknown { ) -> Result { let runtime = tokio::runtime::Runtime::new().unwrap(); ptr.0 - .identify_receiver_outputs(|o| { - Ok(runtime.block_on(is_receiver_output(o.clone()))) - }) + .identify_receiver_outputs(|o| Ok(runtime.block_on(is_receiver_output(o.clone())))) .map(|e| e.into()) .map_err(|e| e.into()) } @@ -146,12 +144,13 @@ impl From for FfiProvisionalPropo } } impl FfiProvisionalProposal { - pub fn try_substitute_receiver_output(&self, generate_script: impl Fn() -> DartFnFuture> ) -> Result<(), PayjoinError> { + pub fn try_substitute_receiver_output( + &self, + generate_script: impl Fn() -> DartFnFuture>, + ) -> Result<(), PayjoinError> { let runtime = tokio::runtime::Runtime::new().unwrap(); self.0 - .try_substitute_receiver_output(|| { - Ok(runtime.block_on(generate_script())) - }) + .try_substitute_receiver_output(|| Ok(runtime.block_on(generate_script()))) .map_err(|e| e.into()) } pub fn contribute_witness_input( @@ -240,7 +239,9 @@ impl FfiPayjoinProposal { self.0.psbt() } } -pub struct FfiClientResponse(pub RustOpaque>>); +pub struct FfiClientResponse( + pub RustOpaque>>, +); impl From for ohttp::ClientResponse { fn from(value: FfiClientResponse) -> Self { @@ -265,7 +266,7 @@ impl From for FfiSessionInitialize impl FfiSessionInitializer { pub fn new( address: String, - expire_after: u64, + expire_after: Option, network: crate::utils::types::Network, directory: FfiUrl, ohttp_keys: FfiOhttpKeys, @@ -278,12 +279,10 @@ impl FfiSessionInitializer { Arc::new((*directory.0).clone()), (*ohttp_keys.0).clone().into(), Arc::new((*ohttp_relay.0).clone()), - )? - .into()) + .into()) } - pub fn extract_req(ptr: Self) -> Result<((FfiUrl, Vec), FfiClientResponse), PayjoinError> { ptr.0 .extract_req() @@ -305,17 +304,22 @@ impl FfiSessionInitializer { pub struct FfiActiveSession(pub RustOpaque); impl From for FfiActiveSession { - fn from(value:payjoin_ffi::receive::v2::ActiveSession) -> Self { + fn from(value: payjoin_ffi::receive::v2::ActiveSession) -> Self { Self(RustOpaque::new(value)) } } impl FfiActiveSession { + ///The per-session public key to use as an identifier + #[frb(sync)] pub fn public_key(&self) -> String { self.0.public_key() } + + #[frb(sync)] pub fn pj_url(ptr: Self) -> FfiUrl { ptr.0.pj_url().into() } + #[frb(sync)] pub fn pj_uri_builder(ptr: Self) -> FfiPjUriBuilder { ptr.0.pj_uri_builder().into() } @@ -375,7 +379,9 @@ impl FfiV2UncheckedProposal { /// So-called "non-interactive" receivers, like payment processors, that allow arbitrary requests are otherwise vulnerable to probing attacks. /// Those receivers call `extract_tx_to_check_broadcast()` and `attest_tested_and_scheduled_broadcast()` after making those checks downstream. pub fn assume_interactive_receiver(&self) -> FfiV2MaybeInputsOwned { - (*self.0.clone().assume_interactive_receiver()).clone().into() + (*self.0.clone().assume_interactive_receiver()) + .clone() + .into() } } #[derive(Clone)] @@ -462,9 +468,7 @@ impl FfiV2OutputsUnknown { ) -> Result { let runtime = tokio::runtime::Runtime::new().unwrap(); self.0 - .identify_receiver_outputs(|o| { - Ok(runtime.block_on(is_receiver_output(o.clone()))) - }) + .identify_receiver_outputs(|o| Ok(runtime.block_on(is_receiver_output(o.clone())))) .map(|e| e.into()) .map_err(|e| e.into()) } @@ -478,14 +482,16 @@ impl From for FfiV2ProvisionalP } } impl FfiV2ProvisionalProposal { - pub fn is_output_substitution_disabled(&self) -> bool { self.0.is_output_substitution_disabled() } - pub fn try_substitute_receiver_output(&self, generate_script: impl Fn() -> DartFnFuture>) -> Result<(), PayjoinError> { + pub fn try_substitute_receiver_output( + &self, + generate_script: impl Fn() -> DartFnFuture>, + ) -> Result<(), PayjoinError> { let runtime = tokio::runtime::Runtime::new().unwrap(); self.0 - .try_substitute_receiver_output(|| Ok(runtime.block_on(generate_script())),) + .try_substitute_receiver_output(|| Ok(runtime.block_on(generate_script()))) .map_err(|e| e.into()) } pub fn contribute_witness_input( @@ -566,7 +572,9 @@ impl FfiV2PayjoinProposal { pub fn extract_v1_req(&self) -> String { self.0.extract_v1_req() } - pub fn extract_v2_req(ptr: Self) -> Result<((FfiUrl, Vec), FfiClientResponse), PayjoinError> { + pub fn extract_v2_req( + ptr: Self, + ) -> Result<((FfiUrl, Vec), FfiClientResponse), PayjoinError> { ptr.0 .clone() .extract_v2_req() @@ -579,7 +587,8 @@ impl FfiV2PayjoinProposal { res: Vec, ohttp_context: FfiClientResponse, ) -> Result<(), PayjoinError> { - self.0.process_res(res, ohttp_context.into()) + self.0 + .process_res(res, ohttp_context.into()) .map_err(|e| e.into()) } } diff --git a/rust/src/api/send.rs b/rust/src/api/send.rs index a3b041a..cea7ca2 100644 --- a/rust/src/api/send.rs +++ b/rust/src/api/send.rs @@ -1,5 +1,5 @@ use crate::api::uri::{FfiPjUri, FfiUrl}; -use crate::{ frb_generated::RustOpaque}; +use crate::frb_generated::RustOpaque; use std::sync::Arc; use super::receive::PayjoinError; @@ -25,9 +25,8 @@ impl FfiRequestBuilder { } } pub fn always_disable_output_substitution(&self, disable: bool) -> FfiRequestBuilder { - (*self.0 + (*self.0.clone().always_disable_output_substitution(disable)) .clone() - .always_disable_output_substitution(disable)).clone() .into() } pub fn build_recommended( @@ -52,11 +51,14 @@ impl FfiRequestBuilder { min_fee_rate, clamp_fee_contribution, ) { - Ok(e) =>Ok((*e).clone().into()), + Ok(e) => Ok((*e).clone().into()), Err(e) => Err(e.into()), } } - pub fn build_non_incentivizing(&self, min_fee_rate: u64) -> anyhow::Result { + pub fn build_non_incentivizing( + &self, + min_fee_rate: u64, + ) -> anyhow::Result { match self.0.clone().build_non_incentivizing(min_fee_rate) { Ok(e) => Ok((*e).clone().into()), Err(e) => Err(e.into()), @@ -115,7 +117,7 @@ impl From for RequestContextV1 { fn from(value: payjoin_ffi::send::v1::RequestContextV1) -> Self { Self { request: ((*value.request.url).clone().into(), value.request.body), - context_v1:(*value.context_v1).clone().into(), + context_v1: (*value.context_v1).clone().into(), } } } @@ -140,7 +142,6 @@ impl From for FfiContextV1 { } } - impl FfiContextV1 { pub fn process_response(&self, response: Vec) -> anyhow::Result { match self.0.process_response(response) { diff --git a/rust/src/api/uri.rs b/rust/src/api/uri.rs index df27eed..b6ed300 100644 --- a/rust/src/api/uri.rs +++ b/rust/src/api/uri.rs @@ -2,7 +2,7 @@ use crate::frb_generated::RustOpaque; use crate::utils::error::PayjoinError; use flutter_rust_bridge::frb; -#[derive( Debug, Clone)] +#[derive(Debug, Clone)] pub struct FfiUrl(pub RustOpaque); impl From for FfiUrl { fn from(value: payjoin_ffi::uri::Url) -> Self { @@ -25,13 +25,11 @@ impl FfiUrl { pub fn as_string(&self) -> String { self.0.as_string() } - } #[derive(Clone)] pub struct FfiPjUri(pub RustOpaque); - impl From for FfiPjUri { fn from(value: payjoin_ffi::uri::PjUri) -> Self { Self(RustOpaque::new(value)) @@ -55,53 +53,59 @@ impl FfiPjUri { } #[derive(Clone)] -pub struct FfiPjUriBuilder(pub RustOpaque); +pub struct FfiPjUriBuilder { + pub internal: RustOpaque, +} impl From for FfiPjUriBuilder { fn from(value: payjoin_ffi::uri::PjUriBuilder) -> Self { - Self(RustOpaque::new(value)) + Self { + internal: RustOpaque::new(value), + } } } impl FfiPjUriBuilder { - #[frb(sync)] - pub fn new( + pub fn create( address: String, pj: FfiUrl, ohttp_keys: Option, + expiry: Option, ) -> Result { payjoin_ffi::uri::PjUriBuilder::new( address, (*pj.0).clone(), - ohttp_keys.map(|e| (*e.0).clone().into())) - .map_err(|e| e.into()) - .map(|e| e.into()) + ohttp_keys.map(|e| (*e.0).clone().into()), + expiry, + ) + .map_err(|e| e.into()) + .map(|e| e.into()) } + ///Accepts the amount you want to receive in sats and sets it in btc. #[frb(sync)] - pub fn amount(&self, amount: u64) -> Self { - self.0.amount(amount).into() + pub fn amount(&self, amount: u64) -> Self { + self.internal.amount(amount).into() } #[frb(sync)] /// Set the message. - pub fn message(&self, message: String) -> Self { - self.0.message(message).into() + pub fn message(&self, message: String) -> Self { + self.internal.message(message).into() } #[frb(sync)] ///Set the label. - pub fn label(&self, label: String)-> Self { - self.0.label(label).into() + pub fn label(&self, label: String) -> Self { + self.internal.label(label).into() } - + ///Set whether payjoin output substitution is allowed. #[frb(sync)] - pub fn pjos(&self, pjos: bool) -> Self{ - self.0.pjos(pjos).into() + pub fn pjos(&self, pjos: bool) -> Self { + self.internal.pjos(pjos).into() } #[frb(sync)] ///Constructs a Uri with PayjoinParams from the parameters set in the builder. pub fn build(&self) -> FfiPjUri { - self.0.build().into() + self.internal.build().into() } - } #[derive(Clone)] @@ -135,27 +139,30 @@ impl FfiUri { } #[frb(sync)] pub fn check_pj_supported(&self) -> Result { - self.0.check_pj_supported() + self.0 + .check_pj_supported() .map(|e| e.into()) .map_err(|e| e.into()) } } pub struct FfiOhttpKeys(pub RustOpaque); -impl From for payjoin_ffi::types::OhttpKeys{ +impl From for payjoin_ffi::types::OhttpKeys { fn from(value: FfiOhttpKeys) -> Self { (*value.0).clone() } } -impl From for FfiOhttpKeys { - fn from(value:payjoin_ffi::types:: OhttpKeys) -> Self { - Self(RustOpaque::new(value)) +impl From for FfiOhttpKeys { + fn from(value: payjoin_ffi::types::OhttpKeys) -> Self { + Self(RustOpaque::new(value)) } } impl FfiOhttpKeys { pub fn decode(bytes: Vec) -> Result { - payjoin_ffi::types::OhttpKeys::decode(bytes).map(|e| e.into()).map_err(|e| e.into()) + payjoin_ffi::types::OhttpKeys::decode(bytes) + .map(|e| e.into()) + .map_err(|e| e.into()) } } #[cfg(test)] @@ -177,7 +184,7 @@ mod tests { FfiUrl::from_str(pj.to_string()).unwrap(), None, ) - .unwrap(); + .unwrap(); let uri = builder .amount(1) .message("message".to_string()) diff --git a/rust/src/frb_generated.io.rs b/rust/src/frb_generated.io.rs index ac46ad9..b6d026a 100644 --- a/rust/src/frb_generated.io.rs +++ b/rust/src/frb_generated.io.rs @@ -524,7 +524,9 @@ impl CstDecode for wire_cst_ffi_pj_uri { impl CstDecode for wire_cst_ffi_pj_uri_builder { // Codec=Cst (C-struct based), see doc to use other codecs fn cst_decode(self) -> crate::api::uri::FfiPjUriBuilder { - crate::api::uri::FfiPjUriBuilder(self.field0.cst_decode()) + crate::api::uri::FfiPjUriBuilder { + internal: self.internal.cst_decode(), + } } } impl CstDecode for wire_cst_ffi_provisional_proposal { @@ -1007,7 +1009,7 @@ impl Default for wire_cst_ffi_pj_uri { impl NewWithNullPtr for wire_cst_ffi_pj_uri_builder { fn new_with_null_ptr() -> Self { Self { - field0: Default::default(), + internal: Default::default(), } } } @@ -1334,18 +1336,16 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_s #[no_mangle] pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_uri_builder( - port_: i64, ptr: *mut wire_cst_ffi_active_session, -) { - wire__crate__api__receive__ffi_active_session_pj_uri_builder_impl(port_, ptr) +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire__crate__api__receive__ffi_active_session_pj_uri_builder_impl(ptr) } #[no_mangle] pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_pj_url( - port_: i64, ptr: *mut wire_cst_ffi_active_session, -) { - wire__crate__api__receive__ffi_active_session_pj_url_impl(port_, ptr) +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire__crate__api__receive__ffi_active_session_pj_url_impl(ptr) } #[no_mangle] @@ -1360,10 +1360,9 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_s #[no_mangle] pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_active_session_public_key( - port_: i64, that: *mut wire_cst_ffi_active_session, -) { - wire__crate__api__receive__ffi_active_session_public_key_impl(port_, that) +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + wire__crate__api__receive__ffi_active_session_public_key_impl(that) } #[no_mangle] @@ -1522,7 +1521,7 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_session_ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__receive__ffi_session_initializer_new( port_: i64, address: *mut wire_cst_list_prim_u_8_strict, - expire_after: u64, + expire_after: *mut u64, network: i32, directory: *mut wire_cst_ffi_url, ohttp_keys: *mut wire_cst_ffi_ohttp_keys, @@ -1952,6 +1951,17 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_build wire__crate__api__uri__ffi_pj_uri_builder_build_impl(that) } +#[no_mangle] +pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_create( + port_: i64, + address: *mut wire_cst_list_prim_u_8_strict, + pj: *mut wire_cst_ffi_url, + ohttp_keys: *mut wire_cst_ffi_ohttp_keys, + expiry: *mut u64, +) { + wire__crate__api__uri__ffi_pj_uri_builder_create_impl(port_, address, pj, ohttp_keys, expiry) +} + #[no_mangle] pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_label( that: *mut wire_cst_ffi_pj_uri_builder, @@ -1968,15 +1978,6 @@ pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_build wire__crate__api__uri__ffi_pj_uri_builder_message_impl(that, message) } -#[no_mangle] -pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_new( - address: *mut wire_cst_list_prim_u_8_strict, - pj: *mut wire_cst_ffi_url, - ohttp_keys: *mut wire_cst_ffi_ohttp_keys, -) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { - wire__crate__api__uri__ffi_pj_uri_builder_new_impl(address, pj, ohttp_keys) -} - #[no_mangle] pub extern "C" fn frbgen_payjoin_flutter_wire__crate__api__uri__ffi_pj_uri_builder_pjos( that: *mut wire_cst_ffi_pj_uri_builder, @@ -2887,7 +2888,7 @@ pub struct wire_cst_ffi_pj_uri { #[repr(C)] #[derive(Clone, Copy)] pub struct wire_cst_ffi_pj_uri_builder { - field0: usize, + internal: usize, } #[repr(C)] #[derive(Clone, Copy)] diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index 77f28e5..fb2ab99 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -38,7 +38,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueNom, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1145331695; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1575278373; // Section: executor @@ -102,48 +102,41 @@ fn wire__crate__api__receive__ffi_active_session_extract_req_impl( ) } fn wire__crate__api__receive__ffi_active_session_pj_uri_builder_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, ptr: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( flutter_rust_bridge::for_generated::TaskInfo { debug_name: "ffi_active_session_pj_uri_builder", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, }, move || { let api_ptr = ptr.cst_decode(); - move |context| { - transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( - crate::api::receive::FfiActiveSession::pj_uri_builder(api_ptr), - )?; - Ok(output_ok) - })()) - } + transform_result_dco::<_, _, ()>((move || { + let output_ok = Result::<_, ()>::Ok( + crate::api::receive::FfiActiveSession::pj_uri_builder(api_ptr), + )?; + Ok(output_ok) + })()) }, ) } fn wire__crate__api__receive__ffi_active_session_pj_url_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, ptr: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( flutter_rust_bridge::for_generated::TaskInfo { debug_name: "ffi_active_session_pj_url", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, }, move || { let api_ptr = ptr.cst_decode(); - move |context| { - transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( - crate::api::receive::FfiActiveSession::pj_url(api_ptr), - )?; - Ok(output_ok) - })()) - } + transform_result_dco::<_, _, ()>((move || { + let output_ok = + Result::<_, ()>::Ok(crate::api::receive::FfiActiveSession::pj_url(api_ptr))?; + Ok(output_ok) + })()) }, ) } @@ -176,25 +169,22 @@ fn wire__crate__api__receive__ffi_active_session_process_res_impl( ) } fn wire__crate__api__receive__ffi_active_session_public_key_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, that: impl CstDecode, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( flutter_rust_bridge::for_generated::TaskInfo { debug_name: "ffi_active_session_public_key", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, }, move || { let api_that = that.cst_decode(); - move |context| { - transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( - crate::api::receive::FfiActiveSession::public_key(&api_that), - )?; - Ok(output_ok) - })()) - } + transform_result_dco::<_, _, ()>((move || { + let output_ok = Result::<_, ()>::Ok( + crate::api::receive::FfiActiveSession::public_key(&api_that), + )?; + Ok(output_ok) + })()) }, ) } @@ -552,7 +542,7 @@ fn wire__crate__api__receive__ffi_session_initializer_extract_req_impl( fn wire__crate__api__receive__ffi_session_initializer_new_impl( port_: flutter_rust_bridge::for_generated::MessagePort, address: impl CstDecode, - expire_after: impl CstDecode, + expire_after: impl CstDecode>, network: impl CstDecode, directory: impl CstDecode, ohttp_keys: impl CstDecode, @@ -1557,6 +1547,39 @@ fn wire__crate__api__uri__ffi_pj_uri_builder_build_impl( }, ) } +fn wire__crate__api__uri__ffi_pj_uri_builder_create_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + address: impl CstDecode, + pj: impl CstDecode, + ohttp_keys: impl CstDecode>, + expiry: impl CstDecode>, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "ffi_pj_uri_builder_create", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let api_address = address.cst_decode(); + let api_pj = pj.cst_decode(); + let api_ohttp_keys = ohttp_keys.cst_decode(); + let api_expiry = expiry.cst_decode(); + move |context| { + transform_result_dco::<_, _, crate::utils::error::PayjoinError>((move || { + let output_ok = crate::api::uri::FfiPjUriBuilder::create( + api_address, + api_pj, + api_ohttp_keys, + api_expiry, + )?; + Ok(output_ok) + })( + )) + } + }, + ) +} fn wire__crate__api__uri__ffi_pj_uri_builder_label_impl( that: impl CstDecode, label: impl CstDecode, @@ -1602,29 +1625,6 @@ fn wire__crate__api__uri__ffi_pj_uri_builder_message_impl( }, ) } -fn wire__crate__api__uri__ffi_pj_uri_builder_new_impl( - address: impl CstDecode, - pj: impl CstDecode, - ohttp_keys: impl CstDecode>, -) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( - flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "ffi_pj_uri_builder_new", - port: None, - mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, - }, - move || { - let api_address = address.cst_decode(); - let api_pj = pj.cst_decode(); - let api_ohttp_keys = ohttp_keys.cst_decode(); - transform_result_dco::<_, _, crate::utils::error::PayjoinError>((move || { - let output_ok = - crate::api::uri::FfiPjUriBuilder::new(api_address, api_pj, api_ohttp_keys)?; - Ok(output_ok) - })()) - }, - ) -} fn wire__crate__api__uri__ffi_pj_uri_builder_pjos_impl( that: impl CstDecode, pjos: impl CstDecode, @@ -2353,9 +2353,11 @@ impl SseDecode for crate::api::uri::FfiPjUri { impl SseDecode for crate::api::uri::FfiPjUriBuilder { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - let mut var_field0 = + let mut var_internal = >::sse_decode(deserializer); - return crate::api::uri::FfiPjUriBuilder(var_field0); + return crate::api::uri::FfiPjUriBuilder { + internal: var_internal, + }; } } @@ -3103,7 +3105,7 @@ impl flutter_rust_bridge::IntoIntoDart for crate::api // Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for crate::api::uri::FfiPjUriBuilder { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { - [self.0.into_into_dart().into_dart()].into_dart() + [self.internal.into_into_dart().into_dart()].into_dart() } } impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive @@ -3904,7 +3906,7 @@ impl SseEncode for crate::api::uri::FfiPjUri { impl SseEncode for crate::api::uri::FfiPjUriBuilder { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - >::sse_encode(self.0, serializer); + >::sse_encode(self.internal, serializer); } } diff --git a/rust/src/utils/types.rs b/rust/src/utils/types.rs index c3838ac..632c8dc 100644 --- a/rust/src/utils/types.rs +++ b/rust/src/utils/types.rs @@ -1,6 +1,6 @@ -use std::collections::HashMap; use flutter_rust_bridge::frb; pub use payjoin_ffi::types::Network; +use std::collections::HashMap; // ///Represents data that needs to be transmitted to the receiver. // ///You need to send this request over HTTP(S) to the receiver. // #[derive(Clone, Debug)] @@ -119,4 +119,4 @@ pub enum _Network { Bitcoin, ///Bitcoin’s signet Signet, -} \ No newline at end of file +}