[bug] take care of redundant local address when pairing
This commit is contained in:
parent
544c3256d6
commit
1d5869561a
16
src/api.rs
16
src/api.rs
@ -290,16 +290,18 @@ pub fn is_linking() -> ApiResult<bool> {
|
|||||||
pub fn pair_device(commitment_tx: String, mut sp_addresses: Vec<String>) -> ApiResult<()> {
|
pub fn pair_device(commitment_tx: String, mut sp_addresses: Vec<String>) -> ApiResult<()> {
|
||||||
let mut local_device = lock_local_device()?;
|
let mut local_device = lock_local_device()?;
|
||||||
|
|
||||||
if local_device.is_linked() {
|
if local_device.get_pairing_commitment().is_some() {
|
||||||
return Err(ApiError::new("Already paired".to_owned()));
|
return Err(ApiError::new("Already paired".to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sp_addresses.push(
|
let local_address = local_device
|
||||||
local_device
|
.get_wallet()
|
||||||
.get_wallet()
|
.get_client()
|
||||||
.get_client()
|
.get_receiving_address();
|
||||||
.get_receiving_address(),
|
|
||||||
);
|
if !sp_addresses.iter().any(|a| *a == local_address) {
|
||||||
|
sp_addresses.push(local_address);
|
||||||
|
}
|
||||||
|
|
||||||
local_device.pair(
|
local_device.pair(
|
||||||
OutPoint::from_str(&commitment_tx)?,
|
OutPoint::from_str(&commitment_tx)?,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user