@atomicfinance/types 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.
- package/.turbo/turbo-build.log +1 -0
- package/.turbo/turbo-test.log +1 -0
- package/CHANGELOG.md +15 -0
- package/dist/address.d.ts +10 -0
- package/dist/address.js +11 -0
- package/dist/address.js.map +1 -0
- package/dist/bitcoin.d.ts +66 -0
- package/dist/bitcoin.js +16 -0
- package/dist/bitcoin.js.map +1 -0
- package/dist/block.d.ts +10 -0
- package/dist/block.js +3 -0
- package/dist/block.js.map +1 -0
- package/dist/cfd.d.ts +0 -0
- package/dist/cfd.js +5 -5
- package/dist/cfd.js.map +0 -0
- package/dist/chain.d.ts +107 -0
- package/dist/chain.js +3 -0
- package/dist/chain.js.map +1 -0
- package/dist/common.d.ts +0 -0
- package/dist/common.js +3 -5
- package/dist/common.js.map +0 -0
- package/dist/dlc.d.ts +0 -0
- package/dist/dlc.js +5 -5
- package/dist/dlc.js.map +0 -0
- package/dist/fees.d.ts +17 -0
- package/dist/fees.js +3 -0
- package/dist/fees.js.map +1 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.js +54 -161
- package/dist/index.js.map +1 -1
- package/dist/jsonrpc.d.ts +72 -0
- package/dist/jsonrpc.js +3 -0
- package/dist/jsonrpc.js.map +1 -0
- package/dist/models/Amount.d.ts +0 -0
- package/dist/models/Amount.js +14 -16
- package/dist/models/Amount.js.map +0 -0
- package/dist/models/Input.d.ts +8 -8
- package/dist/models/Input.js +51 -39
- package/dist/models/Input.js.map +1 -1
- package/dist/models/OracleInfo.d.ts +0 -0
- package/dist/models/OracleInfo.js +6 -9
- package/dist/models/OracleInfo.js.map +0 -0
- package/dist/models/Outcome.d.ts +0 -0
- package/dist/models/Outcome.js +17 -22
- package/dist/models/Outcome.js.map +0 -0
- package/dist/models/Output.d.ts +0 -0
- package/dist/models/Output.js +6 -9
- package/dist/models/Output.js.map +0 -0
- package/dist/models/Utxo.d.ts +0 -0
- package/dist/models/Utxo.js +26 -27
- package/dist/models/Utxo.js.map +0 -0
- package/dist/network.d.ts +5 -0
- package/dist/network.js +3 -0
- package/dist/network.js.map +1 -0
- package/dist/transaction.d.ts +17 -0
- package/dist/transaction.js +10 -0
- package/dist/transaction.js.map +1 -0
- package/dist/wallet.d.ts +78 -0
- package/dist/wallet.js +3 -5
- package/dist/wallet.js.map +0 -0
- package/lib/address.ts +13 -0
- package/lib/bitcoin.ts +72 -0
- package/lib/block.ts +18 -0
- package/lib/chain.ts +126 -0
- package/lib/fees.ts +21 -0
- package/lib/index.ts +31 -9
- package/lib/jsonrpc.ts +81 -0
- package/lib/models/Input.ts +8 -9
- package/lib/network.ts +5 -0
- package/lib/transaction.ts +28 -0
- package/lib/wallet.ts +109 -0
- package/package.json +5 -8
- package/LICENSE +0 -674
- package/dist/financewallet.d.ts +0 -11
- package/dist/financewallet.js +0 -5
- package/dist/financewallet.js.map +0 -1
- package/lib/financewallet.ts +0 -31
package/lib/models/Input.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as bT from '../bitcoin';
|
|
3
2
|
import Amount from './Amount';
|
|
4
3
|
import Utxo from './Utxo';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* Class for interfacing with inputs/utxos in Liquality
|
|
8
|
-
* https://github.com/liquality/
|
|
6
|
+
* Class for interfacing with inputs/utxos in Liquality Chainify
|
|
7
|
+
* https://github.com/liquality/chainify
|
|
9
8
|
*
|
|
10
9
|
* These inputs can have different fields for value
|
|
11
|
-
* satoshis (sats): https://github.com/liquality/
|
|
12
|
-
* amount (btc): https://github.com/liquality/
|
|
13
|
-
* value (sats): https://github.com/liquality/
|
|
10
|
+
* satoshis (sats): https://github.com/liquality/chainify/blob/dev/packages/bitcoin-esplora-api-provider/lib/BitcoinEsploraApiProvider.js#L65
|
|
11
|
+
* amount (btc): https://github.com/liquality/chainify/blob/dev/packages/bitcoin-esplora-api-provider/lib/BitcoinEsploraApiProvider.js#L74
|
|
12
|
+
* value (sats): https://github.com/liquality/chainify/blob/dev/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.js#L331
|
|
14
13
|
*
|
|
15
14
|
* This will be fixed once typescript branch is merged:
|
|
16
|
-
* https://github.com/liquality/
|
|
15
|
+
* https://github.com/liquality/chainify/tree/typescript
|
|
17
16
|
* satoshis and amount will not be necessary, only value
|
|
18
|
-
* https://github.com/liquality/
|
|
17
|
+
* https://github.com/liquality/chainify/blob/typescript/packages/types/lib/bitcoin.ts#L46
|
|
19
18
|
*/
|
|
20
19
|
export default class Input {
|
|
21
20
|
constructor(
|
package/lib/network.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Transaction<T = any> {
|
|
2
|
+
// Transaction hash
|
|
3
|
+
hash: string;
|
|
4
|
+
// The value of the transaction
|
|
5
|
+
value: number;
|
|
6
|
+
// transaction status
|
|
7
|
+
status?: TxStatus;
|
|
8
|
+
// Hash of the block containing the transaction
|
|
9
|
+
blockHash?: string;
|
|
10
|
+
// The block number containing the trnasaction
|
|
11
|
+
blockNumber?: number;
|
|
12
|
+
// The number of confirmations of the transaction
|
|
13
|
+
confirmations?: number;
|
|
14
|
+
// The price per unit of fee
|
|
15
|
+
feePrice?: number;
|
|
16
|
+
// The total fee paid for the transaction
|
|
17
|
+
fee?: number;
|
|
18
|
+
// Secret of a HTLC
|
|
19
|
+
secret?: string;
|
|
20
|
+
// The raw transaction object
|
|
21
|
+
_raw: T;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum TxStatus {
|
|
25
|
+
Pending = 'PENDING',
|
|
26
|
+
Failed = 'FAILED',
|
|
27
|
+
Success = 'SUCCESS',
|
|
28
|
+
}
|
package/lib/wallet.ts
CHANGED
|
@@ -1,5 +1,114 @@
|
|
|
1
|
+
import { Address } from './address';
|
|
2
|
+
import Input from './models/Input';
|
|
3
|
+
import Output from './models/Output';
|
|
4
|
+
|
|
1
5
|
export interface finalizePSBTResponse {
|
|
2
6
|
psbt: string;
|
|
3
7
|
hex?: string;
|
|
4
8
|
complete: boolean;
|
|
5
9
|
}
|
|
10
|
+
|
|
11
|
+
export interface WalletProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Get addresses/accounts of the user.
|
|
14
|
+
* @param {number} [startingIndex] - Index to start
|
|
15
|
+
* @param {number} [numAddresses] - Number of addresses to retrieve
|
|
16
|
+
* @param {boolean} [change] - True for change addresses
|
|
17
|
+
* @return {Promise<Address[], InvalidProviderResponseError>} Resolves with a list
|
|
18
|
+
* of addresses.
|
|
19
|
+
* Rejects with InvalidProviderResponseError if provider's response is invalid.
|
|
20
|
+
*/
|
|
21
|
+
getAddresses(
|
|
22
|
+
startingIndex?: number,
|
|
23
|
+
numAddresses?: number,
|
|
24
|
+
change?: boolean,
|
|
25
|
+
): Promise<Address[]>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get used addresses/accounts of the user.
|
|
29
|
+
* @param {number} [numAddressPerCall] - Number of addresses to retrieve per call
|
|
30
|
+
* @return {Promise<Address[], InvalidProviderResponseError>} Resolves with a list
|
|
31
|
+
* of addresses.
|
|
32
|
+
* Rejects with InvalidProviderResponseError if provider's response is invalid.
|
|
33
|
+
*/
|
|
34
|
+
getUsedAddresses(numAddressPerCall?: number): Promise<Address[]>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* findAddress is an optimized version of upstream CAL's findAddress.
|
|
38
|
+
*
|
|
39
|
+
* It searches through both change and non-change addresses (if change arg is not provided) each iteration.
|
|
40
|
+
*
|
|
41
|
+
* This is in contrast to the original findAddress function which searches
|
|
42
|
+
* through all non-change addresses before moving on to change addresses.
|
|
43
|
+
*
|
|
44
|
+
* @param addresses
|
|
45
|
+
* @returns {Promise<Address>}
|
|
46
|
+
*/
|
|
47
|
+
findAddress(addresses: string[]): Promise<Address>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get unused address/account of the user.
|
|
51
|
+
* @param {boolean} [change] - True for change addresses
|
|
52
|
+
* @param {number} [numAddressPerCall] - Number of addresses to retrieve per call
|
|
53
|
+
* @return {Promise<Address, InvalidProviderResponseError>} Resolves with a address
|
|
54
|
+
* object.
|
|
55
|
+
* Rejects with InvalidProviderResponseError if provider's response is invalid.
|
|
56
|
+
*/
|
|
57
|
+
getUnusedAddress(
|
|
58
|
+
change?: boolean,
|
|
59
|
+
numAddressPerCall?: number,
|
|
60
|
+
): Promise<Address>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Sign a message.
|
|
64
|
+
* @param {!string} message - Message to be signed.
|
|
65
|
+
* @param {!string} from - The address from which the message is signed.
|
|
66
|
+
* @return {Promise<string>} Resolves with a signed message.
|
|
67
|
+
*/
|
|
68
|
+
signMessage(message: string, from: string): Promise<string>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Retrieve the network connected to by the wallet
|
|
72
|
+
* @return {Promise<any>} Resolves with the network object
|
|
73
|
+
*/
|
|
74
|
+
getConnectedNetwork(): Promise<any>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve the availability status of the wallet
|
|
78
|
+
* @return {Promise<Boolean>} True if the wallet is available to use
|
|
79
|
+
*/
|
|
80
|
+
isWalletAvailable(): Promise<boolean>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Flag indicating if the wallet allows apps to update transaction fees
|
|
84
|
+
* @return {Promise<Boolean>} True if wallet accepts fee updating
|
|
85
|
+
*/
|
|
86
|
+
canUpdateFee?: boolean | (() => boolean);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Exports the private key for the account
|
|
90
|
+
* for BTC, https://en.bitcoin.it/wiki/Wallet_import_format
|
|
91
|
+
* for ETH, the privateKey
|
|
92
|
+
* for NEAR, the secretKey
|
|
93
|
+
* @return {Promise<string>} Resolves with the key as a string
|
|
94
|
+
*/
|
|
95
|
+
exportPrivateKey?: () => Promise<string>;
|
|
96
|
+
|
|
97
|
+
buildSweepTransactionWithSetOutputs(
|
|
98
|
+
externalChangeAddress: string,
|
|
99
|
+
feePerByte: number,
|
|
100
|
+
_outputs: Output[],
|
|
101
|
+
fixedInputs: Input[],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
getUnusedAddressesBlacklist();
|
|
105
|
+
|
|
106
|
+
setUnusedAddressesBlacklist(unusedAddressesBlacklist);
|
|
107
|
+
|
|
108
|
+
sendSweepTransactionWithSetOutputs(
|
|
109
|
+
externalChangeAddress: string,
|
|
110
|
+
feePerByte: number,
|
|
111
|
+
_outputs: Output[],
|
|
112
|
+
fixedInputs: Input[],
|
|
113
|
+
);
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomicfinance/types",
|
|
3
3
|
"umdName": "Types",
|
|
4
|
-
"version": "
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "3.0.1",
|
|
5
|
+
"description": "Bitcoin Abstraction Layer Types",
|
|
6
6
|
"author": "Atomic Finance <info@atomic.finance>",
|
|
7
7
|
"homepage": "",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "../../node_modules/.bin/
|
|
11
|
+
"build": "../../node_modules/.bin/tsc --project tsconfig.json",
|
|
12
12
|
"prepublishOnly": "yarn run build",
|
|
13
13
|
"test": "yarn run build",
|
|
14
14
|
"lint": "../../node_modules/.bin/eslint --ignore-path ../../.eslintignore -c ../../.eslintrc.js .",
|
|
15
15
|
"lint:fix": "../../node_modules/.bin/eslint --fix --ignore-path ../../.eslintignore -c ../../.eslintrc.js ."
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@liquality/types": "1.1.5",
|
|
20
|
-
"@node-dlc/messaging": "0.18.3",
|
|
18
|
+
"@node-dlc/messaging": "0.19.1",
|
|
21
19
|
"@node-lightning/bitcoin": "0.26.1",
|
|
22
20
|
"@node-lightning/noise": "0.26.1",
|
|
23
21
|
"lodash": "^4.17.20"
|
|
@@ -28,6 +26,5 @@
|
|
|
28
26
|
},
|
|
29
27
|
"publishConfig": {
|
|
30
28
|
"access": "public"
|
|
31
|
-
}
|
|
32
|
-
"gitHead": "021537d74a46eb5bd578a7c4b122555e6b0a310f"
|
|
29
|
+
}
|
|
33
30
|
}
|