Davide Grilli
ac6ae69329
fix: implement BIP341 key tweaking for P2TR transaction signing
This commit fixes P2TR (Pay-to-Taproot) transaction signing by properly
implementing BIP341 key path spending.
Key changes:
- Add SignSchnorrTaproot() method to CKey for BIP341 tweaked signing
- Implement ComputeTapTweak() and CreatePayToTaprootPubKey() in XOnlyPubKey
- Add GetTaprootInternalKey() to SigningProvider interface for internal key lookup
- Store taproot internal key mappings in LegacyScriptPubKeyMan
- Fix FindTaprootPubKey() to use internal key mapping with fallback
- Use empty scriptCode for Taproot key-path spending (per BIP341 spec)
- Update HaveTaprootKey() to verify tweaked keys correctly
Technical details:
- Internal keys are tweaked using secp256k1_keypair_xonly_tweak_add
- Parity handling is automatic via secp256k1 library
- Empty scriptCode ensures correct sighash for key-path spending
- Internal key to output key mapping stored for efficient lookup
Testing:
- P2TR address creation, funding, and spending work end-to-end
- Multi-hop P2TR transactions tested successfully
- All functional tests pass (feature_taproot.py, wallet_*, rpc_*)
Fixes: non-mandatory-script-verify-flag error on P2TR spending
2026-02-08 00:55:02 +01:00
..
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-06 15:44:58 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-07 10:55:38 +01:00
2025-10-22 20:59:33 +02:00
2026-02-07 23:01:20 +01:00
2026-02-07 12:13:51 +01:00
2026-02-08 00:55:02 +01:00
2026-02-06 10:19:01 +01:00
2026-01-26 17:30:11 +01:00
2026-02-06 15:23:23 +01:00
2024-03-15 18:21:54 +01:00
2026-01-26 17:30:11 +01:00
2026-02-08 00:55:02 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-06 15:23:23 +01:00
2026-02-06 15:23:23 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-06 15:44:58 +01:00
2024-03-15 18:16:03 +01:00
2025-10-30 23:25:15 +01:00
2024-03-15 18:16:03 +01:00
2025-11-18 08:47:44 +01:00
2024-03-15 18:16:03 +01:00
2025-11-22 18:59:39 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-01-26 17:30:11 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-01-26 17:30:11 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-01-13 22:31:02 +01:00
2024-03-15 18:16:03 +01:00
2026-02-06 15:23:23 +01:00
2024-03-15 18:16:03 +01:00
2026-02-08 00:55:02 +01:00
2026-02-08 00:55:02 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2025-10-22 20:59:33 +02:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-01-26 17:30:11 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-04-07 13:33:32 -04:00
2024-04-07 13:33:32 -04:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-08 00:55:02 +01:00
2026-02-07 12:13:51 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2025-11-24 00:03:44 +01:00
2025-10-22 20:59:33 +02:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-08 00:55:02 +01:00
2026-02-08 00:55:02 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-01-26 17:30:11 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-08 00:55:02 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2026-02-06 15:44:58 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00
2024-03-15 18:16:03 +01:00