Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: imabauss on March 20, 2014, 09:55:57 PM



Title: Good Programming Tutorials? [MeanStack]
Post by: imabauss on March 20, 2014, 09:55:57 PM
I'm a Meanstack dev aka mongodb, express, angular, nodejs

I can't seem to find any good tutorials on working directly with bitcoind etc
I want to understand all the api calls etc but its so much to grasp that I'm just not getting it.

if you know any great resources please link me!

-thanks


Title: Re: Good Programming Tutorials? [MeanStack]
Post by: yabtcl on March 20, 2014, 10:14:46 PM
All I know about the RPC's call I got from from the wiki and also playing with the RPC call and the console on testnet.

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
https://en.bitcoin.it/wiki/Elis-API
https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29

As the result is always a json, it will be easy to call the commands in nodeJS


Title: Re: Good Programming Tutorials? [MeanStack]
Post by: imabauss on March 20, 2014, 10:55:01 PM
All I know about the RPC's call I got from from the wiki and also playing with the RPC call and the console on testnet.

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
https://en.bitcoin.it/wiki/Elis-API
https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29

As the result is always a json, it will be easy to call the commands in nodeJS

Thanks I'm definitely going to play around with this!
I was just wondering if anyone has examples for actually doing basic things like:

checking for confirmations securely,
generating a deposit address,
etc etc


Title: Re: Good Programming Tutorials? [MeanStack]
Post by: yabtcl on March 20, 2014, 11:33:39 PM
all this can be acomplished with the RPC calls


get how many confirmations a transaction has:
gettransaction <txid>

generation addresses:
getnewaddress [account]


If you type "help" in the console on bitcoin gui interface, you will get a list of all commands available via RPC, and if you type "help <command>" you will get a explanation about the specific command.


Title: Re: Good Programming Tutorials? [MeanStack]
Post by: Linkeex on March 20, 2014, 11:43:01 PM
Hi!

It's pretty easy to get going.
You could use npm bitcoin: https://www.npmjs.org/package/bitcoin

It just converts a method call to a bash command.
For example you want to generate a new address in your wallet you could connect to your bitcoind client and execute

Code:
client.cmd('getnewaddress', function(err, address, resHeaders){
  if (err) return console.log(err);
  console.log('New Address:', address);
});

or you could just do it by implementing the above mentioned library in your code.
To make a connection to your node call this:

Code:
// all config options are optional
var client = new bitcoin.Client({
  host: 'localhost',
  port: 8332,
  user: 'username',
  pass: 'password',
  timeout: 5000
});


With the client variable you can now execute its implemented methods:
Code:
client.getNewAddress('*', function(err, address) {
  if(err) return err;
  console.log('Address: '+ address);
});


Also, if you want to get started and do not want to download the whole blockchain, blockchain.info has a wallet API for you to play: https://blockchain.info/de/api/json_rpc_api