├── .gitignore ├── node-dogecoin.png ├── package.json ├── LICENSE ├── test ├── test.crt ├── npm-debug.log └── test-node-dogecoin.js ├── lib ├── commands.js ├── errors.js └── dogecoin.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /node-dogecoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/countable/node-dogecoin/HEAD/node-dogecoin.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-dogecoin", 3 | "version": "0.3.9", 4 | "description": "DogeCoin client", 5 | "keywords": ["dogecoin"], 6 | "repository": "git://github.com/countable/node-dogecoin.git", 7 | "author": "Clark Van Oyen ", 8 | "main": "lib/dogecoin.js", 9 | "engines": { "node": ">= 0.4.0" }, 10 | "devDependencies": { 11 | "nodeunit": "*" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright 2012-2013 Brandon Wilson 4 | Copyright 2013-2014 Clark Van Oyen and other contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | -------------------------------------------------------------------------------- /test/test.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC/zCCAeegAwIBAgIJAND9YlfIsQOoMA0GCSqGSIb3DQEBBQUAMBYxFDASBgNV 3 | BAMMC2V4YW1wbGUuY29tMB4XDTE0MDMxMzAzNDgyNVoXDTI0MDMxMDAzNDgyNVow 4 | FjEUMBIGA1UEAwwLZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw 5 | ggEKAoIBAQCq8z1WML4VAQ2o5YY1cig9/zFi7KuGwg/B8MuRWXvf+hlCOtCwMAH5 6 | gOKNp9JN8hdL6y/fF/mLJYHpuJt5xT3yPe8xot3RrHHGMLWdc9D6su3f+qYLji5J 7 | GgKozKgCLdiIGxevVrGcaQgb1zyX8aI0+7VBTF6DNsQA1zdaPT1mdQM5J39yrIXZ 8 | 0VrmozdL4X+d3vFaxbixlxaL6T9T+1qWhuhHLxjzkGVTcWUoIQ8HipTNHs3HeisA 9 | p40RdB6JIff7ALYIAaDJFjy0U1whQhq6CVYlcyKOzs8dkULDITxPe+hyj+amdVzy 10 | YjkKKAE6sTWIQtfHATYbTAmNvAynqi4lAgMBAAGjUDBOMB0GA1UdDgQWBBQs7LNz 11 | /kPGRNsqZKYO3cgEjMZwFzAfBgNVHSMEGDAWgBQs7LNz/kPGRNsqZKYO3cgEjMZw 12 | FzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAdyg8mz8nMfy+XBtIS 13 | 5CtAiaiXDX5sAMN1po9nWZV8JmP9kNb4Sw5q/tBkFigOxNhpo5LukuzRXuHryUG7 14 | uRWxBebmrUqyeptSmrDhaQoUW1UA3KvjrT/EpBq6HHQZdZKHWdhI7cmEBMlPt5jm 15 | /pCQkgxnO2Q3+CDIfo+6N68v30OKSOwYP0wgRWnWEHiaXmPJcKPwvcfeKBAxrqet 16 | 8v29+B4xVG5SfZ8R8IOO61UWCNSV1061ETdXPdhpDGd3k3b8Z8EIKAnJs5ArRZgh 17 | 3ud3rT1bAXqxjfNr0bpVNLpkD9utBDFooLY40VJm/nOM4+cNiKBw9gT92FpnvuIG 18 | tQPj 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /lib/commands.js: -------------------------------------------------------------------------------- 1 | 2 | var commands = module.exports.commands = [ 3 | 'addMultiSigAddress' 4 | , 'backupWallet' 5 | , 'createRawTransaction' 6 | , 'decodeRawTransaction' 7 | , 'dumpPrivKey' 8 | , 'encryptWallet' 9 | , 'getAccount' 10 | , 'getAccountAddress' 11 | , 'getAddressesByAccount' 12 | , 'getBalance' 13 | , 'getBlock' 14 | , 'getBlockCount' 15 | , 'getBlockHash' 16 | , 'getBlockCount' 17 | , 'getConnectionCount' 18 | , 'getDifficulty' 19 | , 'getGenerate' 20 | , 'getHashesPerSec' 21 | , 'getHashesPerSec' 22 | , 'getInfo' 23 | , 'getMemoryPool' 24 | , 'getMemoryPool' 25 | , 'getMiningInfo' 26 | , 'getNewAddress' 27 | , 'getRawTransaction' 28 | , 'getReceivedByAccount' 29 | , 'getReceivedByAddress' 30 | , 'getTransaction' 31 | , 'getWork' 32 | , 'help' 33 | , 'importPrivKey' 34 | , 'importAddress' 35 | , 'keyPoolRefill' 36 | , 'listAccounts' 37 | , 'listReceivedByAccount' 38 | , 'listReceivedByAddress' 39 | , 'listSinceBlock' 40 | , 'listTransactions' 41 | , 'listUnspent' 42 | , 'move' 43 | , 'sendFrom' 44 | , 'sendMany' 45 | , 'sendRawTransaction' 46 | , 'sendToAddress' 47 | , 'setAccount' 48 | , 'setGenerate' 49 | , 'setTxFee' 50 | , 'signMessage' 51 | , 'signRawTransaction' 52 | , 'stop' 53 | , 'validateAddress' 54 | , 'verifyMessage' 55 | , 'walletLock' 56 | , 'walletPassphrase' 57 | , 'walletPassphraseChange' 58 | ] 59 | 60 | module.exports.isCommand = function(command) { 61 | command = command.toLowerCase() 62 | for (var i=0, len=commands.length; i 99 | 100 | Command 101 | Parameters 102 | Description 103 | Requires unlocked wallet? 104 | 105 | 106 | addmultisigaddress 107 | [nrequired] ["key","key"] [account] 108 | Currently only available on testnet Add a nrequired-to-sign multisignature address to the wallet. Each key is a dogecoin address or hex-encoded public key. If [account] is specified, assign address to [account]. 109 | N 110 | 111 | 112 | backupwallet 113 | [destination] 114 | Safely copies wallet.dat to destination, which can be a directory or a path with filename. 115 | N 116 | 117 | 118 | dumpprivkey 119 | [dogecoinaddress] 120 | Reveals the private key corresponding to 121 | Y 122 | 123 | 124 | encryptwallet 125 | [passphrase] 126 | Encrypts the wallet with 127 | N 128 | 129 | 130 | getaccount 131 | [dogecoinaddress] 132 | Returns the account associated with the given address. 133 | N 134 | 135 | 136 | getaccountaddress 137 | [account] 138 | Returns the current dogecoin address for receiving payments to this account. 139 | N 140 | 141 | 142 | getaddressesbyaccount 143 | [account] 144 | Returns the list of addresses for the given account. 145 | N 146 | 147 | 148 | getbalance 149 | [account] [minconf=1] 150 | If [account] is not specified, returns the server's total available balance.
If [account] is specified, returns the balance in the account. 151 | N 152 | 153 | 154 | getblock 155 | [hash] 156 | Returns information about the given block hash. 157 | N 158 | 159 | 160 | getblockcount 161 | 162 | Returns the number of blocks in the longest block chain. 163 | N 164 | 165 | 166 | getblockhash 167 | [index] 168 | Returns hash of block in best-block-chain at 169 | N 170 | 171 | 172 | getblocknumber 173 | 174 | Deprecated. Use getblockcount. 175 | N 176 | 177 | 178 | getconnectioncount 179 | 180 | Returns the number of connections to other nodes. 181 | N 182 | 183 | 184 | getdifficulty 185 | 186 | Returns the proof-of-work difficulty as a multiple of the minimum difficulty. 187 | N 188 | 189 | 190 | getgenerate 191 | 192 | Returns true or false whether dogecoind is currently generating hashes 193 | N 194 | 195 | 196 | gethashespersec 197 | 198 | Returns a recent hashes per second performance measurement while generating. 199 | N 200 | 201 | 202 | getinfo 203 | 204 | Returns an object containing various state info. 205 | N 206 | 207 | 208 | getmemorypool 209 | [data] 210 | If [data] is not specified, returns data needed to construct a block to work on: 211 |
  • "version": block version 212 |
  • "previousblockhash": hash of current highest block 213 |
  • "transactions": contents of non-coinbase transactions that should be included in the next block 214 |
  • "coinbasevalue": maximum allowable input to coinbase transaction, including the generation award and transaction fees 215 |
  • "time": timestamp appropriate for next block 216 |
  • "bits": compressed target of next block 217 |
