@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.
Files changed (77) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/.turbo/turbo-test.log +1 -0
  3. package/CHANGELOG.md +15 -0
  4. package/dist/address.d.ts +10 -0
  5. package/dist/address.js +11 -0
  6. package/dist/address.js.map +1 -0
  7. package/dist/bitcoin.d.ts +66 -0
  8. package/dist/bitcoin.js +16 -0
  9. package/dist/bitcoin.js.map +1 -0
  10. package/dist/block.d.ts +10 -0
  11. package/dist/block.js +3 -0
  12. package/dist/block.js.map +1 -0
  13. package/dist/cfd.d.ts +0 -0
  14. package/dist/cfd.js +5 -5
  15. package/dist/cfd.js.map +0 -0
  16. package/dist/chain.d.ts +107 -0
  17. package/dist/chain.js +3 -0
  18. package/dist/chain.js.map +1 -0
  19. package/dist/common.d.ts +0 -0
  20. package/dist/common.js +3 -5
  21. package/dist/common.js.map +0 -0
  22. package/dist/dlc.d.ts +0 -0
  23. package/dist/dlc.js +5 -5
  24. package/dist/dlc.js.map +0 -0
  25. package/dist/fees.d.ts +17 -0
  26. package/dist/fees.js +3 -0
  27. package/dist/fees.js.map +1 -0
  28. package/dist/index.d.ts +13 -9
  29. package/dist/index.js +54 -161
  30. package/dist/index.js.map +1 -1
  31. package/dist/jsonrpc.d.ts +72 -0
  32. package/dist/jsonrpc.js +3 -0
  33. package/dist/jsonrpc.js.map +1 -0
  34. package/dist/models/Amount.d.ts +0 -0
  35. package/dist/models/Amount.js +14 -16
  36. package/dist/models/Amount.js.map +0 -0
  37. package/dist/models/Input.d.ts +8 -8
  38. package/dist/models/Input.js +51 -39
  39. package/dist/models/Input.js.map +1 -1
  40. package/dist/models/OracleInfo.d.ts +0 -0
  41. package/dist/models/OracleInfo.js +6 -9
  42. package/dist/models/OracleInfo.js.map +0 -0
  43. package/dist/models/Outcome.d.ts +0 -0
  44. package/dist/models/Outcome.js +17 -22
  45. package/dist/models/Outcome.js.map +0 -0
  46. package/dist/models/Output.d.ts +0 -0
  47. package/dist/models/Output.js +6 -9
  48. package/dist/models/Output.js.map +0 -0
  49. package/dist/models/Utxo.d.ts +0 -0
  50. package/dist/models/Utxo.js +26 -27
  51. package/dist/models/Utxo.js.map +0 -0
  52. package/dist/network.d.ts +5 -0
  53. package/dist/network.js +3 -0
  54. package/dist/network.js.map +1 -0
  55. package/dist/transaction.d.ts +17 -0
  56. package/dist/transaction.js +10 -0
  57. package/dist/transaction.js.map +1 -0
  58. package/dist/wallet.d.ts +78 -0
  59. package/dist/wallet.js +3 -5
  60. package/dist/wallet.js.map +0 -0
  61. package/lib/address.ts +13 -0
  62. package/lib/bitcoin.ts +72 -0
  63. package/lib/block.ts +18 -0
  64. package/lib/chain.ts +126 -0
  65. package/lib/fees.ts +21 -0
  66. package/lib/index.ts +31 -9
  67. package/lib/jsonrpc.ts +81 -0
  68. package/lib/models/Input.ts +8 -9
  69. package/lib/network.ts +5 -0
  70. package/lib/transaction.ts +28 -0
  71. package/lib/wallet.ts +109 -0
  72. package/package.json +5 -8
  73. package/LICENSE +0 -674
  74. package/dist/financewallet.d.ts +0 -11
  75. package/dist/financewallet.js +0 -5
  76. package/dist/financewallet.js.map +0 -1
  77. package/lib/financewallet.ts +0 -31
