@airgap/bitcoin 0.13.45-beta.2 → 0.13.45-beta.3
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 +8 -9
- package/v0/protocol/BitcoinAddress.js.map +1 -1
- package/v0/protocol/BitcoinCryptoClient.js +16 -85
- package/v0/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v0/protocol/BitcoinProtocol.js +590 -987
- package/v0/protocol/BitcoinProtocol.js.map +1 -1
- package/v0/protocol/BitcoinProtocolOptions.js +45 -111
- package/v0/protocol/BitcoinProtocolOptions.js.map +1 -1
- package/v0/protocol/BitcoinSegwitAddress.js +12 -29
- package/v0/protocol/BitcoinSegwitAddress.js.map +1 -1
- package/v0/protocol/BitcoinSegwitProtocol.js +348 -483
- package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v0/protocol/BitcoinTestnetProtocol.js +28 -36
- package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +22 -30
- 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 +12 -61
- package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -1
- package/v1/data/BitcoinAddress.js +9 -10
- package/v1/data/BitcoinAddress.js.map +1 -1
- package/v1/data/BitcoinLegacyAddress.js +11 -12
- package/v1/data/BitcoinLegacyAddress.js.map +1 -1
- package/v1/data/BitcoinSegwitAddress.js +11 -12
- package/v1/data/BitcoinSegwitAddress.js.map +1 -1
- package/v1/data/BitcoinTaprootAddress.js +31 -22
- 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 +44 -102
- package/v1/module/BitcoinModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/protocol/BitcoinCryptoClient.js +22 -90
- package/v1/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v1/protocol/BitcoinLegacyProtocol.js +520 -796
- package/v1/protocol/BitcoinLegacyProtocol.js.map +1 -1
- package/v1/protocol/BitcoinProtocol.js +735 -1169
- package/v1/protocol/BitcoinProtocol.js.map +1 -1
- package/v1/protocol/BitcoinSegwitProtocol.js +542 -796
- package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTaprootProtocol.js +688 -1000
- package/v1/protocol/BitcoinTaprootProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTestnetProtocol.js +14 -33
- package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +29 -52
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +98 -165
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +13 -16
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +122 -213
- 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 +4 -6
- package/v1/utils/common.js.map +1 -1
- package/v1/utils/key.d.ts +5 -6
- package/v1/utils/key.js +38 -39
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/network.js +3 -4
- package/v1/utils/network.js.map +1 -1
- package/v1/utils/protocol.js +25 -19
- package/v1/utils/protocol.js.map +1 -1
- package/v1/utils/signature.js +4 -5
- package/v1/utils/signature.js.map +1 -1
package/v1/utils/key.js
CHANGED
|
@@ -3,45 +3,48 @@ 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.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
exports.convertSecretKey = convertSecretKey;
|
|
7
|
+
exports.convertExtendedSecretKey = convertExtendedSecretKey;
|
|
8
|
+
exports.convertPublicKey = convertPublicKey;
|
|
9
|
+
exports.convertExtendedPublicKey = convertExtendedPublicKey;
|
|
10
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
11
|
+
const bs58check_2_1_2_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2"));
|
|
12
|
+
const base_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bs58check-2.1.2/base"));
|
|
13
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
14
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
15
|
+
const EXT_SK_PREFIX = {
|
|
13
16
|
xprv: '0488ade4'
|
|
14
17
|
};
|
|
15
|
-
|
|
18
|
+
const EXT_SK_TESTNET_PREFIX = {
|
|
16
19
|
tprv: '04358394'
|
|
17
20
|
};
|
|
18
|
-
|
|
21
|
+
const EXT_SK_SEGWIT_PREFIX = {
|
|
19
22
|
xprv: '0488ade4',
|
|
20
23
|
yprv: '049d7878',
|
|
21
24
|
zprv: '04b2430c'
|
|
22
25
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
const extendedSecretKeyPrefixes = [EXT_SK_PREFIX, EXT_SK_TESTNET_PREFIX, EXT_SK_SEGWIT_PREFIX];
|
|
27
|
+
const extendedSecretKeyEncodings = createEncodings(extendedSecretKeyPrefixes);
|
|
28
|
+
const EXT_PK_PREFIX = {
|
|
26
29
|
xpub: '0488b21e'
|
|
27
30
|
};
|
|
28
|
-
|
|
31
|
+
const EXT_PK_TESTNET_PREFIX = {
|
|
29
32
|
tpub: '043587cf'
|
|
30
33
|
};
|
|
31
|
-
|
|
34
|
+
const EXT_PK_SEGWIT_PREFIX = {
|
|
32
35
|
xpub: '0488b21e',
|
|
33
36
|
ypub: '049d7cb2',
|
|
34
37
|
zpub: '04b24746'
|
|
35
38
|
};
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const extendedPublicKeyPrefixes = [EXT_PK_PREFIX, EXT_PK_TESTNET_PREFIX, EXT_PK_SEGWIT_PREFIX];
|
|
40
|
+
const extendedPublicKeyEncodings = createEncodings(extendedPublicKeyPrefixes);
|
|
38
41
|
function convertSecretKey(secretKey, targetFormat) {
|
|
39
42
|
if (secretKey.format === targetFormat) {
|
|
40
43
|
return secretKey;
|
|
41
44
|
}
|
|
42
45
|
switch (secretKey.format) {
|
|
43
46
|
case 'encoded':
|
|
44
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
47
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Unsupported secret key format ${secretKey.format}.`);
|
|
45
48
|
case 'hex':
|
|
46
49
|
return (0, module_kit_1.newSecretKey)(convertHexSecretKey(secretKey.value, targetFormat));
|
|
47
50
|
default:
|
|
@@ -49,12 +52,11 @@ function convertSecretKey(secretKey, targetFormat) {
|
|
|
49
52
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported secret key format.');
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
exports.convertSecretKey = convertSecretKey;
|
|
53
55
|
function convertHexSecretKey(secretKey, targetFormat) {
|
|
54
56
|
if (targetFormat === 'hex') {
|
|
55
57
|
return secretKey;
|
|
56
58
|
}
|
|
57
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
59
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Unsupported secret key format ${targetFormat}.`);
|
|
58
60
|
}
|
|
59
61
|
function convertExtendedSecretKey(extendedSecretKey, target) {
|
|
60
62
|
switch (extendedSecretKey.format) {
|
|
@@ -67,17 +69,16 @@ function convertExtendedSecretKey(extendedSecretKey, target) {
|
|
|
67
69
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported extended secret key format.');
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
|
-
exports.convertExtendedSecretKey = convertExtendedSecretKey;
|
|
71
72
|
function convertEncodedExtendedSecretKey(extendedSecretKey, target) {
|
|
72
73
|
if (target.format === 'encoded' && extendedSecretKey.startsWith(target.type)) {
|
|
73
74
|
return extendedSecretKey;
|
|
74
75
|
}
|
|
75
76
|
switch (target.format) {
|
|
76
77
|
case 'encoded':
|
|
77
|
-
|
|
78
|
+
const hexExtendedSecretKey = convertEncodedExtendedSecretKey(extendedSecretKey, { format: 'hex' });
|
|
78
79
|
return convertHexExtendedSecretKey(hexExtendedSecretKey, target);
|
|
79
80
|
case 'hex':
|
|
80
|
-
|
|
81
|
+
const convertedExtendedPublicKey = convertKeyEncodedToHex(extendedSecretKey, extendedSecretKeyEncodings, recognizeExtendedSecretKeyEncoding, target.hashFunction);
|
|
81
82
|
if (convertedExtendedPublicKey === undefined) {
|
|
82
83
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Unsupported encoded extended secret key.');
|
|
83
84
|
}
|
|
@@ -94,7 +95,7 @@ function convertHexExtendedSecretKey(extendedSecretKey, target) {
|
|
|
94
95
|
return convertKeyHexToEncoded(extendedSecretKey, target.type, recognizeExtendedSecretKeyEncoding, target.hashFunction);
|
|
95
96
|
}
|
|
96
97
|
function recognizeExtendedSecretKeyEncoding(type) {
|
|
97
|
-
|
|
98
|
+
const encoding = recognizeExtendedKeyEncoding(type, extendedSecretKeyPrefixes);
|
|
98
99
|
if (encoding === undefined) {
|
|
99
100
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported extended secret key encoding,');
|
|
100
101
|
}
|
|
@@ -106,7 +107,7 @@ function convertPublicKey(publicKey, targetFormat) {
|
|
|
106
107
|
}
|
|
107
108
|
switch (publicKey.format) {
|
|
108
109
|
case 'encoded':
|
|
109
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN,
|
|
110
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Unsupported public key format ${publicKey.format}.`);
|
|
110
111
|
case 'hex':
|
|
111
112
|
return (0, module_kit_1.newPublicKey)(convertHexPublicKey(publicKey.value, targetFormat));
|
|
112
113
|
default:
|
|
@@ -114,12 +115,11 @@ function convertPublicKey(publicKey, targetFormat) {
|
|
|
114
115
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported public key format.');
|
|
115
116
|
}
|
|
116
117
|
}
|
|
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 ${targetFormat}.`);
|
|
123
123
|
}
|
|
124
124
|
function convertExtendedPublicKey(extendedPublicKey, target) {
|
|
125
125
|
switch (extendedPublicKey.format) {
|
|
@@ -132,17 +132,16 @@ 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;
|
|
136
135
|
function convertEncodedExtendedPublicKey(extendedPublicKey, target) {
|
|
137
136
|
if (target.format === 'encoded' && extendedPublicKey.startsWith(target.type)) {
|
|
138
137
|
return extendedPublicKey;
|
|
139
138
|
}
|
|
140
139
|
switch (target.format) {
|
|
141
140
|
case 'encoded':
|
|
142
|
-
|
|
141
|
+
const hexExtendedPublicKey = convertEncodedExtendedPublicKey(extendedPublicKey, { format: 'hex' });
|
|
143
142
|
return convertHexExtendedPublicKey(hexExtendedPublicKey, target);
|
|
144
143
|
case 'hex':
|
|
145
|
-
|
|
144
|
+
const convertedExtendedPublicKey = convertKeyEncodedToHex(extendedPublicKey, extendedPublicKeyEncodings, recognizeExtendedPublicKeyEncoding, target.hashFunction);
|
|
146
145
|
if (convertedExtendedPublicKey === undefined) {
|
|
147
146
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Unsupported encoded extended public key.');
|
|
148
147
|
}
|
|
@@ -159,32 +158,32 @@ function convertHexExtendedPublicKey(extendedPublicKey, target) {
|
|
|
159
158
|
return convertKeyHexToEncoded(extendedPublicKey, target.type, recognizeExtendedPublicKeyEncoding, target.hashFunction);
|
|
160
159
|
}
|
|
161
160
|
function recognizeExtendedPublicKeyEncoding(type) {
|
|
162
|
-
|
|
161
|
+
const encoding = recognizeExtendedKeyEncoding(type, extendedPublicKeyPrefixes);
|
|
163
162
|
if (encoding === undefined) {
|
|
164
163
|
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported extended public key encoding,');
|
|
165
164
|
}
|
|
166
165
|
return encoding;
|
|
167
166
|
}
|
|
168
167
|
function convertKeyEncodedToHex(key, encodings, recognizeEncoding, hashFunction) {
|
|
169
|
-
|
|
168
|
+
const prefix = encodings.find((prefix) => key.startsWith(prefix));
|
|
170
169
|
if (prefix === undefined) {
|
|
171
170
|
return undefined;
|
|
172
171
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
const encoding = recognizeEncoding(prefix);
|
|
173
|
+
const prefixBytes = Buffer.from(encoding[prefix], 'hex').length;
|
|
174
|
+
const bs58check = hashFunction ? (0, base_1.default)(hashFunction) : bs58check_2_1_2_1.default;
|
|
176
175
|
return bs58check.decode(key).slice(prefixBytes).toString('hex');
|
|
177
176
|
}
|
|
178
177
|
function convertKeyHexToEncoded(key, type, recognizeEncoding, hashFunction) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
const encoding = recognizeEncoding(type);
|
|
179
|
+
const prefix = encoding[type];
|
|
180
|
+
const bs58check = hashFunction ? (0, base_1.default)(hashFunction) : bs58check_2_1_2_1.default;
|
|
182
181
|
return bs58check.encode(Buffer.concat([Buffer.from(prefix, 'hex'), Buffer.from(key, 'hex')]));
|
|
183
182
|
}
|
|
184
183
|
function createEncodings(prefixes) {
|
|
185
|
-
return prefixes.reduce(
|
|
184
|
+
return prefixes.reduce((acc, next) => acc.concat(Object.keys(next)), []);
|
|
186
185
|
}
|
|
187
186
|
function recognizeExtendedKeyEncoding(type, candidates) {
|
|
188
|
-
return candidates.find(
|
|
187
|
+
return candidates.find((candidate) => Object.keys(candidate).includes(type));
|
|
189
188
|
}
|
|
190
189
|
//# 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":";;;;;AA+DA,4CAcC;AAqBD,4DAUC;AA+CD,4CAcC;AAqBD,4DAUC;AAxMD,uDAA0D;AAC1D,4GAAoF;AACpF,sGAAsF;AACtF,wDAAuF;AACvF,mDAS2B;AAY3B,MAAM,aAAa,GAAqD;IACtE,IAAI,EAAE,UAAU;CACjB,CAAA;AAED,MAAM,qBAAqB,GAA4D;IACrF,IAAI,EAAE,UAAU;CACjB,CAAA;AAED,MAAM,oBAAoB,GAA2D;IACnF,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;CACjB,CAAA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,SAAiC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;AACtG,CAAC"}
|
package/v1/utils/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 = getBitcoinJSNetwork;
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
6
|
function getBitcoinJSNetwork(protocolNetwork, bitcoinJS) {
|
|
7
7
|
switch (protocolNetwork.type) {
|
|
8
8
|
case 'mainnet':
|
|
@@ -18,5 +18,4 @@ 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;
|
|
22
21
|
//# 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":";;AAKA,kDAcC;AAnBD,uDAA0D;AAC1D,wDAA8D;AAI9D,SAAgB,mBAAmB,CAAC,eAAuC,EAAE,SAAc;IACzF,QAAQ,eAAe,CAAC,IAAI,EAAE,CAAC;QAC7B,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;IACpF,CAAC;AACH,CAAC"}
|
package/v1/utils/protocol.js
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
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
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
15
|
-
|
|
3
|
+
exports.bitcoinTaprootProtocolSchema = exports.bitcoinSegwitProtocolSchema = exports.bitcoinProtocolSchema = void 0;
|
|
4
|
+
exports.isBitcoinProtocol = isBitcoinProtocol;
|
|
5
|
+
exports.isBitcoinSegwitProtocol = isBitcoinSegwitProtocol;
|
|
6
|
+
exports.isBitcoinTaprootProtocol = isBitcoinTaprootProtocol;
|
|
7
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
16
8
|
// Schemas
|
|
17
|
-
exports.bitcoinProtocolSchema =
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
exports.bitcoinProtocolSchema = {
|
|
10
|
+
...module_kit_1.offlineProtocolSchema,
|
|
11
|
+
...module_kit_1.onlineProtocolSchema,
|
|
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
|
+
};
|
|
20
29
|
// Implementation Checks
|
|
21
30
|
function isBitcoinProtocol(protocol) {
|
|
22
31
|
return (0, module_kit_1.implementsInterface)(protocol, exports.bitcoinProtocolSchema);
|
|
23
32
|
}
|
|
24
|
-
exports.isBitcoinProtocol = isBitcoinProtocol;
|
|
25
33
|
function isBitcoinSegwitProtocol(protocol) {
|
|
26
34
|
return (0, module_kit_1.implementsInterface)(protocol, exports.bitcoinSegwitProtocolSchema);
|
|
27
35
|
}
|
|
28
|
-
exports.isBitcoinSegwitProtocol = isBitcoinSegwitProtocol;
|
|
29
36
|
function isBitcoinTaprootProtocol(protocol) {
|
|
30
37
|
return (0, module_kit_1.implementsInterface)(protocol, exports.bitcoinTaprootProtocolSchema);
|
|
31
38
|
}
|
|
32
|
-
exports.isBitcoinTaprootProtocol = isBitcoinTaprootProtocol;
|
|
33
39
|
//# 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":";;;AA6CA,8CAEC;AAED,0DAEC;AAED,4DAEC;AAvDD,mDAa2B;AAK3B,UAAU;AAEG,QAAA,qBAAqB,GAA4B;IAC5D,GAAG,kCAAqB;IACxB,GAAG,iCAAoB;IACvB,GAAG,uCAA0B;IAC7B,GAAG,sCAAyB;IAC5B,GAAG,gCAAmB;IACtB,GAAG,8CAAiC;IACpC,GAAG,qCAAwB;IAC3B,GAAG,8CAAiC;IACpC,GAAG,wDAA2C;IAC9C,kBAAkB,EAAE,UAAU;CAC/B,CAAA;AAEY,QAAA,2BAA2B,GAAkC;IACxE,GAAG,6BAAqB;IACxB,wBAAwB,EAAE,UAAU;CACrC,CAAA;AAEY,QAAA,4BAA4B,GAAmC;IAC1E,GAAG,6BAAqB;IACxB,yBAAyB,EAAE,UAAU;CACtC,CAAA;AAED,wBAAwB;AAExB,SAAgB,iBAAiB,CAAC,QAA2B;IAC3D,OAAO,IAAA,gCAAmB,EAAkB,QAAQ,EAAE,6BAAqB,CAAC,CAAA;AAC9E,CAAC;AAED,SAAgB,uBAAuB,CAAC,QAA2B;IACjE,OAAO,IAAA,gCAAmB,EAAwB,QAAQ,EAAE,mCAA2B,CAAC,CAAA;AAC1F,CAAC;AAED,SAAgB,wBAAwB,CAAC,QAA2B;IAClE,OAAO,IAAA,gCAAmB,EAAyB,QAAQ,EAAE,oCAA4B,CAAC,CAAA;AAC5F,CAAC"}
|
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 = convertSignature;
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
7
7
|
function convertSignature(signature, targetFormat) {
|
|
8
8
|
if (signature.format === targetFormat) {
|
|
9
9
|
return signature;
|
|
@@ -18,7 +18,6 @@ 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;
|
|
22
21
|
function convertEncodedSignature(signature, targetFormat) {
|
|
23
22
|
if (targetFormat === 'encoded') {
|
|
24
23
|
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":";;AAIA,4CAcC;AAlBD,uDAA0D;AAC1D,wDAA8D;AAC9D,mDAA4D;AAE5D,SAAgB,gBAAgB,CAAC,SAAoB,EAAE,YAAiC;IACtF,IAAI,SAAS,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;QACtC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,QAAQ,SAAS,CAAC,MAAM,EAAE,CAAC;QACzB,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;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,SAAiB,EAAE,YAAiC;IACnF,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAA;IAClB,CAAC;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,CAAC;QAC3B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACzD,CAAC"}
|