Skip to content

Commit

Permalink
Merge pull request #1 from sambohler/master
Browse files Browse the repository at this point in the history
Added EcKey constructor signatures to make clientName and envUrl optiona...
  • Loading branch information
ionux committed Nov 24, 2014
2 parents 3093612 + ba1d4a5 commit 00b2a9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions src/controller/BitPay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 00b2a9a

Please sign in to comment.