Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
Fixed small bugs in some functions
Updated some examples
Added receiveWebhook example
  • Loading branch information
neto737 committed Jan 20, 2019
1 parent 382b3e5 commit 59621bc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
3 changes: 1 addition & 2 deletions examples/createAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
use neto737\BitGoSDK\BitGoSDK;
use neto737\BitGoSDK\Enum\CurrencyCode;

$token = 'YOUR_API_KEY_HERE';
$coin = CurrencyCode::BITCOIN_TESTNET;

$bitgo = new BitGoSDK($token, $coin, true);
$bitgo = new BitGoSDK('YOUR_API_KEY_HERE', $coin, true);
$bitgo->walletId = 'WALLET_ID_HERE';

$createAddress = $bitgo->createWalletAddress();
Expand Down
3 changes: 1 addition & 2 deletions examples/getWalletByAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
use neto737\BitGoSDK\BitGoSDK;
use neto737\BitGoSDK\Enum\CurrencyCode;

$token = 'YOUR_API_KEY_HERE';
$coin = CurrencyCode::BITCOIN_TESTNET;

$bitgo = new BitGoSDK($token, $coin, true);
$bitgo = new BitGoSDK('YOUR_API_KEY_HERE', $coin, true);

$getWalletByAddress = $bitgo->getWalletByAddress('WALLET_ADDRESS_HERE');
var_dump($getWalletByAddress);
21 changes: 21 additions & 0 deletions examples/receiveWebhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

require 'vendor/autoload.php';

use neto737\BitGoSDK\BitGoSDK;
use neto737\BitGoSDK\Enum\CurrencyCode;

$coin = CurrencyCode::BITCOIN_TESTNET;

$bitgo = new BitGoSDK('YOUR_API_KEY_HERE', $coin, true);
$bitgo->walletId = 'WALLET_ID_HERE';

$payload = $bitgo->getWebhookPayload();

$txDetails = $bitgo->getWalletTransaction($payload['hash']);

