From 3e355bd0fcfe0a5ab77dd7bb9e512271e5a51d42 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 12 Aug 2014 15:03:04 -0400 Subject: [PATCH] bitcoind.js --- .gitignore | 18 +++++++++++++ .npmignore | 10 +++++++ LICENSE | 19 +++++++++++++ Makefile | 20 ++++++++++++++ README.md | 13 +++++++++ binding.gyp | 16 +++++++++++ index.js | 2 ++ lib/bitcoind.js | 39 +++++++++++++++++++++++++++ package.json | 30 +++++++++++++++++++++ src/bitcoindjs.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++ wscript | 17 ++++++++++++ 11 files changed, 253 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 binding.gyp create mode 100644 index.js create mode 100644 lib/bitcoind.js create mode 100644 package.json create mode 100644 src/bitcoindjs.cc create mode 100644 wscript diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..98d77135 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..cd70b6e4 --- /dev/null +++ b/.npmignore @@ -0,0 +1,10 @@ +.git* +build/ +.lock-wscript +out/ +Makefile.gyp +*.Makefile +*.target.gyp.mk +node_modules/ +test/ +*.node diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..2d7b0fe0 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ceb96145 --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 00000000..df0e7570 --- /dev/null +++ b/README.md @@ -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. `` + +## License + +Copyright (c) 2014, BitPay (MIT License). diff --git a/binding.gyp b/binding.gyp new file mode 100644 index 00000000..c11917f9 --- /dev/null +++ b/binding.gyp @@ -0,0 +1,16 @@ +{ + 'targets': [{ + 'target_name': 'bitcoindjs', + 'include_dirs' : [ + ' +#include +#include + +#include +#include +#include +#include + +using namespace node; +using namespace v8; + +NAN_METHOD(StartBitcoind); + +static int +misc_func(const char *); + +extern "C" void +init(Handle); + +/** + * StartBitcoind + * bitcoind.start(callback) + */ + +NAN_METHOD(StartBitcoind) { + NanScope(); + + if (args.Length() < 1 || !args[0]->IsFunction()) { + return NanThrowError( + "Usage: bitcoind.start(callback)"); + } + + Local obj = NanNew(); + obj->Set(NanNew("foo"), NanNew(100)); + + NanReturnValue(obj); +} + +/** + * misc_func + */ + +static int +misc_func(const char *file) { + return 0; +} + +/** + * Init + */ + +extern "C" void +init(Handle target) { + NanScope(); + NODE_SET_METHOD(target, "start", StartBitcoind); +} + +NODE_MODULE(bitcoindjs, init) diff --git a/wscript b/wscript new file mode 100644 index 00000000..92d54bac --- /dev/null +++ b/wscript @@ -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"