218 |

If [data] is specified, tries to solve the block and returns true if it was successful. 219 |

220 | 221 | N 222 | 223 | 224 | getmininginfo 225 | 226 | Returns an object containing mining-related information: 227 |
  • blocks 228 |
  • currentblocksize 229 |
  • currentblocktx 230 |
  • difficulty 231 |
  • errors 232 |
  • generate 233 |
  • genproclimit 234 |
  • hashespersec 235 |
  • pooledtx 236 |
  • testnet 237 |
238 | 239 | N 240 | 241 | 242 | getnewaddress 243 | [account] 244 | Returns a new dogecoin address for receiving payments. If [account] is specified (recommended), it is added to the address book so payments received with the address will be credited to [account]. 245 | N 246 | 247 | 248 | getreceivedbyaccount 249 | [account] [minconf=1] 250 | Returns the total amount received by addresses with [account] in transactions with at least [minconf] confirmations. If [account] not provided return will include all transactions to all accounts. (version 0.3.24-beta) 251 | N 252 | 253 | 254 | getreceivedbyaddress 255 | [dogecoinaddress] [minconf=1] 256 | Returns the total amount received by 257 | N 258 | 259 | 260 | gettransaction 261 | [txid] 262 | Returns an object about the given transaction containing: 263 |
  • "amount": total amount of the transaction 264 |
  • "confirmations": number of confirmations of the transaction 265 |
  • "txid": the transaction ID 266 |
  • "time": time the transaction occurred 267 |
  • "details" - An array of objects containing: 268 |
    • "account" 269 |
    • "address" 270 |
    • "category" 271 |
    • "amount" 272 |
    273 |
