diff --git a/bindings/core/src/method/wallet.rs b/bindings/core/src/method/wallet.rs index ac153be111..517555dfe8 100644 --- a/bindings/core/src/method/wallet.rs +++ b/bindings/core/src/method/wallet.rs @@ -198,7 +198,7 @@ pub enum WalletMethod { PrepareImplicitAccountTransition { output_id: OutputId, #[serde(default)] - public_key: Option, + public_key: Option, #[serde(default)] bip_path: Option, }, diff --git a/bindings/core/src/method_handler/wallet.rs b/bindings/core/src/method_handler/wallet.rs index 41196e98bb..fd583f6725 100644 --- a/bindings/core/src/method_handler/wallet.rs +++ b/bindings/core/src/method_handler/wallet.rs @@ -3,6 +3,7 @@ use std::time::Duration; +use crypto::signatures::ed25519::PublicKey; use iota_sdk::{ client::api::{ PreparedTransactionData, PreparedTransactionDataDto, SignedTransactionData, SignedTransactionDataDto, @@ -215,9 +216,11 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM public_key, bip_path, } => { - let data = if public_key.is_some() { + let data = if let Some(public_key_str) = public_key { + let public_key = PublicKey::try_from_bytes(prefix_hex::decode(public_key_str)?) + .map_err(iota_sdk::wallet::Error::other)?; wallet - .prepare_implicit_account_transition(&output_id, public_key) + .prepare_implicit_account_transition(&output_id, Some(public_key)) .await? } else { wallet.prepare_implicit_account_transition(&output_id, bip_path).await? diff --git a/sdk/src/wallet/error.rs b/sdk/src/wallet/error.rs index 3e5eea5a01..a490e5a232 100644 --- a/sdk/src/wallet/error.rs +++ b/sdk/src/wallet/error.rs @@ -129,6 +129,12 @@ pub enum Error { ImplicitAccountNotFound, } +impl Error { + pub fn other(err: E) -> Self { + Self::Other(Box::new(err) as _) + } +} + // Serialize type with Display error impl Serialize for Error { fn serialize(&self, serializer: S) -> Result diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index dd926a6b33..5e0138dc42 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -66,7 +66,7 @@ where let public_key = match key_source { BlockIssuerKeySource::Key(public_key) => public_key, - BlockIssuerKeySource::Path(bip_path) => { + BlockIssuerKeySource::Bip44Path(bip_path) => { self.secret_manager .read() .await @@ -107,5 +107,5 @@ where #[derive(From)] pub enum BlockIssuerKeySource { Key(PublicKey), - Path(Bip44), + Bip44Path(Bip44), }