if (!isset($txDetails['fromWallet'])) {
//YOU ARE RECEIVING A TRANSACTION...
} else {
//YOU ARE SENDING A TRANSACTION...
}
8 changes: 4 additions & 4 deletions src/BitGoExpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(string $hostname, int $port, string $coin = Currency
* @param bool $extensible True if the session is supposed to be extensible beyond a one-hour duration.
* @return array
*/
public function login(string $email, string $password, string $otp, bool $extensible = false) {
public function login(string $email, string $password, string $otp, bool $extensible = null) {
$this->url = 'http://' . $this->hostname . ':' . $this->port . '/api/v2/user/#';
$this->params = [
'email' => $email,
Expand All @@ -82,7 +82,7 @@ public function login(string $email, string $password, string $otp, bool $extens
* @param string $passcodeEncryptionCode Encryption code for wallet passphrase (used for lost passphrase recovery)
* @return array
*/
public function generateWallet(string $label, string $passphrase, string $userKey = null, string $backupXpub = null, string $backupXpubProvider = null, string $enterprise = '', bool $disableTransactionNotifications = false, int $gasPrice = 0, string $passcodeEncryptionCode = null) {
public function generateWallet(string $label, string $passphrase, string $userKey = null, string $backupXpub = null, string $backupXpubProvider = null, string $enterprise = null, bool $disableTransactionNotifications = null, int $gasPrice = null, string $passcodeEncryptionCode = null) {
$this->url = $this->APIEndpoint . '/wallet/generate';
$this->params = [
'label' => $label,
Expand Down Expand Up @@ -111,7 +111,7 @@ public function generateWallet(string $label, string $passphrase, string $userKe
* @param bool $disableTransactionNotifications Will prevent wallet transaction notifications if set to true.
* @return array
*/
public function addWallet(string $label, int $m, int $n, array $keys, string $enterprise = null, bool $isCold = null, bool $disableTransactionNotifications = false) {
public function addWallet(string $label, int $m, int $n, array $keys, string $enterprise = null, bool $isCold = null, bool $disableTransactionNotifications = null) {
$this->url = $this->APIEndpoint . '/wallet';
$this->params = [
'label' => $label,
Expand Down Expand Up @@ -244,7 +244,7 @@ public function sendTransactionToMany(array $recipients, string $walletPassphras
* @param bool $enforceMinConfirmsForChange Apply the required confirmations set in minConfirms for change outputs
* @return array
*/
public function consolidateWalletUnspents(string $walletPassphrase, int $numUnspentsToMake = 1, int $limit = 25, int $minValue = null, int $maxValue = null, int $minHeight = null, int $feeRate = null, int $feeTxConfirmTarget = null, int $maxFeePercentage = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null) {
public function consolidateWalletUnspents(string $walletPassphrase, int $numUnspentsToMake = null, int $limit = null, int $minValue = null, int $maxValue = null, int $minHeight = null, int $feeRate = null, int $feeTxConfirmTarget = null, int $maxFeePercentage = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null) {
$this->url = $this->APIEndpoint . '/wallet/' . $this->walletId . '/consolidateunspents';
$this->params = [
'walletPassphrase' => $walletPassphrase,
Expand Down
8 changes: 4 additions & 4 deletions src/BitGoExpressInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
interface BitGoExpressInterface {

// USER AUTHENTICATION
public function login(string $email, string $password, string $otp, bool $extensible = false);
public function login(string $email, string $password, string $otp, bool $extensible = null);

// WALLETS
public function generateWallet(string $label, string $passphrase, string $userKey = null, string $backupXpub = null, string $backupXpubProvider = null, string $enterprise = '', bool $disableTransactionNotifications = false, int $gasPrice = 0, string $passcodeEncryptionCode = null);
public function generateWallet(string $label, string $passphrase, string $userKey = null, string $backupXpub = null, string $backupXpubProvider = null, string $enterprise = null, bool $disableTransactionNotifications = null, int $gasPrice = null, string $passcodeEncryptionCode = null);

public function addWallet(string $label, int $m, int $n, array $keys, string $enterprise = null, bool $isCold = null, bool $disableTransactionNotifications = false);
public function addWallet(string $label, int $m, int $n, array $keys, string $enterprise = null, bool $isCold = null, bool $disableTransactionNotifications = null);

// WALLET OPERATIONS
public function sendTransaction(string $address, int $amount, string $walletPassphrase, string $prv = null, int $numBlocks = null, int $feeRate = null, string $comment = null, array $unspents = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null, int $targetWalletUnspents = null, bool $noSplitChange = null, int $minValue = null, int $maxValue = null, int $gasPrice = null, int $gasLimit = null, int $sequenceId = null, bool $segwit = null, int $lastLedgerSequence = null, string $ledgerSequenceDelta = null);

public function sendTransactionToMany(array $recipients, string $walletPassphrase, string $prv = null, int $numBlocks = null, int $feeRate = null, string $comment = null, array $unspents = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null, int $targetWalletUnspents = null, bool $noSplitChange = null, int $minValue = null, int $maxValue = null, int $gasPrice = null, int $gasLimit = null, int $sequenceId = null, bool $segwit = null, int $lastLedgerSequence = null, string $ledgerSequenceDelta = null);

// WALLET OPERATIONS - ADVANCED
public function consolidateWalletUnspents(string $walletPassphrase, int $numUnspentsToMake = 1, int $limit = 25, int $minValue = null, int $maxValue = null, int $minHeight = null, int $feeRate = null, int $feeTxConfirmTarget = null, int $maxFeePercentage = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null);
public function consolidateWalletUnspents(string $walletPassphrase, int $numUnspentsToMake = null, int $limit = null, int $minValue = null, int $maxValue = null, int $minHeight = null, int $feeRate = null, int $feeTxConfirmTarget = null, int $maxFeePercentage = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null);

public function funoutWalletUnspents(string $walletPassphrase, string $xprv = null, int $maxNumInputsToUse = null, int $numUnspentsToMake = null, int $minValue = null, int $maxValue = null, int $minHeight = null, int $maxFeePercentage = null, int $minConfirms = null, bool $enforceMinConfirmsForChange = null, int $feeRate = null, int $feeTxConfirmTarget = null);

Expand Down
2 changes: 1 addition & 1 deletion src/BitGoSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public function listPendingApprovals(string $walletID = null, string $enterprise
return $this->__execute('GET');
}

public function getWebhookPayload(bool $decodeJson = false, bool $decodeAsArray = false) {
public function getWebhookPayload(bool $decodeJson = true, bool $decodeAsArray = true) {
if ($decodeJson) {
return json_decode(file_get_contents('php://input'), $decodeAsArray);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/BitGoSDKInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getPendingApproval(string $pendingApprovalId);
public function listPendingApprovals(string $walletID = null, string $enterprise = null, bool $allTokens = false);

// WEBHOOKS
public function getWebhookPayload(bool $decodeJson = false, bool $decodeAsArray = false);
public function getWebhookPayload(bool $decodeJson = true, bool $decodeAsArray = true);

public function listWalletWebhooks(bool $allTokens = false);

Expand Down

0 comments on commit 59621bc

Please # to comment.