Skip to content

Commit 00b2a9a

Browse files
committed
Merge pull request #1 from sambohler/master
Added EcKey constructor signatures to make clientName and envUrl optiona...
2 parents 3093612 + ba1d4a5 commit 00b2a9a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ json-simple
1616
Getting Started
1717
---------------
1818

19-
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.
19+
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.
2020

2121
```java
2222
String privateKey = KeyUtils.readBitcoreKeyFromFile(privateKeyFile);
2323
ECKey key = KeyUtils.loadKey(privateKey);
24-
this.bitpay = new BitPay(key, SIN);
24+
this.bitpay = new BitPay(key);
2525
```
2626

2727
####Create an invoice

src/controller/BitPay.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,37 @@ public BitPay(ECKey ecKey, String clientName, String envUrl) throws BitPayExcept
109109
{
110110
_ecKey = ecKey;
111111
this.deriveIdentity();
112+
113+
if (clientName.equals(BITPAY_PLUGIN_INFO))
114+
{
115+
try {
116+
clientName += " on " + java.net.InetAddress.getLocalHost();
117+
} catch (UnknownHostException e) {
118+
clientName += " on unknown host";
119+
}
120+
}
121+
// Eliminate special characters from the client name (used as a token label). Trim to 60 chars.
122+
_clientName = clientName.replaceAll("[^a-zA-Z0-9_ ]", "_");
123+
if (_clientName.length() > 60)
124+
{
125+
_clientName = _clientName.substring(0, 60);
126+
}
127+
112128
_baseUrl = envUrl;
113129
_httpClient = HttpClientBuilder.create().build();
114130
this.tryGetAccessTokens();
115131
}
116132

133+
public BitPay(ECKey ecKey, String clientName) throws BitPayException
134+
{
135+
this(ecKey, clientName, BITPAY_URL);
136+
}
137+
138+
public BitPay(ECKey ecKey) throws BitPayException
139+
{
140+
this(ecKey, BITPAY_PLUGIN_INFO, BITPAY_URL);
141+
}
142+
117143
public String getIdentity()
118144
{
119145
return _identity;

0 commit comments

Comments
 (0)