forked from Sfippa/api-client-v1-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (21 loc) · 770 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
var API = require('../api')
, url = require('url')
, parse = require('url-parse')
, UrlPattern = require('url-pattern');
var endpoints = {
receive: new UrlPattern('/receive?xpub=:xpub&callback=:callback&key=:key')
};
var api = new API('https://api.blockchain.info/v2', endpoints);
function Receive(xpub, callback, key) {
this.xpub = xpub;
this.callback = callback;
this.key = key;
}
Receive.prototype.generate = function (query) {
var callbackUrl = parse(this.callback).set('query', query).toString()
, callbackEnc = encodeURIComponent(callbackUrl)
, params = { xpub: this.xpub, key: this.key, callback: callbackEnc };
return api.request('receive', params);
};
module.exports = Receive;