Skip to content

Commit

Permalink
Merge pull request #31 from pvyhnal-generalbytes/BATM-929-uppercase-b…
Browse files Browse the repository at this point in the history
…c1-address

BATM-929 support uppercase bc1 address
  • Loading branch information
generalbytes authored Jun 13, 2019
2 parents 1f84217 + 39134b2 commit 80911bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ public Classification classify(String input) {
} catch (AddressFormatException e) {
e.printStackTrace();
}
} else if (input.startsWith("bc1")) {
} else if (input.toLowerCase().startsWith("bc1")) {
try {
if (isAddressValidBech32Internal(input)) {
return new Classification(Classification.TYPE_ADDRESS, IClient.BTC, input);
return new Classification(Classification.TYPE_ADDRESS, IClient.BTC, input.toLowerCase());
}
} catch (AddressFormatException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ public Classification classify(String input) {
} catch (AddressFormatException e) {
e.printStackTrace();
}
} else if (input.startsWith("ltc1")) {
} else if (input.toLowerCase().startsWith("ltc1")) {
try {
if (isAddressValidBech32Internal(input)) {
return new Classification(Classification.TYPE_ADDRESS, IClient.LTC, input);
return new Classification(Classification.TYPE_ADDRESS, IClient.LTC, input.toLowerCase());
}
} catch (AddressFormatException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ public void classify() {
Assert.assertEquals("BTC", walletToolsBTC.classify("3CuvPRVeG3jWhm1dLSACKDN9PMPuY6FVXT", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("112pN943KyuQY26epMwFFvcj85EVVc2fnJ", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("bc1qlgp42vadfqkdjr0wdwvfnpqlvs5cg3xnl5zukw", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("BC1QLGP42VADFQKDJR0WDWVFNPQLVS5CG3XNL5ZUKW", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("bitcoin:3CuvPRVeG3jWhm1dLSACKDN9PMPuY6FVXT", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("bitcoin:112pN943KyuQY26epMwFFvcj85EVVc2fnJ", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("bitcoin:bc1qlgp42vadfqkdjr0wdwvfnpqlvs5cg3xnl5zukw", "BTC").getCryptoCurrency());
Assert.assertEquals("BTC", walletToolsBTC.classify("bitcoin:BC1QLGP42VADFQKDJR0WDWVFNPQLVS5CG3XNL5ZUKW", "BTC").getCryptoCurrency());

Assert.assertNull(walletToolsBTC.classify("bitcoin:bc1QLGP42VADFQKDJR0WDWVFNPQLVS5CG3XNL5ZUKW", "BTC").getCryptoCurrency());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public void getWalletAddress() {
public void classify() {
Assert.assertEquals("LTC", walletToolsLTC.classify("ltc1q3cv28h4f33dj7msgm85va0epdw6298rxsparl7", "LTC").getCryptoCurrency());
Assert.assertEquals("LTC", walletToolsLTC.classify("litecoin:ltc1q3cv28h4f33dj7msgm85va0epdw6298rxsparl7", "LTC").getCryptoCurrency());
Assert.assertEquals("LTC", walletToolsLTC.classify("litecoin:LTC1Q3CV28H4F33DJ7MSGM85VA0EPDW6298RXSPARL7", "LTC").getCryptoCurrency());
Assert.assertEquals("LTC", walletToolsLTC.classify("MV5sqqgY5qG3rxBciUQgz9dSYSKiyxN2n3", "LTC").getCryptoCurrency());
Assert.assertEquals("LTC", walletToolsLTC.classify("litecoin:MV5sqqgY5qG3rxBciUQgz9dSYSKiyxN2n3", "LTC").getCryptoCurrency());
Assert.assertEquals("LTC", walletToolsLTC.classify("LZpVz2zJ9Mq4tUx2UeSiFHRqKfN54BL6yr", "LTC").getCryptoCurrency());
Assert.assertEquals("LTC", walletToolsLTC.classify("litecoin:LZpVz2zJ9Mq4tUx2UeSiFHRqKfN54BL6yr", "LTC").getCryptoCurrency());

Assert.assertNull(walletToolsLTC.classify("litecoin:ltc1Q3CV28H4F33DJ7MSGM85VA0EPDW6298RXSPARL7", "LTC").getCryptoCurrency());
Assert.assertNull(walletToolsLTC.classify("ltc1QQQQQQQQQ3cv28h4f33dj7msgm85va0epdw6298rxsparl7", "LTC").getCryptoCurrency());
Assert.assertNull(walletToolsLTC.classify("MV5sqqgY5qG3rxBciUXXXXXdSYSKiyxN2n3", "LTC").getCryptoCurrency());
}
Expand Down

0 comments on commit 80911bd

Please sign in to comment.