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

DeterministicKey::serializePublic and serializePrivate are deprecated without giving a migration path #3150

Open
Polve opened this issue Aug 8, 2023 · 6 comments

Comments

@Polve
Copy link

Polve commented Aug 8, 2023

In version 0.16.2 the two methods are deprecated but it's not clear (at least to me) what I should use in place of them since the serialize() method is private

@msgilligan
Copy link
Member

For deserialize there are static methods:
https://bitcoinj.org/javadoc/0.16.2/org/bitcoinj/crypto/DeterministicKey.html#deserialize(org.bitcoinj.core.NetworkParameters,byte%5B%5D)

For serialize there are getPrivKeyBytes and getSecretBytes

Note that in 0.17 we will be migrating from NetworkParameters to the new Network enum and there will be more deprecations. But the methods I mentioned above still exist in 0.17.

@Polve
Copy link
Author

Polve commented Aug 8, 2023

I'm sorry I don't understand: while I know how to get the private bytes, how do I call serialize on them?

@msgilligan
Copy link
Member

At present, it seems to me, you have 3 options:

  1. Continue using the deprecated method.
  2. Serialize to a Base58 string.
  3. Write your own serialization with the private bytes.

What is your use case? If it's something we overlooked we would consider adding a replacement method in 0.17.

@Polve
Copy link
Author

Polve commented Aug 9, 2023

An old library I need to mantain has a different way to serialize to b58 so I need the serialized bytes.

Anyway if it's not planned a replacement I can go with solution 2, it seems viable, thanks.

@schildbach
Copy link
Member

For reference, the methods were removed via 5ae7a42.

@schildbach
Copy link
Member

I think if you've got your own (non-standard) serialization format for deterministic keys, you should implement that format from scratch, so basically copy and adapt the private byte[] serialize(Network network, boolean pub, ScriptType outputScriptType) method to your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants