@atomicfinance/bitcoin-wallet-provider 2.4.2 → 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.
@@ -0,0 +1 @@
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: 
@@ -0,0 +1 @@
1
+ @atomicfinance/bitcoin-wallet-provider:test: cache hit, replaying output 6d78adb12d3efcbb
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # @atomicfinance/bitcoin-wallet-provider
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
+
16
+ ## 2.5.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Upgrade various package dependencies
21
+ - Updated dependencies
22
+ - @atomicfinance/provider@2.5.1
23
+ - @atomicfinance/types@2.5.1
@@ -1,87 +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
- constructor(network: BitcoinNetwork);
13
- buildSweepTransactionWithSetOutputs(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): Promise<{
14
- hex: string;
15
- fee: number;
16
- }>;
17
- getUnusedAddressesBlacklist(): UnusedAddressesBlacklist;
18
- setUnusedAddressesBlacklist(unusedAddressesBlacklist: UnusedAddressesBlacklist): void;
19
- _createMultisigPayment(m: number, pubkeys: string[]): bitcoin.Payment;
20
- /**
21
- * Creates a native-segwit multi-signature address (P2MS in P2WSH) with n signatures of m required keys
22
- * https://developer.bitcoin.org/reference/rpc/createmultisig.html
23
- * @param m the number of required signatures
24
- * @param pubkeys n possible pubkeys in total
25
- * @returns a json object containing the `address` and `redeemScript`
26
- */
27
- createMultisig(m: number, pubkeys: string[]): CreateMultisigResponse;
28
- /**
29
- * Creates a PSBT of a native-segwit multi-signature address (P2MS in P2WSH) with n signatures of m required keys
30
- * https://developer.bitcoin.org/reference/rpc/createmultisig.html
31
- * https://developer.bitcoin.org/reference/rpc/createpsbt.html
32
- * @param m the number of required signatures
33
- * @param pubkeys n possible pubkeys in total
34
- * @param inputs the Inputs to the PSBT
35
- * @param ouputs the Outputs to the PSBT
36
- * @returns a base64 encoded psbt string
37
- */
38
- buildMultisigPSBT(m: number, pubkeys: string[], inputs: Input[], outputs: Output[]): string;
39
- /**
40
- * Update a PSBT with input information from our wallet and then sign inputs that we can sign for
41
- * https://developer.bitcoin.org/reference/rpc/walletprocesspsbt.html
42
- * @param psbt a base64 encoded psbt string (P2WSH only)
43
- * @returns a base64 encoded signed psbt string
44
- */
45
- walletProcessPSBT(psbtString: string): Promise<string>;
46
- /**
47
- * Finalize the inputs of a PSBT. If the transaction is fully signed, it will
48
- * produce a network serialized transaction which can be broadcast with sendrawtransaction
49
- * https://developer.bitcoin.org/reference/rpc/finalizepsbt.html
50
- * @param psbt a base64 encoded psbt string
51
- * @returns a json object containing `psbt` in base64, `hex` for transaction and `complete` for if
52
- * the transaction has a complete set of signatures
53
- */
54
- finalizePSBT(psbtString: string): finalizePSBTResponse;
55
- getUnusedAddress(change?: boolean, numAddressPerCall?: number): Promise<any>;
56
- _getUsedUnusedAddresses(numAddressPerCall: number, addressType: any): Promise<{
57
- usedAddresses: any[];
58
- 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[];
59
111
  change: any;
60
- nonChange: any;
61
- };
62
- firstUnusedAddress: any;
63
- }>;
64
- sendSweepTransactionWithSetOutputs(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): Promise<Transaction<bT.Transaction>>;
65
- _buildSweepTransaction(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): Promise<{
66
- hex: string;
67
- fee: number;
68
- }>;
69
- _getInputForAmountWithoutUtxoCheck(_outputs: Output[], _feePerByte: number, fixedInputs: Input[]): {
70
- inputs: bT.UTXO[];
71
- outputs: {
72
- value: number;
73
- id?: string;
74
- }[];
75
- fee: number;
76
- change: {
77
- value: number;
78
- id?: string;
79
- };
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;
80
118
  };
81
- _buildTransactionWithoutUtxoCheck(outputs: Output[], feePerByte: number, fixedInputs: Input[]): Promise<{
82
- hex: string;
83
- fee: number;
84
- }>;
85
- quickFindAddress(addresses: string[]): Promise<Address>;
86
- }
87
- export {};
119
+ } & T;
120
+ export default _default;