bitcoind.js
This commit is contained in:
commit
3e355bd0fc
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
node_modules/*
|
||||||
|
out/*
|
||||||
|
build/*
|
||||||
|
.lock-wscript
|
||||||
|
Makefile.gyp
|
||||||
|
*.swp
|
||||||
|
*.Makefile
|
||||||
|
*.target.gyp.mk
|
||||||
|
*.node
|
||||||
|
*.sln
|
||||||
|
*.sdf
|
||||||
|
*.vcxproj
|
||||||
|
*.suo
|
||||||
|
*.opensdf
|
||||||
|
*.filters
|
||||||
|
*.user
|
||||||
|
*.project
|
||||||
|
test.js
|
||||||
10
.npmignore
Normal file
10
.npmignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.git*
|
||||||
|
build/
|
||||||
|
.lock-wscript
|
||||||
|
out/
|
||||||
|
Makefile.gyp
|
||||||
|
*.Makefile
|
||||||
|
*.target.gyp.mk
|
||||||
|
node_modules/
|
||||||
|
test/
|
||||||
|
*.node
|
||||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2014, BitPay
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
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.
|
||||||
20
Makefile
Normal file
20
Makefile
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
all:
|
||||||
|
@type node-gyp > /dev/null 2>&1 && make gyp || make waf
|
||||||
|
|
||||||
|
waf:
|
||||||
|
node-waf configure build
|
||||||
|
|
||||||
|
gyp:
|
||||||
|
node-gyp configure
|
||||||
|
node-gyp build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@type node-gyp > /dev/null 2>&1 && make clean-gyp || make clean-waf
|
||||||
|
|
||||||
|
clean-waf:
|
||||||
|
@rm -rf ./build .lock-wscript
|
||||||
|
|
||||||
|
clean-gyp:
|
||||||
|
@node-gyp clean 2>/dev/null
|
||||||
|
|
||||||
|
.PHONY: all waf gyp clean clean-waf clean-gyp
|
||||||
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# bitcoind.js
|
||||||
|
|
||||||
|
Bitcoind for node
|
||||||
|
|
||||||
|
## Contribution and License Agreement
|
||||||
|
|
||||||
|
If you contribute code to this project, you are implicitly allowing your code
|
||||||
|
to be distributed under the MIT license. You are also implicitly verifying that
|
||||||
|
all code is your original work. `</legalese>`
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2014, BitPay (MIT License).
|
||||||
16
binding.gyp
Normal file
16
binding.gyp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
'targets': [{
|
||||||
|
'target_name': 'bitcoindjs',
|
||||||
|
'include_dirs' : [
|
||||||
|
'<!(node -e "require(\'nan\')")',
|
||||||
|
],
|
||||||
|
'sources': [
|
||||||
|
'src/bitcoindjs.cc'
|
||||||
|
],
|
||||||
|
'libraries': [
|
||||||
|
'-lutil',
|
||||||
|
'-L/usr/lib',
|
||||||
|
'-L/usr/local/lib'
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
||||||
2
index.js
Normal file
2
index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var os = process.platform === 'win32' ? '_win' : '';
|
||||||
|
module.exports = require('./lib/pty'+ os +'.js');
|
||||||
39
lib/bitcoind.js
Normal file
39
lib/bitcoind.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* bitcoind.js
|
||||||
|
* Copyright (c) 2014, BitPay (MIT License)
|
||||||
|
* A bitcoind node.js binding.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var net = require('net');
|
||||||
|
var EventEmitter = require('events').EventEmitter;
|
||||||
|
var bitcoindjs = require('../build/Release/bitcoindjs.node');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bitcoin
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Bitcoin(flag) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if (!(this instanceof Bitcoind)) {
|
||||||
|
return new Bitcoind(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventEmitter.call(this);
|
||||||
|
|
||||||
|
var ret = bitcoindjs.start(function() {
|
||||||
|
self.emit('open');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.ret = ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitcoin.prototype.__proto__ = EventEmitter.prototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = exports = Bitcoin;
|
||||||
|
exports.Bitcoin = Bitcoin;
|
||||||
|
exports.native = bitcoindjs;
|
||||||
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "bitcoind.js",
|
||||||
|
"description": "Node binding for bitcoind",
|
||||||
|
"author": "Christopher Jeffrey",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"main": "./index.js",
|
||||||
|
"repository": "git://github.com/chjj/bitcoind.js.git",
|
||||||
|
"homepage": "https://github.com/chjj/bitcoind.js",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/chjj/bitcoind.js/issues"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"pty",
|
||||||
|
"tty",
|
||||||
|
"terminal"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "NODE_ENV=test mocha -R spec"
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"bitcoin",
|
||||||
|
"bitcoind"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"nan": "~1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "~1.16.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/bitcoindjs.cc
Normal file
69
src/bitcoindjs.cc
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* bitcoind.js
|
||||||
|
* Copyright (c) 2014, BitPay (MIT License)
|
||||||
|
*
|
||||||
|
* bitcoindjs.cc:
|
||||||
|
* A bitcoind node.js binding.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nan.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
using namespace node;
|
||||||
|
using namespace v8;
|
||||||
|
|
||||||
|
NAN_METHOD(StartBitcoind);
|
||||||
|
|
||||||
|
static int
|
||||||
|
misc_func(const char *);
|
||||||
|
|
||||||
|
extern "C" void
|
||||||
|
init(Handle<Object>);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StartBitcoind
|
||||||
|
* bitcoind.start(callback)
|
||||||
|
*/
|
||||||
|
|
||||||
|
NAN_METHOD(StartBitcoind) {
|
||||||
|
NanScope();
|
||||||
|
|
||||||
|
if (args.Length() < 1 || !args[0]->IsFunction()) {
|
||||||
|
return NanThrowError(
|
||||||
|
"Usage: bitcoind.start(callback)");
|
||||||
|
}
|
||||||
|
|
||||||
|
Local<Object> obj = NanNew<Object>();
|
||||||
|
obj->Set(NanNew<String>("foo"), NanNew<Number>(100));
|
||||||
|
|
||||||
|
NanReturnValue(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* misc_func
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
misc_func(const char *file) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" void
|
||||||
|
init(Handle<Object> target) {
|
||||||
|
NanScope();
|
||||||
|
NODE_SET_METHOD(target, "start", StartBitcoind);
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_MODULE(bitcoindjs, init)
|
||||||
17
wscript
Normal file
17
wscript
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
srcdir = "."
|
||||||
|
blddir = "build"
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
|
||||||
|
def set_options(opt):
|
||||||
|
opt.tool_options("compiler_cxx")
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.check_tool("compiler_cxx")
|
||||||
|
conf.check_tool("node_addon")
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
|
||||||
|
obj.cxxflags = ["-Wall"]
|
||||||
|
obj.linkflags = []
|
||||||
|
obj.target = "bitcoindjs"
|
||||||
|
obj.source = "src/bitcoindjs.cc"
|
||||||
Loading…
Reference in New Issue
Block a user