[create-xpub] Add types

This commit is contained in:
Dimitri Benin
2019-02-01 20:35:30 +01:00
parent de2477f5eb
commit 32e29fd830
4 changed files with 99 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import createXpub = require('create-xpub');
// $ExpectType string
createXpub({
depth: 3,
childNumber: 2147483648,
chainCode: '84cf7d9029cdd9fcadbb3717fd92ec0db7d7d9787c57c13c08fc887c389b566b',
publicKey:
'048bcdcf59f046b13f1eb35b608d1211265fde8cc44fc7a5a7f7107c5cf238095328a0e0d7be17c7d3e48490e8c6433af6d2c3dacc687f3fecaa98a3d05f17de97',
});
// $ExpectType string
createXpub({
networkVersion: createXpub.testnet,
depth: 3,
childNumber: 2147483648,
chainCode: '84cf7d9029cdd9fcadbb3717fd92ec0db7d7d9787c57c13c08fc887c389b566b',
publicKey:
'048bcdcf59f046b13f1eb35b608d1211265fde8cc44fc7a5a7f7107c5cf238095328a0e0d7be17c7d3e48490e8c6433af6d2c3dacc687f3fecaa98a3d05f17de97',
});
createXpub.mainnet; // $ExpectType 76067358
createXpub.testnet; // $ExpectType 70617039
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for create-xpub 2.1
// Project: https://github.com/lukechilds/create-xpub#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = createXpub;
/**
* Creates a Base58 encoded extended public key (xpub) for use in a
* [BIP32 hierarchical deterministic wallet](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).
*
* Tip: If you're working with ledgerjs you can pass the output of
* [`getWalletPublicKey()`](http://ledgerhq.github.io/ledgerjs/docs/#btcgetwalletpublickey) almost directly in.
*
* @returns A Base58 encoded extended public key.
*/
declare function createXpub(options: createXpub.Options): string;
declare namespace createXpub {
/**
* Mainnet (xpub) version bytes.
*/
const mainnet: 0x0488B21E;
/**
* Testnet (tpub) version bytes.
*/
const testnet: 0x043587CF;
interface Options {
/**
* Network version bytes.
* @default 0x0488B21E
*/
networkVersion?: number;
/**
* The depth of the derived key.
*/
depth: number;
/**
* The child number.
*/
childNumber: number;
/**
* The chain code.
*/
chainCode: string;
/**
* The public key in compressed or uncompressed form.
*/
publicKey: string;
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"create-xpub-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }