From f09d9891bc635ae48effae1b13de42204f8f4385 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Fri, 13 Nov 2026 10:30:56 +0100 Subject: [PATCH] feat(key-wallet): expose `masternode_collateral` and `holds_coin` A wallet store that locks collateral on its own, for masternodes it tracks outside the wallet's registrations, needs the same two answers the wallet uses: which outpoint a ProRegTx registers, and whether the wallet holds that coin. Without them it copies the logic and drifts: a copy that looks only at the UTXO set misses a coin the wallet keeps aside as spent. `masternode_collateral` is re-exported from `wallet::managed_wallet_info`, and `ManagedWalletInfo::holds_coin` becomes public. No behaviour changes. Co-Authored-By: Claude Fable 5.2 --- key-wallet/src/wallet/managed_wallet_info/locked_outpoints.rs | 4 ++-- key-wallet/src/wallet/managed_wallet_info/mod.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/key-wallet/src/wallet/managed_wallet_info/locked_outpoints.rs b/key-wallet/src/wallet/managed_wallet_info/locked_outpoints.rs index 66d35eba1..e9a697a8d 100644 --- a/key-wallet/src/wallet/managed_wallet_info/locked_outpoints.rs +++ b/key-wallet/src/wallet/managed_wallet_info/locked_outpoints.rs @@ -12,7 +12,7 @@ use std::collections::BTreeSet; /// A null collateral txid means the ProRegTx creates its collateral itself, as /// its own output at `collateralIndex`. An index past its outputs names no coin /// (Core rejects such a registration), so it yields `None`. -pub(crate) fn masternode_collateral(tx: &Transaction) -> Option { +pub fn masternode_collateral(tx: &Transaction) -> Option { let Some(TransactionPayload::ProviderRegistrationPayloadType(registration)) = &tx.special_transaction_payload else { @@ -144,7 +144,7 @@ impl ManagedWalletInfo { /// Whether a funds account of this wallet holds `outpoint` as a coin. A /// coin it keeps aside as spent counts: a fork that drops the spend gives /// it back. - pub(crate) fn holds_coin(&self, outpoint: &OutPoint) -> bool { + pub fn holds_coin(&self, outpoint: &OutPoint) -> bool { self.accounts .all_funding_accounts() .iter() diff --git a/key-wallet/src/wallet/managed_wallet_info/mod.rs b/key-wallet/src/wallet/managed_wallet_info/mod.rs index ceb443298..c0da74858 100644 --- a/key-wallet/src/wallet/managed_wallet_info/mod.rs +++ b/key-wallet/src/wallet/managed_wallet_info/mod.rs @@ -9,6 +9,7 @@ pub mod fee; pub mod helpers; pub use helpers::AbandonOutcome; pub(crate) mod locked_outpoints; +pub use locked_outpoints::masternode_collateral; pub mod managed_account_operations; pub mod managed_accounts; pub mod transaction_builder;