jb55 / node-bitcoin

zero-dependency bitcoin core rpc lib for nodejs
The Unlicense
45 stars 127 forks source link

undefined:1 #6

Closed mcandre closed 12 years ago

mcandre commented 12 years ago

When I try your sample code, I get an error.

Example:

client.getBalance('*', 6, function(err, balance) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});

Trace:

undefined:1

^^
SyntaxError: Unexpected token ILLEGAL
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/Users/andrew/Desktop/src/mijnwerker/node_modules/bitcoin/lib/jsonrpc.js:62:28)
    at IncomingMessage.emit (events.js:81:20)
    at HTTPParser.onMessageComplete (http.js:133:23)
    at Client.onData [as ondata] (http.js:1488:27)
    at Client._onReadable (net.js:683:27)
    at IOWatcher.onReadable [as callback] (net.js:177:10)
freewil commented 12 years ago

Have you setup bitcoin to listen for rpc commands or are you able to make any other api calls?

mcandre commented 12 years ago

getInfo seems to work, but because the API is sparse and JavaScript doesn't print objects well, I have no idea what getInfo and other commands take as input or what they give as output. I know that they use callbacks, but not much beyond that.

For me, getInfo(function (err, data) { console.log("Data: " + data); }); prints "Data: Object", which isn't very useful at all.

Another source of confusion: Are the RPC credentials meant for some global Bitcoin server or to connect to my local server?

Yet another source of confusion: If I have my Bitcoin GUI working and set to a specific Bitcoin wallet, how do I set a bitcoind server to use that wallet? I'm guessing that I should use setAccount, but I have no idea of the syntax nor the semantics for such an operation.

Cheers,

Andrew Pennebaker www.yellosoft.us

On Wed, Feb 1, 2012 at 9:26 PM, Sean < reply@reply.github.com

wrote:

Have you setup bitcoin to listen for rpc commands or are you able to make any other api calls?


Reply to this email directly or view it on GitHub: https://github.com/jb55/node-bitcoin/issues/6#issuecomment-3771583

freewil commented 12 years ago

Most of your confusion stems from a lack of understanding about how Bitcoin and the Bitcoin client works, please don't create any more issues that are not directly related to node-bitcoin.

If I have my Bitcoin GUI working and set to a specific Bitcoin wallet, how do I set a bitcoind server to use that wallet?

You can't have have two clients accessing the same wallet at the same time, I believe there is a lockfile created by the bitcoin client to prevent that.

console.log("Data: " + data); }); prints "Data: Object", which isn't very useful at all.

Try just printing the object by itself so it's not casted to a string: console.log(data)

Another source of confusion: Are the RPC credentials meant for some global Bitcoin server or to connect to my local server?

Local server.