Giter VIP home page Giter VIP logo

bitgosdk-php's Introduction

BitGoSDK PHP

BitGoSDK written in PHP. This SDK contains methods for easily interacting with the BitGo API.

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Requirements

  • PHP 7.0 or earlier with:
    • cURL
    • BCMath

Installation

To install the SDK, you will need to be using Composer in your project. If you aren't using Composer yet, it's really simple! Here's how to install composer and the BitGoSDK PHP.

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add the BitGoSDK as a dependency
php composer.phar require neto737/bitgosdk-php

Next, require Composer's autoloader, in your application, to automatically load the BitGoSDK in your project:

require 'vendor/autoload.php';

use neto737\BitGoSDK\BitGoSDK;

Or if put the following in your composer.json:

"neto737/bitgosdk-php": "*"

Example

require 'vendor/autoload.php';

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

$bitgo = new BitGoSDK('YOUR_API_KEY_HERE', CurrencyCode::BITCOIN, false);
$bitgo->walletId = 'YOUR_WALLET_ID_HERE';

$createAddress = $bitgo->createWalletAddress();

BitGo Express

If you are going to use BitGo Express you have to run a BitGo Express node. You can find how to run your own BitGo Express node here.

Attention

Keep your cacert.pem always up to date. You can find updates on the site curl.haxx.se.

Credits

Donate

Donate BTC Donate ETH Donate LTC Donate with PayPal

bitgosdk-php's People

Contributors

neto737 avatar prajit21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bitgosdk-php's Issues

Send Transaction

BitGoSDK Version

Type here, e.g. 2.1

Related Issues

Found anything that might be related to this? It might help us find the cause.

Other Notes

Anything else?

Getting unauthorized error

hello.
I m using your library.
I have integrated your code into my codeigniter project.
And I chanaged your code a little.

public function __construct()
{
$this->_ci = & get_instance();
}

public function set_init($accessToken, $testNet = false)
{
    $this->accessToken = $accessToken;
    $this->testNet = $testNet;

    if ($this->testNet) {
        $this->API_Endpoint = self::BITGO_TESTNET_API_ENDPOINT;
    } else {
        $this->API_Endpoint = self::BITGO_PRODUCTION_API_ENDPOINT;
    }

    var_dump($this->API_Endpoint);
}

... ... ...
private function execute($requestType) {
$ch = curl_init($this->url);
if ($requestType === 'GET') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
} elseif ($requestType === 'PUT') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->params));
} elseif ($requestType === 'DELETE') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
} elseif ($requestType === 'POST') {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->params));
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->accessToken));
curl_setopt($ch, CURLOPT_CAINFO, dirname(FILE) . '/cacert.pem');

    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response, true);
}

i called in controller.

$access_token = 'XXXX';
$wallet = "XXX";
$this->bitgosdk->set_init($access_token, true);
$result = $this->bitgosdk->listWalletTransactions($wallet);

response data is :
"https://test.bitgo.com/api/v1" array(3) { ["error"]=> string(12) "unauthorized" ["name"]=> string(12) "Unauthorized" ["requestId"]=> string(25) "cjf9ji8ux0alwitrt3ddzmdh9" }

I need to help me

Bug found and fixed..

In the getWalletAddress function you need to use execute('GET') as below, you didn't have the 'GET' and it was always returning null. Just FYI.

public function getWalletAddress(string $wallet,$cointype,$id) {
    $this->url = $this->API_Endpoint . '/' . $cointype . '/wallet/' . $wallet . '/address/'.$id;
    $this->params = [
        'wallet' => $wallet
    ];
    return $this->execute('GET');
}

Error in BitGoExpress

I get a NULL response error with any function in BitGoExpress, both as a local server and in the cloud.
I leave the code used that is completely copied from the example.

$hostname = 'localhost';
$port = 3080;
$coin = CurrencyCode::BITCOIN_TESTNET;
$bitgoExpress = new BitGoExpress($hostname, $port, $coin);
$bitgoExpress->accessToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx';
$generateWallet = $bitgoExpress->generateWallet('LABEL', 'PASSPHRASE');
var_dump($generateWallet);

RESP: NULL

sendTransaction - doesnot return the response (testnet)

Hi
I used send transaction functionality, but it doesnot return any response.
It showing blank page in return response.

