Repository navigation
Description
Expected Behavior
An asset lock built by key-wallet is always relayable: at most 100 inputs and at most 20 480 bytes, the limits Dash Core (v23.1.7+ and v24) applies to asset locks (and Platform applies in consensus). A drain over a larger account locks what fits and leaves the rest for a later transfer; an exact-amount build that cannot be funded within the cap fails with a typed error before anything is signed or reserved.
Current Behavior
In drain mode the builder spends every final UTXO of the funding account. The only input-count check is the generic MAX_STANDARD_TX_INPUTS = 500. That limit is right for a regular transaction, but an asset lock may have at most 100 inputs. The same 500-input cap applies to exact-amount asset-lock builds.
With a CoinJoin account holding 104 UTXOs, every CoinJoin → Shielded attempt builds a 104-input asset lock (~15.4 KB):
asset lock built txid=<txid> type=Asset Lock Transaction inputs=104 outputs=["<amount>:6a00"] size=15397 drain=true sources=[CoinJoin]
Broadcast <txid> to 2/3 peers (1 withheld for acceptance detection)
Broadcast <txid> outcome uncertain: no acceptance signal within 60s
Peers drop it without a reject (Dash P2P sends none), so the wallet only ever sees Uncertain. Submitting the same transaction through DAPI returns Core's verdict:
Transaction is rejected: assetlocktx-too-many-inputs
Seven attempts over a month all ended this way. The inputs are valid and unspent, and every signature verifies.
Possible Solution
Root cause: Dash Core IsStandardSpecialTx (src/evo/specialtxman.cpp, dashpay/dash commit 9ad2afb91, backported to v23.1.7 and v23.1.8, which most mainnet nodes run, and on the v24 line) treats an asset lock as non-standard if it has more than MAX_STANDARD_ASSET_LOCK_INPUTS{100} inputs (assetlocktx-too-many-inputs) or is larger than 20 480 bytes (assetlocktx-too-big). Platform enforces the same 100-input cap in consensus (max_asset_lock_transaction_inputs, dashpay/platform#3491), so even a mined lock with more inputs could not be used on Platform.
The builder applies only the regular-transaction cap to asset locks:
const MAX_STANDARD_TX_INPUTS: usize = 500:and its checkconst MAX_STANDARD_TX_INPUTS: usize = 500; rust-dashcore/key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
Lines 515 to 520 in d35a8d6
if selected_inputs.len() > MAX_STANDARD_TX_INPUTS { return Err(BuilderError::TooManyInputs { count: selected_inputs.len(), max: MAX_STANDARD_TX_INPUTS, }); } - drain →
SelectionStrategy::All:rust-dashcore/key-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rs
Lines 398 to 400 in d35a8d6
if drain { builder = builder.set_selection_strategy(SelectionStrategy::All); } SelectionStrategy::Alltakes every candidate:SelectionStrategy::All => { - doc: "
drainlocks the sourced accounts' whole spendable balance: every final UTXO is consumed":/// `drain` locks the sourced accounts' whole spendable balance: every final
Fix direction:
- A per-build input cap: 500 for regular transactions, 100 for any build that carries an asset-lock payload. The 100 is a public constant mirroring Core's policy, so platform-wallet can reference it. Exact-amount builds keep returning
BuilderError::TooManyInputs { count, max }, now withmax: 100. - A bounded drain: when more than 100 final UTXOs are available, take the 100 largest and lock their sum minus the fee. The rest stays in the account. With ≤100 UTXOs the behaviour is unchanged.
- Exact-amount coin selection stays within the cap.
- A final check on the signed transaction (inputs ≤100, size ≤20 480). On violation, release the reservation through the owner-guarded path and return a typed error.
Steps to Reproduce
- A wallet whose CoinJoin account (or BIP44 account for an exact/drain Core → Shielded build) holds more than 100 final UTXOs.
- Build a drain asset lock from it (CoinJoin → Shielded in the iOS wallet).
- Broadcast and observe: no acceptance, no InstantSend lock.
testmempoolaccepton any v24 node returnsassetlocktx-too-many-inputs.
A unit test is enough: fund an account with 101 UTXOs and assert that the drain build has 101 inputs.
Context
- Users: any wallet with more than 100 coins in the funding account cannot shield, register or top up an identity from it. That is mostly long-time CoinJoin users and wallets that collect many small payouts. Funds are safe because Core refuses the transaction before it can be mined.
- Support ticket 32500.
- Related: feat(dpp): add max_asset_lock_transaction_inputs limit to prevent stuck funds platform#3491 (Platform-side 100-input consensus cap), Shield from Asset Lock" fails with "State Transition exceeds maximum size of 20480 bytes platform#4460 / #5460 (oversized ShieldFromAssetLock transition, ChainLock-proof fallback), fix(platform-wallet)!: drain Core balance with restart-safe shielded recovery platform#5396 (Core → Shielded drain, currently assumes a 500-input cap). Companion platform issue: platform-wallet: asset-lock drains are not bounded by
max_asset_lock_transaction_inputs, so CoinJoin → Shielded never completes for wallets with more than 100 mixed coins platform#5478.
Your Environment
- Dash Wallet iOS 9.1.0 → 9.1.4 (TestFlight), mainnet.
- rust-dashcore
e4208c9078,d2367cff,edc4d430(all reproduce). Code cited atdevd35a8d6. - Dash Core v23.1.7+ peers / DAPI.
Activity
[-]key-wallet: asset locks are capped at the regular 500-input limit, not 100 — a drain over more than 100 UTXOs builds a transaction Core v24 refuses as non-standard[/-][+]key-wallet: asset locks are capped at the regular 500-input limit, not 100 — a drain over more than 100 UTXOs builds a transaction Core refuses as non-standard[/+]fix(key-wallet)!: cap asset locks at 100 inputs