Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-26-2017, 05:41 AM   #1
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 54,512
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');
}
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


my contact: fris at fris.net
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
var, client, coinbase, addresses, list, btc, #/usr/bin/node, module, node, installed, apikeyhere, accountidhere;, process.argv.length, btcaccount, apikey, apisecret, apisecrethere, requirecoinbase.client;, api, code, creating, sell, prices, buy, address



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.