jb55 / node-bitcoin

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

Sparse API #7

Closed mcandre closed 12 years ago

mcandre commented 12 years ago

I'm looking at the API and it's really confusing.

I should be able to set the bitcoin address using setaddress, but I have no idea how accounts work. Can I omit the account and just specify a bitcoin address?

Would the following make sense in node-bitcoin?

var myBitCoinAddress = "abc1234567890qwertyQWERTY";
client.setAddress(myBitcoinAddress);
freewil commented 12 years ago

That API page is actually for the official bitcoin client. node-bitcoin directly maps to that API. I think you meant the API call setAccount. You cannot just choose any random string for an address, you must first generate an address, which you can use getNewAddress to do, optionally specifying an account to associate it with. This will generate the public address and add the private key to your wallet. Addresses are public strings that can be used to receive coins, accounts are really for yourself. I think in the GUI, it is the 'label' field in the address book. For more help with using the bitcoin client or the API you can join #bitcoin on FreeNode IRC.