mainnet-js 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,252 @@
1
+ import { RegTestWallet } from "../wallet/Wif";
2
+ import { WalletTypeEnum } from "../wallet/enum";
3
+ import { createWallet } from "../wallet/createWallet";
4
+ import { getAddressHistory } from "./electrumTransformer";
5
+ import { mine } from "../mine";
6
+
7
+ // This class transforms outputs from electrum to a standard array of history.
8
+ test("Should get an address history", async () => {
9
+ // Build Alice's wallet from Wallet Import Format string
10
+ if (!process.env.PRIVATE_WIF) {
11
+ throw Error("Attempted to pass an empty WIF");
12
+ } else {
13
+ let alice = await RegTestWallet.fromWIF(process.env.PRIVATE_WIF); // insert WIF from #1
14
+ const bob = await createWallet({
15
+ type: WalletTypeEnum.Wif,
16
+ network: "regtest",
17
+ });
18
+ const charlie = await createWallet({
19
+ type: WalletTypeEnum.Wif,
20
+ network: "regtest",
21
+ });
22
+ let sendResponse = await alice.send([
23
+ {
24
+ cashaddr: bob.cashaddr!,
25
+ value: 31000,
26
+ unit: "satoshis",
27
+ },
28
+ {
29
+ cashaddr: charlie.cashaddr!,
30
+ value: 41000,
31
+ unit: "satoshis",
32
+ },
33
+ ]);
34
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
35
+ await bob.send([
36
+ {
37
+ cashaddr: charlie.cashaddr!,
38
+ value: 2100,
39
+ unit: "satoshis",
40
+ },
41
+ ]);
42
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 1 });
43
+ await bob.send([
44
+ {
45
+ cashaddr: alice.cashaddr!,
46
+ value: 2100,
47
+ unit: "satoshis",
48
+ },
49
+ ]);
50
+ expect(sendResponse!.txId!.length).toBe(64);
51
+ expect(sendResponse.balance!.bch).toBeGreaterThan(0.01);
52
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
53
+
54
+ // Build Bob's wallet from a public address, check his balance.
55
+ const bobHistory = await getAddressHistory(
56
+ bob.getDepositAddress(),
57
+ bob.provider
58
+ );
59
+ expect(bobHistory.transactions[0].value).toBe(-2100);
60
+ expect(bobHistory.transactions[0].to).toBe(alice.getDepositAddress());
61
+ expect(bobHistory.transactions[0].from).toBe(bob.getDepositAddress());
62
+ expect(bobHistory.transactions[1].value).toBe(-2100);
63
+ expect(bobHistory.transactions[1].from).toBe(bob.getDepositAddress());
64
+ expect(bobHistory.transactions[1].to).toBe(charlie.getDepositAddress());
65
+ expect(bobHistory.transactions[2].value).toBe(31000);
66
+ expect(bobHistory.transactions[2].balance).toBe(31000);
67
+ expect(bobHistory.transactions[2].fee).toBe(0);
68
+ expect(bobHistory.transactions[2].from).toBe(alice.getDepositAddress());
69
+ }
70
+ });
71
+
72
+ // This class transforms outputs from electrum to a standard array of history.
73
+ test("Should get a history with multi-party sends", async () => {
74
+ // Build Alice's wallet from Wallet Import Format string
75
+ if (!process.env.PRIVATE_WIF) {
76
+ throw Error("Attempted to pass an empty WIF");
77
+ } else {
78
+ let alice = await RegTestWallet.fromWIF(process.env.PRIVATE_WIF); // insert WIF from #1
79
+ const bob = await createWallet({
80
+ type: WalletTypeEnum.Wif,
81
+ network: "regtest",
82
+ });
83
+ const charlie = await createWallet({
84
+ type: WalletTypeEnum.Wif,
85
+ network: "regtest",
86
+ });
87
+ let sendResponse = await alice.send([
88
+ {
89
+ cashaddr: bob.cashaddr!,
90
+ value: 31000,
91
+ unit: "satoshis",
92
+ },
93
+ ]);
94
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
95
+ await bob.send([
96
+ {
97
+ cashaddr: charlie.cashaddr!,
98
+ value: 2100,
99
+ unit: "satoshis",
100
+ },
101
+ {
102
+ cashaddr: alice.cashaddr!,
103
+ value: 2100,
104
+ unit: "satoshis",
105
+ },
106
+ ]);
107
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 1 });
108
+ expect(sendResponse!.txId!.length).toBe(64);
109
+ expect(sendResponse.balance!.bch).toBeGreaterThan(0.01);
110
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 1 });
111
+
112
+ // Build Bob's wallet from a public address, check his balance.
113
+ const bobHistory = await getAddressHistory(
114
+ bob.getDepositAddress(),
115
+ bob.provider
116
+ );
117
+ expect(bobHistory.transactions[1].txn).toBe(bobHistory.transactions[0].txn);
118
+ expect(bobHistory.transactions[1].fee).toBe(bobHistory.transactions[0].fee);
119
+ expect(bobHistory.transactions[1].fee).toBeGreaterThan(120);
120
+ expect(bobHistory.transactions[1].fee).toBeLessThan(150);
121
+ expect(bobHistory.transactions[0].value).toBe(-2100);
122
+ expect(bobHistory.transactions[0].to).toBe(alice.getDepositAddress());
123
+ expect(bobHistory.transactions[0].from).toBe(bob.getDepositAddress());
124
+ expect(bobHistory.transactions[1].value).toBe(-2100);
125
+ expect(bobHistory.transactions[1].to).toBe(charlie.getDepositAddress());
126
+ expect(bobHistory.transactions[1].from).toBe(bob.getDepositAddress());
127
+
128
+ expect(bobHistory.transactions[2].value).toBe(31000);
129
+ expect(bobHistory.transactions[2].balance).toBe(31000);
130
+ expect(bobHistory.transactions[2].fee).toBe(0);
131
+ expect(bobHistory.transactions[2].from).toBe(alice.getDepositAddress());
132
+ }
133
+ });
134
+
135
+ // This class transforms outputs from electrum to a standard array of history.
136
+ test("Should cut results with a longer history to given count", async () => {
137
+ // Build Alice's wallet from Wallet Import Format string
138
+ if (!process.env.PRIVATE_WIF) {
139
+ throw Error("Attempted to pass an empty WIF");
140
+ } else {
141
+ let alice = await RegTestWallet.fromWIF(process.env.PRIVATE_WIF); // insert WIF from #1
142
+ const bob = await createWallet({
143
+ type: WalletTypeEnum.Wif,
144
+ network: "regtest",
145
+ });
146
+ const charlie = await createWallet({
147
+ type: WalletTypeEnum.Wif,
148
+ network: "regtest",
149
+ });
150
+ let sendResponse = await alice.send([
151
+ {
152
+ cashaddr: bob.cashaddr!,
153
+ value: 31000,
154
+ unit: "satoshis",
155
+ },
156
+ ]);
157
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
158
+ await bob.send([
159
+ {
160
+ cashaddr: charlie.cashaddr!,
161
+ value: 2100,
162
+ unit: "satoshis",
163
+ },
164
+ {
165
+ cashaddr: alice.cashaddr!,
166
+ value: 2100,
167
+ unit: "satoshis",
168
+ },
169
+ {
170
+ cashaddr: alice.cashaddr!,
171
+ value: 2100,
172
+ unit: "satoshis",
173
+ },
174
+ ]);
175
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 1 });
176
+ expect(sendResponse!.txId!.length).toBe(64);
177
+ expect(sendResponse.balance!.bch).toBeGreaterThan(0.01);
178
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
179
+
180
+ // Build Bob's wallet from a public address, check his balance.
181
+ const bobHistory = await getAddressHistory(
182
+ bob.getDepositAddress(),
183
+ bob.provider,
184
+ "sat",
185
+ 0,
186
+ 2
187
+ );
188
+ expect(bobHistory.transactions.length).toBe(2);
189
+
190
+ expect(bobHistory.transactions[0].value).toBe(-2100);
191
+ expect(bobHistory.transactions[0].to).toBe(alice.getDepositAddress());
192
+ expect(bobHistory.transactions[1].value).toBe(-2100);
193
+ expect(bobHistory.transactions[1].to).toBe(alice.getDepositAddress());
194
+ }
195
+ });
196
+
197
+ // This class transforms outputs from electrum to a standard array of history.
198
+ test("Should handel input and fee from many utxos", async () => {
199
+ // Build Alice's wallet from Wallet Import Format string
200
+ if (!process.env.PRIVATE_WIF) {
201
+ throw Error("Attempted to pass an empty WIF");
202
+ } else {
203
+ let alice = await RegTestWallet.fromWIF(process.env.PRIVATE_WIF); // insert WIF from #1
204
+ const bob = await createWallet({
205
+ type: WalletTypeEnum.Wif,
206
+ network: "regtest",
207
+ });
208
+ const charlie = await createWallet({
209
+ type: WalletTypeEnum.Wif,
210
+ network: "regtest",
211
+ });
212
+ let sendResponse = await alice.send([
213
+ {
214
+ cashaddr: bob.cashaddr!,
215
+ value: 600,
216
+ unit: "satoshis",
217
+ },
218
+ {
219
+ cashaddr: bob.cashaddr!,
220
+ value: 600,
221
+ unit: "satoshis",
222
+ },
223
+ {
224
+ cashaddr: bob.cashaddr!,
225
+ value: 600,
226
+ unit: "satoshis",
227
+ },
228
+ {
229
+ cashaddr: bob.cashaddr!,
230
+ value: 600,
231
+ unit: "satoshis",
232
+ },
233
+ ]);
234
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
235
+ await bob.sendMax(charlie.cashaddr!);
236
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 1 });
237
+ expect(sendResponse!.txId!.length).toBe(64);
238
+ expect(sendResponse.balance!.bch).toBeGreaterThan(0.01);
239
+ await mine({ cashaddr: alice.getDepositAddress(), blocks: 10 });
240
+
241
+ // Build Bob's wallet from a public address, check his balance.
242
+ const bobHistory = await getAddressHistory(
243
+ bob.getDepositAddress(),
244
+ bob.provider,
245
+ "sat"
246
+ );
247
+
248
+ expect(bobHistory.transactions[0].value).toBeLessThan(-1700);
249
+ expect(bobHistory.transactions[0].to).toBe(charlie.getDepositAddress());
250
+ expect(bobHistory.transactions[1].from).toBe(alice.getDepositAddress());
251
+ }
252
+ });
@@ -0,0 +1,318 @@
1
+ import {
2
+ binToHex,
3
+ cashAddressToLockingBytecode,
4
+ decodeTransaction,
5
+ hexToBin,
6
+ binToBigIntUint64LE,
7
+ Transaction,
8
+ lockingBytecodeToCashAddress,
9
+ Output,
10
+ } from "@bitauth/libauth";
11
+ import { UnitEnum } from "../enum";
12
+ import NetworkProvider from "../network/NetworkProvider";
13
+ import { derivePrefix } from "../util/derivePublicKeyHash";
14
+ import { convert } from "../util/convert";
15
+ import { bchParam } from "../chain";
16
+ import { floor } from "../util/floor";
17
+ import { TransactionHistoryI, TransactionHistoryItemI } from "./interface";
18
+
19
+ export async function getAddressHistory(
20
+ cashaddr: string,
21
+ provider: NetworkProvider,
22
+ unit = "sat",
23
+ start = 0,
24
+ count = 25,
25
+ collapseChange = true
26
+ ): Promise<TransactionHistoryI> {
27
+ // Get an array of raw transactions as hex
28
+ let txnHashes = await provider.getHistory(cashaddr);
29
+
30
+ // get the current balance in satoshis
31
+ let currentBalance = await provider.getBalance(cashaddr);
32
+
33
+ // Transform the hex transactions to and array of histroy item array promises.
34
+ let txItemPromises = txnHashes.map((tx) => {
35
+ return getDetailedHistory(
36
+ cashaddr,
37
+ tx.tx_hash,
38
+ tx.height,
39
+ provider,
40
+ collapseChange
41
+ );
42
+ });
43
+
44
+ // await the history array promises
45
+ let items = await Promise.all(txItemPromises);
46
+
47
+ // flatten the array of responses
48
+ let preprocessedTxns = Array.prototype.concat.apply([], items);
49
+
50
+ // Revere cronological order.
51
+ preprocessedTxns = preprocessedTxns.reverse();
52
+
53
+ // Get the factor to apply the requested unit of measure
54
+ let factor =
55
+ (await convert(bchParam.subUnits, "sat", unit)) / bchParam.subUnits;
56
+
57
+ // Apply the unit factor and
58
+ let txns = applyBalance(preprocessedTxns, currentBalance, unit, factor);
59
+
60
+ // Slice the start and count to the provided inputs
61
+ txns = txns.slice(start, start + count);
62
+
63
+ return {
64
+ transactions: txns,
65
+ };
66
+ }
67
+
68
+ export async function getDetailedHistory(
69
+ cashaddr: string,
70
+ hash: string,
71
+ height: number,
72
+ provider: NetworkProvider,
73
+ collapseChange: boolean
74
+ ): Promise<TransactionHistoryItemI[]> {
75
+ let transactionHex = await provider.getRawTransaction(hash);
76
+
77
+ collapseChange;
78
+ let addressBytecode = cashAddressToLockingBytecode(cashaddr);
79
+ if (typeof addressBytecode === "string") throw Error(addressBytecode);
80
+
81
+ let transaction = decodeTransaction(hexToBin(transactionHex));
82
+ if (typeof transaction === "string") throw Error(transaction);
83
+
84
+ let r: TransactionHistoryItemI[] = [];
85
+ r.push(
86
+ ...(await getMatchingInputs(
87
+ transaction,
88
+ cashaddr,
89
+ height,
90
+ hash,
91
+ provider,
92
+ collapseChange
93
+ ))
94
+ );
95
+ return r;
96
+ }
97
+
98
+ async function getMatchingInputs(
99
+ transaction: Transaction,
100
+ cashaddr: string,
101
+ height: number,
102
+ hash: string,
103
+ provider,
104
+ collapseChange
105
+ ) {
106
+ let addressBytecode = cashAddressToLockingBytecode(cashaddr);
107
+ if (typeof addressBytecode === "string") throw Error(addressBytecode);
108
+ let lockingBytecodeHex = binToHex(addressBytecode.bytecode);
109
+ let prefix = derivePrefix(cashaddr);
110
+
111
+ let inputUtxos = await getInputTransactions(transaction, provider);
112
+
113
+ let fee = getFee(
114
+ inputUtxos,
115
+ transaction.outputs,
116
+ lockingBytecodeHex,
117
+ collapseChange
118
+ );
119
+
120
+ let r: TransactionHistoryItemI[] = [];
121
+
122
+ let txIds: string[] = [];
123
+
124
+ for (let input of transaction.inputs) {
125
+ let outpoint = inputUtxos[transaction.inputs.indexOf(input)];
126
+
127
+ // if the utxo of the input matches the address in question
128
+ if (binToHex(outpoint.lockingBytecode) === lockingBytecodeHex) {
129
+ for (let output of transaction.outputs) {
130
+ let idx = transaction.outputs.indexOf(output);
131
+ let from = lockingBytecodeToCashAddress(
132
+ outpoint.lockingBytecode,
133
+ prefix
134
+ ) as string;
135
+
136
+ // the output was change
137
+ if (binToHex(output.lockingBytecode) === lockingBytecodeHex) {
138
+ if (!collapseChange) {
139
+ r.push({
140
+ from: from,
141
+ to: cashaddr,
142
+ unit: "sat",
143
+ index: idx,
144
+ blockheight: height,
145
+ txn: `${hash}`,
146
+ txId: `${hash}:i:${idx}`,
147
+ value: -Number(binToBigIntUint64LE(output.satoshis)),
148
+ fee: 0,
149
+ });
150
+ }
151
+ } else {
152
+ if (!txIds.find((str) => str === `${hash}:i:${idx}`)) {
153
+ // the utxo was sent to another address
154
+ let to = lockingBytecodeToCashAddress(
155
+ output.lockingBytecode,
156
+ prefix
157
+ ) as string;
158
+ r.push({
159
+ from: from,
160
+ to: to,
161
+ unit: "sat",
162
+ index: idx,
163
+ blockheight: height,
164
+ txn: `${hash}`,
165
+ txId: `${hash}:i:${idx}`,
166
+ value: -Number(binToBigIntUint64LE(output.satoshis)),
167
+ fee: fee,
168
+ });
169
+ txIds.push(`${hash}:i:${idx}`);
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+
176
+ // check the transaction outputs for receiving transactions
177
+ for (let output of transaction.outputs) {
178
+ // the output was a utxo for the address in question
179
+ if (binToHex(output.lockingBytecode) === lockingBytecodeHex) {
180
+ // the input was from a single address
181
+ if (transaction.inputs.length == 1) {
182
+ const input = transaction.inputs[0];
183
+ const inHash = binToHex(input.outpointTransactionHash);
184
+ const transactionHex = await provider.getRawTransaction(inHash);
185
+ const inTransaction = decodeTransaction(hexToBin(transactionHex));
186
+ if (typeof inTransaction === "string") throw Error(inTransaction);
187
+
188
+ let outpoint = inTransaction.outputs[input.outpointIndex];
189
+ let from = lockingBytecodeToCashAddress(
190
+ outpoint.lockingBytecode,
191
+ prefix
192
+ ) as string;
193
+
194
+ // if the utxo was from a different address and change is not being output...
195
+ if (from !== cashaddr || !collapseChange) {
196
+ r.push({
197
+ from: from,
198
+ to: cashaddr,
199
+ unit: "sat",
200
+ index: transaction.outputs.indexOf(output),
201
+ blockheight: height,
202
+ txn: `${hash}`,
203
+ txId: `${hash}:o:${transaction.outputs.indexOf(output)}`,
204
+ value: Number(binToBigIntUint64LE(output.satoshis)),
205
+ });
206
+ }
207
+ } else {
208
+ let from = transaction.inputs
209
+ .map(
210
+ (i) => `${binToHex(i.outpointTransactionHash)}:o:${i.outpointIndex}`
211
+ )
212
+ .join(";");
213
+ r.push({
214
+ from: from,
215
+ to: cashaddr,
216
+ unit: "sat",
217
+ index: transaction.outputs.indexOf(output),
218
+ blockheight: height,
219
+ txn: `${hash}`,
220
+ txId: `${hash}:o:${transaction.outputs.indexOf(output)}`,
221
+ value: Number(binToBigIntUint64LE(output.satoshis)),
222
+ // incoming transactions pay no fee.
223
+ fee: 0,
224
+ });
225
+ }
226
+ }
227
+ }
228
+
229
+ return r;
230
+ }
231
+
232
+ async function getInputTransactions(
233
+ transaction: Transaction,
234
+ provider: NetworkProvider
235
+ ) {
236
+ let inputTransactions: Output[] = [];
237
+ for (let input of transaction.inputs) {
238
+ let inHash = binToHex(input.outpointTransactionHash);
239
+ let transactionHex = await provider.getRawTransaction(inHash);
240
+ let inTransaction = decodeTransaction(hexToBin(transactionHex));
241
+ if (typeof inTransaction === "string") throw Error(inTransaction);
242
+
243
+ inputTransactions.push(inTransaction.outputs[input.outpointIndex]);
244
+ }
245
+ return inputTransactions;
246
+ }
247
+
248
+ function getFee(
249
+ inputUtxos: Output[],
250
+ utxos: Output[],
251
+ lockingBytecodeHex,
252
+ collapseChange
253
+ ) {
254
+ let inValues = 0;
255
+ for (let outpoint of inputUtxos) {
256
+ if (binToHex(outpoint.lockingBytecode)) {
257
+ inValues += Number(binToBigIntUint64LE(outpoint.satoshis));
258
+ }
259
+ }
260
+
261
+ const outValues = utxos
262
+ .map((utxo) => Number(binToBigIntUint64LE(utxo.satoshis)))
263
+ .reduce((a: number, b: number) => a + b, 0);
264
+
265
+ let fee = 0;
266
+ if (collapseChange) {
267
+ const nonChangeOutputs = utxos
268
+ .map((output) =>
269
+ binToHex(output.lockingBytecode) === lockingBytecodeHex ? 0 : 1
270
+ )
271
+ .reduce((a: number, b: number) => a + b, 0);
272
+ fee = floor((inValues - outValues) / nonChangeOutputs, 0);
273
+ } else {
274
+ fee = floor((inValues - outValues) / utxos.length, 0);
275
+ }
276
+ return fee;
277
+ }
278
+
279
+ function applyBalance(
280
+ preprocessedTxns: TransactionHistoryItemI[],
281
+ currentBalance: number,
282
+ unit: string,
283
+ factor: number
284
+ ): TransactionHistoryItemI[] {
285
+ // balance in satoshis
286
+ let bal = currentBalance;
287
+
288
+ let r: TransactionHistoryItemI[] = [];
289
+ for (let txn of preprocessedTxns) {
290
+ // set the balance to the current balance in the appropriate unit
291
+ txn.balance = bal;
292
+
293
+ // If fee is not defined, configure it to zero.
294
+ txn.fee = txn.fee ? txn.fee : 0;
295
+
296
+ // update the running balance in satoshis for the next record
297
+ // a receiving value is positive, a send is negative
298
+ // The sign is reversed in cronological order from the current balance.
299
+ bal -= txn.value;
300
+ bal += txn.fee;
301
+
302
+ // transform the value of the transaction
303
+ txn.value = txn.value * factor;
304
+ txn.fee = txn.fee! * factor;
305
+
306
+ // If unit is usd, round to two decimal places.
307
+ if (unit.toLowerCase() == "usd") {
308
+ txn.value = floor(txn.value, 2);
309
+ txn.fee = floor(txn.fee, 2);
310
+ }
311
+
312
+ // note the unit
313
+ txn.unit = unit as UnitEnum;
314
+
315
+ r.push(txn);
316
+ }
317
+ return r;
318
+ }
@@ -0,0 +1,18 @@
1
+ import { UnitEnum } from "../enum";
2
+
3
+ export interface TransactionHistoryItemI {
4
+ to: string;
5
+ from: string;
6
+ unit: UnitEnum;
7
+ index: number;
8
+ blockheight: number;
9
+ txn: string;
10
+ txId: string;
11
+ value: number;
12
+ fee?: number;
13
+ balance?: number;
14
+ }
15
+
16
+ export interface TransactionHistoryI {
17
+ transactions: TransactionHistoryItemI[];
18
+ }
package/src/wallet/Wif.ts CHANGED
@@ -104,6 +104,9 @@ import { amountInSatoshi } from "../util/amountInSatoshi";
104
104
  import { getXPubKey } from "../util/getXPubKey";
105
105
  import { DERIVATION_PATHS, DUST_UTXO_THRESHOLD } from "../constant";
106
106
 
107
+ import { TransactionHistoryI } from "../history/interface";
108
+ import { getAddressHistory } from "../history/electrumTransformer";
109
+
107
110
  //#endregion Imports
108
111
 
109
112
  const secp256k1Promise = instantiateSecp256k1();
@@ -1065,15 +1068,32 @@ export class Wallet extends BaseWallet {
1065
1068
  }
1066
1069
 
1067
1070
  // gets transaction history of this wallet
1068
- public async getHistory(): Promise<TxI[]> {
1071
+ public async getRawHistory(): Promise<TxI[]> {
1069
1072
  return await this.provider!.getHistory(this.cashaddr!);
1070
1073
  }
1071
1074
 
1075
+ // gets transaction history of this wallet
1076
+ public async getHistory(
1077
+ unit: UnitEnum,
1078
+ start?: number,
1079
+ count?: number,
1080
+ collapseChange?: boolean
1081
+ ): Promise<TransactionHistoryI> {
1082
+ return getAddressHistory(
1083
+ this.cashaddr!,
1084
+ this.provider!,
1085
+ unit,
1086
+ start,
1087
+ count,
1088
+ collapseChange
1089
+ );
1090
+ }
1091
+
1072
1092
  // gets last transaction of this wallet
1073
1093
  public async getLastTransaction(
1074
1094
  confirmedOnly: boolean = false
1075
1095
  ): Promise<ElectrumRawTransaction | null> {
1076
- let history: TxI[] = await this.getHistory();
1096
+ let history: TxI[] = await this.getRawHistory();
1077
1097
  if (confirmedOnly) {
1078
1098
  history = history.filter((val) => val.height > 0);
1079
1099
  }