#StackBounty: #blockchain #bitcoind #bitcoincore-development #node.js bitcoin setup using nodejs

Bounty: 100

I have to to use bitcoin api using nodejs. but I cannot understand from where I have to start.Search some node module like bitcoin-core and bitcoin.

Can anyone describe the step how can I set up bitcoin in our system and use using nodejs.
Also refer some link where use of bitcoin api request and response parameter are describe in nodejs.

I have to use bitcoin json-rpc api’s with node.js but dont know from where i can start?

Get this bounty!!!

#StackBounty: #node.js #apache #socket.io #phpwebsocket #phpws Trying to create a socket between servers with SocketIO and PHPws

Bounty: 50

I’m having a bit of an issue with websockets. So, I have a Rpi that provides me some data through a socketIO client in a pretty simple way. The following code shows how do I get to get this data:

<!DOCTYPE html>
    <title>SocketIO test</title>
        var client = io.connect('');
        client.on('connect', function() {
        client.on('raw', function(data){
        client.on('state', function(data){

However, what I need to implement is a little bit more complex. I need to use a Apache server to trait some of the data before it gets to the client side. The following image shows what I attempt to build:

enter image description here

To reach my goal I tried several WebSocket Servers and Client libraries for PHP until I found PHPws, which looks like the best solution for my scenario.
So, I read the examples, I test them and everything went well until I tried to connect to the Rpi with the following code:

$loop = ReactEventLoopFactory::create();
$logger = new ZendLogLogger();
$writer = new ZendLogWriterStream("php://output");

$client = new DevristoPhpwsClientWebSocket("ws://", $loop, $logger);
$client->on("connect", function() use ($logger, $client){
    $logger->notice("Or we can use the connect event!");
    $client->send("Hello world!");
$client->on("raw", function($message) use ($client, $logger){
    $logger->notice("Got message: ".$message->getData());
$client->open()->then(function() use($logger, $client){
    $logger->notice("We can use a promise to determine when the socket has been connected!");

I’ve more or less taken this example from Devristo’s github.

From the server side, the execution of the program is not throwing any error or message.

Is it possible to build what I want to build here with PHPws?
If so, am I connecting properly to de Rpi server with PHPws sample code shown?

Get this bounty!!!

#StackBounty: #javascript #node.js #api #express #passport.js How to Authenticate & Authorize a Client-Side Web App using Remote No…

Bounty: 50

As shown in the illustration below, I have a standalone API Project running on a server with a port say 3001, and I have a Web App running on a server with port say 3002.

Flow of Web APP to API

API on port 3001, has all the API routes required for the Web App (& mobile apps) to fetch and put data, including Authentication API (Using passport-local and passport-jwt). In the API side of the project, I have also handled user role authorization, and every routes has list of roles who can access the APIs.

Example Route


Role Authorization API Method in port 3001

exports.roleAuth = function(roles){

    return function(req, res, next){

        var user = req.user;

        User.findById(user._id, function(err, foundUser){

                res.status(422).json({error: 'No user found.'});
                return next(err);

            if(roles.indexOf(foundUser.role) > -1){
                return next();

            res.status(401).json({error: 'You are not authorized to view this content'});
            return next('Unauthorized');


Response json after login successfully is like this

    "token": "JWT eyJhbGci...",
    "user": {
        "_id": "5986b81d940bab06ddc79b34",
        "email": "myemail@gmail.com",
        "role": "admin"

Now in Web App, I want to use same role authorization and authentication (login), but you see, Web App is not connected to database, for me to make queries like check if the user in session is valid and has the role as in the response it got after login successfully.

Here are bullet points of what I was looking for in this question:

  1. Login on Client-Side Web Application, via Remote API on port 3001 (achieved)
  2. Get User Token and other information (response shown above) (achieved)
  3. Ensure user is authenticated on Client-Side Web App and also remember role of the user loggedin, to use these information for authorization of every routes on Client-side app. In client-side app I have few pages with forms to send data to Server-Side API on port 3002, these pages are used by two different user with roles editor and admin.


Get this bounty!!!

#StackBounty: #node.js #connect #http-proxy #har Node.js Proxy with custom Http(s) Agent and Connect.js Middleware

Bounty: 100

I’ve put together a proxy server in Node that needs the ability to tunnel https requests over tls and that all works. Using the the following two packages this was extremely easy to setup: proxy, https-proxy-agent. My issue is that I’m trying to capture HAR files using connect as a middleware layer and I’m getting the following error:

throw new Error('Can't set headers after they are sent.');
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11)
at ServerResponse.writeHead (_http_server.js:180:21)
at ClientRequest.<anonymous> (/.../node_modules/proxy/proxy.js:233:11)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:473:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
at Socket.socketOnData (_http_client.js:362:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)

The is as simple as the following and it only seems to happen when I’m using connect and proxying through my local browser(this proxy is actually being used with BrowserStackLocal). When I pass through the proxy from anything other than my local machines browser, it’s like it doesn’t even know the middleware exists.

So basically, I just need to get connect working in this scenario and I’m not sure if I need to pause something and resume, or what… any ideas would be greatly appreciated. The base code is below:

const path = require('path');
const http = require('http');
const proxy = require('proxy');
const Agent = require('https-proxy-agent');
const connect = require('connect');
const har = require('./har');

const middleware = connect();

  harOutputDir: path.resolve(process.cwd(), 'har/')

const server = proxy(http.createServer(middleware));
server.agent = new Agent('http://localhost:8081');



EDIT: Just a note: the har middleware is not modifying headers at all.

Get this bounty!!!

#StackBounty: #javascript #node.js #jinja2 #nunjucks Precompiling Nunjucks templates with jinja2 compatibility mode

Bounty: 50

Nunjucks has more and more powerful jinja compatibility mode. If I include full nunjucks I can use it calling nunjucks.installJinjaCompat() before rendering templates (see snippet below):

var res = nunjucks.renderString(
  '{% for i in list[0:2] %}' +
  '  count: {{ i }}' +
  '{% endfor %}',
  {list: [1, 2, 3, 4]}

I cannot figure out how to precompile the same code though. Having file list.njk:

{% for i in list[0:2] %}
    count: {{ i }}
{% endfor %}

I precompile using default nunjucks-precompile list.njk > list.js command, but it raises:

        throw lib.prettifyError(name, false, err);

Template render error: (list.njk) [Line 1, Column 15]
  parseAggregate: expected comma after expression
    at Object.exports.prettifyError (/usr/local/lib/node_modules/nunjucks/src/lib.js:34:15)
    at _precompile (/usr/local/lib/node_modules/nunjucks/src/precompile.js:130:19)
    at precompile (/usr/local/lib/node_modules/nunjucks/src/precompile.js:79:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/nunjucks/bin/precompile:62:13)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)

error if I use array splicing which is jinja-compatibility specific construct. It compiles if I remove [0:2].

How can I precompile templates taking adventage of jinja compat mode?

I have already tried finding this in documentation, nunjucks issues and checking nunjucks-precompile node script for nunjucks variable so I could monkeypatch it including nunjucks.installJinjaCompat() call; sadly it is not there, it only uses Environment.

Get this bounty!!!

#StackBounty: #javascript #node.js #algorithm Punch multiple strings into a single (shortest possible) string that includes all the cha…

Bounty: 50

My purpose is to punch multiple strings into a single (shortest) string that will contain all the character of each string in a forward direction. The question is not specific to any language, but more into the algorithm part. (probably will implement it in a node server, so tagging nodejs/javascript).

So, to explain the problem:

Lets consider I have few strings

["jack", "apple", "maven", "hold", "solid", "mark", "moon", "poor", "spark", "live"]

The Resultant string should be something like:


jack: sjmachppoalidveonrk

apple: sjmachppoalidveonrk

solid: sjmachppoalidveonrk

====================================>>>> all in the forward direction

These all are manual evaluation and the output may not 100% perfect in the example.

So, the point is all the letters of each strings have to exists in the output in
FORWARD DIRECTION (here the actual problem belongs), and possibly the server will send the final strings and numbers like 27594 will be generated and passed to extract the token, in the required end. If I have to punch it in a minimal possible string it would have much easier (That case only unique chars are enough). But in this case there are some points:

  1. Letters can be present multiple time, though I have to reuse any
    letter if possible, eg: for solid and hold o > l > d can be
    reused as forward direction but for apple (a > p) and spark
    (p > a) we have to repeat a as in one case it appears before p
    for apple, and after p for sparks so either we need to repeat
    a or p. we cannot do p > a > p as it will cover both the case
    because we need two p after a

  2. We directly have no option to place a single p and use the same
    index twice in time of extract, we need multiple p with no option
    left as the input token contains that

  3. I am (not) sure, that there is multiple output possible for a set of
    strings. but the concern is it should me minimal in length,
    the combination doesn’t matter if its cover all the tokens
    in a forward direction. all (or one ) outputs of minimal possible length
    need to trace.

I have tried, by starting with a arbitrary string, and then made a analysis of next string and splitting all the letters, and place them accordingly, but after some times, it seems that current string letters can be placed in a better way, If the last string’s (or a previous string’s) letters was placed according to the current string. But again that string was analyzed and placed based on something (multiple) what was processed, and placing something on the favor of something what is not processed seems difficult, because to that we need to process that. Or might me maintaining a tree of all processed/unprocessed tree will help, building the building the final string. Any better way than it, It seems a brute force!

Note: I know there are a lot of other transformation possible, please try not to suggest anything else to use, we are doing a bit research on it, and anything in the context of question will be highly appreciated. If anything is not clear or need any further explanation feel free to comment. Thanks a ton for reading the entire problem with patience.

Get this bounty!!!

#StackBounty: #node.js #mongodb #ffmpeg #fluent-ffmpeg fluent-ffmpeg from an array of input files

Bounty: 50

I want to use fluent-ffmpeg to create a video of last n images of a directory, or database entries.

Which is the correct syntax?

These are my tries:

Mimic shell command

  .addInput('ls *png | tail -n 17')
  .inputOptions("-pattern_type glob")

but it does not accept shell commands;

space – separated paths

  .addInput('a*.png b*.png ')
  .inputOptions("-pattern_type glob")

but it does not accept list of files separated by spaces;

Array of image paths

  .addInput(array) // ['aa.png', 'a1.png',,,'bbb.png']
  .inputOptions("-pattern_type glob")

but it does not accept arrays.


Also, from Merge Multiple Videos using node fluent ffmpeg, I am able to add multiple inputs using an array of files as

var ffmpeg= require('fluent-ffmpeg');
var f=ffmpeg() 
pngarr.forEach(p => f.input(p)) /// pngarr is my array of png paths

But running


I obtain just a video of 0 seconds containing the first png of the list.

Get this bounty!!!

#StackBounty: #node.js #typescript #webstorm WebStorm tsconfig.json appears to not update the correct files

Bounty: 50

I am developing a node.js application using TypeScript.

I’ve created a TypeScript file in the root folder of my project. I run tsconfig and it appears to update the dist folder. However, when I run the app, I am getting an error indicating a function is not defined.

Here is where things get confusing: there seems to be older versions of the .js and .map files in my src folder in the same directories as my source files with the same names. This .js file seems to have an older version of the file missing the necessary functions (class methods), different from the current versions in my /dist folder.

At the end of the day, I am trying to run the debugger on the files in my /dist folder and set breakpoints over in my /src TypeScript files.

This is a sample of the file structure I am seeing in my /src folder (this js file is not current):

enter image description here

Here is a sample of the file structure of my /dist folder where the transpiled js code resides:

enter image description here

Also, here are the debugger settings for the web app (rest) portion of the project:

enter image description here

Finally, here is a sample of the tsconfig.json file:

  "compilerOptions": {
    "module": "commonjs",
    "target": "ES5",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "types": ["reflect-metadata"],
    "lib": ["ES6"],
    "sourceMap": true,
    "inlineSources": true,
    "pretty": true,
    "outDir": "./dist",
    "rootDir": "./src/",
    "noLib": false
  "compileOnSave": true,
  "include": [
  "exclude": [
  1. I would like to understand what is wrong, causing it to read the wrong js files, instead of the ones in the /dist folder?

  2. What can I do to fix this to point to the /dist folder. I thought the debugger settings I setup would do that, but this does not appear to be the case.

Any help would be greatly appreciated.

Update: I deleted the .js files that were generated in the src folder and they eventually returned back to the folder and once again, they were not current after making other changes. I am not sure what is generating these files; is it a setting in webstorm or is it in tsconig.json?

Something else doesn’t look right. When I opened one of the files in the dist folder, I found the following code instead of js code:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=group.js.map

This is not what I was expecting, as I was expecting to see the transpiled js code.

Get this bounty!!!

#StackBounty: #gratis #open-source #command-line #node.js Convert Website to Android APK in Command Line

Bounty: 50

I was wondering does anyone know if there’s a tool similar to nativefier that allows you to convert any website as an android app/apk?

Get this bounty!!!

#StackBounty: #node.js #express #react-router #apollo #react-apollo Server side rendering with Apollo: getaddrinfo ENOTFOUND

Bounty: 100

I’m running Apollo/React with Express and I’m trying to get server side rendering to work. The Apollo docs suggest the following initialisation code for connecting to the API server:

app.use((req, res) => {
  match({ routes, location: req.originalUrl }, (error, redirectLocation, renderProps) => {
    const client = new ApolloClient({
      ssrMode: true,
      networkInterface: createNetworkInterface({
        uri: 'http://localhost:3000', // Instead of 3010
        opts: {
          credentials: 'same-origin',
          headers: {
            cookie: req.header('Cookie'),

    const app = (
      <ApolloProvider client={client}>
        <RouterContext {...renderProps} />

    getDataFromTree(app).then(() => {
      const content = ReactDOM.renderToString(app);
      const initialState = {[client.reduxRootKey]: client.getInitialState()  };
      const html = <Html content={content} state={initialState} />;
      res.send(`<!doctype html>n${ReactDOM.renderToStaticMarkup(html)}`);


which uses the match() function from React Router v3 (as evidenced by package.json in the “GitHunt” example linked from the docs). I’m using React Router v4 from which match() is absent, so I refactored the code as follows, using renderRoutes() from the react-router-config package.

app.use((req, res) => {
  const client = new ApolloClient(/* Same as above */)

  const context = {}

  const app = (
    <ApolloProvider client={client}>
      <StaticRouter context={context} location={req.originalUrl}>
        { renderRoutes(routes) }

  getDataFromTree(app).then(/* Same as above */)

My understanding is that <StaticRouter> obviates the use of match(). However react-router-config provides a matchRoutes() function which seems to provide a similar functionality (albeit without the callback) if needed.

When I visit http://localhost:3000, the page loads as expected and I can follow links to subdirectories (e.g. http://localhost:3000/folder). When I try to directly load a subdirectory by typing in the name in the address bar, my browser keeps waiting for the server to respond. After about six seconds, Terminal shows one of the following errors (not sure what causes the error to change on subsequent tries):

(node:1938) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): Error: Network error: request to
http://localhost:3000 failed, reason: getaddrinfo ENOTFOUND localhost


(node:8691) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): Error: Network error: request to
http://localhost:3000 failed, reason: socket hang up

I’ve been struggling with this problem for a few hours now, but can’t seem to figure it out. The solution to a similar problem seems unrelated to this case. Any help will be much appreciated!

Further information

If I don’t kill the nodemon server, after some time I get thousands of the following errors:

POST / – – ms – –

(node:1938) UnhandledPromiseRejectionWarning:
Unhandled promise rejection (rejection id: 4443): Error: Network
error: request to http://localhost:3000 failed, reason: socket hang up

If I do kill the server, however, I immediately get this error instead:


writer.on("drain", function() {


TypeError: Cannot read property ‘on’ of undefined

at duplex (/Users/…/node_modules/duplexer/index.js:31:11)

at Object.module.exports (/Users/…/node_modules/stream-combiner/index.js:8:17)

at childrenOfPid (/Users/…/node_modules/ps-tree/index.js:50:6)

at kill (/Users/…/node_modules/nodemon/lib/monitor/run.js:271:7)

at Bus.onQuit (/Users/…/node_modules/nodemon/lib/monitor/run.js:327:5)

at emitNone (events.js:91:20)

at Bus.emit (events.js:188:7)

at process. (/Users/…/node_modules/nodemon/lib/monitor/run.js:349:9)

at Object.onceWrapper (events.js:293:19)

at emitNone (events.js:86:13)

Also, port 3000 is correct. If I change the number, I get a different error instead:

(node:2056) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): Error: Network error: request to
http://localhost:3010 failed, reason: connect ECONNREFUSED

Get this bounty!!!