GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   my code for creating btc addresses (https://gfy.com/showthread.php?t=1269010)

fris 06-26-2017 05:41 AM

my code for creating btc addresses
 
I use this for my coinbase (this only works with coinbase api) use it the list all btc addresses in account, create a new address, list buy and sell prices, hopefully this is useful to someone .

node module coinbase needs to be installed.

Code:

#!/usr/bin/node

var Client = require('coinbase').Client;

var client = new Client({
    'apiKey': 'apikeyhere',
    'apiSecret': 'apisecrethere'
});

var btcaccount = 'accountidhere';

if (process.argv.length <= 2) {
    console.log("usage: btc buyprice|sellprice|list|create");
    process.exit(-1);
}

switch (process.argv[2]) {

    case 'buyprice':
        client.getBuyPrice({'currencyPair': 'BTC-USD'}, function(err, price) {
                console.log('$' + price.data.amount);
        });
        break;

    case 'sellprice':
        client.getSellPrice({'currencyPair': 'BTC-USD'}, function(err, price) {
                console.log('$' + price.data.amount);
        });
        break;

    case 'create':
        client.getAccount(btcaccount, function(err, account) {
            account.createAddress(null, function(err, address) {
                console.log(address.address);
            });
        });
        break;

    case 'list':
        client.getAccount(btcaccount, function(err, account) {
            account.getAddresses(null, function(err, addresses) {
                addresses.forEach(function(item) {
                    console.log(item.address)
                })
            });
        });
        break;

    default:
        console.log('Not a Valid Command');
}

:pimp


All times are GMT -7. The time now is 09:31 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123