Add extract_paired_addresses
This commit is contained in:
parent
afc40b4395
commit
2d226392dc
@ -9,10 +9,19 @@ use sp_client::bitcoin::{OutPoint, Transaction};
|
||||
use tsify::Tsify;
|
||||
|
||||
use crate::{
|
||||
pcd::{Member, Pcd, PcdCommitments, RoleDefinition, Roles}, serialization::{deserialize_hex, hex_array_btree, serialize_hex, OutPointMemberMap}, signature::{AnkHash, AnkValidationNoHash, AnkValidationYesHash, Proof}, MutexExt, SpecialRoles
|
||||
pcd::{Member, Pcd, PcdCommitments, RoleDefinition, Roles}, serialization::{deserialize_hex, hex_array_btree, serialize_hex, OutPointMemberMap}, signature::{AnkHash, AnkValidationNoHash, AnkValidationYesHash, Proof}, MutexExt, SpecialRoles, APOPHIS, PAIREDADDRESSES, PAIRING
|
||||
};
|
||||
|
||||
const OBLITERATION_MSG: [u8; 32] = [167, 164, 238, 168, 233, 235, 152, 107, 194, 162, 145, 42, 140, 11, 244, 71, 252, 67, 204, 207, 114, 85, 209, 80, 129, 190, 151, 172, 77, 174, 243, 1];
|
||||
fn extract_paired_addresses(paired_addresses: &Value) -> anyhow::Result<Vec<SilentPaymentAddress>> {
|
||||
let array = paired_addresses.as_array().ok_or(anyhow::Error::msg("pairedAddresses is not an array"))?;
|
||||
let sp_array: anyhow::Result<Vec<SilentPaymentAddress>> = array.into_iter().map(|value| {
|
||||
let str = value.as_str().ok_or(anyhow::Error::msg("array contains a non string value"))?;
|
||||
let sp_address = SilentPaymentAddress::try_from(str)?;
|
||||
Ok(sp_address)
|
||||
})
|
||||
.collect();
|
||||
sp_array
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, Tsify)]
|
||||
#[tsify(into_wasm_abi, from_wasm_abi)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user