274 | 275 | N 276 | 277 | 278 | getwork 279 | [data] 280 | If [data] is not specified, returns formatted hash data to work on: 281 |
  • "midstate": precomputed hash state after hashing the first half of the data 282 |
  • "data": block data 283 |
  • "hash1": formatted hash buffer for second hash 284 |
  • "target": little endian hash target 285 |
286 |

If [data] is specified, tries to solve the block and returns true if it was successful. 287 |

288 | 289 | N 290 | 291 | 292 | help 293 | [command] 294 | List commands, or get help for a command. 295 | N 296 | 297 | 298 | importprivkey 299 | [dogecoinprivkey] [label] 300 | Adds a private key (as returned by dumpprivkey) to your wallet. 301 | Y 302 | 303 | 304 | keypoolrefill 305 | 306 | Fills the keypool, requires wallet passphrase to be set. 307 | Y 308 | 309 | 310 | listaccounts 311 | [minconf=1] 312 | Returns Object that has account names as keys, account balances as values. 313 | N 314 | 315 | 316 | listreceivedbyaccount 317 | [minconf=1] [includeempty=false] 318 | Returns an array of objects containing: 319 |
  • "account": the account of the receiving addresses 320 |
  • "amount": total amount received by addresses with this account 321 |
  • "confirmations": number of confirmations of the most recent transaction included 322 |
323 | 324 | N 325 | 326 | 327 | listreceivedbyaddress 328 | [minconf=1] [includeempty=false] 329 | Returns an array of objects containing: 330 |
  • "address": receiving address 331 |
  • "account": the account of the receiving address 332 |
  • "amount": total amount received by the address 333 |
  • "confirmations": number of confirmations of the most recent transaction included 334 |
335 |

To get a list of accounts on the system, execute dogecoind listreceivedbyaddress 0 true 336 |

