@airgap/bitcoin 0.13.11-beta.1 → 0.13.11-beta.10

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 (148) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +18 -0
  3. package/index.js.map +1 -0
  4. package/package.json +1 -5
  5. package/v0/index.d.ts +14 -0
  6. package/v0/index.js +34 -0
  7. package/v0/index.js.map +1 -0
  8. package/v0/protocol/BitcoinAddress.d.ts +9 -0
  9. package/v0/protocol/BitcoinAddress.js +23 -0
  10. package/v0/protocol/BitcoinAddress.js.map +1 -0
  11. package/v0/protocol/BitcoinCryptoClient.d.ts +11 -0
  12. package/v0/protocol/BitcoinCryptoClient.js +91 -0
  13. package/v0/protocol/BitcoinCryptoClient.js.map +1 -0
  14. package/v0/protocol/BitcoinProtocol.d.ts +167 -0
  15. package/v0/protocol/BitcoinProtocol.js +1063 -0
  16. package/v0/protocol/BitcoinProtocol.js.map +1 -0
  17. package/v0/protocol/BitcoinProtocolOptions.d.ts +26 -0
  18. package/v0/protocol/BitcoinProtocolOptions.js +148 -0
  19. package/v0/protocol/BitcoinProtocolOptions.js.map +1 -0
  20. package/v0/protocol/BitcoinSegwitAddress.d.ts +7 -0
  21. package/v0/protocol/BitcoinSegwitAddress.js +41 -0
  22. package/v0/protocol/BitcoinSegwitAddress.js.map +1 -0
  23. package/v0/protocol/BitcoinSegwitProtocol.d.ts +28 -0
  24. package/v0/protocol/BitcoinSegwitProtocol.js +541 -0
  25. package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -0
  26. package/v0/protocol/BitcoinTestnetProtocol.d.ts +7 -0
  27. package/v0/protocol/BitcoinTestnetProtocol.js +58 -0
  28. package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -0
  29. package/v0/protocol/BitcoinTypes.d.ts +21 -0
  30. package/v0/protocol/BitcoinTypes.js +3 -0
  31. package/v0/protocol/BitcoinTypes.js.map +1 -0
  32. package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin-segwit.json +0 -0
  33. package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin.json +73 -0
  34. package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin-segwit.json +0 -0
  35. package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin.json +37 -0
  36. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin-segwit.json +29 -0
  37. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin.json +73 -0
  38. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin-segwit.json +19 -0
  39. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin.json +37 -0
  40. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  41. package/v0/serializer/validators/transaction-validator.js +81 -0
  42. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  43. package/v0/serializer/validators/validators.d.ts +1 -0
  44. package/v0/serializer/validators/validators.js +151 -0
  45. package/v0/serializer/validators/validators.js.map +1 -0
  46. package/v0/types/signed-transaction-bitcoin-segwit.d.ts +5 -0
  47. package/v0/types/signed-transaction-bitcoin-segwit.js +3 -0
  48. package/v0/types/signed-transaction-bitcoin-segwit.js.map +1 -0
  49. package/v0/types/signed-transaction-bitcoin.d.ts +9 -0
  50. package/v0/types/signed-transaction-bitcoin.js +3 -0
  51. package/v0/types/signed-transaction-bitcoin.js.map +1 -0
  52. package/v0/types/transaction-bitcoin.d.ts +20 -0
  53. package/v0/types/transaction-bitcoin.js +3 -0
  54. package/v0/types/transaction-bitcoin.js.map +1 -0
  55. package/v0/types/unsigned-transaction-bitcoin-segwit.d.ts +7 -0
  56. package/v0/types/unsigned-transaction-bitcoin-segwit.js +3 -0
  57. package/v0/types/unsigned-transaction-bitcoin-segwit.js.map +1 -0
  58. package/v0/types/unsigned-transaction-bitcoin.d.ts +22 -0
  59. package/v0/types/unsigned-transaction-bitcoin.js +3 -0
  60. package/v0/types/unsigned-transaction-bitcoin.js.map +1 -0
  61. package/v1/block-explorer/BlockCypherBlockExplorer.d.ts +9 -0
  62. package/v1/block-explorer/BlockCypherBlockExplorer.js +74 -0
  63. package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -0
  64. package/v1/data/BitcoinAddress.d.ts +7 -0
  65. package/v1/data/BitcoinAddress.js +20 -0
  66. package/v1/data/BitcoinAddress.js.map +1 -0
  67. package/v1/data/BitcoinSegwitAddress.d.ts +8 -0
  68. package/v1/data/BitcoinSegwitAddress.js +25 -0
  69. package/v1/data/BitcoinSegwitAddress.js.map +1 -0
  70. package/v1/index.d.ts +20 -0
  71. package/v1/index.js +24 -0
  72. package/v1/index.js.map +1 -0
  73. package/v1/module/BitcoinModule.d.ts +16 -0
  74. package/v1/module/BitcoinModule.js +112 -0
  75. package/v1/module/BitcoinModule.js.map +1 -0
  76. package/v1/module.d.ts +3 -0
  77. package/v1/module.js +24 -0
  78. package/v1/module.js.map +1 -0
  79. package/v1/protocol/BitcoinCryptoClient.d.ts +12 -0
  80. package/v1/protocol/BitcoinCryptoClient.js +96 -0
  81. package/v1/protocol/BitcoinCryptoClient.js.map +1 -0
  82. package/v1/protocol/BitcoinProtocol.d.ts +72 -0
  83. package/v1/protocol/BitcoinProtocol.js +1193 -0
  84. package/v1/protocol/BitcoinProtocol.js.map +1 -0
  85. package/v1/protocol/BitcoinSegwitProtocol.d.ts +52 -0
  86. package/v1/protocol/BitcoinSegwitProtocol.js +720 -0
  87. package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -0
  88. package/v1/protocol/BitcoinTestnetProtocol.d.ts +12 -0
  89. package/v1/protocol/BitcoinTestnetProtocol.js +73 -0
  90. package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -0
  91. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +13 -0
  92. package/v1/serializer/v3/schemas/converter/transaction-converter.js +75 -0
  93. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  94. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.d.ts +4 -0
  95. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js +3 -0
  96. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js.map +1 -0
  97. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.d.ts +4 -0
  98. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js +3 -0
  99. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js.map +1 -0
  100. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.d.ts +3 -0
  101. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js +3 -0
  102. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js.map +1 -0
  103. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.d.ts +7 -0
  104. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js +3 -0
  105. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js.map +1 -0
  106. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin-segwit.json +29 -0
  107. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin.json +79 -0
  108. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin-segwit.json +19 -0
  109. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin.json +37 -0
  110. package/v1/serializer/v3/serializer-companion.d.ts +14 -0
  111. package/v1/serializer/v3/serializer-companion.js +197 -0
  112. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  113. package/v1/serializer/v3/validators/transaction-validator.d.ts +7 -0
  114. package/v1/serializer/v3/validators/transaction-validator.js +56 -0
  115. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
  116. package/v1/serializer/v3/validators/validators.d.ts +7 -0
  117. package/v1/serializer/v3/validators/validators.js +238 -0
  118. package/v1/serializer/v3/validators/validators.js.map +1 -0
  119. package/v1/types/bitcoinjs.d.ts +14 -0
  120. package/v1/types/bitcoinjs.js +3 -0
  121. package/v1/types/bitcoinjs.js.map +1 -0
  122. package/v1/types/crypto.d.ts +2 -0
  123. package/v1/types/crypto.js +3 -0
  124. package/v1/types/crypto.js.map +1 -0
  125. package/v1/types/indexer.d.ts +81 -0
  126. package/v1/types/indexer.js +3 -0
  127. package/v1/types/indexer.js.map +1 -0
  128. package/v1/types/key.d.ts +6 -0
  129. package/v1/types/key.js +3 -0
  130. package/v1/types/key.js.map +1 -0
  131. package/v1/types/protocol.d.ts +17 -0
  132. package/v1/types/protocol.js +3 -0
  133. package/v1/types/protocol.js.map +1 -0
  134. package/v1/types/transaction.d.ts +39 -0
  135. package/v1/types/transaction.js +3 -0
  136. package/v1/types/transaction.js.map +1 -0
  137. package/v1/utils/common.d.ts +2 -0
  138. package/v1/utils/common.js +28 -0
  139. package/v1/utils/common.js.map +1 -0
  140. package/v1/utils/key.d.ts +34 -0
  141. package/v1/utils/key.js +190 -0
  142. package/v1/utils/key.js.map +1 -0
  143. package/v1/utils/network.d.ts +2 -0
  144. package/v1/utils/network.js +22 -0
  145. package/v1/utils/network.js.map +1 -0
  146. package/v1/utils/signature.d.ts +2 -0
  147. package/v1/utils/signature.js +34 -0
  148. package/v1/utils/signature.js.map +1 -0
