@airgap/bitcoin 0.13.7-beta.21 → 0.13.7-beta.23

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 (159) hide show
  1. package/airgap-coinlib-bitcoin.min.js +16559 -4042
  2. package/index.d.ts +1 -14
  3. package/index.js +15 -19
  4. package/index.js.map +1 -1
  5. package/package.json +4 -2
  6. package/v0/index.d.ts +14 -0
  7. package/v0/index.js +34 -0
  8. package/v0/index.js.map +1 -0
  9. package/{protocol → v0/protocol}/BitcoinAddress.d.ts +0 -0
  10. package/{protocol → v0/protocol}/BitcoinAddress.js +0 -0
  11. package/v0/protocol/BitcoinAddress.js.map +1 -0
  12. package/{protocol → v0/protocol}/BitcoinCryptoClient.d.ts +0 -0
  13. package/{protocol → v0/protocol}/BitcoinCryptoClient.js +2 -0
  14. package/v0/protocol/BitcoinCryptoClient.js.map +1 -0
  15. package/{protocol → v0/protocol}/BitcoinProtocol.d.ts +0 -0
  16. package/{protocol → v0/protocol}/BitcoinProtocol.js +29 -21
  17. package/v0/protocol/BitcoinProtocol.js.map +1 -0
  18. package/{protocol → v0/protocol}/BitcoinProtocolOptions.d.ts +0 -0
  19. package/{protocol → v0/protocol}/BitcoinProtocolOptions.js +9 -3
  20. package/v0/protocol/BitcoinProtocolOptions.js.map +1 -0
  21. package/{protocol → v0/protocol}/BitcoinSegwitAddress.d.ts +0 -0
  22. package/{protocol → v0/protocol}/BitcoinSegwitAddress.js +2 -0
  23. package/v0/protocol/BitcoinSegwitAddress.js.map +1 -0
  24. package/{protocol → v0/protocol}/BitcoinSegwitProtocol.d.ts +0 -0
  25. package/{protocol → v0/protocol}/BitcoinSegwitProtocol.js +32 -21
  26. package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -0
  27. package/{protocol → v0/protocol}/BitcoinTestnetProtocol.d.ts +0 -0
  28. package/{protocol → v0/protocol}/BitcoinTestnetProtocol.js +7 -1
  29. package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -0
  30. package/{protocol → v0/protocol}/BitcoinTypes.d.ts +0 -0
  31. package/{protocol → v0/protocol}/BitcoinTypes.js +0 -0
  32. package/v0/protocol/BitcoinTypes.js.map +1 -0
  33. package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin-segwit.json +0 -0
  34. package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin.json +73 -0
  35. package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin-segwit.json +0 -0
  36. package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin.json +37 -0
  37. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin-segwit.json +32 -0
  38. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin.json +73 -0
  39. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin-segwit.json +19 -0
  40. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin.json +37 -0
  41. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  42. package/v0/serializer/validators/transaction-validator.js +81 -0
  43. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  44. package/v0/serializer/validators/validators.d.ts +1 -0
  45. package/v0/serializer/validators/validators.js +151 -0
  46. package/v0/serializer/validators/validators.js.map +1 -0
  47. package/v0/types/signed-transaction-bitcoin-segwit.d.ts +5 -0
  48. package/{types → v0/types}/signed-transaction-bitcoin-segwit.js +0 -0
  49. package/v0/types/signed-transaction-bitcoin-segwit.js.map +1 -0
  50. package/v0/types/signed-transaction-bitcoin.d.ts +9 -0
  51. package/{types → v0/types}/signed-transaction-bitcoin.js +0 -0
  52. package/v0/types/signed-transaction-bitcoin.js.map +1 -0
  53. package/{types → v0/types}/transaction-bitcoin.d.ts +0 -0
  54. package/{types → v0/types}/transaction-bitcoin.js +0 -0
  55. package/v0/types/transaction-bitcoin.js.map +1 -0
  56. package/v0/types/unsigned-transaction-bitcoin-segwit.d.ts +7 -0
  57. package/{types → v0/types}/unsigned-transaction-bitcoin-segwit.js +0 -0
  58. package/v0/types/unsigned-transaction-bitcoin-segwit.js.map +1 -0
  59. package/{types → v0/types}/unsigned-transaction-bitcoin.d.ts +2 -2
  60. package/{types → v0/types}/unsigned-transaction-bitcoin.js +0 -0
  61. package/v0/types/unsigned-transaction-bitcoin.js.map +1 -0
  62. package/v1/block-explorer/BlockCypherBlockExplorer.d.ts +9 -0
  63. package/v1/block-explorer/BlockCypherBlockExplorer.js +74 -0
  64. package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -0
  65. package/v1/data/BitcoinAddress.d.ts +7 -0
  66. package/v1/data/BitcoinAddress.js +21 -0
  67. package/v1/data/BitcoinAddress.js.map +1 -0
  68. package/v1/data/BitcoinSegwitAddress.d.ts +8 -0
  69. package/v1/data/BitcoinSegwitAddress.js +26 -0
  70. package/v1/data/BitcoinSegwitAddress.js.map +1 -0
  71. package/v1/index.d.ts +20 -0
  72. package/v1/index.js +26 -0
  73. package/v1/index.js.map +1 -0
  74. package/v1/module/BitcoinModule.d.ts +8 -0
  75. package/v1/module/BitcoinModule.js +86 -0
  76. package/v1/module/BitcoinModule.js.map +1 -0
  77. package/v1/module/BitcoinSegwitModule.d.ts +8 -0
  78. package/v1/module/BitcoinSegwitModule.js +87 -0
  79. package/v1/module/BitcoinSegwitModule.js.map +1 -0
  80. package/v1/protocol/BitcoinCryptoClient.d.ts +12 -0
  81. package/v1/protocol/BitcoinCryptoClient.js +96 -0
  82. package/v1/protocol/BitcoinCryptoClient.js.map +1 -0
  83. package/v1/protocol/BitcoinProtocol.d.ts +68 -0
  84. package/v1/protocol/BitcoinProtocol.js +1198 -0
  85. package/v1/protocol/BitcoinProtocol.js.map +1 -0
  86. package/v1/protocol/BitcoinSegwitProtocol.d.ts +51 -0
  87. package/v1/protocol/BitcoinSegwitProtocol.js +734 -0
  88. package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -0
  89. package/v1/protocol/BitcoinTestnetProtocol.d.ts +11 -0
  90. package/v1/protocol/BitcoinTestnetProtocol.js +67 -0
  91. package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -0
  92. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +13 -0
  93. package/v1/serializer/v3/schemas/converter/transaction-converter.js +54 -0
  94. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  95. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.d.ts +4 -0
  96. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js +3 -0
  97. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js.map +1 -0
  98. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.d.ts +4 -0
  99. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js +3 -0
  100. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js.map +1 -0
  101. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.d.ts +3 -0
  102. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js +3 -0
  103. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js.map +1 -0
  104. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.d.ts +7 -0
  105. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js +3 -0
  106. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js.map +1 -0
  107. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin-segwit.json +36 -0
  108. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin.json +86 -0
  109. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin-segwit.json +19 -0
  110. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin.json +37 -0
  111. package/v1/serializer/v3/validators/transaction-validators.d.ts +10 -0
  112. package/v1/serializer/v3/validators/transaction-validators.js +65 -0
  113. package/v1/serializer/v3/validators/transaction-validators.js.map +1 -0
  114. package/v1/serializer/v3/validators/validators.d.ts +7 -0
  115. package/v1/serializer/v3/validators/validators.js +254 -0
  116. package/v1/serializer/v3/validators/validators.js.map +1 -0
  117. package/v1/types/bitcoinjs.d.ts +14 -0
  118. package/v1/types/bitcoinjs.js +3 -0
  119. package/v1/types/bitcoinjs.js.map +1 -0
  120. package/v1/types/indexer.d.ts +81 -0
  121. package/v1/types/indexer.js +3 -0
  122. package/v1/types/indexer.js.map +1 -0
  123. package/v1/types/key.d.ts +6 -0
  124. package/v1/types/key.js +3 -0
  125. package/v1/types/key.js.map +1 -0
  126. package/v1/types/protocol.d.ts +17 -0
  127. package/v1/types/protocol.js +3 -0
  128. package/v1/types/protocol.js.map +1 -0
  129. package/v1/types/transaction.d.ts +39 -0
  130. package/v1/types/transaction.js +3 -0
  131. package/v1/types/transaction.js.map +1 -0
  132. package/v1/utils/common.d.ts +2 -0
  133. package/v1/utils/common.js +28 -0
  134. package/v1/utils/common.js.map +1 -0
  135. package/v1/utils/key.d.ts +12 -0
  136. package/v1/utils/key.js +157 -0
  137. package/v1/utils/key.js.map +1 -0
  138. package/v1/utils/network.d.ts +2 -0
  139. package/v1/utils/network.js +22 -0
  140. package/v1/utils/network.js.map +1 -0
  141. package/v1/utils/signature.d.ts +2 -0
  142. package/v1/utils/signature.js +34 -0
  143. package/v1/utils/signature.js.map +1 -0
  144. package/protocol/BitcoinAddress.js.map +0 -1
  145. package/protocol/BitcoinCryptoClient.js.map +0 -1
  146. package/protocol/BitcoinProtocol.js.map +0 -1
  147. package/protocol/BitcoinProtocolOptions.js.map +0 -1
  148. package/protocol/BitcoinSegwitAddress.js.map +0 -1
  149. package/protocol/BitcoinSegwitProtocol.js.map +0 -1
  150. package/protocol/BitcoinTestnetProtocol.js.map +0 -1
  151. package/protocol/BitcoinTypes.js.map +0 -1
  152. package/types/signed-transaction-bitcoin-segwit.d.ts +0 -5
  153. package/types/signed-transaction-bitcoin-segwit.js.map +0 -1
  154. package/types/signed-transaction-bitcoin.d.ts +0 -9
  155. package/types/signed-transaction-bitcoin.js.map +0 -1
  156. package/types/transaction-bitcoin.js.map +0 -1
  157. package/types/unsigned-transaction-bitcoin-segwit.d.ts +0 -7
  158. package/types/unsigned-transaction-bitcoin-segwit.js.map +0 -1
  159. package/types/unsigned-transaction-bitcoin.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-bitcoin.js","sourceRoot":"","sources":["../../../src/v0/types/transaction-bitcoin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { TransactionSignRequest, TransactionSignRequestV2 } from '@airgap/serializer';
