Use of BitGo to perform operations on cryptocurrencies

Posted By : Krishna Verma | 29-Dec-2018

QUICK SUMMARY OR INTRODUCTION:-
Most Crypto Exchange platforms who deals in cryptocurrencies setup their own server of bitcoin to create wallets and perform transactions of users,So BitGo comes here as a solutions to eliminate the need of setup these currencies on own server.i will show you how you can generate bitcoin wallet and how you can perform transactions of bitcoin on Testnet.

Prerequisites:
1. An account on the BitGo Website(https://www.bitgo.com/info/).
2. Enterprise id which you will get after sign up.
3. Authentication token which you will get after login. 
4. Postman to hit the BitGo API to get the response from the BitGo.
5. Url which you have registered to hit the rest API of BitGo.

Multiple step explanation:

 

 I am going to explain to you how you can get your bitcoin wallet, generate your address for your wallet and how can you perform the bitcoin transaction on the blockchain without having to set up bitcoin server on your own and can use this on any exchange platform. I am supposing you have followed the prerequisites and you have now your enterprise-Id and Authentication token because these will be used to hit the API endpoints of the BitGo Server.
suppose your enterprise id is: ABC,
your authentication token is: bearer XYZ
and URL
 of testnet: https://testvault-api.example.com

Now to get the bitcoin wallet open the postman follow these steps:

1) Make a POST call on the URL https://testvault-api.example.com:3080/api/v2/tbtc/wallet/generate
2) Add these parameters in the Request Header:
    Authorization: Your authorization Token
Content-Type: application/json
 
3) Add these parameters in the request Body:
   {
"label": "any name to label your wallet",
"passphrase": "Your password to protect wallet",
"enterprise": "Your enterprise id (ABC)"
   }
 
When you hit the API You will get a response like this :
 
{
    "id": "5c235c5d52b55fcc03ec0d7d61sadf",
    "users": [
        {
            "user": "5c1c6229b309bcda034b787fdsafa21404c701",
            "permissions": [
                "admin",
                "view",
                "spend"
            ]
        }
    ],
    "coin": "tbtc",
    "label": "your lable name",
    "m": 2,
    "n": 3,
    "keys": [
        "5c235c5d9d1203a803d3e0b344489c51",
        "5c235c5da07037d003653b088b7f7974",
        "5c235c5d8e1495bf039f64490919d665"
    ],
    "keySignatures": {
        "bitgoPub": "208f281fa60cee0ec61b33ac2606c8465cd97d3c076647fc8d8785c69058ddf6c41795607c3e74637045662a0312968f126b88a552f58e642d23af7922263ca895",
        "backupPub": "208f7ce829d3b6c1a27813b881fa992f87bbab6d9a9a7d1b18e5a49bdeffe521a145cacfc9ea96dd876152b1b060ac27bd62e6b45c58f72de1b15734d48f18e326"
    },
    "enterprise": "Your enterprise id",
    "tags": [
        "5c235c5d52b55fcc03ec0d7d61784ba1",
        "5be37d666f617f4805c259bdb44c78c8"
    ],
    "disableTransactionNotifications": false,
    "freeze": {},
    "deleted": false,
    "approvalsRequired": 1,
    "isCold": false,
    "coinSpecific": {},
    "admin": {},
    "clientFlags": [],
    "allowBackupKeySigning": false,
    "recoverable": false,
    "balance": 0,
    "confirmedBalance": 0,
    "spendableBalance": 0,
    "balanceString": "0",
    "confirmedBalanceString": "0",
    "spendableBalanceString": "0",
    "receiveAddress": {
        "id": "5c235c5d52b55fcc03ec0d818f07ae07",
        "address": "Bitcoin Address",
        "chain": 0,
        "index": 0,
        "coin": "tbtc",
        "wallet": "wallet id(123)",
        "coinSpecific": {
            "redeemScript": "522102c24479b7fe93fee32dccd81b1e39db19eb609c30d41fcafb764b06d53ac0e62f21021c51b4bca64e556c15467ef7289e5fbf9ec357a9f99563de9cc98b8abdf7fd5121023c4354333d3c1255941c1cbf4cec19d9e9b3245327773c3b37215bfd77eb5ffa53ae"
        }
    },
    "pendingApprovals": []
}    
        

here you can find your wallet address which is under the receiveAddress key and then under this address Key. this is the address to receive the bitcoin also save the wallet id which is with the key of wallet under receive address key it is used to genereate new address.in this example your wallet id will be 123.

How to Generate new BitCoin address by giving wallet id:

API : https://testvault-api.example.com/api/v2/tbtc/wallet/(your wallet id)/address
parameters to send in headers : Authorization: your authorization token

