@atomicfinance/types 3.4.7 → 3.5.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.
@@ -1 +1 @@
1
- @atomicfinance/types:build: cache hit, replaying output 22e95581a1319bce
1
+
@@ -0,0 +1 @@
1
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atomicfinance/types
2
2
 
3
+ ## 3.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9aa93d3: Fix types for bitcoin-rpc-provider
8
+
9
+ ## 3.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - fb279b7: Update dependencies for Node LTS and fix payout index edge cases
14
+
3
15
  ## 3.4.7
4
16
 
5
17
  ### Patch Changes
package/dist/bitcoin.d.ts CHANGED
@@ -57,7 +57,7 @@ export declare enum SwapMode {
57
57
  P2SH_SEGWIT = "p2shSegwit",
58
58
  P2WSH = "p2wsh"
59
59
  }
60
- export declare type AddressTxCounts = {
60
+ export type AddressTxCounts = {
61
61
  [index: string]: number;
62
62
  };
63
63
  export interface PsbtInputTarget {
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAqC;AA0CnC,oBA1CK,sBAAS,CA0CL;AAxCX,uCAAoC;AA8ClC,wFA9CO,iBAAO,OA8CP;AA7CT,mDAAqC;AAuDnC,0BAAO;AAjDT,+DAAiD;AAgD/C,kDAAmB;AA9CrB,+CAAsD;AAyCpD,yFAzCoB,sBAAQ,OAyCpB;AArBV,wCAAsB;AACtB,2CAAyB;AACzB,wCAAsB;AACtB,0CAAoD;AAA3C,iHAAA,OAAO,OAAU;AAC1B,wCAAkD;AAAzC,+GAAA,OAAO,OAAS;AACzB,kDAA4D;AAAnD,yHAAA,OAAO,OAAc;AAC9B,4CAAsD;AAA7C,mHAAA,OAAO,OAAW;AAC3B,0CAAoD;AAA3C,iHAAA,OAAO,OAAU;AAC1B,sCAAgD;AAAvC,6GAAA,OAAO,OAAQ;AACxB,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAqC;AA0CnC,oBA1CK,sBAAS,CA0CL;AAxCX,uCAAoC;AA8ClC,wFA9CO,iBAAO,OA8CP;AA7CT,mDAAqC;AAuDnC,0BAAO;AAjDT,+DAAiD;AAgD/C,kDAAmB;AA9CrB,+CAAsD;AAyCpD,yFAzCoB,sBAAQ,OAyCpB;AArBV,wCAAsB;AACtB,2CAAyB;AACzB,wCAAsB;AACtB,0CAAoD;AAA3C,iHAAA,OAAO,OAAU;AAC1B,wCAAkD;AAAzC,+GAAA,OAAO,OAAS;AACzB,kDAA4D;AAAnD,yHAAA,OAAO,OAAc;AAC9B,4CAAsD;AAA7C,mHAAA,OAAO,OAAW;AAC3B,0CAAoD;AAA3C,iHAAA,OAAO,OAAU;AAC1B,sCAAgD;AAAvC,6GAAA,OAAO,OAAQ;AACxB,2CAAyB"}
package/dist/jsonrpc.d.ts CHANGED
@@ -39,7 +39,7 @@ export interface AddressInfo {
39
39
  pubkey: string;
40
40
  hdkeypath: string;
41
41
  }
42
- export declare type AddressGrouping = string[][];
42
+ export type AddressGrouping = string[][];
43
43
  export interface ReceivedByAddress {
44
44
  involvesWatchonly: boolean;
45
45
  address: string;
package/lib/address.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Address = void 0;
4
+ class Address {
5
+ constructor(fields) {
6
+ if (fields)
7
+ Object.assign(this, fields);
8
+ }
9
+ }
10
+ exports.Address = Address;
11
+ //# sourceMappingURL=address.js.map
package/lib/bitcoin.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwapMode = exports.AddressType = void 0;
4
+ var AddressType;
5
+ (function (AddressType) {
6
+ AddressType["LEGACY"] = "legacy";
7
+ AddressType["P2SH_SEGWIT"] = "p2sh-segwit";
8
+ AddressType["BECH32"] = "bech32";
9
+ })(AddressType = exports.AddressType || (exports.AddressType = {}));
10
+ var SwapMode;
11
+ (function (SwapMode) {
12
+ SwapMode["P2SH"] = "p2sh";
13
+ SwapMode["P2SH_SEGWIT"] = "p2shSegwit";
14
+ SwapMode["P2WSH"] = "p2wsh";
15
+ })(SwapMode = exports.SwapMode || (exports.SwapMode = {}));
16
+ //# sourceMappingURL=bitcoin.js.map
package/lib/block.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=block.js.map
package/lib/cfd.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable indent */
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=cfd.js.map
package/lib/chain.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=chain.js.map
package/lib/common.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=common.js.map
package/lib/dlc.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable indent */
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=dlc.js.map
package/lib/fees.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=fees.js.map
package/lib/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.bitcoin = exports.BitcoinJsonRpcTypes = exports.TxStatus = exports.Address = exports.BigNumber = exports.Utxo = exports.Output = exports.Outcome = exports.OracleInfo = exports.Input = exports.Amount = void 0;
33
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
34
+ exports.BigNumber = bignumber_js_1.default;
35
+ const address_1 = require("./address");
36
+ Object.defineProperty(exports, "Address", { enumerable: true, get: function () { return address_1.Address; } });
37
+ const bitcoin = __importStar(require("./bitcoin"));
38
+ exports.bitcoin = bitcoin;
39
+ const BitcoinJsonRpcTypes = __importStar(require("./jsonrpc"));
40
+ exports.BitcoinJsonRpcTypes = BitcoinJsonRpcTypes;
41
+ const transaction_1 = require("./transaction");
42
+ Object.defineProperty(exports, "TxStatus", { enumerable: true, get: function () { return transaction_1.TxStatus; } });
43
+ __exportStar(require("./cfd"), exports);
44
+ __exportStar(require("./common"), exports);
45
+ __exportStar(require("./dlc"), exports);
46
+ var Amount_1 = require("./models/Amount");
47
+ Object.defineProperty(exports, "Amount", { enumerable: true, get: function () { return __importDefault(Amount_1).default; } });
48
+ var Input_1 = require("./models/Input");
49
+ Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return __importDefault(Input_1).default; } });
50
+ var OracleInfo_1 = require("./models/OracleInfo");
51
+ Object.defineProperty(exports, "OracleInfo", { enumerable: true, get: function () { return __importDefault(OracleInfo_1).default; } });
52
+ var Outcome_1 = require("./models/Outcome");
53
+ Object.defineProperty(exports, "Outcome", { enumerable: true, get: function () { return __importDefault(Outcome_1).default; } });
54
+ var Output_1 = require("./models/Output");
55
+ Object.defineProperty(exports, "Output", { enumerable: true, get: function () { return __importDefault(Output_1).default; } });
56
+ var Utxo_1 = require("./models/Utxo");
57
+ Object.defineProperty(exports, "Utxo", { enumerable: true, get: function () { return __importDefault(Utxo_1).default; } });
58
+ __exportStar(require("./wallet"), exports);
59
+ //# sourceMappingURL=index.js.map
package/lib/jsonrpc.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=jsonrpc.js.map
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Used to convert between satoshi and bitcoin.
4
+ const ConversionFactor = 100000000;
5
+ class Amount {
6
+ constructor(satoshis) {
7
+ this._satoshis = satoshis;
8
+ this.toJSON = Amount.prototype.toJSON;
9
+ this.GetSatoshiAmount = Amount.prototype.GetSatoshiAmount;
10
+ }
11
+ // Create an Amount object using bitcoin unit.
12
+ static FromBitcoin(bitcoin) {
13
+ return new Amount(bitcoin * ConversionFactor);
14
+ }
15
+ // Create an Amount object using satoshi unit.
16
+ static FromSatoshis(satoshis) {
17
+ return new Amount(satoshis);
18
+ }
19
+ // Get the amount value in bitcoin.
20
+ GetBitcoinAmount() {
21
+ return this._satoshis / ConversionFactor;
22
+ }
23
+ // Get the amount value in satoshi.
24
+ GetSatoshiAmount() {
25
+ return this._satoshis;
26
+ }
27
+ // Return a new Amount object with value increased by the given amount of
28
+ // satoshi.
29
+ AddSatoshis(satoshis) {
30
+ return new Amount(this._satoshis + satoshis);
31
+ }
32
+ // Return a new Amount object with value increased by the given amount of
33
+ // bitcoin.
34
+ AddBitcoins(bitcoins) {
35
+ return new Amount(this._satoshis + bitcoins * ConversionFactor);
36
+ }
37
+ // Return a new Amount object with value increased by the given amount.
38
+ AddAmount(amount) {
39
+ return new Amount(this._satoshis + amount._satoshis);
40
+ }
41
+ // Returns the difference between the amount of satoshi in this object and
42
+ // the amount of satoshi of the given object.
43
+ CompareWith(amount) {
44
+ return new Amount(this._satoshis - amount._satoshis);
45
+ }
46
+ toJSON() {
47
+ return Object.assign({}, this, {
48
+ _satoshis: this._satoshis,
49
+ });
50
+ }
51
+ static fromJSON(json) {
52
+ if (!json)
53
+ return;
54
+ const amount = Object.create(Amount.prototype);
55
+ return Object.assign(amount, json, {
56
+ _satoshis: json._satoshis,
57
+ GetSatoshiAmount: Amount.prototype.GetSatoshiAmount,
58
+ });
59
+ }
60
+ static reviver(key, value) {
61
+ return key === '' ? Amount.fromJSON(value) : value;
62
+ }
63
+ }
64
+ exports.default = Amount;
65
+ //# sourceMappingURL=Amount.js.map
@@ -0,0 +1,75 @@
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 Utxo_1 = __importDefault(require("./Utxo"));
8
+ /**
9
+ * Class for interfacing with inputs/utxos in Liquality Chainify
10
+ * https://github.com/liquality/chainify
11
+ *
12
+ * These inputs can have different fields for value
13
+ * satoshis (sats): https://github.com/liquality/chainify/blob/dev/packages/bitcoin-esplora-api-provider/lib/BitcoinEsploraApiProvider.js#L65
14
+ * amount (btc): https://github.com/liquality/chainify/blob/dev/packages/bitcoin-esplora-api-provider/lib/BitcoinEsploraApiProvider.js#L74
15
+ * value (sats): https://github.com/liquality/chainify/blob/dev/packages/bitcoin-wallet-provider/lib/BitcoinWalletProvider.js#L331
16
+ *
17
+ * This will be fixed once typescript branch is merged:
18
+ * https://github.com/liquality/chainify/tree/typescript
19
+ * satoshis and amount will not be necessary, only value
20
+ * https://github.com/liquality/chainify/blob/typescript/packages/types/lib/bitcoin.ts#L46
21
+ */
22
+ class Input {
23
+ constructor(txid, vout, address, amount, // in BTC
24
+ value, // in sats
25
+ derivationPath, maxWitnessLength, redeemScript, inputSerialId, scriptPubKey, label, confirmations, spendable, solvable, safe) {
26
+ this.txid = txid;
27
+ this.vout = vout;
28
+ this.address = address;
29
+ this.amount = amount;
30
+ this.value = value;
31
+ this.derivationPath = derivationPath;
32
+ this.maxWitnessLength = maxWitnessLength;
33
+ this.redeemScript = redeemScript;
34
+ this.inputSerialId = inputSerialId;
35
+ this.scriptPubKey = scriptPubKey;
36
+ this.label = label;
37
+ this.confirmations = confirmations;
38
+ this.spendable = spendable;
39
+ this.solvable = solvable;
40
+ this.safe = safe;
41
+ }
42
+ toUtxo() {
43
+ let amount;
44
+ if (this.value) {
45
+ amount = Amount_1.default.FromSatoshis(this.value);
46
+ }
47
+ else if (this.amount) {
48
+ amount = Amount_1.default.FromBitcoin(this.amount);
49
+ }
50
+ return {
51
+ txid: this.txid,
52
+ vout: this.vout,
53
+ amount,
54
+ address: this.address,
55
+ derivationPath: this.derivationPath,
56
+ maxWitnessLength: this.maxWitnessLength ? this.maxWitnessLength : 108,
57
+ inputSerialId: this.inputSerialId,
58
+ toJSON: Utxo_1.default.prototype.toJSON,
59
+ toInput: Utxo_1.default.prototype.toInput,
60
+ };
61
+ }
62
+ static fromUTXO(utxo) {
63
+ const amount = Amount_1.default.FromSatoshis(utxo.value);
64
+ return {
65
+ txid: utxo.txid,
66
+ vout: utxo.vout,
67
+ address: utxo.address,
68
+ value: utxo.value,
69
+ amount: amount.GetBitcoinAmount(),
70
+ toUtxo: Input.prototype.toUtxo,
71
+ };
72
+ }
73
+ }
74
+ exports.default = Input;
75
+ //# sourceMappingURL=Input.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class OracleInfo {
4
+ constructor(name, rValues, publicKey) {
5
+ this.name = name;
6
+ this.rValues = rValues;
7
+ this.publicKey = publicKey;
8
+ }
9
+ }
10
+ exports.default = OracleInfo;
11
+ //# sourceMappingURL=OracleInfo.js.map
@@ -0,0 +1,33 @@
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
+ class Outcome {
8
+ constructor(message, local, remote) {
9
+ this.message = message;
10
+ this.local = local;
11
+ this.remote = remote;
12
+ }
13
+ toJSON() {
14
+ return Object.assign({}, this, {
15
+ message: this.message,
16
+ local: this.local.toJSON(),
17
+ remote: this.remote.toJSON(),
18
+ });
19
+ }
20
+ static fromJSON(json) {
21
+ const outcome = Object.create(Outcome.prototype);
22
+ return Object.assign(outcome, json, {
23
+ message: json.message,
24
+ local: Amount_1.default.fromJSON(json.local),
25
+ remote: Amount_1.default.fromJSON(json.remote),
26
+ });
27
+ }
28
+ static reviver(key, value) {
29
+ return key === '' ? Outcome.fromJSON(value) : value;
30
+ }
31
+ }
32
+ exports.default = Outcome;
33
+ //# sourceMappingURL=Outcome.js.map
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Output {
4
+ constructor(value, to) {
5
+ this.value = value;
6
+ this.to = to;
7
+ }
8
+ }
9
+ exports.default = Output;
10
+ //# sourceMappingURL=Output.js.map
@@ -0,0 +1,62 @@
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, inputSerialId) {
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
+ this.inputSerialId = inputSerialId;
21
+ }
22
+ toInput() {
23
+ return {
24
+ txid: this.txid,
25
+ vout: this.vout,
26
+ address: this.address,
27
+ amount: this.amount.GetBitcoinAmount(),
28
+ value: this.amount.GetSatoshiAmount(),
29
+ derivationPath: this.derivationPath,
30
+ maxWitnessLength: this.maxWitnessLength,
31
+ inputSerialId: BigInt(this.inputSerialId),
32
+ toUtxo: Input_1.default.prototype.toUtxo,
33
+ };
34
+ }
35
+ toJSON() {
36
+ return Object.assign({}, this, {
37
+ txid: this.txid,
38
+ vout: this.vout,
39
+ amount: this.amount.toJSON(),
40
+ address: this.address,
41
+ derivationPath: this.derivationPath,
42
+ maxWitnessLength: this.maxWitnessLength,
43
+ inputSerialId: this.inputSerialId,
44
+ });
45
+ }
46
+ static fromJSON(json) {
47
+ const utxo = Object.create(Utxo.prototype);
48
+ return Object.assign(utxo, json, {
49
+ txid: json.txid,
50
+ vout: json.vout,
51
+ amount: Amount_1.default.fromJSON(json.amount),
52
+ address: json.address,
53
+ derivationPath: json.derivationPath,
54
+ maxWitnessLength: json.maxWitnessLength,
55
+ });
56
+ }
57
+ static reviver(key, value) {
58
+ return key === '' ? Utxo.fromJSON(value) : value;
59
+ }
60
+ }
61
+ exports.default = Utxo;
62
+ //# sourceMappingURL=Utxo.js.map
package/lib/network.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=network.js.map
@@ -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
package/lib/wallet.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=wallet.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atomicfinance/types",
3
3
  "umdName": "Types",
4
- "version": "3.4.7",
4
+ "version": "3.5.1",
5
5
  "description": "Bitcoin Abstraction Layer Types",
6
6
  "author": "Atomic Finance <info@atomic.finance>",
7
7
  "homepage": "",