ruimarinho / bitcoin-core

A modern Bitcoin Core REST and RPC client.
477 stars 186 forks source link

pls help me get this work. #73

Closed edmlbox closed 5 years ago

edmlbox commented 6 years ago

In console i receive next error: TypeError: client.getnetworkinfo is not a function.

untitled I'm trying to use bitcoin-rpc commands on testnet but nothing works. My bitcoind server running at http://127.0.0.1:18332/; Look the code below that i use in my node app;


var express = require('express');
var app = express();
const Client = require('bitcoin-core');

app.get('/', function(req, res) {
  res.send('Hello World!');
});

const client = new Client({ host:'localhost',network: 'testnet', port: "18332", username:"user",password:"pass"});

client.getnetworkinfo().then((help) => console.log(help));

app.listen(3000, function() {
    console.log('Example app listening on port 3000!');
  });

What I do wrong? I follow your example tutorial; The only command that work is client.stop();

marinflorin commented 6 years ago

Hey, please check the following link: https://www.npmjs.com/package/bitcoin-core#methods

All RPC methods are exposed on the client interface as a camelcase'd version of those available on bitcoind

Exampes:

client.createRawTransaction([{ txid: '1eb590cd06127f78bf38ab4140c4cdce56ad9eb8886999eb898ddf4d3b28a91d', vout: 0 }], { 'mgnucj8nYqdrPFh2JfZSB1NmUThUGnmsqe': 0.13 });
client.sendMany('test1', { mjSk1Ny9spzU2fouzYgLqGUD8U41iR35QN: 0.1, mgnucj8nYqdrPFh2JfZSB1NmUThUGnmsqe: 0.2 }, 6, 'Example Transaction');
client.sendToAddress('mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.1,  'sendtoaddress example', 'Nemo From Example.com');

Hope it helps, Florin

pedrobranco commented 5 years ago

Closing this as it seems to be already answered.