forked from Emurgo/react-native-cardano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
116 lines (95 loc) · 4.13 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
declare namespace RNCardano {
export type HexString = string;
export namespace HdWallet {
export type XPrv = HexString;
export type XPub = HexString;
// Generate an eXtended private key from the given entropy and the given password.
export function fromEnhancedEntropy(entropy: HexString, password: string): Promise<XPrv>;
// Create a private key from the given seed.
export function fromSeed(seed: HexString): Promise<XPrv>;
// Get a public key for the private one.
export function toPublic(xprv: XPrv): Promise<XPub>;
// Create a derived private key with an index.
export function derivePrivate(xprv: XPrv, index: number): Promise<XPrv>;
// Create a derived public key with an index.
export function derivePublic(xpub: XPub, index: number): Promise<XPub>;
// Sign the given message with the private key.
export function sign(xprv: XPrv, msg: HexString): Promise<HexString>;
}
export namespace Wallet {
export type WalletObj = {
root_cached_key: HdWallet.XPrv
derivation_scheme: string
selection_policy: string
config: {
protocol_magic: number
}
};
export type DaedalusWalletObj = WalletObj;
export type AccountObj = {
root_cached_key: HdWallet.XPrv
derivation_scheme: string
};
export type Address = string;
export type AddressType = "Internal" | "External";
export type SpendInputObj = {
ptr: { id: string; index: number }
value: OutputObj
addressing: { account: number, change: number, index: number }
};
export type MoveInputObj = {
ptr: { id: string; index: number }
value: string
addressing: [number, number]
};
export type OutputObj = {
address: string
value: string
};
export type TransactionObj = {
cbor_encoded_tx: HexString
change_used: boolean
fee: string
};
// Create a wallet object from the given seed.
export function fromMasterKey(xprv: HdWallet.XPrv): Promise<WalletObj>;
// Create a daedalus wallet object from the given seed.
export function fromDaedalusMnemonic(mnemonics: string): Promise<DaedalusWalletObj>;
// Create an account, for public key derivation (using bip44 model).
export function newAccount(wallet: WalletObj, account: number): Promise<AccountObj>;
// Generate addresses for the given wallet.
export function generateAddresses(
account: AccountObj, type: AddressType, indices: Array<number>
): Promise<Array<Address>>;
// Check if the given hexadecimal string is a valid Cardano Extended Address.
export function checkAddress(address: HexString): Promise<boolean>;
// Generate a ready to send, signed, transaction.
export function spend(
wallet: WalletObj, inputs: Array<SpendInputObj>, outputs: Array<OutputObj>, change_addr: Address
): Promise<TransactionObj>;
// Move all UTxO to a single address.
export function move(
wallet: DaedalusWalletObj, inputs: Array<MoveInputObj>, output: Address
): Promise<TransactionObj>;
}
export namespace RandomAddressChecker {
export type AddressCheckerObj = object;
// Create a random address checker, this will allow validating.
export function newChecker(xprv: HdWallet.XPrv): Promise<AddressCheckerObj>;
// Create a random address checker from daedalus mnemonics.
export function newCheckerFromMnemonics(mnemonics: string): Promise<AddressCheckerObj>;
// Check if the given addresses are valid.
export function checkAddresses(
checker: AddressCheckerObj, addresses: Array<Wallet.Address>
): Promise<Array<{ address: Wallet.Address, addressing: [number, number] }>>;
}
export namespace PasswordProtect {
// Encrypt the given data with the password, salt and nonce.
export function encryptWithPassword(
password: string, salt: HexString, nonce: HexString, data: HexString
): Promise<HexString>;
// Decrypt the given data with the password.
export function decryptWithPassword(password: string, data: HexString): Promise<HexString>;
}
}
export = RNCardano;