@airgap/bitcoin 0.13.45-beta.3 → 0.13.45-beta.4
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/package.json +5 -5
- package/v0/index.js +10 -10
- package/v0/index.js.map +1 -1
- package/v0/protocol/BitcoinAddress.js +9 -8
- package/v0/protocol/BitcoinAddress.js.map +1 -1
- package/v0/protocol/BitcoinCryptoClient.js +85 -16
- package/v0/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v0/protocol/BitcoinProtocol.js +987 -590
- package/v0/protocol/BitcoinProtocol.js.map +1 -1
- package/v0/protocol/BitcoinProtocolOptions.js +111 -45
- package/v0/protocol/BitcoinProtocolOptions.js.map +1 -1
- package/v0/protocol/BitcoinSegwitAddress.js +29 -12
- package/v0/protocol/BitcoinSegwitAddress.js.map +1 -1
- package/v0/protocol/BitcoinSegwitProtocol.js +483 -348
- package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v0/protocol/BitcoinTestnetProtocol.js +36 -28
- package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +30 -22
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +23 -23
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/BlockCypherBlockExplorer.js +61 -12
- package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -1
- package/v1/data/BitcoinAddress.js +10 -9
- package/v1/data/BitcoinAddress.js.map +1 -1
- package/v1/data/BitcoinLegacyAddress.js +12 -11
- package/v1/data/BitcoinLegacyAddress.js.map +1 -1
- package/v1/data/BitcoinSegwitAddress.js +12 -11
- package/v1/data/BitcoinSegwitAddress.js.map +1 -1
- package/v1/data/BitcoinTaprootAddress.js +22 -31
- package/v1/data/BitcoinTaprootAddress.js.map +1 -1
- package/v1/index.js +11 -11
- package/v1/index.js.map +1 -1
- package/v1/module/BitcoinModule.d.ts +1 -1
- package/v1/module/BitcoinModule.js +102 -44
- package/v1/module/BitcoinModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/BitcoinCryptoClient.js +90 -22
- package/v1/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v1/protocol/BitcoinLegacyProtocol.js +796 -520
- package/v1/protocol/BitcoinLegacyProtocol.js.map +1 -1
- package/v1/protocol/BitcoinProtocol.js +1169 -735
- package/v1/protocol/BitcoinProtocol.js.map +1 -1
- package/v1/protocol/BitcoinSegwitProtocol.js +796 -542
- package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTaprootProtocol.js +1000 -688
- package/v1/protocol/BitcoinTaprootProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTestnetProtocol.js +33 -14
- package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +52 -29
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +165 -98
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +16 -13
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +213 -122
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/key.d.ts +6 -6
- package/v1/types/protocol.d.ts +2 -2
- package/v1/types/transaction.d.ts +3 -3
- package/v1/utils/common.js +6 -4
- package/v1/utils/common.js.map +1 -1
- package/v1/utils/key.d.ts +6 -5
- package/v1/utils/key.js +39 -38
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/network.js +4 -3
- package/v1/utils/network.js.map +1 -1
- package/v1/utils/protocol.js +19 -25
- package/v1/utils/protocol.js.map +1 -1
- package/v1/utils/signature.js +5 -4
- package/v1/utils/signature.js.map +1 -1
package/v1/utils/key.js
CHANGED
|
@@ -3,48 +3,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.convertSecretKey =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
14
|
-
const module_kit_1 = require("@airgap/module-kit");
|
|
15
|
-
const EXT_SK_PREFIX = {
|
|
6
|
+
exports.convertExtendedPublicKey = exports.convertPublicKey = exports.convertExtendedSecretKey = exports.convertSecretKey = void 0;
|
|
7
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
8
|
+
var bs58check_2_1_2_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2"));
|
|
9
|
+
var base_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2/base"));
|
|
10
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
11
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
12
|
+
var EXT_SK_PREFIX = {
|
|
16
13
|
xprv: '0488ade4'
|
|
17
14
|
};
|
|
18
|
-
|
|
15
|
+
var EXT_SK_TESTNET_PREFIX = {
|
|
19
16
|
tprv: '04358394'
|
|
20
17
|
};
|
|
21
|
-
|
|
18
|
+
var EXT_SK_SEGWIT_PREFIX = {
|
|
22
19
|
xprv: '0488ade4',
|
|
23
20
|
yprv: '049d7878',
|
|
24
21
|
zprv: '04b2430c'
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
var extendedSecretKeyPrefixes = [EXT_SK_PREFIX, EXT_SK_TESTNET_PREFIX, EXT_SK_SEGWIT_PREFIX];
|
|
24
|
+
var extendedSecretKeyEncodings = createEncodings(extendedSecretKeyPrefixes);
|
|
25
|
+
var EXT_PK_PREFIX = {
|
|
29
26
|
xpub: '0488b21e'
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
var EXT_PK_TESTNET_PREFIX = {
|
|
32
29
|
tpub: '043587cf'
|
|
33
30
|
};
|
|
34
|
-
|
|
31
|
+
var EXT_PK_SEGWIT_PREFIX = {
|
|
35
32
|
xpub: '0488b21e',
|
|
36
33
|
ypub: '049d7cb2',
|
|
37
34
|
zpub: '04b24746'
|
|
38
35
|
};
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
var extendedPublicKeyPrefixes = [EXT_PK_PREFIX, EXT_PK_TESTNET_PREFIX, EXT_PK_SEGWIT_PREFIX];
|
|
37
|
+
var extendedPublicKeyEncodings = createEncodings(extendedPublicKeyPrefixes);
|
|
41
38
|
function convertSecretKey(secretKey, targetFormat) {
|
|
42
39
|
if (secretKey.format === targetFormat) {
|
|
43
40
|
return secretKey;
|
|
44
41
|
}
|
|
45
42
|
switch (secretKey.format) {
|
|
46
43
|
case 'encoded':
|
|
47
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
44
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Unsupported secret key format ".concat(secretKey.format, "."));
|
|
48
45
|
case 'hex':
|
|
49
46
|
return (0, module_kit_1.newSecretKey)(convertHexSecretKey(secretKey.value, targetFormat));
|
|
50
47
|
default:
|
|
@@ -52,11 +49,12 @@ function convertSecretKey(secretKey, targetFormat) {
|
|
|
52
49
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported secret key format.');
|
|
53
50
|
}
|
|
54
51
|
}
|
|
52
|
+
exports.convertSecretKey = convertSecretKey;
|
|
55
53
|
function convertHexSecretKey(secretKey, targetFormat) {
|
|
56
54
|
if (targetFormat === 'hex') {
|
|
57
55
|
return secretKey;
|
|
58
56
|
}
|
|
59
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
57
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Unsupported secret key format ".concat(targetFormat, "."));
|
|
60
58
|
}
|
|
61
59
|
function convertExtendedSecretKey(extendedSecretKey, target) {
|
|
62
60
|
switch (extendedSecretKey.format) {
|
|
@@ -69,16 +67,17 @@ function convertExtendedSecretKey(extendedSecretKey, target) {
|
|
|
69
67
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported extended secret key format.');
|
|
70
68
|
}
|
|
71
69
|
}
|
|
70
|
+
exports.convertExtendedSecretKey = convertExtendedSecretKey;
|
|
72
71
|
function convertEncodedExtendedSecretKey(extendedSecretKey, target) {
|
|
73
72
|
if (target.format === 'encoded' && extendedSecretKey.startsWith(target.type)) {
|
|
74
73
|
return extendedSecretKey;
|
|
75
74
|
}
|
|
76
75
|
switch (target.format) {
|
|
77
76
|
case 'encoded':
|
|
78
|
-
|
|
77
|
+
var hexExtendedSecretKey = convertEncodedExtendedSecretKey(extendedSecretKey, { format: 'hex' });
|
|
79
78
|
return convertHexExtendedSecretKey(hexExtendedSecretKey, target);
|
|
80
79
|
case 'hex':
|
|
81
|
-
|
|
80
|
+
var convertedExtendedPublicKey = convertKeyEncodedToHex(extendedSecretKey, extendedSecretKeyEncodings, recognizeExtendedSecretKeyEncoding, target.hashFunction);
|
|
82
81
|
if (convertedExtendedPublicKey === undefined) {
|
|
83
82
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Unsupported encoded extended secret key.');
|
|
84
83
|
}
|
|
@@ -95,7 +94,7 @@ function convertHexExtendedSecretKey(extendedSecretKey, target) {
|
|
|
95
94
|
return convertKeyHexToEncoded(extendedSecretKey, target.type, recognizeExtendedSecretKeyEncoding, target.hashFunction);
|
|
96
95
|
}
|
|
97
96
|
function recognizeExtendedSecretKeyEncoding(type) {
|
|
98
|
-
|
|
97
|
+
var encoding = recognizeExtendedKeyEncoding(type, extendedSecretKeyPrefixes);
|
|
99
98
|
if (encoding === undefined) {
|
|
100
99
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported extended secret key encoding,');
|
|
101
100
|
}
|
|
@@ -107,7 +106,7 @@ function convertPublicKey(publicKey, targetFormat) {
|
|
|
107
106
|
}
|
|
108
107
|
switch (publicKey.format) {
|
|
109
108
|
case 'encoded':
|
|
110
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
109
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Unsupported public key format ".concat(publicKey.format, "."));
|
|
111
110
|
case 'hex':
|
|
112
111
|
return (0, module_kit_1.newPublicKey)(convertHexPublicKey(publicKey.value, targetFormat));
|
|
113
112
|
default:
|
|
@@ -115,11 +114,12 @@ function convertPublicKey(publicKey, targetFormat) {
|
|
|
115
114
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported public key format.');
|
|
116
115
|
}
|
|
117
116
|
}
|
|
117
|
+
exports.convertPublicKey = convertPublicKey;
|
|
118
118
|
function convertHexPublicKey(pk, targetFormat) {
|
|
119
119
|
if (targetFormat === 'hex') {
|
|
120
120
|
return pk;
|
|
121
121
|
}
|
|
122
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
122
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Unsupported public key format ".concat(targetFormat, "."));
|
|
123
123
|
}
|
|
124
124
|
function convertExtendedPublicKey(extendedPublicKey, target) {
|
|
125
125
|
switch (extendedPublicKey.format) {
|
|
@@ -132,16 +132,17 @@ function convertExtendedPublicKey(extendedPublicKey, target) {
|
|
|
132
132
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported extended public key format.');
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
exports.convertExtendedPublicKey = convertExtendedPublicKey;
|
|
135
136
|
function convertEncodedExtendedPublicKey(extendedPublicKey, target) {
|
|
136
137
|
if (target.format === 'encoded' && extendedPublicKey.startsWith(target.type)) {
|
|
137
138
|
return extendedPublicKey;
|
|
138
139
|
}
|
|
139
140
|
switch (target.format) {
|
|
140
141
|
case 'encoded':
|
|
141
|
-
|
|
142
|
+
var hexExtendedPublicKey = convertEncodedExtendedPublicKey(extendedPublicKey, { format: 'hex' });
|
|
142
143
|
return convertHexExtendedPublicKey(hexExtendedPublicKey, target);
|
|
143
144
|
case 'hex':
|
|
144
|
-
|
|
145
|
+
var convertedExtendedPublicKey = convertKeyEncodedToHex(extendedPublicKey, extendedPublicKeyEncodings, recognizeExtendedPublicKeyEncoding, target.hashFunction);
|
|
145
146
|
if (convertedExtendedPublicKey === undefined) {
|
|
146
147
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Unsupported encoded extended public key.');
|
|
147
148
|
}
|
|
@@ -158,32 +159,32 @@ function convertHexExtendedPublicKey(extendedPublicKey, target) {
|
|
|
158
159
|
return convertKeyHexToEncoded(extendedPublicKey, target.type, recognizeExtendedPublicKeyEncoding, target.hashFunction);
|
|
159
160
|
}
|
|
160
161
|
function recognizeExtendedPublicKeyEncoding(type) {
|
|
161
|
-
|
|
162
|
+
var encoding = recognizeExtendedKeyEncoding(type, extendedPublicKeyPrefixes);
|
|
162
163
|
if (encoding === undefined) {
|
|
163
164
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported extended public key encoding,');
|
|
164
165
|
}
|
|
165
166
|
return encoding;
|
|
166
167
|
}
|
|
167
168
|
function convertKeyEncodedToHex(key, encodings, recognizeEncoding, hashFunction) {
|
|
168
|
-
|
|
169
|
+
var prefix = encodings.find(function (prefix) { return key.startsWith(prefix); });
|
|
169
170
|
if (prefix === undefined) {
|
|
170
171
|
return undefined;
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
var encoding = recognizeEncoding(prefix);
|
|
174
|
+
var prefixBytes = Buffer.from(encoding[prefix], 'hex').length;
|
|
175
|
+
var bs58check = hashFunction ? (0, base_1.default)(hashFunction) : bs58check_2_1_2_1.default;
|
|
175
176
|
return bs58check.decode(key).slice(prefixBytes).toString('hex');
|
|
176
177
|
}
|
|
177
178
|
function convertKeyHexToEncoded(key, type, recognizeEncoding, hashFunction) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
var encoding = recognizeEncoding(type);
|
|
180
|
+
var prefix = encoding[type];
|
|
181
|
+
var bs58check = hashFunction ? (0, base_1.default)(hashFunction) : bs58check_2_1_2_1.default;
|
|
181
182
|
return bs58check.encode(Buffer.concat([Buffer.from(prefix, 'hex'), Buffer.from(key, 'hex')]));
|
|
182
183
|
}
|
|
183
184
|
function createEncodings(prefixes) {
|
|
184
|
-
return prefixes.reduce((acc, next)
|
|
185
|
+
return prefixes.reduce(function (acc, next) { return acc.concat(Object.keys(next)); }, []);
|
|
185
186
|
}
|
|
186
187
|
function recognizeExtendedKeyEncoding(type, candidates) {
|
|
187
|
-
return candidates.find((candidate)
|
|
188
|
+
return candidates.find(function (candidate) { return Object.keys(candidate).includes(type); });
|
|
188
189
|
}
|
|
189
190
|
//# sourceMappingURL=key.js.map
|
package/v1/utils/key.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/v1/utils/key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/v1/utils/key.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA0D;AAC1D,0GAAoF;AACpF,oGAAsF;AACtF,sDAAuF;AACvF,iDAS2B;AAY3B,IAAM,aAAa,GAAqD;IACtE,IAAI,EAAE,UAAU;CACjB,CAAA;AAED,IAAM,qBAAqB,GAA4D;IACrF,IAAI,EAAE,UAAU;CACjB,CAAA;AAED,IAAM,oBAAoB,GAA2D;IACnF,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,E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network.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBitcoinJSNetwork =
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.getBitcoinJSNetwork = void 0;
|
|
4
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
6
|
function getBitcoinJSNetwork(protocolNetwork, bitcoinJS) {
|
|
7
7
|
switch (protocolNetwork.type) {
|
|
8
8
|
case 'mainnet':
|
|
@@ -18,4 +18,5 @@ function getBitcoinJSNetwork(protocolNetwork, bitcoinJS) {
|
|
|
18
18
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported protocol network type.');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
exports.getBitcoinJSNetwork = getBitcoinJSNetwork;
|
|
21
22
|
//# sourceMappingURL=network.js.map
|
package/v1/utils/network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/v1/utils/network.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/v1/utils/network.ts"],"names":[],"mappings":";;;AAAA,qDAA0D;AAC1D,sDAA8D;AAI9D,SAAgB,mBAAmB,CAAC,eAAuC,EAAE,SAAc;IACzF,QAAQ,eAAe,CAAC,IAAI,EAAE;QAC5B,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAA;YACjC,MAAK;QACP,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAA;YACjC,MAAK;QACP,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAA;QACjE;YACE,IAAA,0BAAW,EAAC,eAAe,CAAC,CAAA;YAC5B,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,oCAAoC,CAAC,CAAA;KACnF;AACH,CAAC;AAdD,kDAcC"}
|
package/v1/utils/protocol.js
CHANGED
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bitcoinTaprootProtocolSchema = exports.bitcoinSegwitProtocolSchema = exports.bitcoinProtocolSchema = void 0;
|
|
4
|
-
|
|
5
|
-
exports.isBitcoinSegwitProtocol = isBitcoinSegwitProtocol;
|
|
6
|
-
exports.isBitcoinTaprootProtocol = isBitcoinTaprootProtocol;
|
|
7
|
-
const module_kit_1 = require("@airgap/module-kit");
|
|
14
|
+
exports.isBitcoinTaprootProtocol = exports.isBitcoinSegwitProtocol = exports.isBitcoinProtocol = exports.bitcoinTaprootProtocolSchema = exports.bitcoinSegwitProtocolSchema = exports.bitcoinProtocolSchema = void 0;
|
|
15
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
8
16
|
// Schemas
|
|
9
|
-
exports.bitcoinProtocolSchema = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
...module_kit_1.bip32OfflineProtocolSchema,
|
|
13
|
-
...module_kit_1.bip32OnlineProtocolSchema,
|
|
14
|
-
...module_kit_1.aesEncryptionSchema,
|
|
15
|
-
...module_kit_1.asymmetricEncryptionOfflineSchema,
|
|
16
|
-
...module_kit_1.signMessageOfflineSchema,
|
|
17
|
-
...module_kit_1.fetchDataForAddressProtocolSchema,
|
|
18
|
-
...module_kit_1.fetchDataForMultipleAddressesProtocolSchema,
|
|
19
|
-
_isBitcoinProtocol: 'required'
|
|
20
|
-
};
|
|
21
|
-
exports.bitcoinSegwitProtocolSchema = {
|
|
22
|
-
...exports.bitcoinProtocolSchema,
|
|
23
|
-
_isBitcoinSegwitProtocol: 'required'
|
|
24
|
-
};
|
|
25
|
-
exports.bitcoinTaprootProtocolSchema = {
|
|
26
|
-
...exports.bitcoinProtocolSchema,
|
|
27
|
-
_isBitcoinTaprootProtocol: 'required'
|
|
28
|
-
};
|
|
17
|
+
exports.bitcoinProtocolSchema = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, module_kit_1.offlineProtocolSchema), module_kit_1.onlineProtocolSchema), module_kit_1.bip32OfflineProtocolSchema), module_kit_1.bip32OnlineProtocolSchema), module_kit_1.aesEncryptionSchema), module_kit_1.asymmetricEncryptionOfflineSchema), module_kit_1.signMessageOfflineSchema), module_kit_1.fetchDataForAddressProtocolSchema), module_kit_1.fetchDataForMultipleAddressesProtocolSchema), { _isBitcoinProtocol: 'required' });
|
|
18
|
+
exports.bitcoinSegwitProtocolSchema = __assign(__assign({}, exports.bitcoinProtocolSchema), { _isBitcoinSegwitProtocol: 'required' });
|
|
19
|
+
exports.bitcoinTaprootProtocolSchema = __assign(__assign({}, exports.bitcoinProtocolSchema), { _isBitcoinTaprootProtocol: 'required' });
|
|
29
20
|
// Implementation Checks
|
|
30
21
|
function isBitcoinProtocol(protocol) {
|
|
31
22
|
return (0, module_kit_1.implementsInterface)(protocol, exports.bitcoinProtocolSchema);
|
|
32
23
|
}
|
|
24
|
+
exports.isBitcoinProtocol = isBitcoinProtocol;
|
|
33
25
|
function isBitcoinSegwitProtocol(protocol) {
|
|
34
26
|
return (0, module_kit_1.implementsInterface)(protocol, exports.bitcoinSegwitProtocolSchema);
|
|
35
27
|
}
|
|
28
|
+
exports.isBitcoinSegwitProtocol = isBitcoinSegwitProtocol;
|
|
36
29
|
function isBitcoinTaprootProtocol(protocol) {
|
|
37
30
|
return (0, module_kit_1.implementsInterface)(protocol, exports.bitcoinTaprootProtocolSchema);
|
|
38
31
|
}
|
|
32
|
+
exports.isBitcoinTaprootProtocol = isBitcoinTaprootProtocol;
|
|
39
33
|
//# sourceMappingURL=protocol.js.map
|
package/v1/utils/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/utils/protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/utils/protocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAa2B;AAK3B,UAAU;AAEG,QAAA,qBAAqB,iGAC7B,kCAAqB,GACrB,iCAAoB,GACpB,uCAA0B,GAC1B,sCAAyB,GACzB,gCAAmB,GACnB,8CAAiC,GACjC,qCAAwB,GACxB,8CAAiC,GACjC,wDAA2C,KAC9C,kBAAkB,EAAE,UAAU,IAC/B;AAEY,QAAA,2BAA2B,yBACnC,6BAAqB,KACxB,wBAAwB,EAAE,UAAU,IACrC;AAEY,QAAA,4BAA4B,yBACpC,6BAAqB,KACxB,yBAAyB,EAAE,UAAU,IACtC;AAED,wBAAwB;AAExB,SAAgB,iBAAiB,CAAC,QAA2B;IAC3D,OAAO,IAAA,gCAAmB,EAAkB,QAAQ,EAAE,6BAAqB,CAAC,CAAA;AAC9E,CAAC;AAFD,8CAEC;AAED,SAAgB,uBAAuB,CAAC,QAA2B;IACjE,OAAO,IAAA,gCAAmB,EAAwB,QAAQ,EAAE,mCAA2B,CAAC,CAAA;AAC1F,CAAC;AAFD,0DAEC;AAED,SAAgB,wBAAwB,CAAC,QAA2B;IAClE,OAAO,IAAA,gCAAmB,EAAyB,QAAQ,EAAE,oCAA4B,CAAC,CAAA;AAC5F,CAAC;AAFD,4DAEC"}
|
package/v1/utils/signature.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertSignature =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.convertSignature = void 0;
|
|
4
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
7
7
|
function convertSignature(signature, targetFormat) {
|
|
8
8
|
if (signature.format === targetFormat) {
|
|
9
9
|
return signature;
|
|
@@ -18,6 +18,7 @@ function convertSignature(signature, targetFormat) {
|
|
|
18
18
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported signature format.');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
exports.convertSignature = convertSignature;
|
|
21
22
|
function convertEncodedSignature(signature, targetFormat) {
|
|
22
23
|
if (targetFormat === 'encoded') {
|
|
23
24
|
return signature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../src/v1/utils/signature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../src/v1/utils/signature.ts"],"names":[],"mappings":";;;AAAA,qDAA0D;AAC1D,sDAA8D;AAC9D,iDAA4D;AAE5D,SAAgB,gBAAgB,CAAC,SAAoB,EAAE,YAAiC;IACtF,IAAI,SAAS,CAAC,MAAM,KAAK,YAAY,EAAE;QACrC,OAAO,SAAS,CAAA;KACjB;IAED,QAAQ,SAAS,CAAC,MAAM,EAAE;QACxB,KAAK,SAAS;YACZ,OAAO,IAAA,yBAAY,EAAC,uBAAuB,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAA;QAC7E,KAAK,KAAK;YACR,OAAO,IAAA,yBAAY,EAAC,mBAAmB,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAA;QACzE;YACE,IAAA,0BAAW,EAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAC7B,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,+BAA+B,CAAC,CAAA;KAC9E;AACH,CAAC;AAdD,4CAcC;AAED,SAAS,uBAAuB,CAAC,SAAiB,EAAE,YAAiC;IACnF,IAAI,YAAY,KAAK,SAAS,EAAE;QAC9B,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACzD,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAiB,EAAE,YAAiC;IAC/E,IAAI,YAAY,KAAK,KAAK,EAAE;QAC1B,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACzD,CAAC"}
|