diff --git a/README.md b/README.md index 3af8f0a..b4ece18 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -node-libcoin -============ +libcoin +======= Nodejs Bitcoin Library diff --git a/RpcClient.js b/RpcClient.js new file mode 100644 index 0000000..224706a --- /dev/null +++ b/RpcClient.js @@ -0,0 +1,176 @@ +// RpcClient.js +// MIT/X11-like license. See LICENSE.txt. +// Copyright 2013 BitPay, Inc. +require('classtool'); + +function ClassSpec(b) { + var http = b.http || require('http'); + var https = b.https || require('https'); + + function RpcClient(opts) { + opts = opts || {}; + this.host = opts.host || '127.0.0.1'; + this.port = opts.port || 8332; + this.user = opts.user || 'user'; + this.pass = opts.pass || 'pass'; + this.protocol = (opts.protocol == 'http') ? http : https; + } + + var callspec = { + addMultiSigAddress: '', + addNode: '', + backupWallet: '', + createMultiSig: '', + createRawTransaction: '', + decodeRawTransaction: '', + dumpPrivKey: '', + encryptWallet: '', + getAccount: '', + getAccountAddress: '', + getAddedNodeInfo: '', + getAddressesByAccount: '', + getBalance: '', + getBlock: '', + getBlockCount: '', + getBlockHash: 'int', + getBlockNumber: '', + getBlockTemplate: '', + getConnectionCount: '', + getDifficulty: '', + getGenerate: '', + getHashesPerSec: '', + getInfo: '', + getMemoryPool: '', + getMiningInfo: '', + getNewAddress: '', + getPeerInfo: '', + getRawMemPool: '', + getRawTransaction: 'str int', + getReceivedByAccount: 'str int', + getReceivedByAddress: 'str int', + getTransaction: '', + getTxOut: 'str int bool', + getTxOutSetInfo: '', + getWork: '', + help: '', + importPrivKey: 'str str bool', + keypoolRefill: '', + listAccounts: 'int', + listAddressGroupings: '', + listReceivedByAccount: 'int bool', + listReceivedByAddress: 'int bool', + listSinceBlock: 'str int', + listTransactions: 'str int int', + listUnspent: 'int int', + listLockUnspent: 'bool', + lockUnspent: '', + move: 'str str float int str', + sendFrom: 'str str float int str str', + sendMany: 'str str int str', //not sure this is will work + sendRawTransaction: '', + sendToAddress: 'str float str str', + setAccount: '', + setGenerate: 'bool int', + setTxFee: 'float', + signMessage: '', + signRawTransaction: '', + stop: '', + submitBlock: '', + validateAddress: '', + verifyMessage: '', + walletLock: '', + walletPassphrase: 'string int', + walletPassphraseChange: '', + }; + + var slice = function(arr, start, end) { + return Array.prototype.slice.call(arr, start, end); + }; + + function generateRPCMethods(constructor, apiCalls, rpc) { + function createRPCMethod(methodName, argMap) { + return function() { + for (var i=0; i