@atomicfinance/bitcoin-wallet-provider 2.5.0 → 3.0.1

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 98a9bcec703e0822
@@ -0,0 +1 @@
1
+ @atomicfinance/bitcoin-wallet-provider:test: cache hit, replaying output d2bf08a921f65444
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # @atomicfinance/bitcoin-wallet-provider
2
+
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @atomicfinance/bitcoin-utils@3.0.1
8
+ - @atomicfinance/provider@3.0.1
9
+ - @atomicfinance/types@3.0.1
10
+
11
+ ## 3.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - a06082e: Create unified standalone `bitcoin-abstraction-layer` package
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [a06082e]
20
+ - @atomicfinance/provider@3.0.0
21
+ - @atomicfinance/types@3.0.0
22
+ - @atomicfinance/bitcoin-utils@3.0.0
23
+
24
+ ## 2.5.1
25
+
26
+ ### Patch Changes
27
+
28
+ - Upgrade various package dependencies
29
+ - Updated dependencies
30
+ - @atomicfinance/provider@2.5.1
31
+ - @atomicfinance/types@2.5.1
@@ -1,91 +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
- quickGetAddresses(startingIndex?: number, numAddresses?: number, change?: boolean): Promise<Address[]>;
89
- quickFindAddress(addresses: string[]): Promise<Address>;
90
- }
91
- export {};
119
+ } & T;
120
+ export default _default;