From 598b088fbb881d6079d2d038c08a197c32648675 Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Wed, 24 Jul 2024 12:55:57 -0700 Subject: [PATCH] route hint in keysend, asyncpay in keysend bindings, routehint in parse_invoice --- sphinx-ffi/Cargo.toml | 2 +- sphinx-ffi/src/auto.rs | 15 +++++++++++---- sphinx-ffi/src/sphinxrs.swift | 7 ++++--- sphinx-ffi/src/sphinxrs.udl | 2 +- sphinx-ffi/src/sphinxrsFFI.h | 2 +- sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt | 8 ++++---- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/sphinx-ffi/Cargo.toml b/sphinx-ffi/Cargo.toml index 2955764..291a16f 100644 --- a/sphinx-ffi/Cargo.toml +++ b/sphinx-ffi/Cargo.toml @@ -25,7 +25,7 @@ sphinx-signer = { path = "../signer", default-features = false, features = [ "no-native", ] } sphinx-glyph = { path = "../glyph", default-features = false } -sphinx = { git = "https://github.com/stakwork/sphinx", rev = "161a308b505a48a613d0d50107f1f1df72b5fbe8", features = [ +sphinx = { git = "https://github.com/stakwork/sphinx", rev = "6c0b5cc85d6ce3f5907ad6e48fbc47409efa3218", features = [ "msg", "bindings", "macaroon", diff --git a/sphinx-ffi/src/auto.rs b/sphinx-ffi/src/auto.rs index 94e3457..13970ae 100644 --- a/sphinx-ffi/src/auto.rs +++ b/sphinx-ffi/src/auto.rs @@ -290,12 +290,19 @@ pub fn keysend( full_state: Vec, amt_msat: u64, data: Option>, + route_hint: Option, ) -> Result { - Ok( - bindings::keysend(&seed, &unique_time, &to, &full_state, amt_msat, data) - .map_err(|e| SphinxError::SendFailed { r: e.to_string() })? - .into(), + Ok(bindings::keysend( + &seed, + &unique_time, + &to, + &full_state, + amt_msat, + data, + route_hint, ) + .map_err(|e| SphinxError::SendFailed { r: e.to_string() })? + .into()) } fn my_img_opt(my_img: &str) -> Option<&str> { diff --git a/sphinx-ffi/src/sphinxrs.swift b/sphinx-ffi/src/sphinxrs.swift index fe3fb8e..f6638fe 100644 --- a/sphinx-ffi/src/sphinxrs.swift +++ b/sphinx-ffi/src/sphinxrs.swift @@ -2177,7 +2177,7 @@ public func `send`(`seed`: String, `uniqueTime`: String, `to`: String, `msgType` ) } -public func `keysend`(`seed`: String, `uniqueTime`: String, `to`: String, `state`: Data, `amtMsat`: UInt64, `data`: Data?) throws -> RunReturn { +public func `keysend`(`seed`: String, `uniqueTime`: String, `to`: String, `state`: Data, `amtMsat`: UInt64, `data`: Data?, `routeHint`: String?) throws -> RunReturn { return try FfiConverterTypeRunReturn.lift( try rustCallWithError(FfiConverterTypeSphinxError.lift) { uniffi_sphinxrs_fn_func_keysend( @@ -2186,7 +2186,8 @@ public func `keysend`(`seed`: String, `uniqueTime`: String, `to`: String, `state FfiConverterString.lower(`to`), FfiConverterData.lower(`state`), FfiConverterUInt64.lower(`amtMsat`), - FfiConverterOptionData.lower(`data`),$0) + FfiConverterOptionData.lower(`data`), + FfiConverterOptionString.lower(`routeHint`),$0) } ) } @@ -2773,7 +2774,7 @@ private var initializationResult: InitializationResult { if (uniffi_sphinxrs_checksum_func_send() != 56750) { return InitializationResult.apiChecksumMismatch } - if (uniffi_sphinxrs_checksum_func_keysend() != 64232) { + if (uniffi_sphinxrs_checksum_func_keysend() != 58116) { return InitializationResult.apiChecksumMismatch } if (uniffi_sphinxrs_checksum_func_make_media_token() != 53931) { diff --git a/sphinx-ffi/src/sphinxrs.udl b/sphinx-ffi/src/sphinxrs.udl index 0394e5e..0ef9fc2 100644 --- a/sphinx-ffi/src/sphinxrs.udl +++ b/sphinx-ffi/src/sphinxrs.udl @@ -195,7 +195,7 @@ namespace sphinxrs { [Throws=SphinxError] RunReturn send(string seed, string unique_time, string to, u8 msg_type, string msg_json, bytes state, string my_alias, string my_img, u64 amt_msat, optional boolean is_tribe = false); [Throws=SphinxError] - RunReturn keysend(string seed, string unique_time, string to, bytes state, u64 amt_msat, bytes? data); + RunReturn keysend(string seed, string unique_time, string to, bytes state, u64 amt_msat, bytes? data, string? route_hint); [Throws=SphinxError] string make_media_token(string seed, string unique_time, bytes state, string host, string muid, string to, u32 expiry); [Throws=SphinxError] diff --git a/sphinx-ffi/src/sphinxrsFFI.h b/sphinx-ffi/src/sphinxrsFFI.h index a403757..894195a 100644 --- a/sphinx-ffi/src/sphinxrsFFI.h +++ b/sphinx-ffi/src/sphinxrsFFI.h @@ -149,7 +149,7 @@ RustBuffer uniffi_sphinxrs_fn_func_handle(RustBuffer topic, RustBuffer payload, ); RustBuffer uniffi_sphinxrs_fn_func_send(RustBuffer seed, RustBuffer unique_time, RustBuffer to, uint8_t msg_type, RustBuffer msg_json, RustBuffer state, RustBuffer my_alias, RustBuffer my_img, uint64_t amt_msat, int8_t is_tribe, RustCallStatus *_Nonnull out_status ); -RustBuffer uniffi_sphinxrs_fn_func_keysend(RustBuffer seed, RustBuffer unique_time, RustBuffer to, RustBuffer state, uint64_t amt_msat, RustBuffer data, RustCallStatus *_Nonnull out_status +RustBuffer uniffi_sphinxrs_fn_func_keysend(RustBuffer seed, RustBuffer unique_time, RustBuffer to, RustBuffer state, uint64_t amt_msat, RustBuffer data, RustBuffer route_hint, RustCallStatus *_Nonnull out_status ); RustBuffer uniffi_sphinxrs_fn_func_make_media_token(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustBuffer host, RustBuffer muid, RustBuffer to, uint32_t expiry, RustCallStatus *_Nonnull out_status ); diff --git a/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt b/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt index 4e3c622..8e01a0c 100644 --- a/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt +++ b/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt @@ -450,7 +450,7 @@ internal interface _UniFFILib : Library { ): RustBuffer.ByValue fun uniffi_sphinxrs_fn_func_send(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`to`: RustBuffer.ByValue,`msgType`: Byte,`msgJson`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`myAlias`: RustBuffer.ByValue,`myImg`: RustBuffer.ByValue,`amtMsat`: Long,`isTribe`: Byte,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue - fun uniffi_sphinxrs_fn_func_keysend(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`to`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`amtMsat`: Long,`data`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + fun uniffi_sphinxrs_fn_func_keysend(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`to`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`amtMsat`: Long,`data`: RustBuffer.ByValue,`routeHint`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue fun uniffi_sphinxrs_fn_func_make_media_token(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`host`: RustBuffer.ByValue,`muid`: RustBuffer.ByValue,`to`: RustBuffer.ByValue,`expiry`: Int,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue @@ -834,7 +834,7 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) { if (lib.uniffi_sphinxrs_checksum_func_send() != 56750.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_sphinxrs_checksum_func_keysend() != 64232.toShort()) { + if (lib.uniffi_sphinxrs_checksum_func_keysend() != 58116.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_sphinxrs_checksum_func_make_media_token() != 53931.toShort()) { @@ -2781,10 +2781,10 @@ fun `send`(`seed`: String, `uniqueTime`: String, `to`: String, `msgType`: UByte, @Throws(SphinxException::class) -fun `keysend`(`seed`: String, `uniqueTime`: String, `to`: String, `state`: ByteArray, `amtMsat`: ULong, `data`: ByteArray?): RunReturn { +fun `keysend`(`seed`: String, `uniqueTime`: String, `to`: String, `state`: ByteArray, `amtMsat`: ULong, `data`: ByteArray?, `routeHint`: String?): RunReturn { return FfiConverterTypeRunReturn.lift( rustCallWithError(SphinxException) { _status -> - _UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_keysend(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterString.lower(`to`),FfiConverterByteArray.lower(`state`),FfiConverterULong.lower(`amtMsat`),FfiConverterOptionalByteArray.lower(`data`),_status) + _UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_keysend(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterString.lower(`to`),FfiConverterByteArray.lower(`state`),FfiConverterULong.lower(`amtMsat`),FfiConverterOptionalByteArray.lower(`data`),FfiConverterOptionalString.lower(`routeHint`),_status) }) }