Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Keychain support for Taproot P2TR addresses #3342

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

msgilligan
Copy link
Member

@msgilligan msgilligan commented Dec 31, 2023

  • Add ScriptType.P2TR to various checks and if/else blocks
  • Add P2TR and HDPath.BIP86_PARENT to KeyChainGroupStructure
  • Add OutputScriptType of P2TR = 3 to wallet.proto
  • Add BIP-86 paths and address != null tests to WalletAccountPathTest

Remaining issues with this PR:

  1. ECKey.toAddress(): Needs to call calcWitnessProgram (see TODO on line 431)
  2. KeyChainGroup: decision/implementation needed for fallbackChain support.
  3. More tests should be added.

Remaining issues for full P2TR support:

  1. Need Taproot ECC support (for address generation, tx verification, tx signing)
  2. Need to implement TX verification support for P2TR in bitcoinj
  3. Need to implement TX signing support for P2TR in bitcoinj

I tagged this as for milestone 0.17, because I think we should at least consider the possibility of trying to get P2TR into 0.17. Though I think it make make more sense to wait for 0.18 for this feature.

* Add ScriptType.P2TR to various checks and if/else blocks
* Add P2TR and HDPath.BIP86_PARENT to KeyChainGroupStructure
* Add OutputScriptType of `P2TR = 3` to wallet.proto
* Add BIP-86 paths and address != null tests to WalletAccountPathTest

Remaining issues with this PR:

1. ECKey.toAddress(): Needs to call `calcWitnessProgram` (see TODO on line 431)
2. KeyChainGroup: decision/implementation needed for fallbackChain support.

Remaining issues for P2TR support:

1. Need Taproot ECC support (for address generation, tx verification, tx signing)
2. Need to implement TX verification support for P2TR in bitcoinj
3. Need to implement TX signing support for P2TR in bitcoinj
@msgilligan msgilligan added this to the 0.17 milestone Dec 31, 2023
@msgilligan msgilligan added Module: Crypto classes in org.bitcoinj.crypto and subpackages Enhancement Request for enhancement, or the implementation of one labels Dec 31, 2023
@msgilligan msgilligan added the Module: Wallet classes in org.bitcoinj.wallet and subpackages label Dec 31, 2023
Copy link
Member

@schildbach schildbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting the Taproot train going!

I always planned to start with the prerequisites, namely Schnorr.

Honestly I would not try to target this to 0.17 in its current state. It could needlessly defer the release of 0.17, which I'd really like to get out soon.

@@ -108,6 +108,8 @@ static HDPath purpose(ScriptType scriptType) {
return HDPath.BIP44_PARENT;
} else if (scriptType == ScriptType.P2WPKH) {
return HDPath.BIP84_PARENT;
} else if (scriptType == ScriptType.P2TR) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should at the same time define a path for BIP32 – I'd pick m/2'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. We should also consider not using the ACCOUNT_ZERO, ACCOUNT_ONE constants for these child numbers as they are misleading in the BIP32 context.

@@ -64,6 +67,10 @@ void walletStructurePathTest2(KeyChainGroupStructure structure, HDPath expectedP

// Then the account path is as expected
assertEquals(expectedPath, wallet.getActiveKeyChain().getAccountPath());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to PR and merge this change right away?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change asserting that the first receive address is not null?

@schildbach
Copy link
Member

I feel we won't get this into a releasable state for 0.17.

@schildbach schildbach modified the milestones: 0.17, 0.18 Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Request for enhancement, or the implementation of one Module: Crypto classes in org.bitcoinj.crypto and subpackages Module: Wallet classes in org.bitcoinj.wallet and subpackages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants