Skip to content

Commit 11d5062

Browse files
committed
Clean up balance structure
1 parent 0f2e4f7 commit 11d5062

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

node/src/wallets.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ pub enum AddressKind {
106106

107107
#[derive(Debug, Clone, Serialize, Deserialize)]
108108
pub struct Balance {
109+
pub balance: Amount,
110+
pub details: BalanceDetails,
111+
}
112+
113+
#[derive(Debug, Clone, Serialize, Deserialize)]
114+
pub struct BalanceDetails {
109115
#[serde(flatten)]
110116
pub balance: bdk_wallet::wallet::Balance,
111-
pub locked: Amount,
117+
pub dust: Amount,
112118
}
113119

114120
#[derive(Clone)]
@@ -144,13 +150,18 @@ impl RpcWallet {
144150
let unspent = Self::list_unspent(wallet, state)?;
145151
let balance = wallet.spaces.balance();
146152

147-
Ok(Balance {
153+
let details = BalanceDetails {
148154
balance,
149-
locked: unspent
155+
dust: unspent
150156
.into_iter()
151157
.filter(|output| output.is_spaceout)
152158
.map(|output| output.output.txout.value)
153159
.sum(),
160+
};
161+
162+
Ok(Balance {
163+
balance: (details.balance.confirmed + details.balance.trusted_pending) - details.dust,
164+
details,
154165
})
155166
}
156167

0 commit comments

Comments
 (0)