Skip to content

Commit f302aeb

Browse files
authored
Merge pull request #99 from KeystoneHQ/update
Update
2 parents 33ca564 + 4a94264 commit f302aeb

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

URRegistryFFI.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = "URRegistryFFI"
3-
spec.version = "0.2.5"
3+
spec.version = "0.2.6"
44
spec.summary = "An BC-UR registry implementation with rust-lang"
55
spec.homepage = "https://github.com/KeystoneHQ/keystone-sdk-rust"
66
spec.license = { :type => 'Copyright', :text => 'Copyright 2023 Keystone' }
@@ -9,6 +9,6 @@ Pod::Spec.new do |spec|
99
spec.swift_version = "5.6"
1010
spec.platform = :ios, '13.0'
1111
spec.static_framework = true
12-
spec.source = { :http => "https://github.com/KeystoneHQ/keystone-sdk-rust/releases/download/sdk-0.1.8/URRegistryFFI.xcframework.zip", :type => "zip" }
12+
spec.source = { :http => "https://github.com/KeystoneHQ/keystone-sdk-rust/releases/download/sdk-0.2.0/URRegistryFFI.xcframework.zip", :type => "zip" }
1313
spec.ios.vendored_frameworks = 'URRegistryFFI.xcframework'
1414
end

libs/ur-registry-ffi/src/zcash/zcash_pczt.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use crate::export;
1+
use crate::{export, util_internal::string_helper::remove_prefix_0x};
2+
use anyhow::{format_err, Error};
23
use serde_json::json;
34
use ur_registry::{registry_types::ZCASH_PCZT, zcash::zcash_pczt::ZcashPczt};
45

56
export! {
6-
@Java_com_keystone_sdk_KeystoneNativeSDK_generateZcashPcZt
7+
@Java_com_keystone_sdk_KeystoneNativeSDK_generateZcashPczt
78
fn generate_zcash_pczt(
89
data: &str
910
) -> String {
@@ -31,4 +32,24 @@ export! {
3132
});
3233
ur.to_string()
3334
}
35+
36+
@Java_com_keystone_sdk_KeystoneNativeSDK_parseZcashPczt
37+
fn parse_zcash_pczt(ur_type: &str, cbor_hex: &str) -> String {
38+
if ZCASH_PCZT.get_type() != ur_type {
39+
return json!({"error": "type not match"}).to_string();
40+
}
41+
42+
let parse = || -> Result<String, Error> {
43+
let cbor = hex::decode(remove_prefix_0x(cbor_hex).to_string())?;
44+
let pczt = ZcashPczt::try_from(cbor).map_err(|_| format_err!(""))?;
45+
let pczt_hex = hex::encode(pczt.get_data());
46+
Ok(pczt_hex)
47+
};
48+
match parse() {
49+
Ok(v) => json!({
50+
"pczt": v,
51+
}).to_string(),
52+
Err(_) => json!({"error": "PCZT is invalid"}).to_string(),
53+
}
54+
}
3455
}

0 commit comments

Comments
 (0)