bernardladenthin / BitcoinAddressFinder

A high performance bitcoin address finder.
Apache License 2.0
170 stars 49 forks source link

Try to parse P2TR more properly #19

Open bernardladenthin opened 1 year ago

bernardladenthin commented 1 year ago

In a newer release P2TR might be supported. https://bitcoinj.org/release-notes Implement Taproot BIP341 – send to P2TR addresses. Receiving to and spending from P2TR addresses and chains will be implemented in a future release.

In AddressTxtLine the code SegwitAddress.fromBech32(keyUtility.networkParameters, address); is not correct for P2TR addresses and throws an

org.bitcoinj.core.AddressFormatException$InvalidChecksum: Checksum does not validate
    at org.bitcoinj.core.Bech32.decode(Bech32.java:156)
    at org.bitcoinj.core.SegwitAddress.fromBech32(SegwitAddress.java:167)

A workaround is used to catch the exception.

The goal is to prevent this exception. See StaticUnsupportedAddress and BitcoinP2TR for the test.