mainnet-js 2.3.16 → 2.4.0
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.
- package/dist/index.html +1 -1
- package/dist/{mainnet-2.3.16.js → mainnet-2.4.0.js} +3 -3
- package/dist/module/history/electrumTransformer.d.ts +11 -3
- package/dist/module/history/electrumTransformer.d.ts.map +1 -1
- package/dist/module/history/electrumTransformer.js +199 -195
- package/dist/module/history/electrumTransformer.js.map +1 -1
- package/dist/module/history/interface.d.ts +19 -13
- package/dist/module/history/interface.d.ts.map +1 -1
- package/dist/module/network/ElectrumNetworkProvider.d.ts +2 -2
- package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -1
- package/dist/module/network/ElectrumNetworkProvider.js +6 -6
- package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
- package/dist/module/network/NetworkProvider.d.ts +1 -1
- package/dist/module/network/NetworkProvider.d.ts.map +1 -1
- package/dist/module/util/header.d.ts.map +1 -1
- package/dist/module/util/header.js.map +1 -1
- package/dist/module/wallet/Wif.d.ts +25 -4
- package/dist/module/wallet/Wif.d.ts.map +1 -1
- package/dist/module/wallet/Wif.js +29 -7
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/history/electrumTransformer.test.ts +112 -55
- package/src/history/electrumTransformer.ts +279 -284
- package/src/history/interface.ts +19 -13
- package/src/network/ElectrumNetworkProvider.ts +32 -9
- package/src/network/NetworkProvider.ts +5 -1
- package/src/util/header.test.ts +14 -8
- package/src/util/header.ts +1 -1
- package/src/wallet/Wif.ts +53 -19
|
@@ -1,211 +1,215 @@
|
|
|
1
|
-
import { binToHex,
|
|
2
|
-
import { derivePrefix } from "../util/derivePublicKeyHash.js";
|
|
1
|
+
import { binToHex, decodeTransaction, hexToBin, lockingBytecodeToCashAddress, decodeCashAddress, } from "@bitauth/libauth";
|
|
3
2
|
import { convert } from "../util/convert.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
3
|
+
export const getAddressHistory = async ({ address, provider, unit = "sat", fromHeight = 0, toHeight = -1, start = 0, count = -1, }) => {
|
|
4
|
+
if (count === -1) {
|
|
5
|
+
count = 1e10;
|
|
6
|
+
}
|
|
7
|
+
const history = (await provider.getHistory(address, fromHeight, toHeight))
|
|
8
|
+
.sort((a, b) => a.height <= 0 || b.height <= 0 ? a.height - b.height : b.height - a.height)
|
|
9
|
+
.slice(start, start + count);
|
|
10
|
+
// fill transaction timestamps by requesting headers from network and parsing them
|
|
11
|
+
const heights = history
|
|
12
|
+
.map((tx) => tx.height)
|
|
13
|
+
.filter((height) => height > 0)
|
|
14
|
+
.filter((value, index, array) => array.indexOf(value) === index);
|
|
15
|
+
const timestampMap = (await Promise.all(heights.map(async (height) => [
|
|
16
|
+
height,
|
|
17
|
+
(await provider.getHeader(height, true)).timestamp,
|
|
18
|
+
]))).reduce((acc, [height, timestamp]) => ({ ...acc, [height]: timestamp }), {});
|
|
19
|
+
// first load all transactions
|
|
20
|
+
const historicTransactions = await Promise.all(history.map(async (tx) => {
|
|
21
|
+
const txHex = (await provider.getRawTransaction(tx.tx_hash));
|
|
22
|
+
const transactionCommon = decodeTransaction(hexToBin(txHex));
|
|
23
|
+
if (typeof transactionCommon === "string") {
|
|
24
|
+
throw transactionCommon;
|
|
25
|
+
}
|
|
26
|
+
const transaction = transactionCommon;
|
|
27
|
+
transaction.blockHeight = tx.height;
|
|
28
|
+
transaction.timestamp = timestampMap[tx.height];
|
|
29
|
+
transaction.hash = tx.tx_hash;
|
|
30
|
+
transaction.size = txHex.length / 2;
|
|
31
|
+
return transaction;
|
|
32
|
+
}));
|
|
33
|
+
// then load their prevout transactions
|
|
34
|
+
const prevoutTransactionHashes = historicTransactions
|
|
35
|
+
.map((tx) => tx.inputs.map((input) => binToHex(input.outpointTransactionHash)))
|
|
36
|
+
.flat()
|
|
37
|
+
.filter((value, index, array) => array.indexOf(value) === index);
|
|
38
|
+
const prevoutTransactionMap = (await Promise.all(prevoutTransactionHashes.map(async (hash) => {
|
|
39
|
+
const txHex = (await provider.getRawTransaction(hash));
|
|
40
|
+
const transaction = decodeTransaction(hexToBin(txHex));
|
|
41
|
+
if (typeof transaction === "string") {
|
|
42
|
+
throw transaction;
|
|
43
|
+
}
|
|
44
|
+
return [hash, transaction];
|
|
45
|
+
}))).reduce((acc, [hash, transaction]) => ({
|
|
46
|
+
...acc,
|
|
47
|
+
[hash]: transaction,
|
|
48
|
+
}), {});
|
|
49
|
+
const decoded = decodeCashAddress(address);
|
|
50
|
+
if (typeof decoded === "string") {
|
|
51
|
+
throw decoded;
|
|
52
|
+
}
|
|
53
|
+
const addressCache = {};
|
|
54
|
+
// map decoded transaction data to TransactionHistoryItem
|
|
55
|
+
const historyItems = historicTransactions.map((tx) => {
|
|
56
|
+
const result = {};
|
|
57
|
+
let inputTotalValue = 0n;
|
|
58
|
+
let outputTotalValue = 0n;
|
|
59
|
+
result.inputs = tx.inputs.map((input) => {
|
|
60
|
+
const prevoutTx = prevoutTransactionMap[binToHex(input.outpointTransactionHash)];
|
|
61
|
+
if (!prevoutTx) {
|
|
62
|
+
throw new Error("Could not find prevout transaction");
|
|
63
|
+
}
|
|
64
|
+
const prevoutOutput = prevoutTx.outputs[input.outpointIndex];
|
|
65
|
+
if (!prevoutOutput) {
|
|
66
|
+
throw new Error("Could not find prevout output");
|
|
67
|
+
}
|
|
68
|
+
const cached = addressCache[prevoutOutput.lockingBytecode];
|
|
69
|
+
let address;
|
|
70
|
+
if (!cached) {
|
|
71
|
+
address = lockingBytecodeToCashAddress(prevoutOutput.lockingBytecode, decoded.prefix);
|
|
72
|
+
addressCache[prevoutOutput.lockingBytecode] = address;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
address = cached;
|
|
76
|
+
}
|
|
77
|
+
inputTotalValue += prevoutOutput.valueSatoshis;
|
|
78
|
+
return {
|
|
79
|
+
address: address,
|
|
80
|
+
value: Number(prevoutOutput.valueSatoshis),
|
|
81
|
+
token: prevoutOutput.token
|
|
82
|
+
? {
|
|
83
|
+
tokenId: binToHex(prevoutOutput.token.category),
|
|
84
|
+
amount: prevoutOutput.token.amount,
|
|
85
|
+
capability: prevoutOutput.token.nft?.capability
|
|
86
|
+
? prevoutOutput.token.nft.capability
|
|
87
|
+
: undefined,
|
|
88
|
+
commitment: prevoutOutput.token.nft?.capability
|
|
89
|
+
? binToHex(prevoutOutput.token.nft.commitment)
|
|
90
|
+
: undefined,
|
|
77
91
|
}
|
|
92
|
+
: undefined,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
result.outputs = tx.outputs.map((output) => {
|
|
96
|
+
const cached = addressCache[output.lockingBytecode];
|
|
97
|
+
let address;
|
|
98
|
+
if (!cached) {
|
|
99
|
+
if (output.valueSatoshis === 0n) {
|
|
100
|
+
address = `OP_RETURN: ${binToHex(output.lockingBytecode)}`;
|
|
78
101
|
}
|
|
79
102
|
else {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
address = lockingBytecodeToCashAddress(output.lockingBytecode, decoded.prefix);
|
|
104
|
+
addressCache[output.lockingBytecode] = address;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
address = cached;
|
|
109
|
+
}
|
|
110
|
+
outputTotalValue += output.valueSatoshis;
|
|
111
|
+
return {
|
|
112
|
+
address: address,
|
|
113
|
+
value: Number(output.valueSatoshis),
|
|
114
|
+
token: output.token
|
|
115
|
+
? {
|
|
116
|
+
tokenId: binToHex(output.token.category),
|
|
117
|
+
amount: output.token.amount,
|
|
118
|
+
capability: output.token.nft?.capability
|
|
119
|
+
? output.token.nft.capability
|
|
120
|
+
: undefined,
|
|
121
|
+
commitment: output.token.nft?.capability
|
|
122
|
+
? binToHex(output.token.nft.commitment)
|
|
123
|
+
: undefined,
|
|
95
124
|
}
|
|
125
|
+
: undefined,
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
result.blockHeight = tx.blockHeight;
|
|
129
|
+
result.timestamp = tx.timestamp;
|
|
130
|
+
result.hash = tx.hash;
|
|
131
|
+
result.size = tx.size;
|
|
132
|
+
result.fee = Number(inputTotalValue - outputTotalValue);
|
|
133
|
+
return result;
|
|
134
|
+
});
|
|
135
|
+
// compute value changes
|
|
136
|
+
historyItems.forEach((tx) => {
|
|
137
|
+
let satoshiBalance = 0;
|
|
138
|
+
const ftTokenBalances = {};
|
|
139
|
+
const nftTokenBalances = {};
|
|
140
|
+
tx.inputs.forEach((input) => {
|
|
141
|
+
if (input.address === address) {
|
|
142
|
+
satoshiBalance -= input.value;
|
|
143
|
+
if (input.token?.amount) {
|
|
144
|
+
ftTokenBalances[input.token.tokenId] =
|
|
145
|
+
(ftTokenBalances[input.token.tokenId] || BigInt(0)) -
|
|
146
|
+
input.token.amount;
|
|
147
|
+
}
|
|
148
|
+
if (input.token?.capability) {
|
|
149
|
+
nftTokenBalances[input.token.tokenId] =
|
|
150
|
+
(nftTokenBalances[input.token.tokenId] || BigInt(0)) - 1n;
|
|
96
151
|
}
|
|
97
152
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (typeof inTransaction === "string")
|
|
111
|
-
throw Error(inTransaction);
|
|
112
|
-
let outpoint = inTransaction.outputs[input.outpointIndex];
|
|
113
|
-
let from = lockingBytecodeToCashAddress(outpoint.lockingBytecode, prefix);
|
|
114
|
-
// if the utxo was from a different address and change is not being output...
|
|
115
|
-
if (from !== cashaddr || !collapseChange) {
|
|
116
|
-
r.push({
|
|
117
|
-
from: from,
|
|
118
|
-
to: cashaddr,
|
|
119
|
-
unit: "sat",
|
|
120
|
-
index: transaction.outputs.indexOf(output),
|
|
121
|
-
blockheight: height,
|
|
122
|
-
txn: `${hash}`,
|
|
123
|
-
txId: `${hash}:o:${transaction.outputs.indexOf(output)}`,
|
|
124
|
-
value: Number(output.valueSatoshis),
|
|
125
|
-
});
|
|
153
|
+
});
|
|
154
|
+
tx.outputs.forEach((output) => {
|
|
155
|
+
if (output.address === address) {
|
|
156
|
+
satoshiBalance += Number(output.value);
|
|
157
|
+
if (output.token?.amount) {
|
|
158
|
+
ftTokenBalances[output.token.tokenId] =
|
|
159
|
+
(ftTokenBalances[output.token.tokenId] || BigInt(0)) +
|
|
160
|
+
output.token.amount;
|
|
161
|
+
}
|
|
162
|
+
if (output.token?.capability) {
|
|
163
|
+
nftTokenBalances[output.token.tokenId] =
|
|
164
|
+
(nftTokenBalances[output.token.tokenId] || BigInt(0)) + 1n;
|
|
126
165
|
}
|
|
127
166
|
}
|
|
167
|
+
});
|
|
168
|
+
tx.valueChange = satoshiBalance;
|
|
169
|
+
tx.tokenAmountChanges = Object.entries(ftTokenBalances).map(([tokenId, amount]) => ({
|
|
170
|
+
tokenId,
|
|
171
|
+
amount,
|
|
172
|
+
nftAmount: BigInt(0),
|
|
173
|
+
}));
|
|
174
|
+
for (const [tokenId, nftAmount] of Object.entries(nftTokenBalances)) {
|
|
175
|
+
const tokenChange = tx.tokenAmountChanges.find((tokenChange) => tokenChange.tokenId === tokenId);
|
|
176
|
+
if (tokenChange) {
|
|
177
|
+
tokenChange.nftAmount = nftAmount;
|
|
178
|
+
}
|
|
128
179
|
else {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
from: from,
|
|
134
|
-
to: cashaddr,
|
|
135
|
-
unit: "sat",
|
|
136
|
-
index: transaction.outputs.indexOf(output),
|
|
137
|
-
blockheight: height,
|
|
138
|
-
txn: `${hash}`,
|
|
139
|
-
txId: `${hash}:o:${transaction.outputs.indexOf(output)}`,
|
|
140
|
-
value: Number(output.valueSatoshis),
|
|
141
|
-
// incoming transactions pay no fee.
|
|
142
|
-
fee: 0,
|
|
180
|
+
tx.tokenAmountChanges.push({
|
|
181
|
+
tokenId,
|
|
182
|
+
amount: BigInt(0),
|
|
183
|
+
nftAmount,
|
|
143
184
|
});
|
|
144
185
|
}
|
|
145
186
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
.reduce((a, b) => a + b, 0);
|
|
171
|
-
let fee = 0;
|
|
172
|
-
if (collapseChange) {
|
|
173
|
-
const nonChangeOutputs = utxos
|
|
174
|
-
.map((output) => binToHex(output.lockingBytecode) === lockingBytecodeHex ? 0 : 1)
|
|
175
|
-
.reduce((a, b) => a + b, 0);
|
|
176
|
-
fee = floor((inValues - outValues) / nonChangeOutputs, 0);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
fee = floor((inValues - outValues) / utxos.length, 0);
|
|
180
|
-
}
|
|
181
|
-
return fee;
|
|
182
|
-
}
|
|
183
|
-
function applyBalance(preprocessedTxns, currentBalance, unit, factor) {
|
|
184
|
-
// balance in satoshis
|
|
185
|
-
let bal = currentBalance;
|
|
186
|
-
let r = [];
|
|
187
|
-
for (let txn of preprocessedTxns) {
|
|
188
|
-
// set the balance to the current balance in the appropriate unit
|
|
189
|
-
txn.balance = bal;
|
|
190
|
-
// If fee is not defined, configure it to zero.
|
|
191
|
-
txn.fee = txn.fee ? txn.fee : 0;
|
|
192
|
-
// update the running balance in satoshis for the next record
|
|
193
|
-
// a receiving value is positive, a send is negative
|
|
194
|
-
// The sign is reversed in cronological order from the current balance.
|
|
195
|
-
bal -= txn.value;
|
|
196
|
-
bal += txn.fee;
|
|
197
|
-
// transform the value of the transaction
|
|
198
|
-
txn.value = txn.value * factor;
|
|
199
|
-
txn.fee = txn.fee * factor;
|
|
200
|
-
// If unit is usd, round to two decimal places.
|
|
201
|
-
if (unit.toLowerCase() == "usd") {
|
|
202
|
-
txn.value = floor(txn.value, 2);
|
|
203
|
-
txn.fee = floor(txn.fee, 2);
|
|
187
|
+
});
|
|
188
|
+
// order transactions in a way such that receives are always ordered before sends, per block
|
|
189
|
+
historyItems.sort((a, b) => (a.blockHeight <= 0 || b.blockHeight <= 0
|
|
190
|
+
? a.blockHeight - b.blockHeight
|
|
191
|
+
: b.blockHeight - a.blockHeight) || a.valueChange - b.valueChange);
|
|
192
|
+
// backfill the balances
|
|
193
|
+
let prevBalance = await provider.getBalance(address);
|
|
194
|
+
let prevValueChange = 0;
|
|
195
|
+
historyItems.forEach((tx) => {
|
|
196
|
+
tx.balance = prevBalance - prevValueChange;
|
|
197
|
+
prevBalance = tx.balance;
|
|
198
|
+
prevValueChange = tx.valueChange;
|
|
199
|
+
});
|
|
200
|
+
// convert units if needed
|
|
201
|
+
if (!unit.includes("sat")) {
|
|
202
|
+
for (const tx of historyItems) {
|
|
203
|
+
for (const input of tx.inputs) {
|
|
204
|
+
input.value = await convert(input.value, "sat", unit);
|
|
205
|
+
}
|
|
206
|
+
for (const output of tx.outputs) {
|
|
207
|
+
output.value = await convert(output.value, "sat", unit);
|
|
208
|
+
}
|
|
209
|
+
tx.valueChange = await convert(tx.valueChange, "sat", unit);
|
|
210
|
+
tx.balance = await convert(tx.balance, "sat", unit);
|
|
204
211
|
}
|
|
205
|
-
// note the unit
|
|
206
|
-
txn.unit = unit;
|
|
207
|
-
r.push(txn);
|
|
208
212
|
}
|
|
209
|
-
return
|
|
210
|
-
}
|
|
213
|
+
return historyItems;
|
|
214
|
+
};
|
|
211
215
|
//# sourceMappingURL=electrumTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electrumTransformer.js","sourceRoot":"","sources":["../../../src/history/electrumTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"electrumTransformer.js","sourceRoot":"","sources":["../../../src/history/electrumTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,4BAA4B,EAE5B,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE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,IAAI,CAAC,CAAC;aACvD;YAED,KAAK,MAAM,MAAM,IAAI,EAAE,CAAC,OAAO,EAAE;gBAC/B,MAAM,CAAC,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;aACzD;YAED,EAAE,CAAC,WAAW,GAAG,MAAM,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC5D,EAAE,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACrD;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
from: string;
|
|
5
|
-
unit: UnitEnum;
|
|
6
|
-
index: number;
|
|
7
|
-
blockheight: number;
|
|
8
|
-
txn: string;
|
|
9
|
-
txId: string;
|
|
1
|
+
import { TokenI } from "../interface.js";
|
|
2
|
+
export interface InOutput {
|
|
3
|
+
address: string;
|
|
10
4
|
value: number;
|
|
11
|
-
|
|
12
|
-
balance?: number;
|
|
5
|
+
token?: TokenI;
|
|
13
6
|
}
|
|
14
|
-
export interface
|
|
15
|
-
|
|
7
|
+
export interface TransactionHistoryItem {
|
|
8
|
+
inputs: InOutput[];
|
|
9
|
+
outputs: InOutput[];
|
|
10
|
+
blockHeight: number;
|
|
11
|
+
timestamp?: number;
|
|
12
|
+
hash: string;
|
|
13
|
+
size: number;
|
|
14
|
+
fee: number;
|
|
15
|
+
balance: number;
|
|
16
|
+
valueChange: number;
|
|
17
|
+
tokenAmountChanges: {
|
|
18
|
+
tokenId: string;
|
|
19
|
+
amount: bigint;
|
|
20
|
+
nftAmount: bigint;
|
|
21
|
+
}[];
|
|
16
22
|
}
|
|
17
23
|
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/history/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/history/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;CACL"}
|
|
@@ -23,13 +23,13 @@ export default class ElectrumNetworkProvider implements NetworkProvider {
|
|
|
23
23
|
getRawTransaction(txHash: string, verbose?: boolean, loadInputValues?: boolean): Promise<string>;
|
|
24
24
|
getRawTransactionObject(txHash: string, loadInputValues?: boolean): Promise<ElectrumRawTransaction>;
|
|
25
25
|
sendRawTransaction(txHex: string, awaitPropagation?: boolean): Promise<string>;
|
|
26
|
-
getHistory(cashaddr: string): Promise<TxI[]>;
|
|
26
|
+
getHistory(cashaddr: string, fromHeight?: number, toHeight?: number): Promise<TxI[]>;
|
|
27
27
|
getRelayFee(): Promise<number>;
|
|
28
28
|
watchAddressStatus(cashaddr: string, callback: (status: string) => void): CancelWatchFn;
|
|
29
29
|
watchAddress(cashaddr: string, callback: (txHash: string) => void): CancelWatchFn;
|
|
30
30
|
watchAddressTransactions(cashaddr: string, callback: (tx: ElectrumRawTransaction) => void): CancelWatchFn;
|
|
31
31
|
watchAddressTokenTransactions(cashaddr: string, callback: (tx: ElectrumRawTransaction) => void): CancelWatchFn;
|
|
32
|
-
watchBlocks(callback: (header: HexHeaderI) => void): CancelWatchFn;
|
|
32
|
+
watchBlocks(callback: (header: HexHeaderI) => void, skipCurrentHeight?: boolean): CancelWatchFn;
|
|
33
33
|
waitForBlock(height?: number): Promise<HexHeaderI>;
|
|
34
34
|
subscribeToHeaders(callback: (header: HexHeaderI) => void): Promise<void>;
|
|
35
35
|
unsubscribeFromHeaders(callback: (header: HexHeaderI) => void): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectrumNetworkProvider.d.ts","sourceRoot":"","sources":["../../../src/network/ElectrumNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"ElectrumNetworkProvider.d.ts","sourceRoot":"","sources":["../../../src/network/ElectrumNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,UAAU,EACV,GAAG,EACH,KAAK,EAEL,OAAO,EACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAgB,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,MA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I,EAAE,GAAG,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC;IAQV,sBAAsB,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC;IAQV,0BAA0B,CAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC;YAQF,cAAc;YAsCd,gBAAgB;YAkBhB,kBAAkB;IAkB1B,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAInC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIhC,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAWhC,gBAAgB,IAAI,OAAO;IAIrB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAezD,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKhD,cAAc,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIjC,aAAa,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAiBhC,iBAAiB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC,gBAAgB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG7C"}
|
|
@@ -86,7 +86,7 @@ export default class ElectrumNetworkProvider {
|
|
|
86
86
|
else {
|
|
87
87
|
ElectrumNetworkProvider.rawTransactionCache[key];
|
|
88
88
|
}
|
|
89
|
-
const result = await this.performRequest("blockchain.header.get", height);
|
|
89
|
+
const result = (await this.performRequest("blockchain.header.get", height));
|
|
90
90
|
if (Config.UseLocalStorageCache) {
|
|
91
91
|
localStorage.setItem(key, JSON.stringify(result));
|
|
92
92
|
}
|
|
@@ -171,8 +171,8 @@ export default class ElectrumNetworkProvider {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
// Get transaction history of a given cashaddr
|
|
174
|
-
async getHistory(cashaddr) {
|
|
175
|
-
const result = (await this.performRequest("blockchain.address.get_history", cashaddr));
|
|
174
|
+
async getHistory(cashaddr, fromHeight = 0, toHeight = -1) {
|
|
175
|
+
const result = (await this.performRequest("blockchain.address.get_history", cashaddr, fromHeight, toHeight));
|
|
176
176
|
return result;
|
|
177
177
|
}
|
|
178
178
|
// Get the minimum fee a low-priority transaction must pay in order to be accepted to the daemon's memory pool.
|
|
@@ -233,9 +233,9 @@ export default class ElectrumNetworkProvider {
|
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
//
|
|
237
|
-
watchBlocks(callback) {
|
|
238
|
-
let acknowledged =
|
|
236
|
+
// watch for block headers and block height, if `skipCurrentHeight` is set, the notification about current block will not arrive
|
|
237
|
+
watchBlocks(callback, skipCurrentHeight = true) {
|
|
238
|
+
let acknowledged = !skipCurrentHeight;
|
|
239
239
|
const waitForBlockCallback = (_header) => {
|
|
240
240
|
if (!acknowledged) {
|
|
241
241
|
acknowledged = true;
|