Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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