@@ -1,13 +1,10 @@
1
- Object.defineProperty(exports, "__esModule", {
2
- value: true
3
- });
4
- exports.default = void 0;
5
- let Output = class Output {
6
- constructor(value, to){
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Output {
4
+ constructor(value, to) {
7
5
  this.value = value;
8
6
  this.to = to;
9
7
  }
10
- };
8
+ }
11
9
  exports.default = Output;
12
-
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL2xpYi9tb2RlbHMvT3V0cHV0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGNsYXNzIE91dHB1dCB7XG4gIGNvbnN0cnVjdG9yKHJlYWRvbmx5IHZhbHVlOiBudW1iZXIsIHJlYWRvbmx5IHRvPzogc3RyaW5nKSB7fVxufVxuIl0sIm5hbWVzIjpbIk91dHB1dCIsImNvbnN0cnVjdG9yIiwidmFsdWUiLCJ0byJdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7QUFBZSxJQUFBLEFBQU1BLE1BQU0sR0FBWixNQUFNQSxNQUFNO0lBQ3pCQyxZQUFxQkMsS0FBYSxFQUFXQyxFQUFXLENBQUU7YUFBckNELEtBQWEsR0FBYkEsS0FBYTthQUFXQyxFQUFXLEdBQVhBLEVBQVc7S0FBSTtDQUM3RDtrQkFGb0JILE1BQU0ifQ==
10
+ //# sourceMappingURL=Output.js.map
File without changes
File without changes
@@ -1,15 +1,23 @@
1
- Object.defineProperty(exports, "__esModule", {
2
- value: true
3
- });
4
- exports.default = void 0;
5
- var _amount = _interopRequireDefault(require("./Amount"));
6
- var _input = _interopRequireDefault(require("./Input"));
7
- function _interopRequireDefault(obj) {
8
- return obj && obj.__esModule ? obj : {
9
- default: obj
10
- };
11
- }
12
- let Utxo = class Utxo {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Amount_1 = __importDefault(require("./Amount"));
7
+ const Input_1 = __importDefault(require("./Input"));
8
+ /**
9
+ * Class for interfacing with utxos in CFD DLC JS
10
+ * https://github.com/atomicfinance/cfd-dlc-js.git#v0.0.18
11
+ */
12
+ class Utxo {
13
+ constructor(txid, vout, amount, address, derivationPath, maxWitnessLength) {
14
+ this.txid = txid;
15
+ this.vout = vout;
16
+ this.amount = amount;
17
+ this.address = address;
18
+ this.derivationPath = derivationPath;
19
+ this.maxWitnessLength = maxWitnessLength;
20
+ }
13
21
  toInput() {
14
22
  return {
15
23
  txid: this.txid,
@@ -19,7 +27,7 @@ let Utxo = class Utxo {
19
27
  value: this.amount.GetSatoshiAmount(),
20
28
  derivationPath: this.derivationPath,
21
29
  maxWitnessLength: this.maxWitnessLength,
22
- toUtxo: _input.default.prototype.toUtxo
30
+ toUtxo: Input_1.default.prototype.toUtxo,
23
31
  };
24
32
  }
25
33
  toJSON() {
@@ -29,7 +37,7 @@ let Utxo = class Utxo {
29
37
  amount: this.amount.toJSON(),
30
38
  address: this.address,
31
39
  derivationPath: this.derivationPath,
32
- maxWitnessLength: this.maxWitnessLength
40
+ maxWitnessLength: this.maxWitnessLength,
33
41
  });
34
42
  }
35
43
  static fromJSON(json) {
@@ -37,24 +45,15 @@ let Utxo = class Utxo {
37
45
  return Object.assign(utxo, json, {
38
46
  txid: json.txid,
39
47
  vout: json.vout,
40
- amount: _amount.default.fromJSON(json.amount),
48
+ amount: Amount_1.default.fromJSON(json.amount),
41
49
  address: json.address,
42
50
  derivationPath: json.derivationPath,
43
- maxWitnessLength: json.maxWitnessLength
51
+ maxWitnessLength: json.maxWitnessLength,
44
52
  });
45
53
  }
46
54
  static reviver(key, value) {
47
55
  return key === '' ? Utxo.fromJSON(value) : value;
48
56
  }
49
- constructor(txid, vout, amount, address, derivationPath, maxWitnessLength){
50
- this.txid = txid;
51
- this.vout = vout;
52
- this.amount = amount;
53
- this.address = address;
54
- this.derivationPath = derivationPath;
55
- this.maxWitnessLength = maxWitnessLength;
56
- }
57
- };
57
+ }
58
58
  exports.default = Utxo;
59
-
60
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL2xpYi9tb2RlbHMvVXR4by50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgQW1vdW50LCB7IEFtb3VudEpTT04gfSBmcm9tICcuL0Ftb3VudCc7XG5pbXBvcnQgSW5wdXQgZnJvbSAnLi9JbnB1dCc7XG5cbi8qKlxuICogQ2xhc3MgZm9yIGludGVyZmFjaW5nIHdpd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FBUSxDQUFDVixLQUFLLENBQUMsR0FBR0EsS0FBSyxDQUFDO0tBQ2xEO0lBL0NEaUIsWUFDV3RCLElBQVksRUFDWkMsSUFBWSxFQUNaRSxNQUFjLEVBQ2RELE9BQWUsRUFDZkssY0FBc0IsRUFDdEJDLGdCQUF3QixDQUNqQzthQU5TUixJQUFZLEdBQVpBLElBQVk7YUFDWkMsSUFBWSxHQUFaQSxJQUFZO2FBQ1pFLE1BQWMsR0FBZEEsTUFBYzthQUNkRCxPQUFlLEdBQWZBLE9BQWU7YUFDZkssY0FBc0IsR0FBdEJBLGNBQXNCO2FBQ3RCQyxnQkFBd0IsR0FBeEJBLGdCQUF3QjtLQUMvQjtDQXlDTDtrQkFqRG9CVixJQUFJIn0=
59
+ //# sourceMappingURL=Utxo.js.map
File without changes
@@ -0,0 +1,5 @@
1
+ export interface Network {
2
+ name: string;
3
+ coinType: string;
4
+ isTestnet: boolean;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../lib/network.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ export interface Transaction<T = any> {
2
+ hash: string;
3
+ value: number;
4
+ status?: TxStatus;
5
+ blockHash?: string;
6
+ blockNumber?: number;
7
+ confirmations?: number;
8
+ feePrice?: number;
9
+ fee?: number;
10
+ secret?: string;
11
+ _raw: T;
12
+ }
13
+ export declare enum TxStatus {
14
+ Pending = "PENDING",
15
+ Failed = "FAILED",
16
+ Success = "SUCCESS"
17
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TxStatus = void 0;
4
+ var TxStatus;
5
+ (function (TxStatus) {
6
+ TxStatus["Pending"] = "PENDING";
7
+ TxStatus["Failed"] = "FAILED";
8
+ TxStatus["Success"] = "SUCCESS";
9
+ })(TxStatus = exports.TxStatus || (exports.TxStatus = {}));
10
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../lib/transaction.ts"],"names":[],"mappings":";;;AAuBA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;AACrB,CAAC,EAJW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAInB"}
package/dist/wallet.d.ts CHANGED
@@ -1,5 +1,83 @@
1
+ import { Address } from './address';
2
+ import Input from './models/Input';
3
+ import Output from './models/Output';
1
4
  export interface finalizePSBTResponse {
2
5
  psbt: string;
3
6
  hex?: string;
4
7
  complete: boolean;
5
8
  }
9
+ export interface WalletProvider {
10
+ /**
11
+ * Get addresses/accounts of the user.
12
+ * @param {number} [startingIndex] - Index to start
13
+ * @param {number} [numAddresses] - Number of addresses to retrieve
14
+ * @param {boolean} [change] - True for change addresses
15
+ * @return {Promise<Address[], InvalidProviderResponseError>} Resolves with a list
16
+ * of addresses.
17
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
18
+ */
19
+ getAddresses(startingIndex?: number, numAddresses?: number, change?: boolean): Promise<Address[]>;
20
+ /**
21
+ * Get used addresses/accounts of the user.
22
+ * @param {number} [numAddressPerCall] - Number of addresses to retrieve per call
23
+ * @return {Promise<Address[], InvalidProviderResponseError>} Resolves with a list
24
+ * of addresses.
25
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
26
+ */
27
+ getUsedAddresses(numAddressPerCall?: number): Promise<Address[]>;
28
+ /**
29
+ * findAddress is an optimized version of upstream CAL's findAddress.
30
+ *
31
+ * It searches through both change and non-change addresses (if change arg is not provided) each iteration.
32
+ *
33
+ * This is in contrast to the original findAddress function which searches
34
+ * through all non-change addresses before moving on to change addresses.
35
+ *
36
+ * @param addresses
37
+ * @returns {Promise<Address>}
38
+ */
39
+ findAddress(addresses: string[]): Promise<Address>;
40
+ /**
41
+ * Get unused address/account of the user.
42
+ * @param {boolean} [change] - True for change addresses
43
+ * @param {number} [numAddressPerCall] - Number of addresses to retrieve per call
44
+ * @return {Promise<Address, InvalidProviderResponseError>} Resolves with a address
45
+ * object.
46
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
47
+ */
48
+ getUnusedAddress(change?: boolean, numAddressPerCall?: number): Promise<Address>;
49
+ /**
50
+ * Sign a message.
51
+ * @param {!string} message - Message to be signed.
52
+ * @param {!string} from - The address from which the message is signed.
53
+ * @return {Promise<string>} Resolves with a signed message.
54
+ */
55
+ signMessage(message: string, from: string): Promise<string>;
56
+ /**
57
+ * Retrieve the network connected to by the wallet
58
+ * @return {Promise<any>} Resolves with the network object
59
+ */
60
+ getConnectedNetwork(): Promise<any>;
61
+ /**
62
+ * Retrieve the availability status of the wallet
63
+ * @return {Promise<Boolean>} True if the wallet is available to use
64
+ */
65
+ isWalletAvailable(): Promise<boolean>;
66
+ /**
67
+ * Flag indicating if the wallet allows apps to update transaction fees
68
+ * @return {Promise<Boolean>} True if wallet accepts fee updating
69
+ */
70
+ canUpdateFee?: boolean | (() => boolean);
71
+ /**
72
+ * Exports the private key for the account
73
+ * for BTC, https://en.bitcoin.it/wiki/Wallet_import_format
74
+ * for ETH, the privateKey
75
+ * for NEAR, the secretKey
76
+ * @return {Promise<string>} Resolves with the key as a string
77
+ */
78
+ exportPrivateKey?: () => Promise<string>;
79
+ buildSweepTransactionWithSetOutputs(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): any;
80
+ getUnusedAddressesBlacklist(): any;
81
+ setUnusedAddressesBlacklist(unusedAddressesBlacklist: any): any;
82
+ sendSweepTransactionWithSetOutputs(externalChangeAddress: string, feePerByte: number, _outputs: Output[], fixedInputs: Input[]): any;
83
+ }
package/dist/wallet.js CHANGED
@@ -1,5 +1,3 @@
1
- Object.defineProperty(exports, "__esModule", {
2
- value: true
3
- });
4
-
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL2xpYi93YWxsZXQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBmaW5hbGl6ZVBTQlRSZXNwb25zZSB7XG4gIHBzYnQ6IHN0cmluZztcbiAgaGV4Pzogc3RyaW5nO1xuICBjb21wbGV0ZTogYm9vbGVhbjtcbn1cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=wallet.js.map
File without changes
package/lib/address.ts ADDED
@@ -0,0 +1,13 @@
1
+ export class Address {
2
+ address: string;
3
+ derivationPath?: string;
4
+ publicKey?: string;
5
+
6
+ constructor(fields?: {
7
+ address: string;
8
+ derivationPath?: string;
9
+ publicKey?: string;
10
+ }) {
11
+ if (fields) Object.assign(this, fields);
12
+ }
13
+ }
package/lib/bitcoin.ts ADDED
@@ -0,0 +1,72 @@
1
+ export interface OutputTarget {
2
+ address?: string;
3
+ script?: Buffer;
4
+ value: number;
5
+ }
6
+
7
+ export interface ScriptPubKey {
8
+ asm: string;
9
+ hex: string;
10
+ reqSigs: number;
11
+ type: string;
12
+ addresses: string[];
13
+ }
14
+
15
+ export interface Output {
16
+ value: number;
17
+ n: number;
18
+ scriptPubKey: ScriptPubKey;
19
+ }
20
+
21
+ export interface Input {
22
+ txid: string;
23
+ vout: number;
24
+ scriptSig: {
25
+ asm: string;
26
+ hex: string;
27
+ };
28
+ txinwitness: string[];
29
+ sequence: number;
30
+ coinbase?: string;
31
+ }
32
+
33
+ export interface Transaction {
34
+ txid: string;
35
+ hash: string;
36
+ version: number;
37
+ locktime: number;
38
+ size: number;
39
+ vsize: number;
40
+ weight: number;
41
+ vin: Input[];
42
+ vout: Output[];
43
+ confirmations?: number;
44
+ hex: string;
45
+ }
46
+
47
+ export interface UTXO {
48
+ txid: string;
49
+ vout: number;
50
+ value: number;
51
+ address: string;
52
+ derivationPath?: string;
53
+ }
54
+
55
+ export enum AddressType {
56
+ LEGACY = 'legacy',
57
+ P2SH_SEGWIT = 'p2sh-segwit',
58
+ BECH32 = 'bech32',
59
+ }
60
+
61
+ export enum SwapMode {
62
+ P2SH = 'p2sh',
63
+ P2SH_SEGWIT = 'p2shSegwit',
64
+ P2WSH = 'p2wsh',
65
+ }
66
+
67
+ export type AddressTxCounts = { [index: string]: number };
68
+
69
+ export interface PsbtInputTarget {
70
+ index: number;
71
+ derivationPath: string;
72
+ }
package/lib/block.ts ADDED
@@ -0,0 +1,18 @@
1
+ export interface Block<TransactionType = any> {
2
+ // Block number
3
+ number: number;
4
+ // Block hash
5
+ hash: string;
6
+ // Block timestamp in seconds
7
+ timestamp: number;
8
+ // The size of this block in bytes
9
+ size: number;
10
+ // Hash of the parent block
11
+ parentHash: string;
12
+ // The difficulty field
13
+ difficulty?: number;
14
+ // Nonce
15
+ nonce?: number;
16
+ // List of transactions
17
+ transactions?: TransactionType[];
18
+ }
package/lib/chain.ts ADDED
@@ -0,0 +1,126 @@
1
+ import BigNumber from 'bignumber.js';
2
+
3
+ import { Address } from './address';
4
+ import { Block } from './block';
5
+ import { Transaction } from './transaction';
6
+
7
+ export interface SendOptions {
8
+ to: Address | string;
9
+ value: BigNumber;
10
+ data?: string;
11
+ fee?: number;
12
+ }
13
+
14
+ export interface ChainProvider {
15
+ /**
16
+ * Generate a block
17
+ * @param {!number} numberOfBlocks - Number of blocks to be generated
18
+ * @return {<Promise>}
19
+ */
20
+ generateBlock(numberOfBlocks: number): Promise<void>;
21
+
22
+ /**
23
+ * Get a block given its hash.
24
+ * @param {!string} blockHash - A hexadecimal string that represents the
25
+ * *hash* of the desired block.
26
+ * @param {boolean} [includeTx=false] - If true, fetches transactions in the block.
27
+ * @return {Promise<Block, TypeError|InvalidProviderResponseError>}
28
+ * Resolves with a Block with the same hash as the given input.
29
+ * If `includeTx` is true, the transaction property is an array of Transactions;
30
+ * otherwise, it is a list of transaction hashes.
31
+ * Rejects with TypeError if input is invalid.
32
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
33
+ */
34
+ getBlockByHash(blockHash: string, includeTx?: boolean): Promise<Block>;
35
+
36
+ /**
37
+ * Get a block given its number.
38
+ * @param {!number} blockNumber - The number of the desired block.
39
+ * @param {boolean} [includeTx=false] - If true, fetches transaction in the block.
40
+ * @return {Promise<Block, TypeError|InvalidProviderResponseError>}
41
+ * Resolves with a Block with the same number as the given input.
42
+ * If `includeTx` is true, the transaction property is an array of Transactions;
43
+ * otherwise, it is a list of transaction hashes.
44
+ * Rejects with TypeError if input is invalid.
45
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
46
+ */
47
+ getBlockByNumber(blockNumber: number, includeTx?: boolean): Promise<Block>;
48
+
49
+ /**
50
+ * Get current block height of the chain.
51
+ * @return {Promise<number, InvalidProviderResponseError>} Resolves with
52
+ * chain height.
53
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
54
+ */
55
+ getBlockHeight(): Promise<number>;
56
+
57
+ /**
58
+ * Get a transaction given its hash.
59
+ * @param {!string} txHash - A hexadecimal string that represents the *hash* of the
60
+ * desired transaction.
61
+ * @return {Promise<Transaction, TypeError|InvalidProviderResponseError>}
62
+ * Resolves with a Transaction with the same hash as the given input.
63
+ * Rejects with TypeError if input is invalid.
64
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
65
+ */
66
+ getTransactionByHash(txHash: string): Promise<Transaction>;
67
+
68
+ /**
69
+ * Get the balance of an account given its addresses.
70
+ * @param {(string | Address)[]} addresses - A list of addresses.
71
+ * @return {Promise<BigNumber, InvalidProviderResponseError>} If addresses is given,
72
+ * returns the cumulative balance of the given addresses. Otherwise returns the balance
73
+ * of the addresses that the signing provider controls.
74
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
75
+ */
76
+ getBalance(addresses: (Address | string)[]): Promise<BigNumber>;
77
+
78
+ /**
79
+ * Create, sign & broadcast a transaction.
80
+ * @param {!string} to - Recepient address.
81
+ * @param {!number} value - Value of transaction.
82
+ * @param {!string} data - Data to be passed to the transaction.
83
+ * @param {!Fee} [fee] - Fee price in native unit (e.g. sat/b, wei)
84
+ * @return {Promise<Transaction>} Resolves with a signed transaction.
85
+ */
86
+ sendTransaction(options: SendOptions): Promise<Transaction>;
87
+
88
+ /**
89
+ * Create, sign & broadcast a sweep transaction.
90
+ * @param {!string} address - External address.
91
+ * @param {Fee} [fee] - Fee price in native unit (e.g. sat/b, wei)
92
+ * @return {Promise<Transaction>} Resolves with a signed transaction.
93
+ */
94
+ sendSweepTransaction(
95
+ address: Address | string,
96
+ fee?: number,
97
+ ): Promise<Transaction>;
98
+
99
+ /**
100
+ * Update the fee of a transaction.
101
+ * @param {(string|Transaction)} tx - Transaction object or hash of the transaction to update
102
+ * @param {!Fee} newFee - New fee price in native unit (e.g. sat/b, wei)
103
+ * @return {Promise<Transaction>} Resolves with the new transaction
104
+ */
105
+ updateTransactionFee(
106
+ tx: string | Transaction,
107
+ newFee: number,
108
+ ): Promise<Transaction>;
109
+
110
+ /**
111
+ * Create, sign & broad a transaction with multiple outputs.
112
+ * @param {string[]} transactions - to, value, data
113
+ * @return {Promise<Transaction>} Resolves with a signed transaction.
114
+ */
115
+ sendBatchTransaction(transactions: SendOptions[]): Promise<Transaction>;
116
+
117
+ /**
118
+ * Broadcast a signed transaction to the network.
119
+ * @param {!string} rawTransaction - A raw transaction usually in the form of a
120
+ * hexadecimal string that represents the serialized transaction.
121
+ * @return {Promise<string, InvalidProviderResponseError>} Resolves with an
122
+ * identifier for the broadcasted transaction.
123
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
124
+ */
125
+ sendRawTransaction(rawTransaction: string): Promise<string>;
126
+ }
package/lib/fees.ts ADDED
@@ -0,0 +1,21 @@
1
+ export interface FeeDetail {
2
+ // Fee price
3
+ fee: number;
4
+ // Estimated time to confirmation
5
+ wait?: number;
6
+ }
7
+
8
+ export interface FeeDetails {
9
+ slow: FeeDetail;
10
+ average: FeeDetail;
11
+ fast: FeeDetail;
12
+ }
13
+
14
+ export interface FeeProvider {
15
+ /**
16
+ * @return {Promise<FeeDetails>} Resolves with an
17
+ * identifier for the broadcasted transaction.
18
+ * Rejects with InvalidProviderResponseError if provider's response is invalid.
19
+ */
20
+ getFees(): Promise<FeeDetails>;
21
+ }
package/lib/index.ts CHANGED
@@ -1,11 +1,18 @@
1
- import { Provider } from '@liquality/provider';
2
- import { ChainProvider, SwapProvider, WalletProvider } from '@liquality/types';
1
+ import BigNumber from 'bignumber.js';
3
2
 
3
+ import { Address } from './address';
4
+ import * as bitcoin from './bitcoin';
5
+ import { Block } from './block';
4
6
  import { CfdProvider } from './cfd';
7
+ import { ChainProvider, SendOptions } from './chain';
5
8
  import { DlcProvider } from './dlc';
6
- import { FinanceWalletProvider } from './financewallet';
9
+ import { FeeDetail, FeeDetails, FeeProvider } from './fees';
10
+ import * as BitcoinJsonRpcTypes from './jsonrpc';
11
+ import { Network } from './network';
12
+ import { Transaction, TxStatus } from './transaction';
13
+ import { WalletProvider } from './wallet';
7
14
 
8
- interface IFinanceClient {
15
+ interface IClient {
9
16
  /**
10
17
  * Helper method that returns method from a provider.
11
18
  * @param {!string} method - Name of the method to look for in the provider stack
@@ -14,20 +21,17 @@ interface IFinanceClient {
14
21
  * @return {function} Returns method from provider instance associated with the requested method
15
22
  */
16
23
  getMethod(method: string, requestor?: any): () => any;
17
- getProviderForMethod(method: string, requestor?: boolean): Provider;
24
+ getProviderForMethod(method: string, requestor?: boolean): any;
18
25
 
19
26
  chain: ChainProvider;
20
- swap: SwapProvider;
21
27
  wallet: WalletProvider;
22
28
  cfd: CfdProvider;
23
29
  dlc: DlcProvider;
24
- financewallet: FinanceWalletProvider;
25
30
  }
26
31
 
27
32
  export * from './cfd';
28
33
  export * from './common';
29
34
  export * from './dlc';
30
- export * from './financewallet';
31
35
  export { default as Amount } from './models/Amount';
32
36
  export { default as Input } from './models/Input';
33
37
  export { default as OracleInfo } from './models/OracleInfo';
@@ -35,4 +39,22 @@ export { default as Outcome } from './models/Outcome';
35
39
  export { default as Output } from './models/Output';
36
40
  export { default as Utxo } from './models/Utxo';
37
41
  export * from './wallet';
38
- export { IFinanceClient, CfdProvider, DlcProvider, FinanceWalletProvider };
42
+ export {
43
+ BigNumber,
44
+ IClient,
45
+ CfdProvider,
46
+ DlcProvider,
47
+ ChainProvider,
48
+ WalletProvider,
49
+ Address,
50
+ SendOptions,
51
+ Block,
52
+ Transaction,
53
+ TxStatus,
54
+ FeeDetails,
55
+ FeeDetail,
56
+ FeeProvider,
57
+ Network,
58
+ BitcoinJsonRpcTypes,
59
+ bitcoin,
60
+ };
package/lib/jsonrpc.ts ADDED
@@ -0,0 +1,81 @@
1
+ import { Transaction } from './bitcoin';
2
+
3
+ export interface UTXO {
4
+ txid: string;
5
+ vout: number;
6
+ address: string;
7
+ label: string;
8
+ scriptPubKey: string;
9
+ amount: number;
10
+ confirmations: number;
11
+ redeemScript: string;
12
+ witnessScript: string;
13
+ spendable: boolean;
14
+ solvable: boolean;
15
+ desc: string;
16
+ safe: boolean;
17
+ }
18
+
19
+ export interface ReceivedByAddress {
20
+ involvesWatchOnly: boolean;
21
+ address: string;
22
+ account: string;
23
+ amount: number;
24
+ cofirmations: number;
25
+ label: string;
26
+ txids: string[];
27
+ }
28
+
29
+ export interface MinedTransaction extends Transaction {
30
+ blockhash: string;
31
+ confirmations: number;
32
+ blocktime: number;
33
+ number: number;
34
+ }
35
+
36
+ export interface FundRawResponse {
37
+ hex: string;
38
+ fee: number;
39
+ changepos: number;
40
+ }
41
+
42
+ export interface AddressInfo {
43
+ iswatchonly: boolean;
44
+ pubkey: string;
45
+ hdkeypath: string;
46
+ // ...
47
+ }
48
+
49
+ export type AddressGrouping = string[][];
50
+
51
+ export interface ReceivedByAddress {
52
+ involvesWatchonly: boolean;
53
+ address: string;
54
+ account: string;
55
+ amount: number;
56
+ confirmations: number;
57
+ label: string;
58
+ txids: string[];
59
+ }
60
+
61
+ export interface Block {
62
+ hash: string;
63
+ confirmations: number;
64
+ size: number;
65
+ strippedSize: number;
66
+ weight: number;
67
+ height: number;
68
+ version: number;
69
+ versionHex: string;
70
+ merkleroot: string;
71
+ tx: string[];
72
+ time: number;
73
+ mediantime: number;
74
+ nonce: number;
75
+ bits: string;
76
+ difficulty: number;
77
+ chainwork: string;
78
+ nTx: number;
79
+ previousblockhash: string;
80
+ nextblockhash?: string;
81
+ }