diff --git a/core/src/main/java/org/bitcoinj/uri/BitcoinURI.java b/core/src/main/java/org/bitcoinj/uri/BitcoinURI.java index 7b403dea..8d9508fc 100644 --- a/core/src/main/java/org/bitcoinj/uri/BitcoinURI.java +++ b/core/src/main/java/org/bitcoinj/uri/BitcoinURI.java @@ -146,9 +146,10 @@ public class BitcoinURI { String blockchainInfoScheme = scheme + "://"; String correctScheme = scheme + ":"; String schemeSpecificPart; - if (input.startsWith(blockchainInfoScheme)) { + final String inputLc = input.toLowerCase(Locale.US); + if (inputLc.startsWith(blockchainInfoScheme)) { schemeSpecificPart = input.substring(blockchainInfoScheme.length()); - } else if (input.startsWith(correctScheme)) { + } else if (inputLc.startsWith(correctScheme)) { schemeSpecificPart = input.substring(correctScheme.length()); } else { throw new BitcoinURIParseException("Unsupported URI scheme: " + uri.getScheme()); diff --git a/core/src/test/java/org/bitcoinj/uri/BitcoinURITest.java b/core/src/test/java/org/bitcoinj/uri/BitcoinURITest.java index c0b4ad3f..7de1bea4 100644 --- a/core/src/test/java/org/bitcoinj/uri/BitcoinURITest.java +++ b/core/src/test/java/org/bitcoinj/uri/BitcoinURITest.java @@ -29,6 +29,8 @@ import org.bitcoinj.core.SegwitAddress; import static org.junit.Assert.*; +import java.util.Locale; + public class BitcoinURITest { private BitcoinURI testObject = null; @@ -101,6 +103,15 @@ public class BitcoinURITest { assertEquals("Unexpected label", 20, testObject.getAddress().getHash().length); } + @Test + public void testGood_uppercaseScheme() throws BitcoinURIParseException { + testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME.toUpperCase(Locale.US) + ":" + MAINNET_GOOD_ADDRESS); + assertEquals(MAINNET_GOOD_ADDRESS, testObject.getAddress().toString()); + assertNull("Unexpected amount", testObject.getAmount()); + assertNull("Unexpected label", testObject.getLabel()); + assertEquals("Unexpected label", 20, testObject.getAddress().getHash().length); + } + @Test public void testGood_segwit() throws BitcoinURIParseException { testObject = new BitcoinURI(MAINNET, BITCOIN_SCHEME + ":" + MAINNET_GOOD_SEGWIT_ADDRESS);