@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.
@@ -1,2 +1 @@
1
- @atomicfinance/bitcoin-wallet-provider:build: cache hit, replaying output d819286900be3739
2
- @atomicfinance/bitcoin-wallet-provider:build: $ ../../node_modules/.bin/tsc --project tsconfig.json
1
+ @atomicfinance/bitcoin-wallet-provider:build: cache hit, replaying output b325ad3ff6de7aac
@@ -0,0 +1 @@
1
+ @atomicfinance/bitcoin-wallet-provider:lint: cache hit, replaying output af872b95486337af
@@ -0,0 +1,15 @@
1
+ @atomicfinance/bitcoin-wallet-provider:lint:fix: cache hit, replaying output 6e84e23ff8f9523c
2
+ @atomicfinance/bitcoin-wallet-provider:lint:fix: 
3
+ @atomicfinance/bitcoin-wallet-provider:lint:fix: /Users/steven/src/atomicfinance/chainify-finance/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.ts
4
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  48:47 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
5
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  56:16 warning Missing return type on function @typescript-eslint/explicit-module-boundary-types
6
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  67:26 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
7
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  105:52 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
8
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  108:11 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
9
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  606:45 warning 'i' is defined but never used @typescript-eslint/no-unused-vars
10
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  662:15 warning 'paymentVariant' is assigned a value but never used @typescript-eslint/no-unused-vars
11
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  872:39 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
12
+ @atomicfinance/bitcoin-wallet-provider:lint:fix:  887:52 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
13
+ @atomicfinance/bitcoin-wallet-provider:lint:fix: 
14
+ @atomicfinance/bitcoin-wallet-provider:lint:fix: ✖ 9 problems (0 errors, 9 warnings)
15
+ @atomicfinance/bitcoin-wallet-provider:lint:fix: 
@@ -1,3 +1 @@
1
- @atomicfinance/bitcoin-wallet-provider:test: cache hit, replaying output cc5a2e402ef25414
2
- @atomicfinance/bitcoin-wallet-provider:test: $ yarn run build
3
- @atomicfinance/bitcoin-wallet-provider:test: $ ../../node_modules/.bin/tsc --project tsconfig.json
1
+ @atomicfinance/bitcoin-wallet-provider:test: cache hit, replaying output 6d78adb12d3efcbb
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 { CreateMultisigResponse, finalizePSBTResponse, FinanceWalletProvider, Input, Output } from '@atomicfinance/types';
3
- import { BitcoinNetwork } from '@liquality/bitcoin-networks';
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 default class BitcoinWalletProvider extends Provider implements Partial<FinanceWalletProvider> {
10
- _network: BitcoinNetwork;
11
- _unusedAddressesBlacklist: UnusedAddressesBlacklist;
12
- _maxAddressesToDerive: number;
13
- constructor(network: BitcoinNetwork);
14
- buildSweepTransactionWithSetOutputs(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): Promise<{
15
- hex: string;
16
- fee: number;
17
- }>;
18
- getUnusedAddressesBlacklist(): UnusedAddressesBlacklist;
19
- setUnusedAddressesBlacklist(unusedAddressesBlacklist: UnusedAddressesBlacklist): void;
20
- setMaxAddressesToDerive(maxAddressesToDerive: number): void;
21
- getMaxAddressesToDerive(): number;
22
- _createMultisigPayment(m: number, pubkeys: string[]): bitcoin.Payment;
23
- /**
24
- * Creates a native-segwit multi-signature address (P2MS in P2WSH) with n signatures of m required keys
25
- * https://developer.bitcoin.org/reference/rpc/createmultisig.html
26
- * @param m the number of required signatures
27
- * @param pubkeys n possible pubkeys in total
28
- * @returns a json object containing the `address` and `redeemScript`
29
- */
30
- createMultisig(m: number, pubkeys: string[]): CreateMultisigResponse;
31
- /**
32
- * Creates a PSBT of a native-segwit multi-signature address (P2MS in P2WSH) with n signatures of m required keys
33
- * https://developer.bitcoin.org/reference/rpc/createmultisig.html
34
- * https://developer.bitcoin.org/reference/rpc/createpsbt.html
35
- * @param m the number of required signatures
36
- * @param pubkeys n possible pubkeys in total
37
- * @param inputs the Inputs to the PSBT
38
- * @param ouputs the Outputs to the PSBT
39
- * @returns a base64 encoded psbt string
40
- */
41
- buildMultisigPSBT(m: number, pubkeys: string[], inputs: Input[], outputs: Output[]): string;
42
- /**
43
- * Update a PSBT with input information from our wallet and then sign inputs that we can sign for
44
- * https://developer.bitcoin.org/reference/rpc/walletprocesspsbt.html
45
- * @param psbt a base64 encoded psbt string (P2WSH only)
46
- * @returns a base64 encoded signed psbt string
47
- */
48
- walletProcessPSBT(psbtString: string): Promise<string>;
49
- /**
50
- * Finalize the inputs of a PSBT. If the transaction is fully signed, it will
51
- * produce a network serialized transaction which can be broadcast with sendrawtransaction
52
- * https://developer.bitcoin.org/reference/rpc/finalizepsbt.html
53
- * @param psbt a base64 encoded psbt string
54
- * @returns a json object containing `psbt` in base64, `hex` for transaction and `complete` for if
55
- * the transaction has a complete set of signatures
56
- */
57
- finalizePSBT(psbtString: string): finalizePSBTResponse;
58
- getUnusedAddress(change?: boolean, numAddressPerCall?: number): Promise<any>;
59
- _getUsedUnusedAddresses(numAddressPerCall: number, addressType: any): Promise<{
60
- usedAddresses: any[];
61
- unusedAddress: {
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
- nonChange: any;
64
- };
65
- firstUnusedAddress: any;
66
- }>;
67
- sendSweepTransactionWithSetOutputs(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): Promise<Transaction<bT.Transaction>>;
68
- _buildSweepTransaction(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): Promise<{
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
- _buildTransactionWithoutUtxoCheck(outputs: Output[], feePerByte: number, fixedInputs: Input[]): Promise<{
85
- hex: string;
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;