2
+ import { RawBitcoinSegwitTransaction } from './transaction-bitcoin';
3
+ export interface UnsignedBitcoinSegwitTransaction extends TransactionSignRequest, TransactionSignRequestV2 {
4
+ transaction: RawBitcoinSegwitTransaction;
5
+ publicKey: string;
6
+ callbackURL?: string;
7
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsigned-transaction-bitcoin-segwit.js","sourceRoot":"","sources":["../../../src/v0/types/unsigned-transaction-bitcoin-segwit.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { UnsignedTransaction } from '@airgap/coinlib-core/types/unsigned-transaction';
1
+ import { TransactionSignRequest, TransactionSignRequestV2 } from '@airgap/serializer';
2
2
  interface IInTransaction {
3
3
  txId: string;
4
4
  value: string;
@@ -16,7 +16,7 @@ interface RawBitcoinTransaction {
16
16
  ins: IInTransaction[];
17
17
  outs: IOutTransaction[];
18
18
  }
19
- export interface UnsignedBitcoinTransaction extends UnsignedTransaction {
19
+ export interface UnsignedBitcoinTransaction extends TransactionSignRequest, TransactionSignRequestV2 {
20
20
  transaction: RawBitcoinTransaction;
21
21
  }
22
22
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsigned-transaction-bitcoin.js","sourceRoot":"","sources":["../../../src/v0/types/unsigned-transaction-bitcoin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { AirGapBlockExplorer, BlockExplorerMetadata } from '@airgap/module-kit';
2
+ export declare class BlockCypherBlockExplorer implements AirGapBlockExplorer {
3
+ readonly url: string;
4
+ constructor(url?: string);
5
+ private readonly metadata;
6
+ getMetadata(): Promise<BlockExplorerMetadata>;
7
+ createAddressUrl(address: string): Promise<string>;
8
+ createTransactionUrl(transactionId: string): Promise<string>;
9
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.BlockCypherBlockExplorer = void 0;
40
+ var BLOCK_EXPLORER_MAINNET_URL = 'https://live.blockcypher.com/btc';
41
+ var BlockCypherBlockExplorer = /** @class */ (function () {
42
+ function BlockCypherBlockExplorer(url) {
43
+ if (url === void 0) { url = BLOCK_EXPLORER_MAINNET_URL; }
44
+ this.url = url;
45
+ this.metadata = {
46
+ name: 'BlockCypher',
47
+ url: this.url
48
+ };
49
+ }
50
+ BlockCypherBlockExplorer.prototype.getMetadata = function () {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ return __generator(this, function (_a) {
53
+ return [2 /*return*/, this.metadata];
54
+ });
55
+ });
56
+ };
57
+ BlockCypherBlockExplorer.prototype.createAddressUrl = function (address) {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ return __generator(this, function (_a) {
60
+ return [2 /*return*/, "".concat(this.url, "/address/").concat(address, "/")];
61
+ });
62
+ });
63
+ };
64
+ BlockCypherBlockExplorer.prototype.createTransactionUrl = function (transactionId) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ return __generator(this, function (_a) {
67
+ return [2 /*return*/, "".concat(this.url, "/tx/").concat(transactionId)];
68
+ });
69
+ });
70
+ };
71
+ return BlockCypherBlockExplorer;
72
+ }());
73
+ exports.BlockCypherBlockExplorer = BlockCypherBlockExplorer;
74
+ //# sourceMappingURL=BlockCypherBlockExplorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockCypherBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/BlockCypherBlockExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,0BAA0B,GAAW,kCAAkC,CAAA;AAE7E;IACE,kCAAmC,GAAwC;QAAxC,oBAAA,EAAA,gCAAwC;QAAxC,QAAG,GAAH,GAAG,CAAqC;QAE1D,aAAQ,GAA0B;YACjD,IAAI,EAAE,aAAa;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IAL6E,CAAC;IAOlE,8CAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,mDAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,sBAAY,OAAO,MAAG,EAAA;;;KACzC;IAEY,uDAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,iBAAO,aAAa,CAAE,EAAA;;;KACzC;IACH,+BAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,4DAAwB"}
@@ -0,0 +1,7 @@
1
+ export declare class BitcoinAddress {
2
+ protected readonly value: string;
3
+ private constructor();
4
+ static fromHDNode(node: any): BitcoinAddress;
5
+ static fromECPair(keyPair: any): BitcoinAddress;
6
+ asString(): string;
7
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitcoinAddress = void 0;
4
+ // tslint:disable: max-classes-per-file
5
+ var BitcoinAddress = /** @class */ (function () {
6
+ function BitcoinAddress(value) {
7
+ this.value = value;
8
+ }
9
+ BitcoinAddress.fromHDNode = function (node) {
10
+ return new BitcoinAddress(node.getAddress());
11
+ };
12
+ BitcoinAddress.fromECPair = function (keyPair) {
13
+ return new BitcoinAddress(keyPair.getAddress());
14
+ };
15
+ BitcoinAddress.prototype.asString = function () {
16
+ return this.value;
17
+ };
18
+ return BitcoinAddress;
19
+ }());
20
+ exports.BitcoinAddress = BitcoinAddress;
21
+ //# sourceMappingURL=BitcoinAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinAddress.js","sourceRoot":"","sources":["../../../src/v1/data/BitcoinAddress.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC;IACE,wBAAuC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE1C,yBAAU,GAAxB,UAAyB,IAAS;QAChC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IAC9C,CAAC;IAEa,yBAAU,GAAxB,UAAyB,OAAY;QACnC,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACjD,CAAC;IAEM,iCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IACH,qBAAC;AAAD,CAAC,AAdD,IAcC;AAdY,wCAAc"}
@@ -0,0 +1,8 @@
1
+ import type * as bitcoin from 'bitcoinjs-lib';
2
+ export declare class BitcoinSegwitAddress {
3
+ protected readonly value: string;
4
+ private constructor();
5
+ static fromBip32(bip32: bitcoin.BIP32Interface): BitcoinSegwitAddress;
6
+ static fromPayment(payment: bitcoin.Payment): BitcoinSegwitAddress;
7
+ asString(): string;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitcoinSegwitAddress = void 0;
4
+ // tslint:disable: max-classes-per-file
5
+ var coinlib_core_1 = require("@airgap/coinlib-core");
6
+ var errors_1 = require("@airgap/coinlib-core/errors");
7
+ var BitcoinSegwitAddress = /** @class */ (function () {
8
+ function BitcoinSegwitAddress(value) {
9
+ this.value = value;
10
+ }
11
+ BitcoinSegwitAddress.fromBip32 = function (bip32) {
12
+ return new BitcoinSegwitAddress(bip32.toBase58());
13
+ };
14
+ BitcoinSegwitAddress.fromPayment = function (payment) {
15
+ if (payment.address === undefined) {
16
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Could not generate address.');
17
+ }
18
+ return new BitcoinSegwitAddress(payment.address);
19
+ };
20
+ BitcoinSegwitAddress.prototype.asString = function () {
21
+ return this.value;
22
+ };
23
+ return BitcoinSegwitAddress;
24
+ }());
25
+ exports.BitcoinSegwitAddress = BitcoinSegwitAddress;
26
+ //# sourceMappingURL=BitcoinSegwitAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinSegwitAddress.js","sourceRoot":"","sources":["../../../src/v1/data/BitcoinSegwitAddress.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,qDAA6C;AAC7C,sDAA8D;AAG9D;IACE,8BAAuC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE1C,8BAAS,GAAvB,UAAwB,KAA6B;QACnD,OAAO,IAAI,oBAAoB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IACnD,CAAC;IAEa,gCAAW,GAAzB,UAA0B,OAAwB;QAChD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;YACjC,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAA;SAC1E;QAED,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,CAAC;IAEM,uCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IACH,2BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,oDAAoB"}
package/v1/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { BlockCypherBlockExplorer } from './block-explorer/BlockCypherBlockExplorer';
2
+ import { BitcoinModule } from './module/BitcoinModule';
3
+ import { BitcoinSegwitModule } from './module/BitcoinSegwitModule';
4
+ import { BitcoinProtocol, createBitcoinProtocol, createBitcoinProtocolOptions } from './protocol/BitcoinProtocol';
5
+ import { BitcoinSegwitProtocol, createBitcoinSegwitProtocol } from './protocol/BitcoinSegwitProtocol';
6
+ import { BitcoinTestnetProtocol, createBitcoinTestnetProtocol } from './protocol/BitcoinTestnetProtocol';
7
+ import { bitcoinSignedTransactionToResponse, bitcoinTransactionSignRequestToUnsigned, bitcoinTransactionSignResponseToSigned, bitcoinUnsignedTransactionToRequest } from './serializer/v3/schemas/converter/transaction-converter';
8
+ import { BitcoinTransactionSignRequest } from './serializer/v3/schemas/definitions/transaction-sign-request-bitcoin';
9
+ import { BitcoinSegwitTransactionSignRequest } from './serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit';
10
+ import { BitcoinTransactionSignResponse } from './serializer/v3/schemas/definitions/transaction-sign-response-bitcoin';
11
+ import { BitcoinSegwitTransactionSignResponse } from './serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit';
12
+ import { BitcoinTransactionValidator } from './serializer/v3/validators/transaction-validators';
13
+ import { bitcoinValidators } from './serializer/v3/validators/validators';
14
+ import { BitcoinProtocolNetwork, BitcoinProtocolOptions, BitcoinUnits } from './types/protocol';
15
+ import { BitcoinInTransaction, BitcoinOutTransaction, BitcoinSegwitSignedTransaction, BitcoinSegwitUnsignedTransaction, BitcoinSignedTransaction, BitcoinTransactionCursor, BitcoinUnsignedTransaction } from './types/transaction';
16
+ export { BitcoinModule, BitcoinSegwitModule };
17
+ export { BitcoinProtocol, BitcoinTestnetProtocol, BitcoinSegwitProtocol, createBitcoinProtocol, createBitcoinTestnetProtocol, createBitcoinSegwitProtocol, createBitcoinProtocolOptions };
18
+ export { BlockCypherBlockExplorer };
19
+ export { BitcoinUnits, BitcoinProtocolNetwork, BitcoinProtocolOptions, BitcoinUnsignedTransaction, BitcoinSignedTransaction, BitcoinSegwitUnsignedTransaction, BitcoinSegwitSignedTransaction, BitcoinInTransaction, BitcoinOutTransaction, BitcoinTransactionCursor };
20
+ export { BitcoinTransactionSignRequest, BitcoinTransactionSignResponse, BitcoinSegwitTransactionSignRequest, BitcoinSegwitTransactionSignResponse, BitcoinTransactionValidator, bitcoinValidators, bitcoinUnsignedTransactionToRequest, bitcoinSignedTransactionToResponse, bitcoinTransactionSignRequestToUnsigned, bitcoinTransactionSignResponseToSigned };
package/v1/index.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bitcoinTransactionSignResponseToSigned = exports.bitcoinTransactionSignRequestToUnsigned = exports.bitcoinSignedTransactionToResponse = exports.bitcoinUnsignedTransactionToRequest = exports.bitcoinValidators = exports.BitcoinTransactionValidator = exports.BlockCypherBlockExplorer = exports.createBitcoinProtocolOptions = exports.createBitcoinSegwitProtocol = exports.createBitcoinTestnetProtocol = exports.createBitcoinProtocol = exports.BitcoinSegwitModule = exports.BitcoinModule = void 0;
4
+ var BlockCypherBlockExplorer_1 = require("./block-explorer/BlockCypherBlockExplorer");
5
+ Object.defineProperty(exports, "BlockCypherBlockExplorer", { enumerable: true, get: function () { return BlockCypherBlockExplorer_1.BlockCypherBlockExplorer; } });
6
+ var BitcoinModule_1 = require("./module/BitcoinModule");
7
+ Object.defineProperty(exports, "BitcoinModule", { enumerable: true, get: function () { return BitcoinModule_1.BitcoinModule; } });
8
+ var BitcoinSegwitModule_1 = require("./module/BitcoinSegwitModule");
9
+ Object.defineProperty(exports, "BitcoinSegwitModule", { enumerable: true, get: function () { return BitcoinSegwitModule_1.BitcoinSegwitModule; } });
10
+ var BitcoinProtocol_1 = require("./protocol/BitcoinProtocol");
11
+ Object.defineProperty(exports, "createBitcoinProtocol", { enumerable: true, get: function () { return BitcoinProtocol_1.createBitcoinProtocol; } });
12
+ Object.defineProperty(exports, "createBitcoinProtocolOptions", { enumerable: true, get: function () { return BitcoinProtocol_1.createBitcoinProtocolOptions; } });
13
+ var BitcoinSegwitProtocol_1 = require("./protocol/BitcoinSegwitProtocol");
14
+ Object.defineProperty(exports, "createBitcoinSegwitProtocol", { enumerable: true, get: function () { return BitcoinSegwitProtocol_1.createBitcoinSegwitProtocol; } });
15
+ var BitcoinTestnetProtocol_1 = require("./protocol/BitcoinTestnetProtocol");
16
+ Object.defineProperty(exports, "createBitcoinTestnetProtocol", { enumerable: true, get: function () { return BitcoinTestnetProtocol_1.createBitcoinTestnetProtocol; } });
17
+ var transaction_converter_1 = require("./serializer/v3/schemas/converter/transaction-converter");
18
+ Object.defineProperty(exports, "bitcoinSignedTransactionToResponse", { enumerable: true, get: function () { return transaction_converter_1.bitcoinSignedTransactionToResponse; } });
19
+ Object.defineProperty(exports, "bitcoinTransactionSignRequestToUnsigned", { enumerable: true, get: function () { return transaction_converter_1.bitcoinTransactionSignRequestToUnsigned; } });
20
+ Object.defineProperty(exports, "bitcoinTransactionSignResponseToSigned", { enumerable: true, get: function () { return transaction_converter_1.bitcoinTransactionSignResponseToSigned; } });
21
+ Object.defineProperty(exports, "bitcoinUnsignedTransactionToRequest", { enumerable: true, get: function () { return transaction_converter_1.bitcoinUnsignedTransactionToRequest; } });
22
+ var transaction_validators_1 = require("./serializer/v3/validators/transaction-validators");
23
+ Object.defineProperty(exports, "BitcoinTransactionValidator", { enumerable: true, get: function () { return transaction_validators_1.BitcoinTransactionValidator; } });
24
+ var validators_1 = require("./serializer/v3/validators/validators");
25
+ Object.defineProperty(exports, "bitcoinValidators", { enumerable: true, get: function () { return validators_1.bitcoinValidators; } });
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,sFAAoF;AA+C3E,yGA/CA,mDAAwB,OA+CA;AA9CjC,wDAAsD;AA8B7C,8FA9BA,6BAAa,OA8BA;AA7BtB,oEAAkE;AA6B1C,oGA7Bf,yCAAmB,OA6Be;AA5B3C,8DAAiH;AAoC/G,sGApCwB,uCAAqB,OAoCxB;AAGrB,6GAvC+C,8CAA4B,OAuC/C;AAtC9B,0EAAqG;AAqCnG,4GArC8B,mDAA2B,OAqC9B;AApC7B,4EAAwG;AAmCtG,6GAnC+B,qDAA4B,OAmC/B;AAlC9B,iGAKgE;AA+D9D,mHAnEA,0DAAkC,OAmEA;AAClC,wHAnEA,+DAAuC,OAmEA;AACvC,uHAnEA,8DAAsC,OAmEA;AAHtC,oHA/DA,2DAAmC,OA+DA;AAzDrC,4FAA+F;AAuD7F,4GAvDO,oDAA2B,OAuDP;AAtD7B,oEAAyE;AAuDvE,kGAvDO,8BAAiB,OAuDP"}
@@ -0,0 +1,8 @@
1
+ import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, ProtocolNetwork } from '@airgap/module-kit';
2
+ export declare class BitcoinModule implements AirGapModule {
3
+ private readonly networkRegistry;
4
+ supportedNetworks: Record<string, ProtocolNetwork>;
5
+ createOfflineProtocol(): Promise<AirGapOfflineProtocol | undefined>;
6
+ createOnlineProtocol(networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
7
+ createBlockExplorer(networkId?: string): Promise<AirGapBlockExplorer | undefined>;
8
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.BitcoinModule = void 0;
40
+ var coinlib_core_1 = require("@airgap/coinlib-core");
41
+ var errors_1 = require("@airgap/coinlib-core/errors");
42
+ var module_kit_1 = require("@airgap/module-kit");
43
+ var BlockCypherBlockExplorer_1 = require("../block-explorer/BlockCypherBlockExplorer");
44
+ var BitcoinProtocol_1 = require("../protocol/BitcoinProtocol");
45
+ var BitcoinModule = /** @class */ (function () {
46
+ function BitcoinModule() {
47
+ this.networkRegistry = new module_kit_1.ModuleNetworkRegistry({
48
+ supportedNetworks: [BitcoinProtocol_1.BITCOIN_MAINNET_PROTOCOL_NETWORK]
49
+ });
50
+ this.supportedNetworks = this.networkRegistry.supportedNetworks;
51
+ }
52
+ BitcoinModule.prototype.createOfflineProtocol = function () {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ return __generator(this, function (_a) {
55
+ return [2 /*return*/, (0, BitcoinProtocol_1.createBitcoinProtocol)()];
56
+ });
57
+ });
58
+ };
59
+ BitcoinModule.prototype.createOnlineProtocol = function (networkId) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var network;
62
+ return __generator(this, function (_a) {
63
+ network = this.networkRegistry.findNetwork(networkId);
64
+ if (network === undefined) {
65
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Protocol network not supported.');
66
+ }
67
+ return [2 /*return*/, (0, BitcoinProtocol_1.createBitcoinProtocol)({ network: network })];
68
+ });
69
+ });
70
+ };
71
+ BitcoinModule.prototype.createBlockExplorer = function (networkId) {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var network;
74
+ return __generator(this, function (_a) {
75
+ network = this.networkRegistry.findNetwork(networkId);
76
+ if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
77
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Block Explorer network not supported.');
78
+ }
79
+ return [2 /*return*/, new BlockCypherBlockExplorer_1.BlockCypherBlockExplorer()];
80
+ });
81
+ });
82
+ };
83
+ return BitcoinModule;
84
+ }());
85
+ exports.BitcoinModule = BitcoinModule;
86
+ //# sourceMappingURL=BitcoinModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinModule.js","sourceRoot":"","sources":["../../../src/v1/module/BitcoinModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6C;AAC7C,sDAAqE;AACrE,iDAO2B;AAE3B,uFAAqF;AACrF,+DAAqG;AAErG;IAAA;QACmB,oBAAe,GAA0B,IAAI,kCAAqB,CAAC;YAClF,iBAAiB,EAAE,CAAC,kDAAgC,CAAC;SACtD,CAAC,CAAA;QAEK,sBAAiB,GAAoC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAA;IAuBpG,CAAC;IArBc,6CAAqB,GAAlC;;;gBACE,sBAAO,IAAA,uCAAqB,GAAE,EAAA;;;KAC/B;IAEY,4CAAoB,GAAjC,UAAkC,SAAkB;;;;gBAC5C,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAA;iBACrF;gBAED,sBAAO,IAAA,uCAAqB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,EAAA;;;KAC1C;IAEY,2CAAmB,GAAhC,UAAiC,SAAkB;;;;gBAC3C,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,SAAS,EAAE;oBAC/B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,OAAO,EAAE,uCAAuC,CAAC,CAAA;iBAC3F;gBAED,sBAAO,IAAI,mDAAwB,EAAE,EAAA;;;KACtC;IACH,oBAAC;AAAD,CAAC,AA5BD,IA4BC;AA5BY,sCAAa"}
@@ -0,0 +1,8 @@
1
+ import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, ProtocolNetwork } from '@airgap/module-kit';
2
+ export declare class BitcoinSegwitModule implements AirGapModule {
3
+ private readonly networkRegistry;
4
+ supportedNetworks: Record<string, ProtocolNetwork>;
5
+ createOfflineProtocol(): Promise<AirGapOfflineProtocol | undefined>;
6
+ createOnlineProtocol(networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
7
+ createBlockExplorer(networkId?: string): Promise<AirGapBlockExplorer | undefined>;
8
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.BitcoinSegwitModule = void 0;
40
+ var coinlib_core_1 = require("@airgap/coinlib-core");
41
+ var errors_1 = require("@airgap/coinlib-core/errors");
42
+ var module_kit_1 = require("@airgap/module-kit");
43
+ var BlockCypherBlockExplorer_1 = require("../block-explorer/BlockCypherBlockExplorer");
44
+ var BitcoinProtocol_1 = require("../protocol/BitcoinProtocol");
45
+ var BitcoinSegwitProtocol_1 = require("../protocol/BitcoinSegwitProtocol");
46
+ var BitcoinSegwitModule = /** @class */ (function () {
47
+ function BitcoinSegwitModule() {
48
+ this.networkRegistry = new module_kit_1.ModuleNetworkRegistry({
49
+ supportedNetworks: [BitcoinProtocol_1.BITCOIN_MAINNET_PROTOCOL_NETWORK]
50
+ });
51
+ this.supportedNetworks = this.networkRegistry.supportedNetworks;
52
+ }
53
+ BitcoinSegwitModule.prototype.createOfflineProtocol = function () {
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ return __generator(this, function (_a) {
56
+ return [2 /*return*/, (0, BitcoinSegwitProtocol_1.createBitcoinSegwitProtocol)()];
57
+ });
58
+ });
59
+ };
60
+ BitcoinSegwitModule.prototype.createOnlineProtocol = function (networkId) {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var network;
63
+ return __generator(this, function (_a) {
64
+ network = this.networkRegistry.findNetwork(networkId);
65
+ if (network === undefined) {
66
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Protocol network not supported.');
67
+ }
68
+ return [2 /*return*/, (0, BitcoinSegwitProtocol_1.createBitcoinSegwitProtocol)({ network: network })];
69
+ });
70
+ });
71
+ };
72
+ BitcoinSegwitModule.prototype.createBlockExplorer = function (networkId) {
73
+ return __awaiter(this, void 0, void 0, function () {
74
+ var network;
75
+ return __generator(this, function (_a) {
76
+ network = this.networkRegistry.findNetwork(networkId);
77
+ if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
78
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Block Explorer network not supported.');
79
+ }
80
+ return [2 /*return*/, new BlockCypherBlockExplorer_1.BlockCypherBlockExplorer()];
81
+ });
82
+ });
83
+ };
84
+ return BitcoinSegwitModule;
85
+ }());
86
+ exports.BitcoinSegwitModule = BitcoinSegwitModule;
87
+ //# sourceMappingURL=BitcoinSegwitModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinSegwitModule.js","sourceRoot":"","sources":["../../../src/v1/module/BitcoinSegwitModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6C;AAC7C,sDAAqE;AACrE,iDAO2B;AAE3B,uFAAqF;AACrF,+DAA8E;AAC9E,2EAA+E;AAE/E;IAAA;QACmB,oBAAe,GAA0B,IAAI,kCAAqB,CAAC;YAClF,iBAAiB,EAAE,CAAC,kDAAgC,CAAC;SACtD,CAAC,CAAA;QAEK,sBAAiB,GAAoC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAA;IAuBpG,CAAC;IArBc,mDAAqB,GAAlC;;;gBACE,sBAAO,IAAA,mDAA2B,GAAE,EAAA;;;KACrC;IAEY,kDAAoB,GAAjC,UAAkC,SAAkB;;;;gBAC5C,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAA;iBACrF;gBAED,sBAAO,IAAA,mDAA2B,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,EAAA;;;KAChD;IAEY,iDAAmB,GAAhC,UAAiC,SAAkB;;;;gBAC3C,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,SAAS,EAAE;oBAC/B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,OAAO,EAAE,uCAAuC,CAAC,CAAA;iBAC3F;gBAED,sBAAO,IAAI,mDAAwB,EAAE,EAAA;;;KACtC;IACH,0BAAC;AAAD,CAAC,AA5BD,IA4BC;AA5BY,kDAAmB"}
@@ -0,0 +1,12 @@
1
+ import { Secp256k1CryptoClient } from '@airgap/coinlib-core/protocols/Secp256k1CryptoClient';
2
+ import { BitcoinProtocol } from '../../v1';
3
+ import { BitcoinJS } from '../types/bitcoinjs';
4
+ export declare class BitcoinCryptoClient extends Secp256k1CryptoClient {
5
+ private readonly protocol;
6
+ private readonly bitcoinjs;
7
+ constructor(protocol: BitcoinProtocol, bitcoinjs: BitcoinJS);
8
+ signMessage(message: string, keypair: {
9
+ privateKey: string;
10
+ }): Promise<string>;
11
+ verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
12
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.BitcoinCryptoClient = void 0;
55
+ var Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
56
+ var hex_1 = require("@airgap/coinlib-core/utils/hex");
57
+ var module_kit_1 = require("@airgap/module-kit");
58
+ var BitcoinCryptoClient = /** @class */ (function (_super) {
59
+ __extends(BitcoinCryptoClient, _super);
60
+ function BitcoinCryptoClient(protocol, bitcoinjs) {
61
+ var _this = _super.call(this) || this;
62
+ _this.protocol = protocol;
63
+ _this.bitcoinjs = bitcoinjs;
64
+ return _this;
65
+ }
66
+ BitcoinCryptoClient.prototype.signMessage = function (message, keypair) {
67
+ return __awaiter(this, void 0, void 0, function () {
68
+ var signature;
69
+ return __generator(this, function (_a) {
70
+ signature = this.bitcoinjs.message.sign(message, Buffer.from(keypair.privateKey, 'hex'), true);
71
+ return [2 /*return*/, signature.toString('base64')];
72
+ });
73
+ });
74
+ };
75
+ BitcoinCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var rawSignature, _publicKey, address;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0:
81
+ rawSignature = Buffer.from(signature, 'base64');
82
+ _publicKey = (0, hex_1.isHex)(publicKey)
83
+ ? (0, module_kit_1.newPublicKey)(publicKey, 'hex')
84
+ : (0, module_kit_1.newExtendedPublicKey)(publicKey, 'encoded');
85
+ return [4 /*yield*/, this.protocol.getAddressFromPublicKey(_publicKey)];
86
+ case 1:
87
+ address = _a.sent();
88
+ return [2 /*return*/, this.bitcoinjs.message.verify(message, address, rawSignature)];
89
+ }
90
+ });
91
+ });
92
+ };
93
+ return BitcoinCryptoClient;
94
+ }(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
95
+ exports.BitcoinCryptoClient = BitcoinCryptoClient;
96
+ //# sourceMappingURL=BitcoinCryptoClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinCryptoClient.js","sourceRoot":"","sources":["../../../src/v1/protocol/BitcoinCryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA4F;AAC5F,sDAAsD;AACtD,iDAAqG;AAKrG;IAAyC,uCAAqB;IAC5D,6BAA6B,QAAyB,EAAmB,SAAoB;QAA7F,YACE,iBAAO,SACR;QAF4B,cAAQ,GAAR,QAAQ,CAAiB;QAAmB,eAAS,GAAT,SAAS,CAAW;;IAE7F,CAAC;IAEY,yCAAW,GAAxB,UAAyB,OAAe,EAAE,OAA+B;;;;gBACjE,SAAS,GAAW,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;gBAE5G,sBAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAA;;;KACpC;IAEY,2CAAa,GAA1B,UAA2B,OAAe,EAAE,SAAiB,EAAE,SAAiB;;;;;;wBACxE,YAAY,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;wBAGvD,UAAU,GAAkC,IAAA,WAAK,EAAC,SAAS,CAAC;4BAChE,CAAC,CAAC,IAAA,yBAAY,EAAC,SAAS,EAAE,KAAK,CAAC;4BAChC,CAAC,CAAC,IAAA,iCAAoB,EAAC,SAAS,EAAE,SAAS,CAAC,CAAA;wBAE9B,qBAAM,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,UAAU,CAAC,EAAA;;wBAAjE,OAAO,GAAG,SAAuD;wBAEvE,sBAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,EAAA;;;;KACrE;IACH,0BAAC;AAAD,CAAC,AAvBD,CAAyC,6CAAqB,GAuB7D;AAvBY,kDAAmB"}