Skip to content

Commit

Permalink
Bech32: use ByteUtils.concat() in verifyChecksum()
Browse files Browse the repository at this point in the history
  • Loading branch information
msgilligan authored and schildbach committed Feb 25, 2025
1 parent 9683514 commit 5edb96c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/src/main/java/org/bitcoinj/base/Bech32.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.bitcoinj.base.exceptions.AddressFormatException;
import org.bitcoinj.base.internal.ByteArray;
import org.bitcoinj.base.internal.ByteUtils;

import java.io.ByteArrayOutputStream;
import java.util.Arrays;
Expand Down Expand Up @@ -197,9 +198,7 @@ private static byte[] expandHrp(final String hrp) {
*/
private static Encoding verifyChecksum(final String hrp, final byte[] values) {
byte[] hrpExpanded = expandHrp(hrp);
byte[] combined = new byte[hrpExpanded.length + values.length];
System.arraycopy(hrpExpanded, 0, combined, 0, hrpExpanded.length);
System.arraycopy(values, 0, combined, hrpExpanded.length, values.length);
byte[] combined = ByteUtils.concat(hrpExpanded, values);
final int check = polymod(combined);
if (check == BECH32_CONST)
return Encoding.BECH32;
Expand Down

0 comments on commit 5edb96c

Please sign in to comment.