blockcypher / node-client Goto Github PK
View Code? Open in Web Editor NEWNode.js SDK for the BlockCypher Web services. See http://www.blockcypher.com
License: MIT License
Node.js SDK for the BlockCypher Web services. See http://www.blockcypher.com
License: MIT License
Since replacing requests by superagent and #37 get and post unit tests are not working. Any help appreciated.
The version installed by npm contains old code, though the package.json
has the "latest" 0.2, the version number doesn't seem to have been altered after recent changes.
Note that the !error
below is a bug that was has already been fixed
> npm install blockcypher@latest
> grep '!error' node_modules/blockcypher/lib/bcypher.js
if (!error || response.statusCode !== 200) {
if (!error || (response.statusCode !== 200 && response.statusCode !== 201)) {
if (!error || response.statusCode !== 204) {
> grep 'version' node_modules/blockcypher/package.json
"version" : "0.2.0",
Blockcypher makes this page available to push transactions: https://live.blockcypher.com/btc-testnet/pushtx/
I don't see a way in this module to make use of that functionality. am I missing something?
Looks like getBlock()
is broken now.
To reproduce, just run the example in the README.md file
This repo needs an update
main
and test3
are working.
test
is not at time of writing.
I get the following response Endpoint not found. Please check your URL for typos and make sure you're using the correct HTTP method (GET, POST, etc).
The documentation should have examples based on this library.
Hi, I need help, I register on blockcypher and I have only api token, how can I get "extended_public_key" and how can I create HD wallet using node-client?
I am using the Blockcypher API for test bitcoin transactions and I have troubles with the websocket API endpoint.
When sending the regular ping object after creating a new Websocket it works fine:
this.ws.onopen = () => {
this.ws.send(JSON.stringify({"event": "ping"}))
but when trying to check the confidence of a transaction like this we get an error
this.ws.onopen = () => {
this.ws.send(JSON.stringify({event: 'tx-confidence', address:'<bitcoin address as string>', confidence:0.9}))
These are the references I am using are
API reference
Event reference
Is there anything wrong with the datatypes? Any help would be great!
If you are willing to only support node 4+, xtend can be replaced with object.assign.
request.del()
at
Line 654 in c2b99e9
error: {
"errno": "ECONNREFUSED",
"code": "ECONNREFUSED",
"syscall": "connect",
"address": "127.0.0.1",
"port": 80
}
When I replace the request.del()
call with this HTTP.call()
deletion works:
const response = HTTP.call("DELETE", urlr,
{
query: "token=" + Meteor.settings.BC_TOKEN
})
if (response.statusCode === 204) {
console.log("webhook deleted successfully: ", response.statusCode)
return true
} else {
console.error("error when deleting webhook:", response.statusCode)
console.log("response.content:", response.content)
}
Please fix this.
All hooks endpoints are returning the following for me: Endpoint not found. Please check your URL for typos and make sure you're using the correct HTTP method (GET, POST, etc).
// $ TOKEN=<My Token> node index.js
// Endpoint not found. Please check your URL for typos and make sure you're using the correct HTTP method (GET, POST, etc).
const bcypher = require('blockcypher');
var ecapi = new bcypher('eth','main', process.env.TOKEN);
var webhook = {
event: "unconfirmed-tx",
address: "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
url: "https://my.domain.com/callbacks/new-tx"
};
ecapi.createHook(webhook, (t) => console.log(t.response.text));
I've tried generating a new token with no luck.
Let me know if there's anything else that would be helpful to debug. Thanks!
Hello,
I'm having an issue with my transaction processing.
It's been almost 24 hours and my transaction is still labeled as unspent.
Can someone help me with this?
The method getBlock and others have an optional second parameter. Allow it be a callback function if caller does not want to pass any parameters.
//current
bcapi.getBlock(300000, {}, printResponse); //works
bcapi.getBlock(300000, printResponse); //fails with cb is not a function error
//proposed
bcapi.getBlock(300000, {}, printResponse); //works
bcapi.getBlock(300000, printResponse); //works
I have created a wallet with name: "test wallet" and it seems the url generated is like this:
https://api.blockcypher.com/v1/bcy/test/wallets/test wallet/addresses
It works using the url encoded version of the wallet name:
https://api.blockcypher.com/v1/bcy/test/wallets/test%20wallet/addresses
I create the new-block and confirmed-tx events webhook, which url is generated by ngrok service.
I can access the url by postman and other request tool, but I cannot receive the webhook event.
Am I wrong?
let hook = {
"event": "confirmed-tx",
// "url": "http://192.168.137.1:3721/api/test"
"url": "https://2ea43af3c8bd.ngrok.io/btc/cb"
}
bcapi.createHook(hook, (err, data) => {
if (err !== null) {
console.error("hook error:", err);
} else {
console.log(data)
}
})
the webhook is create successfully!
How can I test the event!
So this works fine with BTC but not ETH? I'm trying to create a webhook for ETH address and listen for unconfirmed transactions. With BTC this works as usual and I can see created webhook in https://accounts.blockcypher.com/tokens/hooks/token
but when I create the same hook but initiate the blockcypher
class with ETH -> it responds me that webhook was created but I can't find it. And it definitely wont work.
const bcApi = new blockCypher('btc', 'main', process.env.BTC_WEBHOOKS_API_TOKEN)
- works
const bcApi = new blockCypher('eth', 'main', process.env.BTC_WEBHOOKS_API_TOKEN)
- does not work
how to solve this?
I've wrote a version of the SDK in my fork
If it was a interesting thing for you guys and it's relevant I can make a pull request.
Hi Blockcypher team,
I got some help earlier on the correct way to format a transaction using the TX skeleton, so I decided to try it again when I got home. I created a new, un-broadcasted, transaction, and I got this error when posting:
{ error: 'Error validating transaction: Transaction 02b1be3be0a6a4f7d8e369cca88520443b3fc0993d3660d4d52e5f383d505650 has an input referencing an unknown transaction: d69adc7c6a355ea4297755350f86c52710a6ebd72a150215c276f3cd4c659d5e.' }
The transaction referenced in the error has 6 confirmations after about an hour:
Is there a minimum amount of transactions needed for the API to broadcast? Thanks again for helping me earlier!
Here's the raw transaction hash and a gist of the script I'm using:
var axios = require('axios')
axios.post('https://api.blockcypher.com/v1/bcy/test/txs/push',
{"tx": "01000000015e9d654ccdf376c21502152ad7eba61027c5860f35557729a45e356a7cdc9ad6000000008a47304402201f06d4679b3f835215c338bace1d8b317aeade5346309389b60f4d7753f5a710022033d9e5aafdd4154889b6ab71eb927b8879eeb3dc9c6c2e665e665485f71a4e0b014104f0087a849a6e9ebc5b3fb9090849a22b72c71564e165458a9957150a7dd24639f1f60746cbfa25950ec9bc7064a77141a78c5a309ff7cc0b90050e8a6a1a8ed7ffffffff02da210000000000001976a914fed9eb51a9d13032e4cf2d6a4856fe8bde18b18c88ac0000000000000000546a4c5177723335322d33316472342d4141412d30322d31362d31352d32336f6c2d313030303030303030302d33323132322d333435352d363933352d323334392d323334302d31323333322d30322d31302d313500000000"}
)
.then(function (response) {
console.log(response.data);
})
.catch(function (response) {
console.log(response.data);
});
If you try to create a new TX for LTC using as output address and address that starts with M (new format), it does not work
Please disregard this as the following comments are more accurate
I have been scouring the internet for a more detailed example on how to actually sign transactions against the BCY testnet but I am not having any luck finding updated information.
Here's the steps I've taken and sorry in advance if I'm doing this completely wrong. I am extremely new to the crypto world.
newTX()
function provided by this library.I attempt to get the ECPair with the following:
const seed = bip32.fromBase58('bprvTxeXPZq5...');
const firstKeyECPair = bitcoin.ECPair.fromPrivateKey(seed.privateKey);
This is currently failing with "Invalid network version."
Any help at addressing this issue would be GREATLY appreciated.
I noticed that in the example code I can only print the json retireved, but I can't manage to retrieve it in a variable. How do I do it? I tried:
var dados;
function printResponse(err, data) {
if (err !== null) {
console.log(err);
} else {
return data;
}
}
dados = bcapi.getBlock(1, {}, (dados = printResponse));
console.log(dados);
but "dados" is coming undefined
Hello,
We have problems when we try to make a TX with multisig address
bcapi.newTX({ inputs: [{ addresses: ['35wm5tDfFeEYjeeTZ17Lee16JCi9DkXBBG']}], outputs: [{ addresses: ['1AxY6mEfFn9r2ynScSyb3KRXRS7q6FBGX'], value: 2500 }] }, printResponse)
Output:
{ error: 'Error building input: Cannot use P2SH as input without \'script_type\' set to \'multisig-n-of-m\'' }, { error: 'Not enough funds in 1 inputs to pay for 1 outputs, missing -2500.' }, { error: 'Not enough funds after fees in 0 inputs to pay for 1 outputs, missing -11200.' }, { error: 'Error validating generated transaction: Transaction missing input or output.' } ],
Also, we try with 'script_type': 'multisig-2-of-3' any ideas how to solve it?
Sorry for writing here - this is not directly related to the development of the node-client module - but I've written BlockCypher support 3 times now and haven't got a response and now I'm thinking a better approach may be to reach out to other developers familiar with BlockCypher and Node and this seemed the best place.
Apologies that this is off topic - thanks for your time ๐โโ๏ธ
I'd like to know how to format a simple GET request against BlockCypher using only the native Node https module.
Example code:
// example options object generated from internal code
options = { hostname: 'api.blockcypher.com',
path: '/v1/ltc/main/txs/090a0f034b2973f4e13a3a20c1acf86fcc388dff4cca99220ef0e95d176ed0f0',
port: 443,
method: 'GET',
strictSSL: true }
return new Promise( (resolve, reject) => {
https.request(options, (response) => {
let data = ''
console.log('statusCode:', response.status)
console.log('headers:', response.headers)
response.setEncoding('utf8')
response.on('data', (chunk) => {
data += chunk
})
response.on('end', () => {
resolve(data)
})
}).on('error', (err) => {
reject(err)
})
})
}
When I send a request from above I don't get any chunks back and eventually just get a socket hang up after 60 seconds. From everything I've seen in the API documentation (and looking at what request is doing inside the request NPM docs) this simple HTTPS get request should be sending a properly formatted request which matches the request formatted here.
The logic for forming the param string in my code is a little different but as you can see from the example generated object, the path includes the version number for the API which should result in the same request
How can i sign transactions on test network?
the blockcypher documentation about transactions sending is out of date and if i try to solve it malually, has catch an error.
If i try to sign tx by another library (bitcore-explorers, bitcore-lib)
i'm getting the error around deffirence of networks. Somethink like "Address has mismatched network type".
Anybody please show me example that working for now please.
Hi,
I am trying to consume blockcypher, when i try from console application c#, its fetching the result. but when i use the same in MVC web app. It's not retruning me anything, it's keeping loading all the time. didn't get back again. any idea why i am facing this.
below code i am using:
Blockcypher objmain = new Blockcypher("******************************", Endpoint.BtcTest3);
objmain.GenerateAddress().Wait();
Hey, For a few days now, I have been having trouble trying to send dogecoin via the blockcypher API.
var newtx = { inputs: [{addresses: [inputAddr]}], outputs: outputFrmt, preference: 'medium' };
This is how we have set preference, its set to medium, but the transaction is always sent as low miner preference, and hence the transaction does not get accepted to the blockchain.
As can be seen here,
https://live.blockcypher.com/doge/tx/8205508dc4ab75215305ccdd84baa0f1484f377a14eb22de5775370e3c1b7edd/
I have also tried to set Miner Preference to high, but same issue occurs and Miner Preference still stays at low. Due to this the transactions stays for around 12 hours and then doesnt get accepted on the blockchain.
What could be a possible solution to this?
using Asset api on main net, getting internal error from transfer endpoint.
Also, can't use tx builder from coinprism with block cypher pushTX endpoint because coinprism signs with high-s. there a legacy mode for pushTX?
request = { from_private: 'xxx',
to_address: 'akErbek7ic5u2wmSx61RsKQa6NdhDJYJVZD',
asset_id: 'AXt4jSi1FF4uCtXQ4u1FvXpW5C9sF9zpWM',
amount: 1 }
bcapi._post('/oap/' + request.asset_id + '/transfer', {}, request, function(error, body) {
etc . . .
}
from_private hidden, the source address is akJcvSJanxtVtqb1vvYA6nGwjidVTreCHyk
https://www.coinprism.info/address/akJcvSJanxtVtqb1vvYA6nGwjidVTreCHyk
error is:
{ error: 'Error broadcasting transfer transaction: Error pushing transaction e1a8b17dcd5a3dcd95e07e9e87f96f9da94e8b738023d65c935d49de711ef3dc: Error validating transaction: Sum of inputs 4600 lesser than outputs 5460..' }
Will be cool add this repo to npm for easy install in own projects :)
The required file "blockcypher-api-v1.md" to generate the api object is not in the repo and nowhere to be found.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.