Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ members = [
]

[workspace.dependencies]
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "70d4bf8e36057c58e02d56769a6e9760f701dd06" }
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "8f78baa6b7979b9bea56501ad75b5a7b7150a711" }

tokio-metrics = "0.5"

Expand Down
36 changes: 23 additions & 13 deletions packages/rs-platform-wallet-ffi/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use key_wallet::bip32::DerivationPath;
use key_wallet::bip32::ExtendedPubKey;
use key_wallet::derivation_bls_bip32::ExtendedBLSPubKey;
use key_wallet::derivation_slip10::ExtendedEd25519PubKey;
use key_wallet::managed_account::address_pool::{AddressPool, AddressPoolType, PublicKeyType};
use key_wallet::managed_account::address_pool::{
AddressPool, AddressPoolType, AddressState, PublicKeyType,
};
use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface;
use key_wallet::wallet::managed_wallet_info::ManagedWalletInfo;
use key_wallet::wallet::Wallet;
Expand Down Expand Up @@ -3125,7 +3127,8 @@ fn build_core_address_entry_ffi(
key_type_tag,
pool_type_tag,
address_index: info.index,
is_used: info.used,
// key-wallet #818: `used` bool -> `state` enum (Used == funded).
is_used: matches!(info.state, AddressState::Used),
balance: info.balance,
address_base58: address_ptr,
derivation_path: path_ptr,
Expand Down Expand Up @@ -3221,9 +3224,17 @@ unsafe fn address_info_from_ffi(
public_key,
index: entry.address_index,
path,
used: entry.is_used,
generated_at: 0,
used_at: if entry.is_used { Some(0) } else { None },
// key-wallet #818: the flat `used`/`generated_at`/`used_at` fields
// became the `state` enum. The FFI entry only carries `is_used`, so
// it round-trips to `Used`/`Available` (platform never hands out the
// `Reserved` state across FFI). The synthetic `generated_at: 0` /
// `used_at` values had no clock backing and have no equivalent on the
// new variants, so they are dropped without loss.
state: if entry.is_used {
AddressState::Used
} else {
AddressState::Available
},
tx_count: 0,
total_received: 0,
total_sent: 0,
Expand Down Expand Up @@ -3270,7 +3281,8 @@ fn restore_address_pool(pool: &mut AddressPool, infos: Vec<AddressInfo>) {
pool.script_pubkey_index
.insert(info.script_pubkey.clone(), idx);
pool.highest_generated = Some(pool.highest_generated.map_or(idx, |h| h.max(idx)));
if info.used {
// key-wallet #818: `used` bool -> `state` enum (Used == funded).
if matches!(info.state, AddressState::Used) {
pool.used_indices.insert(idx);
pool.highest_used = Some(pool.highest_used.map_or(idx, |h| h.max(idx)));
}
Expand Down Expand Up @@ -6248,9 +6260,8 @@ mod tests {
index,
path: DerivationPath::from_str(&format!("m/9'/1'/2'/{}", index))
.expect("static derivation path must parse"),
used: false,
generated_at: 0,
used_at: None,
// key-wallet #818: `used`/`generated_at`/`used_at` -> `state` enum.
state: AddressState::Available,
tx_count: 0,
total_received: 0,
total_sent: 0,
Expand Down Expand Up @@ -7072,9 +7083,8 @@ mod tests {
public_key: Some(PublicKeyType::ECDSA(TEST_PUBKEY_G.to_vec())),
index,
path,
used: true,
generated_at: 0,
used_at: None,
// key-wallet #818: `used`/`generated_at`/`used_at` -> `state`.
state: AddressState::Used,
tx_count: 0,
total_received: 0,
total_sent: 0,
Expand Down Expand Up @@ -7124,7 +7134,7 @@ mod tests {
entries
.iter()
.flat_map(|e| e.addresses.iter())
.all(|a| a.used),
.all(|a| matches!(a.state, AddressState::Used)),
"every emitted marked-used address must carry used == true"
);
}
Expand Down
12 changes: 8 additions & 4 deletions packages/rs-platform-wallet/src/changeset/changeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ mod tests {
index: u32,
) -> key_wallet::transaction_checking::DerivedAddressInfo {
use key_wallet::bip32::{ChildNumber, DerivationPath};
use key_wallet::managed_account::address_pool::{AddressInfo, PublicKeyType};
use key_wallet::managed_account::address_pool::{AddressInfo, AddressState, PublicKeyType};

let pubkey =
dashcore::PublicKey::from_slice(&TEST_PUBKEY_G).expect("generator point is valid");
Expand All @@ -2177,9 +2177,13 @@ mod tests {
public_key: Some(PublicKeyType::ECDSA(TEST_PUBKEY_G.to_vec())),
index,
path,
used: true,
generated_at: 0,
used_at: None,
// key-wallet #818 replaced the flat `used`/`generated_at`/
// `used_at` fields with the `state` enum. This stub models a
// used address, so `used: true` maps to `AddressState::Used`.
// The new `Used` variant carries no timestamp, so the former
// `generated_at`/`used_at` values have no equivalent and are
// dropped (they were write-only in this test stub).
state: AddressState::Used,
tx_count: 0,
total_received: 0,
total_sent: 0,
Expand Down
11 changes: 7 additions & 4 deletions packages/rs-platform-wallet/src/changeset/core_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use std::sync::Arc;
use dashcore::blockdata::transaction::{txout::TxOut, OutPoint};
use dashcore::ScriptBuf;
use key_wallet::account::AccountType;
use key_wallet::managed_account::address_pool::{AddressPool, AddressPoolType};
use key_wallet::managed_account::address_pool::{AddressPool, AddressPoolType, AddressState};
use key_wallet::managed_account::transaction_record::{OutputRole, TransactionRecord};
use key_wallet::transaction_checking::transaction_router::AccountTypeToCheck;
use key_wallet::transaction_checking::{DerivedAddressInfo, TransactionContext};
Expand Down Expand Up @@ -565,7 +565,10 @@ fn collect_usage_deltas_from_accounts(
touched.insert(*owner_type);
if seen.insert((*owner_type, pool.pool_type, pool_info.index)) {
let mut info = pool_info.clone();
info.used = true;
// key-wallet #818: the flat `used` bool became the
// `state` enum. Marking the address used is now
// `AddressState::Used`.
info.state = AddressState::Used;
marked_used.push(DerivedAddressInfo {
account_type: *owner_type,
pool_type: pool.pool_type,
Expand Down Expand Up @@ -836,7 +839,7 @@ mod usage_delta_tests {
assert_eq!(entry.account_type, bip44_account_0());
assert_eq!(entry.pool_type, AddressPoolType::External);
assert_eq!(entry.info.index, 0);
assert!(entry.info.used);
assert!(matches!(entry.info.state, AddressState::Used));

let watermarks = highest
.get(&bip44_account_0())
Expand Down Expand Up @@ -902,7 +905,7 @@ mod usage_delta_tests {
.find(|d| d.info.address == receive_address)
.expect("spent-input address must be in the marked-used delta");
assert_eq!(entry.pool_type, AddressPoolType::External);
assert!(entry.info.used);
assert!(matches!(entry.info.state, AddressState::Used));
// The foreign output must NOT resolve to any pool.
assert!(
marked.iter().all(|d| d.info.address != {
Expand Down
Loading
Loading