diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 9f059d16..a37edde3 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -338,6 +338,29 @@ NAN_METHOD(IsStopped) { NanReturnValue(NanNew(shutdownComplete)); } +/** + * GetBlock(height) + * bitcoind.getBlock(height) + */ + +NAN_METHOD(GetBlock) { + NanScope(); + int nHeight = 0; + CBlockIndex *pindex = chainActive[nHeight]; + CBlock block; + if (ReadBlockFromDisk(block, pindex)) { + // const uint256 txhash = 0; + // uint256 hashBlock = pindex->GetBlockHash(); + // BOOST_FOREACH(const CTransaction &tx, block.vtx) { + // if (tx.GetHash() == txhash) { + // return true; + // } + // } + // NanReturnValue(NanNew("")); + } + NanReturnValue(NanNew(false)); +} + /** * start_node(void) * start_node_thread(void) @@ -651,6 +674,7 @@ init(Handle target) { NODE_SET_METHOD(target, "stop", StopBitcoind); NODE_SET_METHOD(target, "stopping", IsStopping); NODE_SET_METHOD(target, "stopped", IsStopped); + NODE_SET_METHOD(target, "getBlock", GetBlock); } NODE_MODULE(bitcoindjs, init)