When you hit the api you will get a new wallet address to receive bitcoin the response will looks like :

 

{
    "id": "required it",
    "address": "new BTC address",
    "chain": 10,
    "index": 1,
    "coin": "tbtc",
    "wallet": "wallet id",
    "coinSpecific": {
        "redeemScript": "00209aadd1a3b6b467bf5018e77b0514bff22a78ed611cdd710fff36efd6b05fbb46",
        "witnessScript": "522102d0b7fe9bbd7dd92a7c753ed77df7cd02c50459c689158e8de12fdac21852a53a21030f4f9ad1296d1d4cb064766c2052ad3316464f20d16f23ae3ee460187cbea15c2103c199059a81f0ee183bb878f7747a49376ff8b9a3caedd3ea30351e857221c8bf53ae"
    }
}
 

How to send bitcoins from my wallet to someone else wallet :

 

API : https://testvault-api.example.com:3080/api/v2/tbtc/wallet/(wallet id from which you want to send the bitcoin)/sendcoins
Request Parameters : 
Headers : 
Authorization: your Authorization Token
Content-Type: application/json
 Request Body parametes;
{
"walletPassphrase":"provide your wallet password",
"address":"bitcoin wallet address whom you want to send bitcoin",
"amount":"Amount which you want to send"
}
 
Response Object will look like :
 
 
{
    "transfer": {
        "id": "request id",
        "coin": "tbtc",
        "wallet": "wallet id",
        "enterprise": "enterprise id",
        "txid": "transaction ID",
        "height": 999999999,
        "date": "2018-12-27T09:52:15.081Z",
        "type": "send",
        "value": -1000935,
        "valueString": "-1000935",
        "feeString": "935",
        "payGoFee": 0,
        "payGoFeeString": "0",
        "usd": -37.8396470205,
        "usdRate": 3780.43,
        "state": "signed",
        "instant": false,
        "tags": [
            "5c235c5d52b55fcc03ec0d7d61784ba1",
            "5be37d666f617f4805c259bdb44c78c8"
        ],
        "history": [
            {
                "date": "2018-12-27T09:52:15.081Z",
                "action": "signed"
            },
            {
                "date": "2018-12-27T09:52:14.115Z",
                "action": "created"
            }
        ],
        "vSize": 374,
        "nSegwitInputs": 0,
        "entries": [
            {
                "address": "bitocin address",
                "wallet": "wallet id",
                "value": -19478521,
                "valueString": "-19478521"
            },
            {
                "address": "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB",
                "value": 1000000,
                "valueString": "1000000",
                "isChange": false,
                "isPayGo": false
            },
            {
                "address": "2Mx19hqNDuuXuTBkqdi8sbUfJdnoUEKtgUK",
                "wallet": "5c235c5d52b55fcc03ec0d7d61784ba1",
                "value": 18477586,
                "valueString": "18477586",
                "isChange": true,
                "isPayGo": false
            }
        ],
        "signedTime": "2018-12-27T09:52:15.081Z",
        "createdTime": "2018-12-27T09:52:14.115Z"
    },
    "txid": "transaction ID",
    "tx": "0100000001e47868862bfe9d8c5bdbf58d96671643c3d17a7621390eb5d954adc649137dad00000000fdfd0000483045022100a6f8774e162363823bf91139674c851a9cc16504d697aebdcb32f54e164f9ede0220372944bee31dafde9c7393881449f936276a781d1e845e030a3bef561e1c56270147304402200b69c4bbb9839de39cf700a66c8026d495aa7411cc8c7d4b491a301ee2af22e002204564527ce64aeb5c2dbd734ec69d14189e3179606a946dbac0db1fa7281fc6b0014c69522102c24479b7fe93fee32dccd81b1e39db19eb609c30d41fcafb764b06d53ac0e62f21021c51b4bca64e556c15467ef7289e5fbf9ec357a9f99563de9cc98b8abdf7fd5121023c4354333d3c1255941c1cbf4cec19d9e9b3245327773c3b37215bfd77eb5ffa53aeffffffff0240420f00000000001976a9149f9a7abd600c0caa03983a77c8c3df8e062cb2fa88ac12f219010000000017a914342f3acc3249333d68f35c4b936629902cf3e95087fe1e1600",
    "status": "signed"
}

Conclusion:

BitGo is a third party service which can be used to eliminate the need of setup different cryptocurries on our own server which costs us a huge amout of money so now most of the exchange platforms are moving towards BitGo.

About Author

Author Image
Krishna Verma

Krishna is a Software Developer having key skills in java , his hobbies are learning new technologies

Request for Proposal

Name is required

Comment is required

Sending message..