File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
libs/ur-registry-ffi/src/zcash Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 11Pod ::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'
1414end
Original file line number Diff line number Diff line change 1- use crate :: export;
1+ use crate :: { export, util_internal:: string_helper:: remove_prefix_0x} ;
2+ use anyhow:: { format_err, Error } ;
23use serde_json:: json;
34use ur_registry:: { registry_types:: ZCASH_PCZT , zcash:: zcash_pczt:: ZcashPczt } ;
45
56export ! {
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}
You can’t perform that action at this time.
0 commit comments