Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
4538fc4
feat(platform-wallet): let a Core build fund from only the inputs it …
jeanpierreroma Aug 31, 2026
d207874
feat(platform-wallet): let a Core build fund from only the inputs it …
jeanpierreroma Sep 1, 2026
28044ee
feat(platform-wallet): report the balance a pooled build can actually…
jeanpierreroma Sep 1, 2026
96c8be1
refactor(platform-wallet): drive both funding paths from one account …
jeanpierreroma Sep 3, 2026
c002d33
Merge branch 'v4.2-dev' into feat/pooled-spendable-balance
jeanpierreroma Sep 3, 2026
bb3ea98
test(platform-wallet): pin pooled_spendable_balance to the funding set
jeanpierreroma Sep 3, 2026
dd92e1b
feat(platform-wallet): price the fee into a pooled send-max figure
jeanpierreroma Sep 3, 2026
6444e67
style: rustfmt the new pooled-max-sendable FFI entry point
jeanpierreroma Sep 3, 2026
f95e401
fix(platform-wallet): cap pooled_max_sendable at the standard input l…
jeanpierreroma Sep 3, 2026
2abc906
fix(platform-wallet-ffi): look the pooled-balance handle up in the co…
jeanpierreroma Sep 7, 2026
e9c69dd
fix(platform-wallet): make the pooled send-max figure safe to act on
jeanpierreroma Sep 9, 2026
8a857a8
Merge remote-tracking branch 'origin/v4.2-dev' into feat/pooled-spend…
jeanpierreroma Sep 9, 2026
6ca60d2
Merge branch 'v4.2-dev' into feat/pooled-spendable-balance
romchornyi Sep 10, 2026
61daa8d
fix(platform-wallet): price the pooled maximum the way coin selection…
jeanpierreroma Sep 10, 2026
8a3ecc7
Merge branch 'v4.2-dev' into feat/pooled-spendable-balance
romchornyi Sep 10, 2026
8b6131f
Merge remote-tracking branch 'origin/v4.2-dev' into feat/pooled-spend…
jeanpierreroma Sep 10, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,73 @@ pub unsafe extern "C" fn core_wallet_tx_builder_use_only_added_inputs(
PlatformWalletFFIResult::ok()
}

/// The balance a build funded by `account_type` could actually select from — the
Comment thread
romchornyi marked this conversation as resolved.
/// same accounts `core_wallet_tx_builder_finalize` would fund from, counting
/// only UTXOs coin selection accepts.
///
/// Gate amount entry on this rather than on `core_wallet_get_balance`, which
/// sums every funding account the wallet has — CoinJoin included — and so
/// reports money a build then refuses.
///
/// Reservations are not subtracted; see `CoreWallet::pooled_spendable_balance`.
///
/// # Safety
/// `out_balance` must be a valid, writable pointer.
#[no_mangle]
pub unsafe extern "C" fn core_wallet_pooled_spendable_balance(
wallet: Handle,
account_type: CoreAccountTypeFFI,
account_index: u32,
out_balance: *mut u64,
) -> PlatformWalletFFIResult {
check_ptr!(out_balance);
*out_balance = 0;

let wallet = unwrap_option_or_return!(PLATFORM_WALLET_STORAGE.with_item(wallet, |w| w.clone()));
let balance = unwrap_result_or_return!(runtime().block_on(
wallet
.core()
.pooled_spendable_balance(account_type.funding_sources(), account_index)
));

*out_balance = balance;
PlatformWalletFFIResult::ok()
}

/// The largest amount a build funded by `account_type` could actually pay out,
/// net of the fee spending it costs — what a "send max" control must use.
///
/// `core_wallet_pooled_spendable_balance` is the gross figure: entering it
/// verbatim as an amount fails, because a build needs `amount + fee`. This
/// prices the fee off the inputs that spending everything would take, at
/// `fee_rate_sat_per_kb` — pass 0 for the same default `TransactionBuilder`
/// starts from, or the rate the host sets on its builders.
///
/// # Safety
/// `out_max_sendable` must be a valid, writable pointer.
#[no_mangle]
pub unsafe extern "C" fn core_wallet_pooled_max_sendable(
wallet: Handle,
account_type: CoreAccountTypeFFI,
account_index: u32,
fee_rate_sat_per_kb: u64,
out_max_sendable: *mut u64,
) -> PlatformWalletFFIResult {
check_ptr!(out_max_sendable);
*out_max_sendable = 0;

let fee_rate = (fee_rate_sat_per_kb != 0).then(|| FeeRate::new(fee_rate_sat_per_kb));
let wallet = unwrap_option_or_return!(PLATFORM_WALLET_STORAGE.with_item(wallet, |w| w.clone()));
let max_sendable = unwrap_result_or_return!(runtime().block_on(
wallet
.core()
.pooled_max_sendable(account_type.funding_sources(), account_index, fee_rate)
));

*out_max_sendable = max_sendable;
PlatformWalletFFIResult::ok()
}

/// # Safety
/// `builder` must be a valid, non-destroyed pointer.
#[no_mangle]
Expand Down
Loading
Loading