Skip to content

Commit 20f9e90

Browse files
author
Micah Riggan
committed
Merge branch 'v8.0.0' of github.com:bitpay/bitcore into v8.0.0
2 parents 6435ed0 + 824a22c commit 20f9e90

File tree

18 files changed

+11080
-12321
lines changed

18 files changed

+11080
-12321
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
3+
const program = require('../lib/program');
4+
const Wallet = require('../lib/wallet');
5+
6+
program
7+
.version(require('../package.json').version)
8+
.option('--name <name>', 'REQUIRED - Wallet name')
9+
.option('--path [path]', 'optional - Custom wallet storage path')
10+
.option('--startDate [startDate]')
11+
.option('--endDate [endDate]')
12+
.parse(process.argv);
13+
14+
const main = async () => {
15+
const { name, path, startDate, endDate } = program;
16+
try {
17+
const wallet = await Wallet.loadWallet({ name, path });
18+
const txStream = wallet.listTransactions({ startDate, endDate });
19+
txStream.pipe(process.stdout);
20+
} catch (e) {
21+
console.error(e);
22+
}
23+
};
24+
25+
main();

packages/bitcore-client/lib/client.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
const requestStream = require('request');
13
const request = require('request-promise-native');
24
const bitcoreLib = require('bitcore-lib');
35
const secp256k1 = require('secp256k1');
@@ -59,13 +61,23 @@ Client.prototype.getCoins = async function (params) {
5961
});
6062
};
6163

64+
Client.prototype.listTransactions = function (params) {
65+
const { payload, pubKey, startDate, endDate } = params;
66+
const url = `${this.baseUrl}/wallet/${pubKey}/transactions?startDate=${startDate}&endDate=${endDate}`;
67+
const signature = this.sign({ method: 'GET', url, payload });
68+
return requestStream.get(url, {
69+
headers: { 'x-signature': signature },
70+
json: true
71+
});
72+
};
73+
6274
Client.prototype.getFee = async function (params) {
6375
const { target } = params;
6476
const url = `${this.baseUrl}/fee/${target}`;
6577
return request.get(url, {
6678
json: true
6779
});
68-
}
80+
};
6981

7082
Client.prototype.importAddresses = async function(params) {
7183
const { payload, pubKey } = params;

packages/bitcore-client/lib/wallet.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ class Wallet {
145145
});
146146
}
147147

148+
listTransactions(params) {
149+
return this.client.listTransactions({
150+
...params,
151+
pubKey: this.xPubKey
152+
});
153+
}
154+
148155
async newTx(params) {
149156
const utxos = params.utxos || (await this.getUtxos(params));
150157
const payload = {

0 commit comments

Comments
 (0)