diff --git a/README.md b/README.md index 02c3ea07..225a6b03 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ json-simple Getting Started --------------- -Log into your BitPay merchant account and generate a Private Key and SIN. Then all you need to do is instantiate a BitPay object, and pass in your private key and the SIN. +Log into your BitPay merchant account and generate a Private Key. Then all you need to do is instantiate a BitPay object, and pass in your private key. ```java String privateKey = KeyUtils.readBitcoreKeyFromFile(privateKeyFile); ECKey key = KeyUtils.loadKey(privateKey); -this.bitpay = new BitPay(key, SIN); +this.bitpay = new BitPay(key); ``` ####Create an invoice diff --git a/src/controller/BitPay.java b/src/controller/BitPay.java index 1a981e51..83cc384c 100644 --- a/src/controller/BitPay.java +++ b/src/controller/BitPay.java @@ -109,11 +109,37 @@ public BitPay(ECKey ecKey, String clientName, String envUrl) throws BitPayExcept { _ecKey = ecKey; this.deriveIdentity(); + + if (clientName.equals(BITPAY_PLUGIN_INFO)) + { + try { + clientName += " on " + java.net.InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + clientName += " on unknown host"; + } + } + // Eliminate special characters from the client name (used as a token label). Trim to 60 chars. + _clientName = clientName.replaceAll("[^a-zA-Z0-9_ ]", "_"); + if (_clientName.length() > 60) + { + _clientName = _clientName.substring(0, 60); + } + _baseUrl = envUrl; _httpClient = HttpClientBuilder.create().build(); this.tryGetAccessTokens(); } + public BitPay(ECKey ecKey, String clientName) throws BitPayException + { + this(ecKey, clientName, BITPAY_URL); + } + + public BitPay(ECKey ecKey) throws BitPayException + { + this(ecKey, BITPAY_PLUGIN_INFO, BITPAY_URL); + } + public String getIdentity() { return _identity;