337 | 338 | N 339 | 340 | 341 | listsinceblock 342 | [blockhash] [target-confirmations] 343 | Get all transactions in blocks since block [blockhash], or all transactions if omitted. 344 | N 345 | 346 | 347 | listtransactions 348 | [account] [count=10] [from=0] 349 | Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]. If [account] not provided will return recent transaction from all accounts. 350 | 351 | N 352 | 353 | 354 | move 355 | [fromaccount] [toaccount] [amount] [minconf=1] [comment] 356 | Move from one account in your wallet to another 357 | N 358 | 359 | 360 | sendfrom 361 | [fromaccount] [todogecoinaddress] [amount] [minconf=1] [comment] [comment-to] 362 | 363 | Y 364 | 365 | 366 | sendmany 367 | [fromaccount] [address:amount,...] [minconf=1] [comment] 368 | amounts are double-precision floating point numbers 369 | Y 370 | 371 | 372 | sendtoaddress 373 | [dogecoinaddress] [amount] [comment] [comment-to] 374 | 375 | Y 376 | 377 | 378 | setaccount 379 | [dogecoinaddress] [account] 380 | Sets the account associated with the given address. Assigning address that is already assigned to the same account will create a new address associated with that account. 381 | N 382 | 383 | 384 | setgenerate 385 | [generate] [genproclimit] 386 | [generate] is true or false to turn generation on or off. 387 | 388 | Generation is limited to [genproclimit] processors, -1 is unlimited. 389 | N 390 | 391 | 392 | signmessage 393 | [dogecoinaddress] [message] 394 | Sign a message with the private key of an address. 395 | Y 396 | 397 | 398 | settxfee 399 | [amount] 400 | [amount] is a real and is rounded to the nearest 0.00000001 401 | N 402 | 403 | 404 | stop 405 | 406 | Stop dogecoin server. 407 | N 408 | 409 | 410 | validateaddress 411 | [dogecoinaddress] 412 | Return information about [dogecoinaddress]. 413 | N 414 | 415 | 416 | verifymessage 417 | [dogecoinaddress] [signature] [message] 418 | Verify a signed message. 419 | N 420 | 421 | 422 | walletlock 423 | 424 | Removes the wallet encryption key from memory, locking the wallet. After calling this method, you will need to call walletpassphrase again before being able to call any methods which require the wallet to be unlocked. 425 | N 426 | 427 | 428 | walletpassphrase 429 | [passphrase] [timeout] 430 | Stores the wallet decryption key in memory for 431 | N 432 | 433 | 434 | walletpassphrasechange 435 | [oldpassphrase] [newpassphrase] 436 | Changes the wallet passphrase from 437 | N 438 | 439 | 440 | ## Options 441 | 442 | You may pass options to the initialization function or to the `set` method. 443 | 444 | ```js 445 | 446 | var dogecoin = require('dogecoin')({ 447 | user:'user' 448 | }) 449 | 450 | dogecoin.set('pass', 'somn') 451 | dogecoin.set({port:22555}) 452 | 453 | ``` 454 | 455 | Available options and default values: 456 | 457 | + host *localhost* 458 | + port *22555* 459 | + user 460 | + pass 461 | + passphrasecallback 462 | + https 463 | + ca 464 | 465 | ### Passphrase Callback 466 | 467 | With an encryped wallet, any operation that accesses private keys requires a wallet unlock. A wallet is unlocked using the `walletpassphrase ` JSON-RPC method: the wallet will relock after `timeout` seconds. 468 | 469 | You may pass an optional function `passphrasecallback` to the `node-dogecoin` initialization function to manage wallet unlocks. `passphrasecallback` should be a function accepting three arguments: 470 | 471 | function(command, args, callback) {} 472 | 473 | + **command** is the command that failed due to a locked wallet. 474 | + **args** is the arguments for the failed command. 475 | + **callback** is a typical node-style continuation callback of the form `function(err, passphrase, timeout) {}`. Call callback with the wallet passphrase and desired timeout from within your passphrasecallback to unlock the wallet. 476 | 477 | You may hard code your passphrase (not recommended) as follows: 478 | 479 | ```js 480 | var dogecoin = require('node-dogecoin')({ 481 | passphrasecallback: function(command, args, callback) { 482 | callback(null, 'passphrase', 30); 483 | } 484 | }) 485 | ``` 486 | 487 | Because `passphrasecallback` is a continuation, you can retrieve the passphrase in an asynchronous manner. For example, by prompting the user: 488 | 489 | ```js 490 | var readline = require('readline') 491 | 492 | var rl = readline.createInterface({ 493 | input: process.stdin, 494 | output: process.stdout 495 | }) 496 | 497 | var dogecoin = require('node-dogecoin')({ 498 | passphrasecallback: function(command, args, callback) { 499 | rl.question('Enter passphrase for "' + command + '" operation: ', function(passphrase) { 500 | if (passphrase) { 501 | callback(null, passphrase, 1) 502 | } else { 503 | callback(new Error('no passphrase entered')) 504 | } 505 | }) 506 | } 507 | }) 508 | ``` 509 | 510 | ### Secure RPC with SSL 511 | 512 | By default `dogecoind` exposes its JSON-RPC interface via HTTP; that is, all RPC commands are transmitted in plain text across the network! To secure the JSON-RPC channel you can supply `dogecoind` with a self-signed SSL certificate and an associated private key to enable HTTPS. For example, in your `dogecoin.conf`: 513 | 514 | rpcssl=1 515 | rpcsslcertificatechainfile=/etc/ssl/certs/dogecoind.crt 516 | rpcsslprivatekeyfile=/etc/ssl/private/dogecoind.pem 517 | 518 | In order to securely access an SSL encrypted JSON-RPC interface you need a copy of the self-signed certificate from the server: in this case `dogecoind.crt`. Pass your self-signed certificate in the `ca` option and set `https: true` and node-dogecoin is secured! 519 | 520 | ```js 521 | var fs = require('fs') 522 | 523 | var ca = fs.readFileSync('dogecoind.crt') 524 | 525 | var dogecoin = require('node-dogecoin')({ 526 | user: 'rpcusername', 527 | pass: 'rpcpassword', 528 | https: true, 529 | ca: ca 530 | }) 531 | ``` 532 | 533 | ## Testing 534 | 535 | ``` 536 | npm install -g nodeunit 537 | 538 | nodeunit test/test-node-dogecoin.js 539 | ``` 540 | 541 | ## Bounties 542 | 543 | [Dogecoin](http://www.dogecoin.com) donation address is DE4isu3m2RBma7nGEwnaX8cu4Y2m2J2g8Q 544 | 545 | Donations in [dogecoin](http://www.dogecoin.com) will be used for bounties. The first bounty will be awarded for creating a unit test suite. As a side note: I encourage all GitHub repository owners to post a donation address so their community can easily support development financially. If you accept donations at your repository, [I'll send you a reward!](http://www.reddit.com/r/dogecoindev/comments/203ojs/add_a_dogecoin_donation_link_in_your_github_repo/) 546 | 547 | 548 | 549 | --------------------------------------------------------------------------------