@airgap/bitcoin 0.13.7-beta.11
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/LICENSE.md +7 -0
- package/airgap-coinlib-bitcoin.min.js +87255 -0
- package/index.d.ts +14 -0
- package/index.js +22 -0
- package/index.js.map +1 -0
- package/package.json +64 -0
- package/protocol/BitcoinAddress.d.ts +9 -0
- package/protocol/BitcoinAddress.js +23 -0
- package/protocol/BitcoinAddress.js.map +1 -0
- package/protocol/BitcoinCryptoClient.d.ts +11 -0
- package/protocol/BitcoinCryptoClient.js +89 -0
- package/protocol/BitcoinCryptoClient.js.map +1 -0
- package/protocol/BitcoinProtocol.d.ts +165 -0
- package/protocol/BitcoinProtocol.js +1039 -0
- package/protocol/BitcoinProtocol.js.map +1 -0
- package/protocol/BitcoinProtocolOptions.d.ts +26 -0
- package/protocol/BitcoinProtocolOptions.js +142 -0
- package/protocol/BitcoinProtocolOptions.js.map +1 -0
- package/protocol/BitcoinSegwitAddress.d.ts +7 -0
- package/protocol/BitcoinSegwitAddress.js +39 -0
- package/protocol/BitcoinSegwitAddress.js.map +1 -0
- package/protocol/BitcoinSegwitProtocol.d.ts +28 -0
- package/protocol/BitcoinSegwitProtocol.js +530 -0
- package/protocol/BitcoinSegwitProtocol.js.map +1 -0
- package/protocol/BitcoinTestnetProtocol.d.ts +7 -0
- package/protocol/BitcoinTestnetProtocol.js +52 -0
- package/protocol/BitcoinTestnetProtocol.js.map +1 -0
- package/protocol/BitcoinTypes.d.ts +21 -0
- package/protocol/BitcoinTypes.js +3 -0
- package/protocol/BitcoinTypes.js.map +1 -0
- package/readme.md +121 -0
- package/types/signed-transaction-bitcoin-segwit.d.ts +5 -0
- package/types/signed-transaction-bitcoin-segwit.js +3 -0
- package/types/signed-transaction-bitcoin-segwit.js.map +1 -0
- package/types/signed-transaction-bitcoin.d.ts +9 -0
- package/types/signed-transaction-bitcoin.js +3 -0
- package/types/signed-transaction-bitcoin.js.map +1 -0
- package/types/transaction-bitcoin.d.ts +20 -0
- package/types/transaction-bitcoin.js +3 -0
- package/types/transaction-bitcoin.js.map +1 -0
- package/types/unsigned-transaction-bitcoin-segwit.d.ts +7 -0
- package/types/unsigned-transaction-bitcoin-segwit.js +3 -0
- package/types/unsigned-transaction-bitcoin-segwit.js.map +1 -0
- package/types/unsigned-transaction-bitcoin.d.ts +22 -0
- package/types/unsigned-transaction-bitcoin.js +3 -0
- package/types/unsigned-transaction-bitcoin.js.map +1 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BitcoinAddress } from './protocol/BitcoinAddress';
|
|
2
|
+
import { BitcoinCryptoClient } from './protocol/BitcoinCryptoClient';
|
|
3
|
+
import { BitcoinProtocol } from './protocol/BitcoinProtocol';
|
|
4
|
+
import { BitcoinProtocolConfig, BitcoinProtocolNetwork, BitcoinProtocolNetworkExtras, BitcoinProtocolOptions, BlockcypherBlockExplorer } from './protocol/BitcoinProtocolOptions';
|
|
5
|
+
import { BitcoinSegwitAddress } from './protocol/BitcoinSegwitAddress';
|
|
6
|
+
import { BitcoinSegwitProtocol } from './protocol/BitcoinSegwitProtocol';
|
|
7
|
+
import { BitcoinTestnetProtocol } from './protocol/BitcoinTestnetProtocol';
|
|
8
|
+
import { SignedBitcoinTransaction } from './types/signed-transaction-bitcoin';
|
|
9
|
+
import { SignedBitcoinSegwitTransaction } from './types/signed-transaction-bitcoin-segwit';
|
|
10
|
+
import { RawBitcoinSegwitTransaction, RawBitcoinTransaction } from './types/transaction-bitcoin';
|
|
11
|
+
import { UnsignedBitcoinTransaction } from './types/unsigned-transaction-bitcoin';
|
|
12
|
+
import { UnsignedBitcoinSegwitTransaction } from './types/unsigned-transaction-bitcoin-segwit';
|
|
13
|
+
export { BitcoinProtocol, BitcoinTestnetProtocol, BitcoinCryptoClient, BitcoinProtocolNetworkExtras, BlockcypherBlockExplorer, BitcoinProtocolNetwork, BitcoinProtocolConfig, BitcoinProtocolOptions, BitcoinAddress, RawBitcoinTransaction, UnsignedBitcoinTransaction, UnsignedBitcoinSegwitTransaction, SignedBitcoinTransaction, SignedBitcoinSegwitTransaction };
|
|
14
|
+
export { BitcoinSegwitProtocol, BitcoinSegwitAddress, RawBitcoinSegwitTransaction };
|
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinSegwitAddress = exports.BitcoinSegwitProtocol = exports.BitcoinAddress = exports.BitcoinProtocolOptions = exports.BitcoinProtocolConfig = exports.BitcoinProtocolNetwork = exports.BlockcypherBlockExplorer = exports.BitcoinProtocolNetworkExtras = exports.BitcoinCryptoClient = exports.BitcoinTestnetProtocol = exports.BitcoinProtocol = void 0;
|
|
4
|
+
var BitcoinAddress_1 = require("./protocol/BitcoinAddress");
|
|
5
|
+
Object.defineProperty(exports, "BitcoinAddress", { enumerable: true, get: function () { return BitcoinAddress_1.BitcoinAddress; } });
|
|
6
|
+
var BitcoinCryptoClient_1 = require("./protocol/BitcoinCryptoClient");
|
|
7
|
+
Object.defineProperty(exports, "BitcoinCryptoClient", { enumerable: true, get: function () { return BitcoinCryptoClient_1.BitcoinCryptoClient; } });
|
|
8
|
+
var BitcoinProtocol_1 = require("./protocol/BitcoinProtocol");
|
|
9
|
+
Object.defineProperty(exports, "BitcoinProtocol", { enumerable: true, get: function () { return BitcoinProtocol_1.BitcoinProtocol; } });
|
|
10
|
+
var BitcoinProtocolOptions_1 = require("./protocol/BitcoinProtocolOptions");
|
|
11
|
+
Object.defineProperty(exports, "BitcoinProtocolConfig", { enumerable: true, get: function () { return BitcoinProtocolOptions_1.BitcoinProtocolConfig; } });
|
|
12
|
+
Object.defineProperty(exports, "BitcoinProtocolNetwork", { enumerable: true, get: function () { return BitcoinProtocolOptions_1.BitcoinProtocolNetwork; } });
|
|
13
|
+
Object.defineProperty(exports, "BitcoinProtocolNetworkExtras", { enumerable: true, get: function () { return BitcoinProtocolOptions_1.BitcoinProtocolNetworkExtras; } });
|
|
14
|
+
Object.defineProperty(exports, "BitcoinProtocolOptions", { enumerable: true, get: function () { return BitcoinProtocolOptions_1.BitcoinProtocolOptions; } });
|
|
15
|
+
Object.defineProperty(exports, "BlockcypherBlockExplorer", { enumerable: true, get: function () { return BitcoinProtocolOptions_1.BlockcypherBlockExplorer; } });
|
|
16
|
+
var BitcoinSegwitAddress_1 = require("./protocol/BitcoinSegwitAddress");
|
|
17
|
+
Object.defineProperty(exports, "BitcoinSegwitAddress", { enumerable: true, get: function () { return BitcoinSegwitAddress_1.BitcoinSegwitAddress; } });
|
|
18
|
+
var BitcoinSegwitProtocol_1 = require("./protocol/BitcoinSegwitProtocol");
|
|
19
|
+
Object.defineProperty(exports, "BitcoinSegwitProtocol", { enumerable: true, get: function () { return BitcoinSegwitProtocol_1.BitcoinSegwitProtocol; } });
|
|
20
|
+
var BitcoinTestnetProtocol_1 = require("./protocol/BitcoinTestnetProtocol");
|
|
21
|
+
Object.defineProperty(exports, "BitcoinTestnetProtocol", { enumerable: true, get: function () { return BitcoinTestnetProtocol_1.BitcoinTestnetProtocol; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAA0D;AA4BxD,+FA5BO,+BAAc,OA4BP;AA3BhB,sEAAoE;AAqBlE,oGArBO,yCAAmB,OAqBP;AApBrB,8DAA4D;AAkB1D,gGAlBO,iCAAe,OAkBP;AAjBjB,4EAM0C;AAiBxC,sGAtBA,8CAAqB,OAsBA;AADrB,uGApBA,+CAAsB,OAoBA;AAFtB,6GAjBA,qDAA4B,OAiBA;AAI5B,uGApBA,+CAAsB,OAoBA;AAHtB,yGAhBA,iDAAwB,OAgBA;AAd1B,wEAAsE;AA2BtC,qGA3BvB,2CAAoB,OA2BuB;AA1BpD,0EAAwE;AA0B/D,sGA1BA,6CAAqB,OA0BA;AAzB9B,4EAA0E;AASxE,uGATO,+CAAsB,OASP"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@airgap/bitcoin",
|
|
3
|
+
"version": "0.13.7-beta.11",
|
|
4
|
+
"description": "The @airgap/bitcoin is a Bitcoin implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"airgap",
|
|
7
|
+
"blockchain",
|
|
8
|
+
"crypto",
|
|
9
|
+
"bitcoin"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://www.airgap.it",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/airgap-it/airgap-coin-lib"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js",
|
|
22
|
+
"build-scripts": "tsc scripts/*.ts",
|
|
23
|
+
"lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish --fix",
|
|
24
|
+
"lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
25
|
+
"lint-ci": "tslint -t json -o ../../lint-reports/bitcoin.json --project . || true",
|
|
26
|
+
"lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
|
|
27
|
+
"test": "nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
28
|
+
"test-ci": "nyc --reporter=lcov npm test",
|
|
29
|
+
"test-legacy": "npm run build && mocha --full-trace --timeout 40000 ./test/**/**.spec.js",
|
|
30
|
+
"browserify": "browserify ./dist/index.js -p realpathify -s airgapCoinLibBitcoin > ./dist/airgap-coinlib-bitcoin.min.js"
|
|
31
|
+
},
|
|
32
|
+
"author": "Papers GmbH <contact@papers.ch> (https://papers.ch)",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"bitcoinjs-lib": "5.2.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@airgap/coinlib-core": "^0.13.7-beta.0"
|
|
38
|
+
},
|
|
39
|
+
"localDependencies": {
|
|
40
|
+
"bitcoinjs-message": "2.1.1"
|
|
41
|
+
},
|
|
42
|
+
"nyc": {
|
|
43
|
+
"include": [
|
|
44
|
+
"src/**/*.ts"
|
|
45
|
+
],
|
|
46
|
+
"exclude": [
|
|
47
|
+
"test/**/*.spec.ts"
|
|
48
|
+
],
|
|
49
|
+
"extension": [
|
|
50
|
+
".ts"
|
|
51
|
+
],
|
|
52
|
+
"require": [
|
|
53
|
+
"ts-node/register"
|
|
54
|
+
],
|
|
55
|
+
"reporter": [
|
|
56
|
+
"text",
|
|
57
|
+
"text-summary"
|
|
58
|
+
],
|
|
59
|
+
"report-dir": "../../coverage/bitcoin",
|
|
60
|
+
"sourceMap": true,
|
|
61
|
+
"instrument": true
|
|
62
|
+
},
|
|
63
|
+
"gitHead": "8e8feb6788204501b7173aa825f5456c2a5f185b"
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAirGapAddress } from '@airgap/coinlib-core/interfaces/IAirGapAddress';
|
|
2
|
+
export declare class BitcoinAddress implements IAirGapAddress {
|
|
3
|
+
protected readonly value: string;
|
|
4
|
+
readonly visibilityDerivationIndex?: number | undefined;
|
|
5
|
+
readonly addressDerivationIndex?: number | undefined;
|
|
6
|
+
constructor(value: string, visibilityDerivationIndex?: number | undefined, addressDerivationIndex?: number | undefined);
|
|
7
|
+
static from(node: any, visibilityDerivationIndex?: number, addressDerivationIndex?: number): BitcoinAddress;
|
|
8
|
+
asString(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinAddress = void 0;
|
|
4
|
+
var BitcoinAddress = /** @class */ (function () {
|
|
5
|
+
// TODO: types
|
|
6
|
+
function BitcoinAddress(value, visibilityDerivationIndex, addressDerivationIndex) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
this.visibilityDerivationIndex = visibilityDerivationIndex;
|
|
9
|
+
this.addressDerivationIndex = addressDerivationIndex;
|
|
10
|
+
}
|
|
11
|
+
BitcoinAddress.from = function (node, visibilityDerivationIndex, addressDerivationIndex) {
|
|
12
|
+
var _node = visibilityDerivationIndex !== undefined && addressDerivationIndex !== undefined
|
|
13
|
+
? node.derive(visibilityDerivationIndex).derive(addressDerivationIndex)
|
|
14
|
+
: node;
|
|
15
|
+
return new BitcoinAddress(_node.getAddress(), visibilityDerivationIndex, addressDerivationIndex);
|
|
16
|
+
};
|
|
17
|
+
BitcoinAddress.prototype.asString = function () {
|
|
18
|
+
return this.value;
|
|
19
|
+
};
|
|
20
|
+
return BitcoinAddress;
|
|
21
|
+
}());
|
|
22
|
+
exports.BitcoinAddress = BitcoinAddress;
|
|
23
|
+
//# sourceMappingURL=BitcoinAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitcoinAddress.js","sourceRoot":"","sources":["../../src/protocol/BitcoinAddress.ts"],"names":[],"mappings":";;;AAEA;IACE,cAAc;IACd,wBACqB,KAAa,EAChB,yBAAkC,EAClC,sBAA+B;QAF5B,UAAK,GAAL,KAAK,CAAQ;QAChB,8BAAyB,GAAzB,yBAAyB,CAAS;QAClC,2BAAsB,GAAtB,sBAAsB,CAAS;IAC9C,CAAC;IAEU,mBAAI,GAAlB,UAAmB,IAAS,EAAE,yBAAkC,EAAE,sBAA+B;QAC/F,IAAM,KAAK,GACT,yBAAyB,KAAK,SAAS,IAAI,sBAAsB,KAAK,SAAS;YAC7E,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC;YACvE,CAAC,CAAC,IAAI,CAAA;QAEV,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,yBAAyB,EAAE,sBAAsB,CAAC,CAAA;IAClG,CAAC;IAEM,iCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IACH,qBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,wCAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ICoinProtocol } from '@airgap/coinlib-core';
|
|
2
|
+
import { Secp256k1CryptoClient } from '@airgap/coinlib-core/protocols/Secp256k1CryptoClient';
|
|
3
|
+
export declare class BitcoinCryptoClient extends Secp256k1CryptoClient {
|
|
4
|
+
private readonly protocol;
|
|
5
|
+
private readonly bitcoinJSMessage;
|
|
6
|
+
constructor(protocol: ICoinProtocol, bitcoinJSMessage: any);
|
|
7
|
+
signMessage(message: string, keypair: {
|
|
8
|
+
privateKey: string;
|
|
9
|
+
}): Promise<string>;
|
|
10
|
+
verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
+
function step(op) {
|
|
29
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
+
while (_) try {
|
|
31
|
+
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;
|
|
32
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
+
switch (op[0]) {
|
|
34
|
+
case 0: case 1: t = op; break;
|
|
35
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
+
default:
|
|
39
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
+
if (t[2]) _.ops.pop();
|
|
44
|
+
_.trys.pop(); continue;
|
|
45
|
+
}
|
|
46
|
+
op = body.call(thisArg, _);
|
|
47
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.BitcoinCryptoClient = void 0;
|
|
53
|
+
var Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
|
|
54
|
+
var BitcoinCryptoClient = /** @class */ (function (_super) {
|
|
55
|
+
__extends(BitcoinCryptoClient, _super);
|
|
56
|
+
function BitcoinCryptoClient(protocol, bitcoinJSMessage) {
|
|
57
|
+
var _this = _super.call(this) || this;
|
|
58
|
+
_this.protocol = protocol;
|
|
59
|
+
_this.bitcoinJSMessage = bitcoinJSMessage;
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
BitcoinCryptoClient.prototype.signMessage = function (message, keypair) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
var signature;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
signature = this.bitcoinJSMessage.sign(message, Buffer.from(keypair.privateKey, 'hex'), true);
|
|
67
|
+
return [2 /*return*/, signature.toString('base64')];
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
BitcoinCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var rawSignature, address;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
rawSignature = Buffer.from(signature, 'base64');
|
|
78
|
+
return [4 /*yield*/, this.protocol.getAddressFromPublicKey(publicKey)];
|
|
79
|
+
case 1:
|
|
80
|
+
address = _a.sent();
|
|
81
|
+
return [2 /*return*/, this.bitcoinJSMessage.verify(message, address.address, rawSignature)];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
return BitcoinCryptoClient;
|
|
87
|
+
}(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
|
|
88
|
+
exports.BitcoinCryptoClient = BitcoinCryptoClient;
|
|
89
|
+
//# sourceMappingURL=BitcoinCryptoClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitcoinCryptoClient.js","sourceRoot":"","sources":["../../src/protocol/BitcoinCryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8FAA4F;AAE5F;IAAyC,uCAAqB;IAC5D,6BAA6B,QAAuB,EAAmB,gBAAqB;QAA5F,YACE,iBAAO,SACR;QAF4B,cAAQ,GAAR,QAAQ,CAAe;QAAmB,sBAAgB,GAAhB,gBAAgB,CAAK;;IAE5F,CAAC;IAEY,yCAAW,GAAxB,UAAyB,OAAe,EAAE,OAA+B;;;;gBACjE,SAAS,GAAW,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;gBAE3G,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;wBAE7C,qBAAM,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAA;;wBAAhE,OAAO,GAAG,SAAsD;wBAEtE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,EAAA;;;;KAC5E;IACH,0BAAC;AAAD,CAAC,AAlBD,CAAyC,6CAAqB,GAkB7D;AAlBY,kDAAmB"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { UnsignedTransaction } from '@airgap/coinlib-core';
|
|
2
|
+
import { IAirGapSignedTransaction } from '@airgap/coinlib-core/interfaces/IAirGapSignedTransaction';
|
|
3
|
+
import { AirGapTransactionStatus, IAirGapTransaction } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
|
|
4
|
+
import { CurrencyUnit, FeeDefaults, ICoinProtocol } from '@airgap/coinlib-core/protocols/ICoinProtocol';
|
|
5
|
+
import { ICoinSubProtocol } from '@airgap/coinlib-core/protocols/ICoinSubProtocol';
|
|
6
|
+
import { ProtocolSymbols } from '@airgap/coinlib-core/utils/ProtocolSymbols';
|
|
7
|
+
import { SignedBitcoinTransaction } from '../types/signed-transaction-bitcoin';
|
|
8
|
+
import { RawBitcoinTransaction } from '../types/transaction-bitcoin';
|
|
9
|
+
import { BitcoinCryptoClient } from './BitcoinCryptoClient';
|
|
10
|
+
import { BitcoinProtocolOptions } from './BitcoinProtocolOptions';
|
|
11
|
+
import { BitcoinAddressCursor, BitcoinAddressResult, BitcoinBlockbookTransactionCursor, BitcoinBlockbookTransactionResult } from './BitcoinTypes';
|
|
12
|
+
export interface UTXOResponse {
|
|
13
|
+
txid: string;
|
|
14
|
+
vout: number;
|
|
15
|
+
value: string;
|
|
16
|
+
height: number;
|
|
17
|
+
confirmations: number;
|
|
18
|
+
address: string;
|
|
19
|
+
path: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Vin {
|
|
22
|
+
txid: string;
|
|
23
|
+
sequence: any;
|
|
24
|
+
n: number;
|
|
25
|
+
addresses: string[];
|
|
26
|
+
value: string;
|
|
27
|
+
hex: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Vout {
|
|
30
|
+
value: string;
|
|
31
|
+
n: number;
|
|
32
|
+
hex: string;
|
|
33
|
+
addresses: string[];
|
|
34
|
+
spent?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface Transaction {
|
|
37
|
+
txid: string;
|
|
38
|
+
version: number;
|
|
39
|
+
vin: Vin[];
|
|
40
|
+
vout: Vout[];
|
|
41
|
+
blockhash: string;
|
|
42
|
+
blockHeight: number;
|
|
43
|
+
confirmations: number;
|
|
44
|
+
blockTime: number;
|
|
45
|
+
value: string;
|
|
46
|
+
valueIn: string;
|
|
47
|
+
fees: string;
|
|
48
|
+
hex: string;
|
|
49
|
+
}
|
|
50
|
+
export interface Token {
|
|
51
|
+
type: string;
|
|
52
|
+
name: string;
|
|
53
|
+
path: string;
|
|
54
|
+
transfers: number;
|
|
55
|
+
decimals: number;
|
|
56
|
+
balance: string;
|
|
57
|
+
totalReceived: string;
|
|
58
|
+
totalSent: string;
|
|
59
|
+
}
|
|
60
|
+
export interface XPubResponse {
|
|
61
|
+
page: number;
|
|
62
|
+
totalPages: number;
|
|
63
|
+
itemsOnPage: number;
|
|
64
|
+
address: string;
|
|
65
|
+
balance: string;
|
|
66
|
+
totalReceived: string;
|
|
67
|
+
totalSent: string;
|
|
68
|
+
unconfirmedBalance: string;
|
|
69
|
+
unconfirmedTxs: number;
|
|
70
|
+
txs: number;
|
|
71
|
+
transactions?: Transaction[];
|
|
72
|
+
totalTokens?: number;
|
|
73
|
+
tokens?: Token[];
|
|
74
|
+
}
|
|
75
|
+
export interface AddressResponse {
|
|
76
|
+
page: number;
|
|
77
|
+
totalPages: number;
|
|
78
|
+
itemsOnPage: number;
|
|
79
|
+
address: string;
|
|
80
|
+
balance: string;
|
|
81
|
+
totalReceived: string;
|
|
82
|
+
totalSent: string;
|
|
83
|
+
unconfirmedBalance: string;
|
|
84
|
+
unconfirmedTxs: number;
|
|
85
|
+
txs: number;
|
|
86
|
+
transactions?: Transaction[];
|
|
87
|
+
}
|
|
88
|
+
export declare class BitcoinProtocol implements ICoinProtocol {
|
|
89
|
+
readonly options: BitcoinProtocolOptions;
|
|
90
|
+
symbol: string;
|
|
91
|
+
name: string;
|
|
92
|
+
marketSymbol: string;
|
|
93
|
+
feeSymbol: string;
|
|
94
|
+
feeDefaults: FeeDefaults;
|
|
95
|
+
decimals: number;
|
|
96
|
+
feeDecimals: number;
|
|
97
|
+
identifier: ProtocolSymbols;
|
|
98
|
+
units: CurrencyUnit[];
|
|
99
|
+
supportsHD: boolean;
|
|
100
|
+
standardDerivationPath: string;
|
|
101
|
+
addressIsCaseSensitive: boolean;
|
|
102
|
+
addressValidationPattern: string;
|
|
103
|
+
addressPlaceholder: string;
|
|
104
|
+
readonly cryptoClient: BitcoinCryptoClient;
|
|
105
|
+
constructor(options?: BitcoinProtocolOptions);
|
|
106
|
+
getSymbol(): Promise<string>;
|
|
107
|
+
getName(): Promise<string>;
|
|
108
|
+
getMarketSymbol(): Promise<string>;
|
|
109
|
+
getFeeSymbol(): Promise<string>;
|
|
110
|
+
getFeeDefaults(): Promise<FeeDefaults>;
|
|
111
|
+
getDecimals(): Promise<number>;
|
|
112
|
+
getFeeDecimals(): Promise<number>;
|
|
113
|
+
getIdentifier(): Promise<ProtocolSymbols>;
|
|
114
|
+
getUnits(): Promise<CurrencyUnit[]>;
|
|
115
|
+
getSupportsHD(): Promise<boolean>;
|
|
116
|
+
getStandardDerivationPath(): Promise<string>;
|
|
117
|
+
getAddressIsCaseSensitive(): Promise<boolean>;
|
|
118
|
+
getAddressValidationPattern(): Promise<string>;
|
|
119
|
+
getAddressPlaceholder(): Promise<string>;
|
|
120
|
+
getOptions(): Promise<BitcoinProtocolOptions>;
|
|
121
|
+
getBlockExplorerLinkForAddress(address: string): Promise<string>;
|
|
122
|
+
getBlockExplorerLinkForTxId(txId: string): Promise<string>;
|
|
123
|
+
getPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
124
|
+
getPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
125
|
+
getExtendedPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
126
|
+
getPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
127
|
+
getPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
128
|
+
getExtendedPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
129
|
+
getAddressFromPublicKey(publicKey: string, cursor?: BitcoinAddressCursor): Promise<BitcoinAddressResult>;
|
|
130
|
+
getAddressesFromPublicKey(publicKey: string, cursor?: BitcoinAddressCursor): Promise<BitcoinAddressResult[]>;
|
|
131
|
+
getAddressFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressDerivationIndex: number): Promise<BitcoinAddressResult>;
|
|
132
|
+
getAddressesFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressCount: number, offset: number): Promise<BitcoinAddressResult[]>;
|
|
133
|
+
signWithPrivateKey(privateKey: string, transaction: RawBitcoinTransaction): Promise<IAirGapSignedTransaction>;
|
|
134
|
+
signWithExtendedPrivateKey(extendedPrivateKey: string, transaction: RawBitcoinTransaction): Promise<string>;
|
|
135
|
+
getTransactionDetails(unsignedTx: UnsignedTransaction): Promise<IAirGapTransaction[]>;
|
|
136
|
+
getTransactionDetailsFromSigned(signedTx: SignedBitcoinTransaction): Promise<IAirGapTransaction[]>;
|
|
137
|
+
getBalanceOfAddresses(addresses: string[]): Promise<string>;
|
|
138
|
+
getBalanceOfPublicKey(publicKey: string): Promise<string>;
|
|
139
|
+
getBalanceOfExtendedPublicKey(extendedPublicKey: string, offset?: number): Promise<string>;
|
|
140
|
+
getBalanceOfPublicKeyForSubProtocols(publicKey: string, subProtocols: ICoinSubProtocol[]): Promise<string[]>;
|
|
141
|
+
getAvailableBalanceOfAddresses(addresses: string[]): Promise<string>;
|
|
142
|
+
estimateMaxTransactionValueFromExtendedPublicKey(extendedPublicKey: string, recipients: string[], fee?: string): Promise<string>;
|
|
143
|
+
estimateMaxTransactionValueFromPublicKey(publicKey: string, recipients: string[], fee?: string): Promise<string>;
|
|
144
|
+
estimateFeeDefaultsFromExtendedPublicKey(publicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
|
|
145
|
+
estimateFeeDefaultsFromPublicKey(publicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
|
|
146
|
+
prepareTransactionFromExtendedPublicKey(extendedPublicKey: string, offset: number, recipients: string[], values: string[], fee: string, extras: unknown): Promise<RawBitcoinTransaction>;
|
|
147
|
+
prepareTransactionFromPublicKey(publicKey: string, recipients: string[], values: string[], fee: string): Promise<RawBitcoinTransaction>;
|
|
148
|
+
broadcastTransaction(rawTransaction: string): Promise<string>;
|
|
149
|
+
getTransactionsFromExtendedPublicKey(extendedPublicKey: string, limit: number, cursor?: BitcoinBlockbookTransactionCursor, addressOffset?: number): Promise<BitcoinBlockbookTransactionResult>;
|
|
150
|
+
getTransactionsFromPublicKey(publicKey: string, limit: number, cursor?: BitcoinBlockbookTransactionCursor): Promise<BitcoinBlockbookTransactionResult>;
|
|
151
|
+
getTransactionsFromAddresses(addresses: string[], limit: number, cursor?: BitcoinBlockbookTransactionCursor): Promise<BitcoinBlockbookTransactionResult>;
|
|
152
|
+
private containsSome;
|
|
153
|
+
signMessage(message: string, keypair: {
|
|
154
|
+
privateKey: string;
|
|
155
|
+
}): Promise<string>;
|
|
156
|
+
verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
|
|
157
|
+
encryptAsymmetric(message: string, publicKey: string): Promise<string>;
|
|
158
|
+
decryptAsymmetric(message: string, keypair: {
|
|
159
|
+
publicKey: string;
|
|
160
|
+
privateKey: string;
|
|
161
|
+
}): Promise<string>;
|
|
162
|
+
encryptAES(message: string, privateKey: string): Promise<string>;
|
|
163
|
+
decryptAES(message: string, privateKey: string): Promise<string>;
|
|
164
|
+
getTransactionStatuses(transactionHashes: string[]): Promise<AirGapTransactionStatus[]>;
|
|
165
|
+
}
|