Node.js 区块链比特币 api

Node.js blockchain bitcoin api

所以我想使用这个:(取自他们的 API 网站 -> node.js 文档) https://github.com/blockchain/api-v1-client-node

收款: https://github.com/blockchain/api-v1-client-node/blob/master/docs/Receive.md

var blockchain = require('blockchain.info');
var identifier = 'myidentifier'; 
var password = 'mypassword';
var myWallet = new blockchain.MyWallet(identifier, password);
var myBTCadress = '14Q3ufL1BUHtWskBKtsshVDATRY65TaJMB';

好的,接收部分:

var receive = new blockchain.Receive( [confirmations: 1], ? ); // What do I need to put here?

文档说: callbackURL:回调应该发送到的url(字符串)

我不明白 URL 它应该去哪里?!

回调 URL 应该是重定向回您网站的回调。因此,使用区块链设置回调 url,例如...

https://www.yoursite.com/callback/blockchain

假设你在你的应用程序中使用类似 express 的东西来创建这样的路线。

app.get('/callback/blockchain', function (req, res) {

// Stuff here  

});

您可能需要包括

var https = require('https'); 

这样你就可以在里面设置你的逻辑了……

// Stuff here
 var options = {
    host : 'api.blockchain.info',
    path : '/some/path/',
    port : 443,
    method : 'GET'
  }
 var request = https.request(options, function(response){
    var body = ""
    response.on('data', function(data) {
      body += data;
    });
    response.on('end', function() {
      res.send(JSON.parse(body));
    });
  });
  request.on('error', function(e) {
    console.log('Problem with request: ' + e.message);
  });
  request.end();

例如,这将在您将 app.get('whateverurl') 设置为的任何页面上 json 中请求输出。