Add P2TR (taproot) address generation to ku utility#426
Add P2TR (taproot) address generation to ku utility#426
Conversation
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
…ation Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
pycoin/key/Key.py
Outdated
| address_taproot = self._network.address.for_p2tr(x_only) | ||
| if address_taproot: | ||
| yield ("address_taproot", address_taproot, "%s taproot address" % self._network.network_name) | ||
| yield ("%s_address_taproot" % self._network.symbol, address_taproot, "legacy") |
tests/key_test.py
Outdated
| "18fKPR8s1MQeckAsgya1sx6Z3WmFXd8wv8", | ||
| "1DVJQzgnyCahXdoXdJ3tjGA3hrYVgKpvgK") | ||
|
|
||
| def test_p2tr_address(self): |
There was a problem hiding this comment.
@copilot Can you instead just make this a new ku text test case, like the ones in tests/cmds/test_cases/ku/ ?
There was a problem hiding this comment.
Done in commit c037b48. Created tests/cmds/test_cases/ku/p2tr_address.txt and removed the unit test from tests/key_test.py.
|
@copilot tests are failing now too |
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Fixed in commit 7c6df5e. Updated 5 JSON test files with the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot can you find a source that proves the p2tr test vector address is correct? |
Yes, the P2TR test vector is proven correct by multiple authoritative sources:
The address decodes correctly to witness version 1 (taproot) with the 32-byte x-only pubkey matching the generator point's x-coordinate. |
Plan: Add P2TR Address Generation to ku Utility
ku_output_for_address()inpycoin/key/Key.pyto add P2TR address generationSummary
Successfully implemented P2TR (Pay-to-Taproot) address generation in the ku utility as requested in issue #421.
Implementation Details
Modified Files:
pycoin/key/Key.py: Added P2TR address generation inku_output_for_address()methodtests/cmds/test_cases/ku/p2tr_address.txt: Created dedicated P2TR test case following BIP 350 test vectorstests/key_test.pyper maintainer feedbackHow It Works:
for_p2trmethod exists)network.address.for_p2tr(x_only)address_taprootfield (no legacy{SYMBOL}_address_taprootfield)Example Output:
Testing & Verification
✅ Created dedicated ku text test case (
tests/cmds/test_cases/ku/p2tr_address.txt)✅ All ku functionality tests pass (83/83 ku tests)
✅ Verified against BIP 350 test vectors
✅ Tested with Bitcoin mainnet, Litecoin, and Bitcoin testnet3
✅ Works with both private and public-only keys
✅ No security vulnerabilities found (CodeQL scan clean)
✅ Code review feedback addressed:
Note: 2 unrelated tx tests remain failing (test_tx_ignored_locktime_txt, test_tx_pay_to_opcode_list_txt) - these are pre-existing failures unrelated to P2TR changes.
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.