Skip to content

Commit 6630a92

Browse files
fix(key-wallet): resolve semantic conflicts from merging #672 and #674
PR #674 dropped the add_to_state/bool second arg from next_unused, next_unused_with_info, next_receive_address, and next_change_address. PR #672's new IdentityAuthenticationBls arms and an asset_lock_builder caller still passed the old signatures. PR #672 added AccountType::IdentityAuthenticationEcdsa/Bls variants. Three match statements in ManagedAccountCollection (contains_account_type, get_by_account_type, get_by_account_type_mut) predated those variants and needed arms routing to the existing identity_authentication_ecdsa / _bls BTreeMaps by identity_index. Also update two FFI mark_address_used callsites to destructure the (bool, WalletChangeSet) tuple that #674 returns. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 98a8b8b commit 6630a92

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

key-wallet-ffi/src/address_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,15 +799,15 @@ pub unsafe extern "C" fn managed_wallet_mark_address_used(
799799
}
800800
if !found {
801801
for account in collection.identity_authentication_ecdsa.values_mut() {
802-
if account.mark_address_used(&address) {
802+
if account.mark_address_used(&address).0 {
803803
found = true;
804804
break;
805805
}
806806
}
807807
}
808808
if !found {
809809
for account in collection.identity_authentication_bls.values_mut() {
810-
if account.mark_address_used(&address) {
810+
if account.mark_address_used(&address).0 {
811811
found = true;
812812
break;
813813
}

key-wallet/src/managed_account/managed_account_collection.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,12 @@ impl ManagedAccountCollection {
10271027
account,
10281028
key_class,
10291029
}),
1030+
AccountType::IdentityAuthenticationEcdsa {
1031+
identity_index,
1032+
} => self.identity_authentication_ecdsa.contains_key(&identity_index),
1033+
AccountType::IdentityAuthenticationBls {
1034+
identity_index,
1035+
} => self.identity_authentication_bls.contains_key(&identity_index),
10301036
}
10311037
}
10321038

@@ -1086,6 +1092,12 @@ impl ManagedAccountCollection {
10861092
AccountType::PlatformPayment {
10871093
..
10881094
} => None,
1095+
AccountType::IdentityAuthenticationEcdsa {
1096+
identity_index,
1097+
} => self.identity_authentication_ecdsa.get(&identity_index),
1098+
AccountType::IdentityAuthenticationBls {
1099+
identity_index,
1100+
} => self.identity_authentication_bls.get(&identity_index),
10891101
}
10901102
}
10911103

@@ -1148,6 +1160,12 @@ impl ManagedAccountCollection {
11481160
AccountType::PlatformPayment {
11491161
..
11501162
} => None,
1163+
AccountType::IdentityAuthenticationEcdsa {
1164+
identity_index,
1165+
} => self.identity_authentication_ecdsa.get_mut(&identity_index),
1166+
AccountType::IdentityAuthenticationBls {
1167+
identity_index,
1168+
} => self.identity_authentication_bls.get_mut(&identity_index),
11511169
}
11521170
}
11531171

key-wallet/src/managed_account/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,14 +1051,14 @@ impl ManagedCoreAccount {
10511051
// (similar to `next_bls_operator_key` for ProviderOperatorKeys).
10521052
// Here we only allow progression when the pool already has a
10531053
// pre-derived address cached (NoKeySource).
1054-
addresses.next_unused(&address_pool::KeySource::NoKeySource, add_to_state).map_err(
1055-
|e| match e {
1054+
addresses.next_unused(&address_pool::KeySource::NoKeySource).map_err(|e| {
1055+
match e {
10561056
crate::error::Error::NoKeySource => {
10571057
"No unused addresses available and no key source provided"
10581058
}
10591059
_ => "Failed to generate address",
1060-
},
1061-
)
1060+
}
1061+
})
10621062
}
10631063
ManagedAccountType::IdentityTopUp {
10641064
addresses,
@@ -1174,10 +1174,7 @@ impl ManagedCoreAccount {
11741174
// Here we only allow progression when the pool already has a
11751175
// pre-derived address cached (NoKeySource).
11761176
addresses
1177-
.next_unused_with_info(
1178-
&address_pool::KeySource::NoKeySource,
1179-
add_to_state,
1180-
)
1177+
.next_unused_with_info(&address_pool::KeySource::NoKeySource)
11811178
.map_err(|e| match e {
11821179
crate::error::Error::NoKeySource => {
11831180
"No unused addresses available and no key source provided"
@@ -1343,7 +1340,7 @@ impl ManagedCoreAccount {
13431340
let pool = pools.first_mut().ok_or("Account has no address pool")?;
13441341

13451342
let info = pool
1346-
.next_unused_with_info(&address_pool::KeySource::NoKeySource, false)
1343+
.next_unused_with_info(&address_pool::KeySource::NoKeySource)
13471344
.map_err(|_| "No unused address available")?;
13481345

13491346
Ok((info.path, info.index))

key-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl ManagedWalletInfo {
370370
.accounts
371371
.standard_bip44_accounts
372372
.get_mut(&account_index)
373-
.and_then(|account| account.next_change_address(xpub.as_ref(), true).ok())
373+
.and_then(|account| account.next_change_address(xpub.as_ref()).ok())
374374
.ok_or(AssetLockError::NoChangeAddress)?;
375375

376376
let synced_height = self.synced_height();
@@ -764,7 +764,7 @@ mod tests {
764764
.standard_bip44_accounts
765765
.get_mut(&0)
766766
.unwrap()
767-
.next_receive_address(Some(&account_xpub), true)
767+
.next_receive_address(Some(&account_xpub))
768768
.unwrap();
769769

770770
let utxo = Utxo {

0 commit comments

Comments
 (0)