Add dump_neutered_device
This commit is contained in:
parent
f25c6f27de
commit
ea3fe8b863
22
src/api.rs
22
src/api.rs
@ -442,6 +442,28 @@ pub fn dump_device() -> ApiResult<String> {
|
||||
Ok(serde_json::to_string(&local_device.clone())?)
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn dump_neutered_device() -> ApiResult<Device> {
|
||||
let local_device = lock_local_device()?;
|
||||
|
||||
if local_device.get_pairing_commitment().is_none() {
|
||||
return Err(ApiError::new("Device must be paired".to_owned()));
|
||||
}
|
||||
|
||||
let client = local_device.get_wallet().get_client();
|
||||
let scan_key = client.get_scan_key();
|
||||
let spend_pubkey: PublicKey = client.get_spend_key().into();
|
||||
|
||||
let neutered_client = SpClient::new("default".to_owned(), scan_key, SpendKey::Public(spend_pubkey), None, Network::Signet)?;
|
||||
|
||||
let new_wallet = SpWallet::new(neutered_client, None, vec![])?;
|
||||
let mut neutered_device = Device::new(new_wallet);
|
||||
|
||||
neutered_device.pair(local_device.get_pairing_commitment().unwrap(), local_device.to_member());
|
||||
|
||||
Ok(neutered_device)
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn reset_device() -> ApiResult<()> {
|
||||
let mut device = lock_local_device()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user