@lombard.finance/ts-verifier 0.1.2 → 0.1.4

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/dist/api.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { NetworkParams } from "./bitcoin";
2
+ import { Address, BlockchainConfig } from "./chain-id";
3
+ export interface DepositMetadata {
4
+ to_address: string;
5
+ to_blockchain: string;
6
+ referral: string;
7
+ nonce?: number;
8
+ token_address?: string;
9
+ aux_version?: number;
10
+ }
11
+ export interface AddressInfo {
12
+ btc_address: string;
13
+ type: string;
14
+ deposit_metadata: DepositMetadata;
15
+ created_at: string;
16
+ deprecated: boolean;
17
+ }
18
+ export interface ApiResponse {
19
+ addresses: AddressInfo[];
20
+ }
21
+ export declare class APIError extends Error {
22
+ statusCode?: number | undefined;
23
+ constructor(message: string, statusCode?: number | undefined);
24
+ }
25
+ export interface AddressesResponse {
26
+ addresses: {
27
+ btcAddress: string;
28
+ toAddress: string;
29
+ referralId: string;
30
+ nonce: number;
31
+ auxVersion: number;
32
+ tokenAddress: Address;
33
+ }[];
34
+ }
35
+ export declare function fetchAddressMetadata(chainConfig: BlockchainConfig, toAddress: string, network: NetworkParams): Promise<AddressesResponse>;
36
+ export declare function trimHexPrefix(hex: string): string;
37
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,aAAa,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAa,MAAM,YAAY,CAAC;AASlE,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,eAAe,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,qBAAa,QAAS,SAAQ,KAAK;IAGxB,UAAU,CAAC,EAAE,MAAM;gBAD1B,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA;CAK7B;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,OAAO,CAAC;KACvB,EAAE,CAAC;CACL;AAGD,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,gBAAgB,EAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC,CA2D5B;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD"}
@@ -0,0 +1,2 @@
1
+ export declare function computeAuxData(nonce: number, referrerId: Buffer | Uint8Array, version: number): Buffer;
2
+ //# sourceMappingURL=aux-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aux-data.d.ts","sourceRoot":"","sources":["../src/aux-data.ts"],"names":[],"mappings":"AAsBA,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GAAG,UAAU,EAC/B,OAAO,EAAE,MAAM,GACd,MAAM,CAsBR"}
@@ -0,0 +1,28 @@
1
+ import * as bitcoin from "bitcoinjs-lib";
2
+ export interface NetworkParams {
3
+ messagePrefix: string;
4
+ bech32: string;
5
+ bip32: {
6
+ public: number;
7
+ private: number;
8
+ };
9
+ pubKeyHash: number;
10
+ scriptHash: number;
11
+ wif: number;
12
+ }
13
+ export declare const Networks: {
14
+ mainnet: bitcoin.networks.Network;
15
+ signet: NetworkParams;
16
+ };
17
+ export declare class BitcoinAddressError extends Error {
18
+ constructor(message: string);
19
+ }
20
+ /**
21
+ * Converts a public key to a segwit address
22
+ */
23
+ export declare function pubkeyToSegwitAddr(publicKey: Buffer, network: NetworkParams): string;
24
+ /**
25
+ * Helper function to create a SHA-256 hash
26
+ */
27
+ export declare function sha256(data: Buffer | Uint8Array): Buffer;
28
+ //# sourceMappingURL=bitcoin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../src/bitcoin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AAIzC,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AAGD,eAAO,MAAM,QAAQ;;YAYd,aAAa;CACnB,CAAC;AAGF,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,GACrB,MAAM,CAQR;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAExD"}
@@ -0,0 +1,51 @@
1
+ export type Address = Buffer;
2
+ export type LChainId = Buffer;
3
+ export declare enum Ecosystem {
4
+ EVM = "evm",
5
+ Sui = "sui",
6
+ Solana = "solana"
7
+ }
8
+ export declare enum SupportedBlockchains {
9
+ Ethereum = "ethereum",
10
+ Base = "base",
11
+ BSC = "bsc",
12
+ Sui = "sui",
13
+ Sonic = "sonic",
14
+ Ink = "ink",
15
+ Solana = "solana",
16
+ Katana = "katana"
17
+ }
18
+ export declare const mainnetBlockchainConfigs: Map<SupportedBlockchains, {
19
+ chainId: Buffer<ArrayBuffer>;
20
+ stlbtc: Buffer<ArrayBuffer>;
21
+ nativeLbtc: null;
22
+ name: string;
23
+ ecosystem: Ecosystem;
24
+ } | {
25
+ chainId: Buffer<ArrayBuffer>;
26
+ stlbtc: Buffer<ArrayBuffer>;
27
+ nativeLbtc: Buffer<ArrayBuffer>;
28
+ name: string;
29
+ ecosystem: Ecosystem;
30
+ }>;
31
+ export declare const gastaldBlockchainConfigs: Map<SupportedBlockchains, {
32
+ chainId: Buffer<ArrayBuffer>;
33
+ stlbtc: Buffer<ArrayBuffer>;
34
+ nativeLbtc: null;
35
+ name: string;
36
+ ecosystem: Ecosystem;
37
+ } | {
38
+ chainId: Buffer<ArrayBuffer>;
39
+ stlbtc: Buffer<ArrayBuffer>;
40
+ nativeLbtc: Buffer<ArrayBuffer>;
41
+ name: string;
42
+ ecosystem: Ecosystem;
43
+ }>;
44
+ export interface BlockchainConfig {
45
+ chainId: LChainId;
46
+ stlbtc: Address;
47
+ nativeLbtc: Address | null;
48
+ name: string;
49
+ ecosystem: Ecosystem;
50
+ }
51
+ //# sourceMappingURL=chain-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-id.d.ts","sourceRoot":"","sources":["../src/chain-id.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAG7B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAG9B,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,oBAAY,oBAAoB;IAC9B,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAGD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAwHnC,CAAC;AAGH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAwHnC,CAAC;AAGH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;CACtB"}
@@ -0,0 +1,59 @@
1
+ import { Address, Ecosystem, LChainId, SupportedBlockchains } from "./chain-id";
2
+ import { NetworkParams } from "./bitcoin";
3
+ export declare const MAINNET_PUBLIC_KEY: Buffer<ArrayBuffer>;
4
+ export declare const GASTALD_PUBLIC_KEY: Buffer<ArrayBuffer>;
5
+ export interface Config {
6
+ network: NetworkParams;
7
+ depositPublicKey: Buffer;
8
+ }
9
+ export interface AddressCalculationResult {
10
+ addresses: {
11
+ computed: string;
12
+ expected: string;
13
+ blockchain: string;
14
+ referralId: string;
15
+ nonce: number;
16
+ auxVersion: number;
17
+ tokenAddress: string;
18
+ }[];
19
+ }
20
+ /**
21
+ * DepositTweak Compute the tweak bytes for a deposit address.
22
+ *
23
+ * This is generally defined as
24
+ *
25
+ * taggedHash( AuxData || DeprecatedChainTag || LChainId || LBTCAddress || WalletAddress )
26
+ *
27
+ * where:
28
+ * - 'taggedHash' is a sha256 instance as returned by 'depositHasher()'
29
+ * - 'AuxData' is a 32-byte value encoding chain-agnostic auxiliary data
30
+ * - 'DeprecatedChainTag' is the zero byte previously used to differentiate among chains
31
+ * - 'LChainId' is a 32 bytes big-endian unique identifier of the chain, internally defined by Lombard
32
+ * - 'TokenAddress' and 'ToAddress' are byte arrays representing the respective addresses on the selected chain
33
+ */
34
+ export declare function depositTweak(tokenAddress: Buffer, toAddress: Buffer, chainId: Buffer | Uint8Array, auxData: Buffer | Uint8Array): Buffer;
35
+ /**
36
+ * Calculate tweak bytes for a given request
37
+ */
38
+ export declare function calcTweakBytes(blockchainType: Ecosystem, chainId: Uint8Array, toAddress: Address, tokenAddress: Address, auxData: Uint8Array | Buffer): Buffer;
39
+ /**
40
+ * Service class for calculating deterministic Bitcoin addresses
41
+ */
42
+ export declare class AddressService {
43
+ private tweaker;
44
+ private network;
45
+ constructor(config: Config);
46
+ /**
47
+ * Calculate a deterministic address based on inputs
48
+ */
49
+ calculateDeterministicAddress(version: number, chainId: LChainId, lbtcAddress: Address, toAddress: Address, referralId: Buffer | Uint8Array, nonce: number, blockchainType: Ecosystem): string;
50
+ }
51
+ /**
52
+ * Create a new address service from a configuration
53
+ */
54
+ export declare function createAddressService(config: Config): AddressService;
55
+ /**
56
+ * Main function for calculating a deterministic address
57
+ */
58
+ export declare function calculateDeterministicAddress(chain: SupportedBlockchains, toAddress: string, network?: NetworkParams): Promise<AddressCalculationResult>;
59
+ //# sourceMappingURL=deposit-address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit-address.d.ts","sourceRoot":"","sources":["../src/deposit-address.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAGL,aAAa,EAEd,MAAM,WAAW,CAAC;AAOnB,eAAO,MAAM,kBAAkB,qBAG9B,CAAC;AACF,eAAO,MAAM,kBAAkB,qBAG9B,CAAC;AAWF,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ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"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":""}