@@ -0,0 +1,21 @@
1
+ import { IAirGapAddressResult, IProtocolAddressCursor } from '@airgap/coinlib-core/interfaces/IAirGapAddress';
2
+ import { IAirGapTransaction } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
3
+ export interface BitcoinTransactionCursor {
4
+ offset: number;
5
+ }
6
+ export interface BitcoinTransactionResult {
7
+ transactions: IAirGapTransaction[];
8
+ cursor: BitcoinTransactionCursor;
9
+ }
10
+ export interface BitcoinBlockbookTransactionCursor {
11
+ page: number;
12
+ }
13
+ export interface BitcoinBlockbookTransactionResult {
14
+ transactions: IAirGapTransaction[];
15
+ cursor: BitcoinBlockbookTransactionCursor;
16
+ }
17
+ export interface BitcoinAddressCursor extends IProtocolAddressCursor {
18
+ hasNext: false;
19
+ }
20
+ export interface BitcoinAddressResult extends IAirGapAddressResult<BitcoinAddressCursor> {
21
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=BitcoinTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinTypes.js","sourceRoot":"","sources":["../../../src/v0/protocol/BitcoinTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,73 @@
1
+ {
2
+ "$ref": "#/definitions/UnsignedBitcoinTransaction",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "UnsignedBitcoinTransaction": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "callbackURL": {
9
+ "type": "string"
10
+ },
11
+ "publicKey": {
12
+ "type": "string"
13
+ },
14
+ "transaction": {
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "ins": {
18
+ "items": {
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "address": {
22
+ "type": "string"
23
+ },
24
+ "derivationPath": {
25
+ "type": "string"
26
+ },
27
+ "txId": {
28
+ "type": "string"
29
+ },
30
+ "value": {
31
+ "type": "string"
32
+ },
33
+ "vout": {
34
+ "type": "number"
35
+ }
36
+ },
37
+ "required": ["txId", "value", "vout", "address"],
38
+ "type": "object"
39
+ },
40
+ "type": "array"
41
+ },
42
+ "outs": {
43
+ "items": {
44
+ "additionalProperties": false,
45
+ "properties": {
46
+ "derivationPath": {
47
+ "type": "string"
48
+ },
49
+ "isChange": {
50
+ "type": "boolean"
51
+ },
52
+ "recipient": {
53
+ "type": "string"
54
+ },
55
+ "value": {
56
+ "type": "string"
57
+ }
58
+ },
59
+ "required": ["recipient", "isChange", "value"],
60
+ "type": "object"
61
+ },
62
+ "type": "array"
63
+ }
64
+ },
65
+ "required": ["ins", "outs"],
66
+ "type": "object"
67
+ }
68
+ },
69
+ "required": ["publicKey", "transaction"],
70
+ "type": "object"
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "$ref": "#/definitions/SignedBitcoinTransaction",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "SignedBitcoinTransaction": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "accountIdentifier": {
9
+ "type": "string"
10
+ },
11
+ "amount": {
12
+ "type": "string"
13
+ },
14
+ "fee": {
15
+ "type": "string"
16
+ },
17
+ "from": {
18
+ "items": {
19
+ "type": "string"
20
+ },
21
+ "type": "array"
22
+ },
23
+ "to": {
24
+ "items": {
25
+ "type": "string"
26
+ },
27
+ "type": "array"
28
+ },
29
+ "transaction": {
30
+ "type": "string"
31
+ }
32
+ },
33
+ "required": ["accountIdentifier", "amount", "fee", "from", "to", "transaction"],
34
+ "type": "object"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$ref": "#/definitions/UnsignedBitcoinSegwitTransaction",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "UnsignedBitcoinSegwitTransaction": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "callbackURL": {
9
+ "type": "string"
10
+ },
11
+ "publicKey": {
12
+ "type": "string"
13
+ },
14
+ "transaction": {
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "psbt": {
18
+ "type": "string"
19
+ }
20
+ },
21
+ "required": ["psbt"],
22
+ "type": "object"
23
+ }
24
+ },
25
+ "required": ["publicKey", "transaction"],
26
+ "type": "object"
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "$ref": "#/definitions/UnsignedBitcoinTransaction",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "UnsignedBitcoinTransaction": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "callbackURL": {
9
+ "type": "string"
10
+ },
11
+ "publicKey": {
12
+ "type": "string"
13
+ },
14
+ "transaction": {
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "ins": {
18
+ "items": {
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "address": {
22
+ "type": "string"
23
+ },
24
+ "derivationPath": {
25
+ "type": "string"
26
+ },
27
+ "txId": {
28
+ "type": "string"
29
+ },
30
+ "value": {
31
+ "type": "string"
32
+ },
33
+ "vout": {
34
+ "type": "number"
35
+ }
36
+ },
37
+ "required": ["txId", "value", "vout", "address"],
38
+ "type": "object"
39
+ },
40
+ "type": "array"
41
+ },
42
+ "outs": {
43
+ "items": {
44
+ "additionalProperties": false,
45
+ "properties": {
46
+ "derivationPath": {
47
+ "type": "string"
48
+ },
49
+ "isChange": {
50
+ "type": "boolean"
51
+ },
52
+ "recipient": {
53
+ "type": "string"
54
+ },
55
+ "value": {
56
+ "type": "string"
57
+ }
58
+ },
59
+ "required": ["recipient", "isChange", "value"],
60
+ "type": "object"
61
+ },
62
+ "type": "array"
63
+ }
64
+ },
65
+ "required": ["ins", "outs"],
66
+ "type": "object"
67
+ }
68
+ },
69
+ "required": ["publicKey", "transaction"],
70
+ "type": "object"
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$ref": "#/definitions/SignedBitcoinSegwitTransaction",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "SignedBitcoinSegwitTransaction": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "accountIdentifier": {
9
+ "type": "string"
10
+ },
11
+ "transaction": {
12
+ "type": "string"
13
+ }
14
+ },
15
+ "required": ["accountIdentifier", "transaction"],
16
+ "type": "object"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "$ref": "#/definitions/SignedBitcoinTransaction",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "SignedBitcoinTransaction": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "accountIdentifier": {
9
+ "type": "string"
10
+ },
11
+ "amount": {
12
+ "type": "string"
13
+ },
14
+ "fee": {
15
+ "type": "string"
16
+ },
17
+ "from": {
18
+ "items": {
19
+ "type": "string"
20
+ },
21
+ "type": "array"
22
+ },
23
+ "to": {
24
+ "items": {
25
+ "type": "string"
26
+ },
27
+ "type": "array"
28
+ },
29
+ "transaction": {
30
+ "type": "string"
31
+ }
32
+ },
33
+ "required": ["accountIdentifier", "amount", "fee", "from", "to", "transaction"],
34
+ "type": "object"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ import { TransactionValidator, TransactionValidatorFactory, TransactionValidatorFactoryV2, TransactionValidatorV2 } from '@airgap/serializer';
2
+ import { SignedBitcoinTransaction } from '../../types/signed-transaction-bitcoin';
3
+ import { UnsignedBitcoinTransaction } from '../../types/unsigned-transaction-bitcoin';
4
+ export declare class BitcoinTransactionValidator implements TransactionValidator, TransactionValidatorV2 {
5
+ private readonly version;
6
+ constructor(version?: 'v2' | 'v3');
7
+ validateUnsignedTransaction(unsignedTx: UnsignedBitcoinTransaction): Promise<any>;
8
+ validateSignedTransaction(signedTx: SignedBitcoinTransaction): Promise<any>;
9
+ }
10
+ export declare class BitcoinTransactionValidatorFactory implements TransactionValidatorFactory<BitcoinTransactionValidator> {
11
+ create(): BitcoinTransactionValidator;
12
+ }
13
+ export declare class BitcoinTransactionValidatorFactoryV2 implements TransactionValidatorFactoryV2<BitcoinTransactionValidator> {
14
+ create(): BitcoinTransactionValidator;
15
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitcoinTransactionValidatorFactoryV2 = exports.BitcoinTransactionValidatorFactory = exports.BitcoinTransactionValidator = void 0;
4
+ // tslint:disable: max-classes-per-file
5
+ var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
6
+ var serializer_1 = require("@airgap/serializer");
7
+ var unsignedTransactionConstraints = {
8
+ ins: {
9
+ presence: { allowEmpty: false },
10
+ isValidBitcoinInput: true
11
+ },
12
+ outs: {
13
+ presence: { allowEmpty: false },
14
+ isValidBitcoinOutput: true
15
+ }
16
+ };
17
+ var signedTransactionConstraints = {
18
+ from: {
19
+ presence: { allowEmpty: false },
20
+ isValidBitcoinFromArray: true
21
+ },
22
+ amount: {
23
+ type: 'BigNumber',
24
+ presence: { allowEmpty: false }
25
+ },
26
+ fee: {
27
+ type: 'BigNumber',
28
+ presence: { allowEmpty: false }
29
+ },
30
+ accountIdentifier: {
31
+ type: 'String',
32
+ presence: { allowEmpty: false }
33
+ },
34
+ transaction: {
35
+ isValidBitcoinTxString: true,
36
+ type: 'String',
37
+ presence: { allowEmpty: false }
38
+ }
39
+ };
40
+ var success = function () { return undefined; };
41
+ var error = function (errors) { return errors; };
42
+ var BitcoinTransactionValidator = /** @class */ (function () {
43
+ function BitcoinTransactionValidator(version) {
44
+ if (version === void 0) { version = 'v3'; }
45
+ this.version = version;
46
+ }
47
+ BitcoinTransactionValidator.prototype.validateUnsignedTransaction = function (unsignedTx) {
48
+ var rawBitcoinTx = unsignedTx.transaction;
49
+ if (this.version === 'v3') {
50
+ (0, serializer_1.validateSyncScheme)({});
51
+ }
52
+ else {
53
+ (0, serializer_1.validateSyncSchemeV2)({});
54
+ }
55
+ return (0, validate_1.async)(rawBitcoinTx, unsignedTransactionConstraints).then(success, error);
56
+ };
57
+ BitcoinTransactionValidator.prototype.validateSignedTransaction = function (signedTx) {
58
+ return (0, validate_1.async)(signedTx, signedTransactionConstraints).then(success, error);
59
+ };
60
+ return BitcoinTransactionValidator;
61
+ }());
62
+ exports.BitcoinTransactionValidator = BitcoinTransactionValidator;
63
+ var BitcoinTransactionValidatorFactory = /** @class */ (function () {
64
+ function BitcoinTransactionValidatorFactory() {
65
+ }
66
+ BitcoinTransactionValidatorFactory.prototype.create = function () {
67
+ return new BitcoinTransactionValidator('v3');
68
+ };
69
+ return BitcoinTransactionValidatorFactory;
70
+ }());
71
+ exports.BitcoinTransactionValidatorFactory = BitcoinTransactionValidatorFactory;
72
+ var BitcoinTransactionValidatorFactoryV2 = /** @class */ (function () {
73
+ function BitcoinTransactionValidatorFactoryV2() {
74
+ }
75
+ BitcoinTransactionValidatorFactoryV2.prototype.create = function () {
76
+ return new BitcoinTransactionValidator('v2');
77
+ };
78
+ return BitcoinTransactionValidatorFactoryV2;
79
+ }());
80
+ exports.BitcoinTransactionValidatorFactoryV2 = BitcoinTransactionValidatorFactoryV2;
81
+ //# sourceMappingURL=transaction-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAO2B;AAM3B,IAAM,8BAA8B,GAAG;IACrC,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,mBAAmB,EAAE,IAAI;KAC1B;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,oBAAoB,EAAE,IAAI;KAC3B;CACF,CAAA;AAED,IAAM,4BAA4B,GAAG;IACnC,IAAI,EAAE;QACJ,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,uBAAuB,EAAE,IAAI;KAC9B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;IACD,GAAG,EAAE;QACH,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;IACD,WAAW,EAAE;QACX,sBAAsB,EAAE,IAAI;QAC5B,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KACh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(mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
7
+ var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
8
+ var BitcoinProtocol_1 = require("../../protocol/BitcoinProtocol");
9
+ validate_1.validators.isValidBitcoinInput = function (ins) {
10
+ // if (!Array.isArray(ins)) {
11
+ // ins = [ins]
12
+ // }
13
+ if (!Array.isArray(ins)) {
14
+ return 'not an array';
15
+ }
16
+ for (var i = 0; i < ins.length; i++) {
17
+ var value = ins[i];
18
+ if (!value.hasOwnProperty('txId')) {
19
+ return "doesn't have property txId ";
20
+ }
21
+ else {
22
+ var pattern = RegExp('^[a-fA-F0-9]{64}$');
23
+ if (!pattern.test(value.txId)) {
24
+ return 'not a valid txId';
25
+ }
26
+ }
27
+ if (!value.hasOwnProperty('value')) {
28
+ return "doesn't have property value ";
29
+ }
30
+ else {
31
+ if (!bignumber_1.default.isBigNumber(value.value)) {
32
+ return 'value not a valid BigNumber';
33
+ }
34
+ }
35
+ if (!value.hasOwnProperty('vout')) {
36
+ return "doesn't have property vout";
37
+ }
38
+ else {
39
+ if (typeof value.vout !== 'number') {
40
+ return 'vout is not a number';
41
+ }
42
+ else if (value.vout < 0) {
43
+ return 'vout is not a positive value';
44
+ }
45
+ }
46
+ if (!value.hasOwnProperty('address')) {
47
+ return "doesn't have property address ";
48
+ }
49
+ else {
50
+ var pattern = RegExp(new BitcoinProtocol_1.BitcoinProtocol().addressValidationPattern);
51
+ if (!pattern.test(value.address)) {
52
+ return 'not a valid bitcoin address';
53
+ }
54
+ }
55
+ if (!value.hasOwnProperty('derivationPath')) {
56
+ return "doesn't have property derivationPath";
57
+ }
58
+ else {
59
+ var protocol = new BitcoinProtocol_1.BitcoinProtocol();
60
+ try {
61
+ var mnemonic = 'spell device they juice trial skirt amazing boat badge steak usage february virus art survey';
62
+ protocol.getPublicKeyFromMnemonic(mnemonic, value.derivationPath);
63
+ }
64
+ catch (error) {
65
+ return 'invalid derivation path';
66
+ }
67
+ }
68
+ }
69
+ return null;
70
+ };
71
+ validate_1.validators.isValidBitcoinOutput = function (outs) {
72
+ // console.log(outs)
73
+ // if (!Array.isArray(outs)) {
74
+ // outs = [outs]
75
+ // }
76
+ if (!Array.isArray(outs)) {
77
+ return 'not an array';
78
+ }
79
+ for (var i = 0; i < outs.length; i++) {
80
+ var value = outs[i];
81
+ if (!value.hasOwnProperty('recipient')) {
82
+ return "doesn't have property recipient";
83
+ }
84
+ else {
85
+ var pattern = RegExp(new BitcoinProtocol_1.BitcoinProtocol().addressValidationPattern);
86
+ if (!pattern.test(value.recipient)) {
87
+ return 'invalid Bitcoin address';
88
+ }
89
+ }
90
+ if (!value.hasOwnProperty('isChange')) {
91
+ return "doesn't have property isChange ";
92
+ }
93
+ else {
94
+ if (typeof value.isChange !== 'boolean') {
95
+ return 'change is not a boolean';
96
+ }
97
+ }
98
+ if (!value.hasOwnProperty('value')) {
99
+ return "doesn't have property value ";
100
+ }
101
+ else {
102
+ if (!bignumber_1.default.isBigNumber(value.value)) {
103
+ return 'value is not BigNumber';
104
+ }
105
+ }
106
+ }
107
+ return null;
108
+ };
109
+ validate_1.validators.isValidBitcoinFromArray = function (array) {
110
+ if (!Array.isArray(array)) {
111
+ return 'not an array of Bitcoin addresses';
112
+ }
113
+ for (var i = 0; i < array.length; i++) {
114
+ var address = array[i];
115
+ // const testpattern = RegExp(new BitcoinTestnetProtocol().addressValidationPattern) // TODO maybe don't use the testnetprotocol
116
+ var pattern = RegExp(new BitcoinProtocol_1.BitcoinProtocol().addressValidationPattern); // TODO maybe don't use the testnetprotocol
117
+ if (!pattern.test(address)) {
118
+ return 'not a valid bitcoin address';
119
+ }
120
+ }
121
+ return null;
122
+ };
123
+ validate_1.validators.isBitcoinAccount = function (accountIdentifier) {
124
+ if (accountIdentifier === null || typeof accountIdentifier === 'undefined') {
125
+ return null;
126
+ }
127
+ try {
128
+ var protocol = new BitcoinProtocol_1.BitcoinProtocol();
129
+ protocol.getAddressFromExtendedPublicKey(accountIdentifier, 0, 0);
130
+ return null;
131
+ }
132
+ catch (error) {
133
+ return 'not a valid Bitcoin account';
134
+ }
135
+ };
136
+ validate_1.validators.isValidBitcoinTxString = function (transaction) {
137
+ // allow empty values by default (needs to be checked by "presence" check)
138
+ if (transaction === null || typeof transaction === 'undefined') {
139
+ return null;
140
+ }
141
+ try {
142
+ var protocol = new BitcoinProtocol_1.BitcoinProtocol();
143
+ var bitcoinJSLib = protocol.options.config.bitcoinJSLib;
144
+ bitcoinJSLib.Transaction.fromHex(transaction);
145
+ return null;
146
+ }
147
+ catch (error) {
148
+ return 'is not a valid hex encoded Bitcoin transaction';
149
+ }
150
+ };
151
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/validators.ts"],"names":[],"mappings":";;;;;AAAA,iHAA0F;AAC1F,8FAA8F;AAC9F,kEAAgE;AAEhE,qBAAU,CAAC,mBAAmB,GAAG,UAAC,GAAY;IAC5C,6BAA6B;IAC7B,gBAAgB;IAChB,IAAI;IACJ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,cAAc,CAAA;KACtB;IAED,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,IAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;YACjC,OAAO,6BAA6B,CAAA;SACrC;aAAM;YACL,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;YAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,C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@@
1
+ import { TransactionSignResponse, TransactionSignResponseV2 } from '@airgap/serializer';
2
+ export interface SignedBitcoinSegwitTransaction extends TransactionSignResponse, TransactionSignResponseV2 {
3
+ transaction: string;
4
+ accountIdentifier: string;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=signed-transaction-bitcoin-segwit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-transaction-bitcoin-segwit.js","sourceRoot":"","sources":["../../../src/v0/types/signed-transaction-bitcoin-segwit.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { TransactionSignResponse, TransactionSignResponseV2 } from '@airgap/serializer';
2
+ export interface SignedBitcoinTransaction extends TransactionSignResponse, TransactionSignResponseV2 {
3
+ from: string[];
4
+ to: string[];
5
+ amount: string;
6
+ fee: string;
7
+ accountIdentifier: string;
8
+ transaction: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=signed-transaction-bitcoin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-transaction-bitcoin.js","sourceRoot":"","sources":["../../../src/v0/types/signed-transaction-bitcoin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ export interface IInTransaction {
2
+ txId: string;
3
+ value: string;
4
+ vout: number;
5
+ address: string;
6
+ derivationPath?: string;
7
+ }
8
+ export interface IOutTransaction {
9
+ recipient: string;
10
+ isChange: boolean;
11
+ value: string;
12
+ derivationPath?: string;
13
+ }
14
+ export interface RawBitcoinTransaction {
15
+ ins: IInTransaction[];
16
+ outs: IOutTransaction[];
17
+ }
18
+ export interface RawBitcoinSegwitTransaction {
19
+ psbt: string;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction-bitcoin.js.map
@@ -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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=unsigned-transaction-bitcoin-segwit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsigned-transaction-bitcoin-segwit.js","sourceRoot":"","sources":["../../../src/v0/types/unsigned-transaction-bitcoin-segwit.ts"],"names":[],"mappings":""}