@atomicfinance/bitcoin-wallet-provider 2.5.1 → 3.0.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/.turbo/turbo-build.log +1 -2
- package/.turbo/turbo-lint.log +1 -0
- package/.turbo/turbo-lint:fix.log +15 -0
- package/.turbo/turbo-test.log +1 -3
- package/CHANGELOG.md +13 -0
- package/dist/BitcoinWalletProvider.d.ts +113 -104
- package/dist/BitcoinWalletProvider.js +444 -353
- package/dist/BitcoinWalletProvider.js.map +1 -1
- package/lib/BitcoinWalletProvider.ts +668 -530
- package/package.json +7 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
[35m@atomicfinance/bitcoin-wallet-provider:build: [0m$ ../../node_modules/.bin/tsc --project tsconfig.json
|
|
1
|
+
@atomicfinance/bitcoin-wallet-provider:build: cache hit, replaying output [2mb325ad3ff6de7aac[0m
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[34m@atomicfinance/bitcoin-wallet-provider:lint: [0mcache hit, replaying output [2maf872b95486337af[0m
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0mcache hit, replaying output [2m6e84e23ff8f9523c[0m
|
|
2
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m
|
|
3
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m/Users/steven/src/atomicfinance/chainify-finance/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.ts
|
|
4
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 48:47 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
5
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 56:16 warning Missing return type on function @typescript-eslint/explicit-module-boundary-types
|
|
6
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 67:26 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
7
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 105:52 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
8
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 108:11 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
9
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 606:45 warning 'i' is defined but never used @typescript-eslint/no-unused-vars
|
|
10
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 662:15 warning 'paymentVariant' is assigned a value but never used @typescript-eslint/no-unused-vars
|
|
11
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 872:39 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
12
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m 887:52 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
13
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m
|
|
14
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m✖ 9 problems (0 errors, 9 warnings)
|
|
15
|
+
[35m@atomicfinance/bitcoin-wallet-provider:lint:fix: [0m
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
[33m@atomicfinance/bitcoin-wallet-provider:test: [0m$ yarn run build
|
|
3
|
-
[33m@atomicfinance/bitcoin-wallet-provider:test: [0m$ ../../node_modules/.bin/tsc --project tsconfig.json
|
|
1
|
+
@atomicfinance/bitcoin-wallet-provider:test: cache hit, replaying output [2m6d78adb12d3efcbb[0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atomicfinance/bitcoin-wallet-provider
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- a06082e: Create unified standalone `bitcoin-abstraction-layer` package
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [a06082e]
|
|
12
|
+
- @atomicfinance/provider@3.0.0
|
|
13
|
+
- @atomicfinance/types@3.0.0
|
|
14
|
+
- @atomicfinance/bitcoin-utils@3.0.0
|
|
15
|
+
|
|
3
16
|
## 2.5.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,111 +1,120 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CoinSelectTarget } from '@atomicfinance/bitcoin-utils';
|
|
1
3
|
import Provider from '@atomicfinance/provider';
|
|
2
|
-
import {
|
|
3
|
-
import { BitcoinNetwork } from '
|
|
4
|
-
import { Address, bitcoin as bT, Transaction } from '@liquality/types';
|
|
4
|
+
import { Address, bitcoin as bT, SendOptions, Transaction } from '@atomicfinance/types';
|
|
5
|
+
import { BitcoinNetwork } from 'bitcoin-networks';
|
|
5
6
|
import * as bitcoin from 'bitcoinjs-lib';
|
|
7
|
+
import { BIP32Interface } from 'bitcoinjs-lib';
|
|
6
8
|
declare type UnusedAddressesBlacklist = {
|
|
7
9
|
[address: string]: true;
|
|
8
10
|
};
|
|
9
|
-
export
|
|
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
|
-
|
|
11
|
+
export declare enum AddressSearchType {
|
|
12
|
+
EXTERNAL = 0,
|
|
13
|
+
CHANGE = 1,
|
|
14
|
+
EXTERNAL_OR_CHANGE = 2
|
|
15
|
+
}
|
|
16
|
+
declare type DerivationCache = {
|
|
17
|
+
[index: string]: Address;
|
|
18
|
+
};
|
|
19
|
+
declare type Constructor<T = unknown> = new (...args: any[]) => T;
|
|
20
|
+
declare const _default: <T extends Constructor<Provider>>(superclass: T) => {
|
|
21
|
+
new (...args: any[]): {
|
|
22
|
+
_network: BitcoinNetwork;
|
|
23
|
+
_unusedAddressesBlacklist: UnusedAddressesBlacklist;
|
|
24
|
+
_maxAddressesToDerive: number;
|
|
25
|
+
_baseDerivationPath: string;
|
|
26
|
+
_addressType: bT.AddressType;
|
|
27
|
+
_derivationCache: DerivationCache;
|
|
28
|
+
baseDerivationNode(): Promise<BIP32Interface>;
|
|
29
|
+
_buildTransaction(targets: bT.OutputTarget[], feePerByte?: number, fixedInputs?: bT.Input[]): Promise<{
|
|
30
|
+
hex: string;
|
|
31
|
+
fee: number;
|
|
32
|
+
}>;
|
|
33
|
+
_buildSweepTransaction(externalChangeAddress: string, feePerByte?: number): Promise<{
|
|
34
|
+
hex: string;
|
|
35
|
+
fee: number;
|
|
36
|
+
}>;
|
|
37
|
+
signPSBT(data: string, inputs: bT.PsbtInputTarget[]): Promise<string>;
|
|
38
|
+
signBatchP2SHTransaction(inputs: [
|
|
39
|
+
{
|
|
40
|
+
inputTxHex: string;
|
|
41
|
+
index: number;
|
|
42
|
+
vout: any;
|
|
43
|
+
outputScript: Buffer;
|
|
44
|
+
}
|
|
45
|
+
], addresses: string, tx: any, lockTime?: number, segwit?: boolean): Promise<Buffer[]>;
|
|
46
|
+
getDerivationCache(): DerivationCache;
|
|
47
|
+
setDerivationCache(derivationCache: DerivationCache): Promise<void>;
|
|
48
|
+
sendOptionsToOutputs(transactions: SendOptions[]): bT.OutputTarget[];
|
|
49
|
+
buildTransaction(output: bT.OutputTarget, feePerByte: number): Promise<{
|
|
50
|
+
hex: string;
|
|
51
|
+
fee: number;
|
|
52
|
+
}>;
|
|
53
|
+
buildBatchTransaction(outputs: bT.OutputTarget[]): Promise<{
|
|
54
|
+
hex: string;
|
|
55
|
+
fee: number;
|
|
56
|
+
}>;
|
|
57
|
+
_sendTransaction(transactions: bT.OutputTarget[], feePerByte?: number): Promise<Transaction<bT.Transaction>>;
|
|
58
|
+
sendTransaction(options: SendOptions): Promise<Transaction<bT.Transaction>>;
|
|
59
|
+
sendBatchTransaction(transactions: SendOptions[]): Promise<Transaction<bT.Transaction>>;
|
|
60
|
+
buildSweepTransaction(externalChangeAddress: string, feePerByte: number): Promise<{
|
|
61
|
+
hex: string;
|
|
62
|
+
fee: number;
|
|
63
|
+
}>;
|
|
64
|
+
sendSweepTransaction(externalChangeAddress: Address | string, feePerByte: number): Promise<Transaction<bT.Transaction>>;
|
|
65
|
+
getUnusedAddressesBlacklist(): UnusedAddressesBlacklist;
|
|
66
|
+
setUnusedAddressesBlacklist(unusedAddressesBlacklist: UnusedAddressesBlacklist): void;
|
|
67
|
+
setMaxAddressesToDerive(maxAddressesToDerive: number): void;
|
|
68
|
+
getMaxAddressesToDerive(): number;
|
|
69
|
+
updateTransactionFee(tx: Transaction<bitcoin.Transaction> | string, newFeePerByte: number): Promise<Transaction<bT.Transaction>>;
|
|
70
|
+
getUnusedAddress(change?: boolean, numAddressPerCall?: number): Promise<any>;
|
|
71
|
+
_getUsedUnusedAddresses(numAddressPerCall: number, addressType: any): Promise<{
|
|
72
|
+
usedAddresses: any[];
|
|
73
|
+
unusedAddress: {
|
|
74
|
+
change: any;
|
|
75
|
+
nonChange: any;
|
|
76
|
+
};
|
|
77
|
+
firstUnusedAddress: any;
|
|
78
|
+
}>;
|
|
79
|
+
getWalletAddress(address: string): Promise<Address>;
|
|
80
|
+
getAddressFromPublicKey(publicKey: Buffer): string;
|
|
81
|
+
getPaymentVariantFromPublicKey(publicKey: Buffer): bitcoin.payments.Payment;
|
|
82
|
+
getDerivationPathAddress(path: string): Promise<Address>;
|
|
83
|
+
/**
|
|
84
|
+
* getAddresses is an optimized version of upstream CAL's getAddresses.
|
|
85
|
+
* It removes the call to `asyncSetImmediate()`, speeding up the function by a factor of 6x.
|
|
86
|
+
*
|
|
87
|
+
* @param startingIndex
|
|
88
|
+
* @param numAddresses
|
|
89
|
+
* @param change
|
|
90
|
+
* @returns {Promise<Address[]>}
|
|
91
|
+
*/
|
|
92
|
+
getAddresses(startingIndex?: number, numAddresses?: number, change?: boolean): Promise<Address[]>;
|
|
93
|
+
/**
|
|
94
|
+
* findAddress is an optimized version of upstream CAL's findAddress.
|
|
95
|
+
*
|
|
96
|
+
* It searches through both change and non-change addresses (if change arg is not provided) each iteration.
|
|
97
|
+
*
|
|
98
|
+
* This is in contrast to the original findAddress function which searches
|
|
99
|
+
* through all non-change addresses before moving on to change addresses.
|
|
100
|
+
*
|
|
101
|
+
* @param addresses
|
|
102
|
+
* @returns {Promise<Address>}
|
|
103
|
+
*/
|
|
104
|
+
findAddress(addresses: string[], change?: boolean | null): Promise<Address>;
|
|
105
|
+
getUsedAddresses(numAddressPerCall?: number): Promise<any[]>;
|
|
106
|
+
withCachedUtxos(func: () => any): Promise<any>;
|
|
107
|
+
getTotalFee(opts: SendOptions, max: boolean): Promise<number>;
|
|
108
|
+
getTotalFees(transactions: SendOptions[], max: boolean): Promise<any>;
|
|
109
|
+
getInputsForAmount(_targets: bT.OutputTarget[], feePerByte?: number, fixedInputs?: bT.Input[], numAddressPerCall?: number, sweep?: boolean): Promise<{
|
|
110
|
+
inputs: bT.UTXO[];
|
|
62
111
|
change: any;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
hex: string;
|
|
70
|
-
fee: number;
|
|
71
|
-
}>;
|
|
72
|
-
_getInputForAmountWithoutUtxoCheck(_outputs: Output[], _feePerByte: number, fixedInputs: Input[]): {
|
|
73
|
-
inputs: bT.UTXO[];
|
|
74
|
-
outputs: {
|
|
75
|
-
value: number;
|
|
76
|
-
id?: string;
|
|
77
|
-
}[];
|
|
78
|
-
fee: number;
|
|
79
|
-
change: {
|
|
80
|
-
value: number;
|
|
81
|
-
id?: string;
|
|
82
|
-
};
|
|
112
|
+
outputs: CoinSelectTarget[];
|
|
113
|
+
fee: number;
|
|
114
|
+
}>;
|
|
115
|
+
client: import("@atomicfinance/types").IClient;
|
|
116
|
+
setClient(client?: import("@atomicfinance/types").IClient): void;
|
|
117
|
+
getMethod(method: string, requestor?: any): (...args: any[]) => any;
|
|
83
118
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fee: number;
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* quickGetAddresses is an optimized version of getAddresses.
|
|
90
|
-
* It removes the call to `asyncSetImmediate()`, speeding up the function by a factor of 6x.
|
|
91
|
-
*
|
|
92
|
-
* @param startingIndex
|
|
93
|
-
* @param numAddresses
|
|
94
|
-
* @param change
|
|
95
|
-
* @returns {Promise<Address[]>}
|
|
96
|
-
*/
|
|
97
|
-
quickGetAddresses(startingIndex?: number, numAddresses?: number, change?: boolean): Promise<Address[]>;
|
|
98
|
-
/**
|
|
99
|
-
* quickFindAddress is an optimized version of findAddress.
|
|
100
|
-
*
|
|
101
|
-
* It searches through both change and non-change addresses each iteration.
|
|
102
|
-
*
|
|
103
|
-
* This is in contrast to the original findAddress function which searches
|
|
104
|
-
* through all non-change addresses before moving on to change addresses.
|
|
105
|
-
*
|
|
106
|
-
* @param addresses
|
|
107
|
-
* @returns {Promise<Address[]>}
|
|
108
|
-
*/
|
|
109
|
-
quickFindAddress(addresses: string[]): Promise<Address>;
|
|
110
|
-
}
|
|
111
|
-
export {};
|
|
119
|
+
} & T;
|
|
120
|
+
export default _default;
|