I execute the functionality in local machine.
Please give solution and sample code example.

Thanks.

On production, generate wallet returns NULL

Everything works well on TESTNET, but switching to production, Adding a new wallet is returning null

    $hostname = '0.0.0.0'; //THE HOSTNAME YOU INSTALLED THE BITGOEXPRESS (1st step)
    $port = 3080; //THE PORT YOU SET IN YOUR BITGOEXPRESS INSTALLATION
    $coin = CurrencyCode::BITCOIN; //THE COIN YOU WANT TO USE
     
    $bitgoExpress = new BitGoExpress($hostname, $port, $coin);
    $bitgoExpress->accessToken = 'Your_Token'; 
    
    $label = 'wallet_label';
    
    $pass = 'pass_key';
    
    $generateWallet = $bitgoExpress->generateWallet($pass,$label);
    var_dump($generateWallet);

update getWalletAddresses()

BitGoSDK Version

"neto737/bitgosdk-php": "^2.1",

Related Issues

Hello can you add search address by label. In bitgo documentation endpoint below has param labelContains which help us find address by label.

https://test.bitgo.com//api/v2/{coin}/wallet/{walletId}/addresses

Thanks a lot)

Error on send transaction

Transaction return null

<?php
ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);

require 'vendor/autoload.php';
use neto737\BitGoSDK\BitGoExpress;
use neto737\BitGoSDK\BitGoSDK;
use neto737\BitGoSDK\Enum\CurrencyCode;

$hostname = 'localhost';
$port = 3081;
$coin = CurrencyCode::BITCOIN_TESTNET;
$bitgo = new BitGoSDK('api_token', $coin, true);
$bitgo->unlockSession('0000000');
$bitgoExpress = new BitGoExpress($hostname, $port, $coin);
$bitgoExpress->accessToken = 'api_token';
$bitgoExpress->walletId = 'wallet_id';
/**
 * Send the amount in satoshi
 */
$value_in_btc = 0.05;
$amount = BitGoSDK::toSatoshi($value_in_btc);
$sendTransaction = $bitgoExpress->sendTransaction('addres_destinantion', $amount, 'wallet_password');
var_dump($sendTransaction);

Add 'maxFeeRate' as a post parameter to send crypto function

BitGoSDK Version

Hello i noticed a missing param on the post parameter to the send crpto functions, 'maxFeeRate'
is it possible to be added.

Related Issues

Found anything that might be related to this? It might help us find the cause.

Other Notes

Anything else?

Getting unauthorized error

Hello Neto737,

I am using this SDK for implementation of bitgo wallet. While I am running its function $bitgo->listWalletAddresses('xyz')

xyz = 'my API key'

giving me error

Array ( [error] => unauthorized [name] => Unauthorized [requestId] => cja0w3yb55dvkj9rtcdx6nxck )

Can you please assist me on this. Why I am getting this error.

My skype name is [email protected]

Thanks.
Mo. Rizwan Shaikh

I am unable to implement php sdk in our system.

Hey,
I am new in bitcoin integration. I want integrate your bitgo php sdk in our website built in codeigniter. But i am unable to setup your sdk in our system. Please guide me step by step that how to integrate this sdk.

Please tell me that what is "YOUR_WALLET_PASSPHRASE".

Thanks
Yogesh Goyal

Call to undefined method neto737\\BitGoSDK\\BitGoSDK

PHP Fatal error: Uncaught Error: Call to undefined method neto737\BitGoSDK\BitGoSDK::sendTransaction() in /var/www/html/test.php:7\nStack trace:\n#0 {main}\n thrown in /var/www/html/test.php on line 7

PHP7.2 on CentosOS 7

composer already installed, please suggestion what I missed?

Thank you in advance

2.1.10 breaks createWalletAddress()

BitGoSDK Version

2.1.10

Related Issues

3002fba#diff-77d36084e24607dfce767db7e835c19fL231

public function createWalletAddress(bool $allowMigrated = false, int $chain = 0, int $gasPrice = null, string $label = null)

public function createWalletAddress(int $chain = AddressType::P2SH_DEPOSIT, string $label = null, bool $lowPriority = false, int $gasPrice = null)

Perhaps this warranted a major version increase instead?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.