Problem
The MaxSatisfactionWeight method for Taproot descriptors was incorrectly assuming only keypath spends, leading to significant underestimations of transaction weight. This could cause fee estimation failures for Taproot descriptors with script paths that are more expensive than the key path.
Solution
- Fixed weight calculation: Updated
MaxSatisfactionWeightto properly calculate the maximum weight across all Taproot script leaves, not just the key path
Changes
src/script/descriptor.cpp: Implemented proper weight calculation that iterates through all descriptor leaves to find the maximum satisfaction weightsrc/test/descriptor_tests.cpp: Added comprehensive test casedescriptor_tr_max_satisfaction_weightcovering various Taproot scenariostest/functional/wallet_taproot.py: Updated tests to handle higher fee rates for complex script paths and improved assertions
Testing
- Added unit tests verifying correct weight calculation for Taproot descriptors with script paths heavier than key paths
- Updated functional tests to use appropriate fee rates for edge cases involving large Taproot scripts
- All existing tests continue to pass
This fix ensures wallets can properly estimate fees for all Taproot spending scenarios, preventing transaction failures due to underestimated fees.