@sidhujag/sysweb3-keyring 2.1.2 → 2.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/CHANGELOG.md +6 -0
- package/README.md +55 -47
- package/cjs/current-vault-refusal.js +6 -0
- package/cjs/current-vault-refusal.js.map +1 -0
- package/cjs/evm-fees.js +29 -1
- package/cjs/evm-fees.js.map +1 -1
- package/cjs/hardware-transaction-authority.js +36 -0
- package/cjs/hardware-transaction-authority.js.map +1 -0
- package/cjs/index.js +5 -5
- package/cjs/index.js.map +1 -1
- package/cjs/keyring-core.js +466 -250
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-host.js +113 -0
- package/cjs/keyring-host.js.map +1 -0
- package/cjs/keyring-manager.js +15 -55
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/ledger/host-types.js.map +1 -1
- package/cjs/ledger/index.js +44 -19
- package/cjs/ledger/index.js.map +1 -1
- package/cjs/providers.js +3 -1
- package/cjs/providers.js.map +1 -1
- package/cjs/software.js +10 -43
- package/cjs/software.js.map +1 -1
- package/cjs/storage-core.js +44 -4
- package/cjs/storage-core.js.map +1 -1
- package/cjs/transactions/ethereum.js +358 -294
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-cancellation.js +43 -0
- package/cjs/transactions/evm-cancellation.js.map +1 -0
- package/cjs/transactions/evm-local-signer.js +15 -0
- package/cjs/transactions/evm-local-signer.js.map +1 -1
- package/cjs/transactions/evm-submission.js +61 -65
- package/cjs/transactions/evm-submission.js.map +1 -1
- package/cjs/transactions/hardware-psbt.js +11 -8
- package/cjs/transactions/hardware-psbt.js.map +1 -1
- package/cjs/transactions/index.js +10 -2
- package/cjs/transactions/index.js.map +1 -1
- package/cjs/transactions/prepared-evm.js +10 -7
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/cjs/transactions/syscoin-core.js +282 -202
- package/cjs/transactions/syscoin-core.js.map +1 -1
- package/cjs/trezor/connect.js +19 -2
- package/cjs/trezor/connect.js.map +1 -1
- package/cjs/trezor/index.js +38 -16
- package/cjs/trezor/index.js.map +1 -1
- package/cjs/types.js.map +1 -1
- package/cjs/utils/owned-blockbook-account.js +45 -0
- package/cjs/utils/owned-blockbook-account.js.map +1 -0
- package/esm/current-vault-refusal.js +3 -0
- package/esm/current-vault-refusal.js.map +1 -0
- package/esm/evm-fees.js +242 -0
- package/esm/evm-fees.js.map +1 -0
- package/esm/hardware-transaction-authority.js +33 -0
- package/esm/hardware-transaction-authority.js.map +1 -0
- package/esm/initial-state.js +102 -0
- package/esm/initial-state.js.map +1 -0
- package/esm/keyring-core.js +2781 -0
- package/esm/keyring-core.js.map +1 -0
- package/esm/keyring-host.js +108 -0
- package/esm/keyring-host.js.map +1 -0
- package/esm/ledger/dmk-host.js +31 -0
- package/esm/ledger/dmk-host.js.map +1 -0
- package/esm/ledger/dmk-selected-host.js +6 -0
- package/esm/ledger/dmk-selected-host.js.map +1 -0
- package/esm/ledger/dmk-session.js +154 -34
- package/esm/ledger/dmk-session.js.map +1 -1
- package/esm/ledger/dmk-utxo.js +9 -3
- package/esm/ledger/dmk-utxo.js.map +1 -1
- package/esm/ledger/host-types.js.map +1 -1
- package/esm/ledger/index.js +44 -19
- package/esm/ledger/index.js.map +1 -1
- package/esm/ledger-host.js +3 -27
- package/esm/ledger-host.js.map +1 -1
- package/esm/network-utils.js +70 -0
- package/esm/network-utils.js.map +1 -0
- package/esm/providers.js +3 -1
- package/esm/providers.js.map +1 -1
- package/esm/software-hd-account.js +20 -0
- package/esm/software-hd-account.js.map +1 -0
- package/esm/storage-core.js +258 -0
- package/esm/storage-core.js.map +1 -0
- package/esm/transactions/ethereum.js +2753 -0
- package/esm/transactions/ethereum.js.map +1 -0
- package/esm/transactions/evm-cancellation.js +40 -0
- package/esm/transactions/evm-cancellation.js.map +1 -0
- package/esm/transactions/evm-local-signer.js +202 -0
- package/esm/transactions/evm-local-signer.js.map +1 -0
- package/esm/transactions/evm-submission.js +187 -0
- package/esm/transactions/evm-submission.js.map +1 -0
- package/esm/transactions/prepared-evm.js +194 -0
- package/esm/transactions/prepared-evm.js.map +1 -0
- package/esm/transactions/syscoin-core.js +691 -0
- package/esm/transactions/syscoin-core.js.map +1 -0
- package/esm/trezor/connect.js +19 -2
- package/esm/trezor/connect.js.map +1 -1
- package/esm/trezor/index.js +38 -16
- package/esm/trezor/index.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/excluded-utxos.js +53 -0
- package/esm/utils/excluded-utxos.js.map +1 -0
- package/esm/utils/owned-blockbook-account.js +9 -0
- package/esm/utils/owned-blockbook-account.js.map +1 -0
- package/esm/utils/psbt.js +32 -0
- package/esm/utils/psbt.js.map +1 -0
- package/esm/utils/watch-descriptor.js +138 -0
- package/esm/utils/watch-descriptor.js.map +1 -0
- package/package.json +17 -11
- package/types/current-vault-refusal.d.ts +2 -0
- package/types/evm-fees.d.ts +25 -0
- package/types/hardware-transaction-authority.d.ts +5 -0
- package/types/index.d.ts +3 -3
- package/types/keyring-core.d.ts +48 -44
- package/types/keyring-host.d.ts +46 -0
- package/types/keyring-manager.d.ts +14 -7
- package/types/ledger/dmk-host.d.ts +7 -0
- package/types/ledger/dmk-selected-host.d.ts +7 -0
- package/types/ledger/dmk-session.d.ts +10 -2
- package/types/ledger/host-types.d.ts +4 -1
- package/types/ledger/index.d.ts +1 -1
- package/types/ledger/types.d.ts +3 -2
- package/types/ledger-host.d.ts +6 -2
- package/types/providers.d.ts +1 -1
- package/types/software.d.ts +7 -19
- package/types/storage-core.d.ts +3 -1
- package/types/transactions/ethereum.d.ts +14 -11
- package/types/transactions/evm-cancellation.d.ts +10 -0
- package/types/transactions/evm-local-signer.d.ts +2 -2
- package/types/transactions/evm-submission.d.ts +11 -4
- package/types/transactions/hardware-psbt.d.ts +1 -1
- package/types/transactions/index.d.ts +3 -2
- package/types/transactions/prepared-evm.d.ts +4 -1
- package/types/transactions/syscoin-core.d.ts +48 -21
- package/types/trezor/connect.d.ts +6 -3
- package/types/trezor/index.d.ts +4 -3
- package/types/types.d.ts +95 -63
- package/types/utils/owned-blockbook-account.d.ts +3 -0
- package/cjs/hardware-wallet-manager-singleton.js +0 -34
- package/cjs/hardware-wallet-manager-singleton.js.map +0 -1
- package/cjs/storage.js +0 -20
- package/cjs/storage.js.map +0 -1
- package/cjs/transactions/syscoin.js +0 -16
- package/cjs/transactions/syscoin.js.map +0 -1
- package/cjs/utils/blockbook-cache.js +0 -76
- package/cjs/utils/blockbook-cache.js.map +0 -1
- package/types/hardware-wallet-manager-singleton.d.ts +0 -19
- package/types/storage.d.ts +0 -5
- package/types/transactions/syscoin.d.ts +0 -9
- package/types/utils/blockbook-cache.d.ts +0 -6
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import ecc from '@bitcoinerlab/secp256k1';
|
|
2
|
+
import { findCoin, getNetworkConfig, INetworkType, } from '@sidhujag/sysweb3-network';
|
|
3
|
+
import { BIP32Factory } from 'bip32';
|
|
4
|
+
import bs58check from 'bs58check';
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
6
|
+
import { utils as syscoinUtils } from 'syscoinjs-lib';
|
|
7
|
+
const bip32 = BIP32Factory(ecc);
|
|
8
|
+
const bitcoin = syscoinUtils.bitcoinjs;
|
|
9
|
+
const invalid = () => {
|
|
10
|
+
throw new Error('Unsupported or invalid public watch-only descriptor');
|
|
11
|
+
};
|
|
12
|
+
const childIndex = (value) => {
|
|
13
|
+
if (!Number.isInteger(value) || value < 0 || value >= 0x80000000)
|
|
14
|
+
return invalid();
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
// Bitcoin Core's descriptor checksum, also used by Pali's public-input guard.
|
|
18
|
+
export const descriptorChecksum = (value) => {
|
|
19
|
+
const input = '0123456789()[],\'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#"\\ ';
|
|
20
|
+
const output = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';
|
|
21
|
+
const generators = [
|
|
22
|
+
'f5dee51989',
|
|
23
|
+
'a9fdca3312',
|
|
24
|
+
'1bab10e32d',
|
|
25
|
+
'3706b1677a',
|
|
26
|
+
'644d626ffd',
|
|
27
|
+
].map((hex) => BigInt(`0x${hex}`));
|
|
28
|
+
const poly = (current, next) => {
|
|
29
|
+
const top = current >> BigInt(35);
|
|
30
|
+
let result = ((current & BigInt('0x7ffffffff')) << BigInt(5)) ^ BigInt(next);
|
|
31
|
+
generators.forEach((generator, index) => {
|
|
32
|
+
if ((top & (BigInt(1) << BigInt(index))) !== BigInt(0))
|
|
33
|
+
result ^= generator;
|
|
34
|
+
});
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
let checksum = BigInt(1), group = 0, count = 0;
|
|
38
|
+
for (const character of value) {
|
|
39
|
+
const position = input.indexOf(character);
|
|
40
|
+
if (position < 0)
|
|
41
|
+
return '';
|
|
42
|
+
checksum = poly(checksum, position & 31);
|
|
43
|
+
group = group * 3 + (position >> 5);
|
|
44
|
+
if (++count === 3) {
|
|
45
|
+
checksum = poly(checksum, group);
|
|
46
|
+
group = count = 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (count)
|
|
50
|
+
checksum = poly(checksum, group);
|
|
51
|
+
for (let index = 0; index < 8; index++)
|
|
52
|
+
checksum = poly(checksum, 0);
|
|
53
|
+
checksum ^= BigInt(1);
|
|
54
|
+
return Array.from({ length: 8 }, (_, index) => output[Number((checksum >> BigInt(5 * (7 - index))) & BigInt(31))]).join('');
|
|
55
|
+
};
|
|
56
|
+
/** Derive only the single-key public descriptor forms supported by Blockbook. */
|
|
57
|
+
export const deriveDescriptorAddress = (descriptor, network, options) => {
|
|
58
|
+
if (typeof descriptor !== 'string' ||
|
|
59
|
+
!descriptor ||
|
|
60
|
+
descriptor.length > 16384 ||
|
|
61
|
+
/\s/.test(descriptor) ||
|
|
62
|
+
(options?.change !== undefined && typeof options.change !== 'boolean'))
|
|
63
|
+
return invalid();
|
|
64
|
+
const parts = descriptor.split('#');
|
|
65
|
+
if (parts.length > 2 ||
|
|
66
|
+
(parts.length === 2 && descriptorChecksum(parts[0]) !== parts[1]))
|
|
67
|
+
return invalid();
|
|
68
|
+
const simple = /^(pkh|wpkh|tr)\(([^()]*)\)$/.exec(parts[0]);
|
|
69
|
+
const wrapped = /^sh\(wpkh\(([^()]*)\)\)$/.exec(parts[0]);
|
|
70
|
+
if (!simple && !wrapped)
|
|
71
|
+
return invalid();
|
|
72
|
+
const type = simple?.[1] || 'sh(wpkh)';
|
|
73
|
+
const key = simple?.[2] || wrapped?.[1] || '';
|
|
74
|
+
const parsed = /^(?:\[([\da-fA-F]{8})\/(\d+)['h]\/(\d+)['h]?\/(\d+)['h]?\])?([1-9A-HJ-NP-Za-km-z]{100,112})(?:\/(\d+|\{\d+(?:,\d+)*\}|<\d+(?:;\d+)*>)\/\*)?$/.exec(key);
|
|
75
|
+
if (!parsed)
|
|
76
|
+
return invalid();
|
|
77
|
+
if (parsed[1])
|
|
78
|
+
parsed.slice(2, 5).forEach((value) => childIndex(Number(value)));
|
|
79
|
+
const branches = parsed[6]
|
|
80
|
+
? parsed[6]
|
|
81
|
+
.replace(/[{}<>]/g, '')
|
|
82
|
+
.split(/[,;]/)
|
|
83
|
+
.map((value) => childIndex(Number(value)))
|
|
84
|
+
: [0, 1];
|
|
85
|
+
if (branches.length > 10)
|
|
86
|
+
return invalid();
|
|
87
|
+
const branch = branches[options?.change ? 1 : 0];
|
|
88
|
+
if (branch === undefined)
|
|
89
|
+
return invalid();
|
|
90
|
+
const index = childIndex(options?.index === undefined ? 0 : options.index);
|
|
91
|
+
if (!network || network.kind !== INetworkType.Syscoin)
|
|
92
|
+
return invalid();
|
|
93
|
+
const coin = findCoin({
|
|
94
|
+
slip44: network.slip44,
|
|
95
|
+
name: network.currency,
|
|
96
|
+
exactMatch: true,
|
|
97
|
+
});
|
|
98
|
+
if (!coin ||
|
|
99
|
+
(type !== 'pkh' && coin.segwit !== true) ||
|
|
100
|
+
(type === 'tr' && coin.taproot !== true))
|
|
101
|
+
return invalid();
|
|
102
|
+
const config = getNetworkConfig(network.slip44, network.currency);
|
|
103
|
+
const addressNetwork = network.slip44 === 1 ? config.networks.testnet : config.networks.mainnet;
|
|
104
|
+
const payload = Buffer.from(bs58check.decode(parsed[5]));
|
|
105
|
+
if (payload.length !== 78 || ![2, 3].includes(payload[45]))
|
|
106
|
+
return invalid();
|
|
107
|
+
const root = bip32.fromBase58(parsed[5], {
|
|
108
|
+
...addressNetwork,
|
|
109
|
+
bip32: { public: payload.readUInt32BE(0), private: 0x0488ade4 },
|
|
110
|
+
});
|
|
111
|
+
if (!root.isNeutered())
|
|
112
|
+
return invalid();
|
|
113
|
+
const branchNode = root.derive(branch);
|
|
114
|
+
const addressNode = branchNode.derive(index);
|
|
115
|
+
// Do not let BIP32's invalid-child retry silently select a different path.
|
|
116
|
+
if (branchNode.index !== branch || addressNode.index !== index)
|
|
117
|
+
return invalid();
|
|
118
|
+
const pubkey = addressNode.publicKey;
|
|
119
|
+
const payment = type === 'pkh'
|
|
120
|
+
? bitcoin.payments.p2pkh({ pubkey, network: addressNetwork })
|
|
121
|
+
: type === 'wpkh'
|
|
122
|
+
? bitcoin.payments.p2wpkh({ pubkey, network: addressNetwork })
|
|
123
|
+
: type === 'tr'
|
|
124
|
+
? bitcoin.payments.p2tr({
|
|
125
|
+
internalPubkey: pubkey.slice(1),
|
|
126
|
+
network: addressNetwork,
|
|
127
|
+
})
|
|
128
|
+
: bitcoin.payments.p2sh({
|
|
129
|
+
redeem: bitcoin.payments.p2wpkh({ pubkey, network: addressNetwork }),
|
|
130
|
+
network: addressNetwork,
|
|
131
|
+
});
|
|
132
|
+
if (!payment.address ||
|
|
133
|
+
!payment.output ||
|
|
134
|
+
!Buffer.from(bitcoin.address.toOutputScript(payment.address, addressNetwork)).equals(Buffer.from(payment.output)))
|
|
135
|
+
return invalid();
|
|
136
|
+
return payment.address;
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=watch-descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-descriptor.js","sourceRoot":"","sources":["../../../src/utils/watch-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,yBAAyB,CAAC;AAC1C,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEhB,YAAY,GACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AAChC,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC;AACvC,MAAM,OAAO,GAAG,GAAU,EAAE;IAC1B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;AACzE,CAAC,CAAC;AACF,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,UAAU;QAC9D,OAAO,OAAO,EAAE,CAAC;IACnB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,MAAM,KAAK,GACT,mGAAmG,CAAC;IACtG,MAAM,MAAM,GAAG,kCAAkC,CAAC;IAClD,MAAM,UAAU,GAAG;QACjB,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACb,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,GA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;QAChB,CAAC,OAAO,CAAC,MAAM;QACf,CAAC,MAAM,CAAC,IAAI,CACV,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAChE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAErC,OAAO,OAAO,EAAE,CAAC;IACnB,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sidhujag/sysweb3-keyring",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Keyring Manager for UTXO and Web3 Wallets",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
"cjs/transactions/evm-submission.js": [
|
|
25
25
|
"types/transactions/evm-submission.d.ts"
|
|
26
26
|
],
|
|
27
|
+
"cjs/transactions/evm-cancellation": [
|
|
28
|
+
"types/transactions/evm-cancellation.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"cjs/transactions/evm-cancellation.js": [
|
|
31
|
+
"types/transactions/evm-cancellation.d.ts"
|
|
32
|
+
],
|
|
27
33
|
"cjs/transactions/ethereum": [
|
|
28
34
|
"types/transactions/ethereum.d.ts"
|
|
29
35
|
],
|
|
@@ -36,18 +42,18 @@
|
|
|
36
42
|
"cjs/software.js": [
|
|
37
43
|
"types/software.d.ts"
|
|
38
44
|
],
|
|
39
|
-
"cjs/keyring-core": [
|
|
40
|
-
"types/keyring-core.d.ts"
|
|
41
|
-
],
|
|
42
|
-
"cjs/keyring-core.js": [
|
|
43
|
-
"types/keyring-core.d.ts"
|
|
44
|
-
],
|
|
45
45
|
"esm/ledger-host": [
|
|
46
46
|
"types/ledger-host.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"esm/ledger-host.js": [
|
|
49
49
|
"types/ledger-host.d.ts"
|
|
50
50
|
],
|
|
51
|
+
"esm/ledger/dmk-selected-host": [
|
|
52
|
+
"types/ledger/dmk-selected-host.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"esm/ledger/dmk-selected-host.js": [
|
|
55
|
+
"types/ledger/dmk-selected-host.d.ts"
|
|
56
|
+
],
|
|
51
57
|
"cjs/ledger/host-types": [
|
|
52
58
|
"types/ledger/host-types.d.ts"
|
|
53
59
|
],
|
|
@@ -88,9 +94,9 @@
|
|
|
88
94
|
"@ledgerhq/device-signer-kit-ethereum": "1.18.2",
|
|
89
95
|
"@ledgerhq/device-transport-kit-web-hid": "1.2.4",
|
|
90
96
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
91
|
-
"@sidhujag/sysweb3-core": "
|
|
92
|
-
"@sidhujag/sysweb3-network": "
|
|
93
|
-
"@sidhujag/sysweb3-utils": "
|
|
97
|
+
"@sidhujag/sysweb3-core": "1.0.30",
|
|
98
|
+
"@sidhujag/sysweb3-network": "2.0.0",
|
|
99
|
+
"@sidhujag/sysweb3-utils": "1.1.281",
|
|
94
100
|
"@trezor/connect-webextension": "10.0.1",
|
|
95
101
|
"bip32": "^5.0.1",
|
|
96
102
|
"bip32-path": "^0.4.2",
|
|
@@ -104,7 +110,7 @@
|
|
|
104
110
|
"varuint-bitcoin": "^2.0.0"
|
|
105
111
|
},
|
|
106
112
|
"peerDependencies": {
|
|
107
|
-
"syscoinjs-lib": "^1.0.
|
|
113
|
+
"syscoinjs-lib": "^1.0.279"
|
|
108
114
|
},
|
|
109
115
|
"resolutions": {
|
|
110
116
|
"axios": "^1.18.1",
|
package/types/evm-fees.d.ts
CHANGED
|
@@ -35,6 +35,31 @@ export declare function parseEvmFeeQuantity(value: unknown, label?: string): big
|
|
|
35
35
|
* the configured minimum if larger. Callers retain chain/resource bounds.
|
|
36
36
|
*/
|
|
37
37
|
export declare function bufferedEvmGasLimit(estimate: bigint, minimum?: bigint): bigint;
|
|
38
|
+
export type EvmCancellationFeeInput = Readonly<{
|
|
39
|
+
type: 0;
|
|
40
|
+
currentGasPrice: bigint;
|
|
41
|
+
originalGasPrice?: bigint;
|
|
42
|
+
} | {
|
|
43
|
+
type: 2;
|
|
44
|
+
currentMaxFeePerGas: bigint;
|
|
45
|
+
currentMaxPriorityFeePerGas: bigint;
|
|
46
|
+
originalMaxFeePerGas?: bigint;
|
|
47
|
+
originalMaxPriorityFeePerGas?: bigint;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const EVM_CANCELLATION_GAS_LIMIT = 42000n;
|
|
50
|
+
/** Plan only the cancellation fees. The host validates the rates and envelope. */
|
|
51
|
+
export declare function planEvmCancellationFees(input: EvmCancellationFeeInput): Readonly<{
|
|
52
|
+
type: 0;
|
|
53
|
+
gasLimit: 42000n;
|
|
54
|
+
gasPrice: bigint;
|
|
55
|
+
maximumFee: bigint;
|
|
56
|
+
}> | Readonly<{
|
|
57
|
+
type: 2;
|
|
58
|
+
gasLimit: 42000n;
|
|
59
|
+
maxFeePerGas: bigint;
|
|
60
|
+
maxPriorityFeePerGas: bigint;
|
|
61
|
+
maximumFee: bigint;
|
|
62
|
+
}>;
|
|
38
63
|
/**
|
|
39
64
|
* No signer, transport, network registry or provider implementation is imported.
|
|
40
65
|
* Reads are serialized and guarded; RPC failures never become fabricated fees.
|
package/types/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * from './transactions';
|
|
2
2
|
export * from './types';
|
|
3
|
-
export
|
|
3
|
+
export { VaultAuthenticationError } from './storage-core';
|
|
4
4
|
export * from './signers';
|
|
5
5
|
export * from './initial-state';
|
|
6
6
|
export * from './keyring-manager';
|
|
7
|
+
export { createKeyringHost } from './keyring-host';
|
|
8
|
+
export type { KeyringHost, KeyringOptions } from './keyring-host';
|
|
7
9
|
export { MAX_PRIVATE_RECORD_BYTES, MAX_PRIVATE_RECORD_LABEL_BYTES, } from './private-records';
|
|
8
10
|
export type { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams, } from './private-records';
|
|
9
11
|
export * from './providers';
|
|
10
12
|
export * from './utils/derivation-paths';
|
|
11
13
|
export * from './network-utils';
|
|
12
14
|
export * from './hardware-wallet-manager';
|
|
13
|
-
export * from './hardware-wallet-manager-singleton';
|
|
14
15
|
export { PsbtUtils } from './utils/psbt';
|
|
15
|
-
export { invalidateBlockbookAccountCache } from './utils/blockbook-cache';
|
|
16
16
|
export { deriveDescriptorAddress, descriptorChecksum, } from './utils/watch-descriptor';
|
package/types/keyring-core.d.ts
CHANGED
|
@@ -2,20 +2,43 @@ import { INetwork, INetworkType } from '@sidhujag/sysweb3-network';
|
|
|
2
2
|
import { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
|
|
3
3
|
import { SyscoinHDSigner } from './signers';
|
|
4
4
|
import { type ISyscoinHardwareSigners } from './transactions/syscoin-core';
|
|
5
|
-
import { IKeyringAccountState, ICreateSmartAccountParams, ISyscoinTransactions, KeyringAccountType, IEthereumTransactions } from './types';
|
|
5
|
+
import { IKeyringAccountState, ICreateSmartAccountParams, ISyscoinTransactions, KeyringAccountType, IEthereumTransactions, type SyscoinOwnedReadOptions } from './types';
|
|
6
|
+
import type { KeyringHostBinding } from './keyring-host';
|
|
6
7
|
import type { LedgerKeyring } from './ledger';
|
|
7
8
|
import type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest } from './software-hd-account';
|
|
8
|
-
import type {
|
|
9
|
-
import type { CaptureEvmSubmission } from './transactions/evm-submission';
|
|
9
|
+
import type { VaultStoragePort } from './storage-core';
|
|
10
10
|
import type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction } from './transactions/prepared-evm';
|
|
11
11
|
import type { TrezorKeyring } from './trezor';
|
|
12
12
|
/** Explicit asynchronous host storage; no browser or global DI fallback. */
|
|
13
13
|
export interface KeyringStoragePort extends VaultStoragePort {
|
|
14
14
|
get(key: string): Promise<any>;
|
|
15
15
|
deleteItem(key: string): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/** Atomically read this authority's current encrypted vault and salt. */
|
|
17
|
+
readDeviceUnlockVaultPair?(): Promise<DeviceUnlockVaultPair | null>;
|
|
18
18
|
}
|
|
19
|
+
export type DeviceUnlockVaultPair = Readonly<{
|
|
20
|
+
vault: string;
|
|
21
|
+
keys: unknown;
|
|
22
|
+
pairFingerprint: string;
|
|
23
|
+
}>;
|
|
24
|
+
export type DeviceUnlockCredential = Readonly<{
|
|
25
|
+
pairFingerprint: string;
|
|
26
|
+
key: Uint8Array;
|
|
27
|
+
}>;
|
|
28
|
+
/** Only a trusted software host may supply this protected credential I/O. */
|
|
29
|
+
export type DeviceUnlockPort = Readonly<{
|
|
30
|
+
/** Transfer ownership of the returned key bytes to the SDK. */
|
|
31
|
+
readCredential(pairFingerprint: string): Promise<DeviceUnlockCredential | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Consume the bytes and check the guard before saving. The SDK clears the
|
|
34
|
+
* bytes on settlement. Publish enrollment only after issue returns true.
|
|
35
|
+
*/
|
|
36
|
+
writeCredential(credential: DeviceUnlockCredential, assertCurrent: () => void): Promise<void>;
|
|
37
|
+
}>;
|
|
38
|
+
export type DeviceUnlockControls = Readonly<{
|
|
39
|
+
issue(password: string, assertCurrent: () => void): Promise<boolean>;
|
|
40
|
+
resume(assertCurrent: () => void): Promise<boolean>;
|
|
41
|
+
}>;
|
|
19
42
|
/** Only the device capabilities consumed by the wallet authority. */
|
|
20
43
|
export interface KeyringLedgerSigner {
|
|
21
44
|
destroy: LedgerKeyring['destroy'];
|
|
@@ -24,18 +47,10 @@ export interface KeyringLedgerSigner {
|
|
|
24
47
|
verifyUtxoAddress: LedgerKeyring['verifyUtxoAddress'];
|
|
25
48
|
}
|
|
26
49
|
export type KeyringTrezorSigner = Pick<TrezorKeyring, 'destroy' | 'getAccountInfo' | 'getPublicKey' | 'signTypedData' | 'signMessage' | 'signEthTransaction' | 'verifyUtxoAddress'>;
|
|
27
|
-
|
|
28
|
-
/** Immutable identity shared only by keyrings in the same wallet authority. */
|
|
29
|
-
authority: object;
|
|
30
|
-
storage: KeyringStoragePort;
|
|
31
|
-
/** Must be bound to this authority's storage and shared across its keyrings. */
|
|
32
|
-
vaultPersistence: VaultPersistence;
|
|
50
|
+
interface KeyringHardware<TLedger extends KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined> {
|
|
33
51
|
ledgerSigner: TLedger;
|
|
34
52
|
trezorSigner: TTrezor;
|
|
35
|
-
/** Trusted host adapters; absent device capabilities fail closed. */
|
|
36
53
|
syscoinHardwareSigners?: ISyscoinHardwareSigners;
|
|
37
|
-
/** Trusted host lifecycle, captured before each locally signed EVM submission. */
|
|
38
|
-
captureEvmSubmission?: CaptureEvmSubmission;
|
|
39
54
|
}
|
|
40
55
|
export interface ISysAccount {
|
|
41
56
|
address: string;
|
|
@@ -43,20 +58,8 @@ export interface ISysAccount {
|
|
|
43
58
|
xprv?: string;
|
|
44
59
|
xpub: string;
|
|
45
60
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Secure Buffer implementation for sensitive data
|
|
48
|
-
* Provides explicit memory clearing capability
|
|
49
|
-
*/
|
|
50
|
-
declare class SecureBuffer {
|
|
51
|
-
private buffer;
|
|
52
|
-
private _isCleared;
|
|
53
|
-
constructor(data: string | Buffer);
|
|
54
|
-
get(): Buffer;
|
|
55
|
-
toString(): string;
|
|
56
|
-
clear(): void;
|
|
57
|
-
isCleared(): boolean;
|
|
58
|
-
}
|
|
59
61
|
export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined = KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined = KeyringTrezorSigner | undefined> {
|
|
62
|
+
#private;
|
|
60
63
|
trezorSigner: TTrezor;
|
|
61
64
|
ledgerSigner: TLedger;
|
|
62
65
|
initialTrezorAccountState: IKeyringAccountState;
|
|
@@ -76,19 +79,15 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
|
|
|
76
79
|
private sessionPassword;
|
|
77
80
|
private sessionMnemonic;
|
|
78
81
|
private privateRecordSessionRevision;
|
|
79
|
-
constructor(
|
|
82
|
+
constructor(binding: KeyringHostBinding, hardware: KeyringHardware<TLedger, TTrezor>);
|
|
80
83
|
private createSyscoinTransactions;
|
|
81
84
|
private requireLedgerSigner;
|
|
82
85
|
private requireTrezorSigner;
|
|
83
86
|
initialize(seed: string, password: string, network?: INetwork): Promise<IKeyringAccountState>;
|
|
84
|
-
setStorage: (client: any) => void;
|
|
85
87
|
validateAccountType: (account: IKeyringAccountState) => KeyringAccountType.HDAccount | KeyringAccountType.Imported;
|
|
86
88
|
isUnlocked: () => boolean;
|
|
87
89
|
lockWallet: () => Promise<void>;
|
|
88
|
-
transferSessionTo: (targetKeyring:
|
|
89
|
-
private acceptSessionFrom;
|
|
90
|
-
receiveSessionOwnership: (sessionPassword: SecureBuffer, sessionMnemonic: SecureBuffer) => void;
|
|
91
|
-
private replaceSessionBuffers;
|
|
90
|
+
transferSessionTo: (targetKeyring: KeyringCore) => void;
|
|
92
91
|
addNewAccount: (label?: string) => Promise<IKeyringAccountState>;
|
|
93
92
|
createSmartAccount: ({ address, deriveAccount, label, metadata, }: ICreateSmartAccountParams) => Promise<IKeyringAccountState>;
|
|
94
93
|
/**
|
|
@@ -100,11 +99,14 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
|
|
|
100
99
|
canLogin: boolean;
|
|
101
100
|
needsAccountCreation?: boolean;
|
|
102
101
|
}>;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
private getActiveUtxoAddressAccount;
|
|
103
|
+
getNewChangeAddress: (ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
104
|
+
getChangeAddress: (id: number, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
105
|
+
getPubkey: (id: number, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
106
|
+
getBip32Path: (id: number, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
107
|
+
updateReceivingAddress: (ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
108
|
+
private getAddressForUtxoAccount;
|
|
109
|
+
private assertUtxoDerivationAvailable;
|
|
108
110
|
getAccountById: (id: number, accountType: KeyringAccountType) => Omit<IKeyringAccountState, "xprv">;
|
|
109
111
|
getPrivateKeyByAccountId: (id: number, accountType: KeyringAccountType, pwd: string) => Promise<string>;
|
|
110
112
|
getActiveAccount: () => {
|
|
@@ -145,12 +147,15 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
|
|
|
145
147
|
getActiveUTXOAccountState: () => any;
|
|
146
148
|
getNetwork: () => any;
|
|
147
149
|
createEthAccount: (privateKey: string) => import("./transactions/evm-local-signer").EvmLocalAccount;
|
|
150
|
+
private loadBip84AddressAccount;
|
|
151
|
+
private deriveFirstUtxoAddress;
|
|
148
152
|
private fetchCurrentAccountData;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
getCurrentAddressPubkey: (xpub: string, isChangeAddress: boolean) => Promise<string>;
|
|
153
|
-
|
|
153
|
+
private discoverUtxoAddress;
|
|
154
|
+
getAddress: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
155
|
+
private getAddressPubkey;
|
|
156
|
+
getCurrentAddressPubkey: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
157
|
+
private getAddressBip32Path;
|
|
158
|
+
getCurrentAddressBip32Path: (xpub: string, isChangeAddress: boolean, ownedRead: SyscoinOwnedReadOptions) => Promise<string>;
|
|
154
159
|
logout: () => void;
|
|
155
160
|
importAccount(privKey: string, label?: string, options?: {
|
|
156
161
|
utxoAddressType?: 'p2wpkh' | 'p2pkh' | 'p2tr';
|
|
@@ -228,7 +233,6 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
|
|
|
228
233
|
private setDerivedWeb3Accounts;
|
|
229
234
|
private setSignerEVM;
|
|
230
235
|
private clearTemporaryLocalKeys;
|
|
231
|
-
private recreateSessionFromVault;
|
|
232
236
|
private _getPrivateKeyAccountInfos;
|
|
233
237
|
/**
|
|
234
238
|
* Common method to decrypt mnemonic from session
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { DeviceUnlockControls, DeviceUnlockPort, KeyringStoragePort } from './keyring-core';
|
|
2
|
+
import type { VaultPersistence } from './storage-core';
|
|
3
|
+
import type { CaptureEvmSubmission } from './transactions/evm-submission';
|
|
4
|
+
declare const keyringHostBrand: unique symbol;
|
|
5
|
+
/** Opaque identity for one fixed wallet store and its unlock session. */
|
|
6
|
+
export interface KeyringHost {
|
|
7
|
+
readonly [keyringHostBrand]: true;
|
|
8
|
+
}
|
|
9
|
+
export type SessionOwner = {
|
|
10
|
+
current?: symbol;
|
|
11
|
+
epoch: number;
|
|
12
|
+
};
|
|
13
|
+
type BoundHost = {
|
|
14
|
+
storage: KeyringStoragePort;
|
|
15
|
+
vaultPersistence: VaultPersistence;
|
|
16
|
+
sessionOwner: SessionOwner;
|
|
17
|
+
deviceUnlockPort?: DeviceUnlockPort;
|
|
18
|
+
};
|
|
19
|
+
export declare function createKeyringHost(storage: KeyringStoragePort, options?: {
|
|
20
|
+
deviceUnlock?: DeviceUnlockPort;
|
|
21
|
+
}): KeyringHost;
|
|
22
|
+
export type KeyringOptions = {
|
|
23
|
+
captureEvmSubmission: CaptureEvmSubmission | null;
|
|
24
|
+
receiveDeviceUnlock?(controls: DeviceUnlockControls): void;
|
|
25
|
+
};
|
|
26
|
+
declare const bindingBrand: unique symbol;
|
|
27
|
+
export interface KeyringHostBinding {
|
|
28
|
+
readonly [bindingBrand]: true;
|
|
29
|
+
}
|
|
30
|
+
type PreparedHost = Omit<BoundHost, 'deviceUnlockPort'> & {
|
|
31
|
+
authority: KeyringHost;
|
|
32
|
+
captureEvmSubmission: CaptureEvmSubmission | null;
|
|
33
|
+
deviceUnlock?: {
|
|
34
|
+
port: DeviceUnlockPort;
|
|
35
|
+
receive(controls: DeviceUnlockControls): void;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare function takeKeyringHostBinding(binding: KeyringHostBinding): PreparedHost;
|
|
39
|
+
export declare function prepareKeyringHost(host: KeyringHost, options: KeyringOptions): {
|
|
40
|
+
binding: KeyringHostBinding;
|
|
41
|
+
publishControls?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
binding: KeyringHostBinding;
|
|
44
|
+
publishControls(): void;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -2,16 +2,23 @@ import { HardwareWalletManager } from './hardware-wallet-manager';
|
|
|
2
2
|
import { KeyringCore } from './keyring-core';
|
|
3
3
|
import { LedgerKeyring } from './ledger';
|
|
4
4
|
import { TrezorKeyring } from './trezor';
|
|
5
|
+
import type { KeyringHost, KeyringOptions } from './keyring-host';
|
|
5
6
|
import type { LedgerHost } from './ledger/host-types';
|
|
6
7
|
import type { CaptureEvmSubmission } from './transactions/evm-submission';
|
|
7
8
|
import type { IKeyringManager } from './types';
|
|
8
9
|
export type { ISysAccount } from './keyring-core';
|
|
9
|
-
|
|
10
|
+
export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
|
|
11
|
+
export type KeyringManagerOptions = Omit<KeyringOptions, 'captureEvmSubmission'> & {
|
|
12
|
+
captureEvmSubmission: CaptureEvmSubmission;
|
|
13
|
+
} & ({
|
|
14
|
+
ledgerHost: LedgerHost;
|
|
15
|
+
hardwareManager?: never;
|
|
16
|
+
} | {
|
|
17
|
+
ledgerHost?: never;
|
|
18
|
+
hardwareManager: HardwareWalletManager;
|
|
19
|
+
});
|
|
20
|
+
/** Browser keyring with an explicit wallet authority and hardware adapter. */
|
|
10
21
|
export declare class KeyringManager extends KeyringCore<LedgerKeyring, TrezorKeyring> implements IKeyringManager {
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
static createInitialized(seed: string, password: string, vaultStateGetter: () => any, options?: {
|
|
15
|
-
captureEvmSubmission?: CaptureEvmSubmission;
|
|
16
|
-
}): Promise<KeyringManager>;
|
|
22
|
+
constructor(host: KeyringHost, options: KeyringManagerOptions);
|
|
23
|
+
static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringManagerOptions): Promise<KeyringManager>;
|
|
17
24
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LedgerEvmConfig, type LedgerHost } from './host-types';
|
|
2
|
+
export interface LedgerDmkHost extends LedgerHost {
|
|
3
|
+
/** Start before enumerating. The returned capability is single use. */
|
|
4
|
+
beginDeviceSelection(signal?: AbortSignal): (candidate: object) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/** Shared implementation; the default browser host supplies its own transport. */
|
|
7
|
+
export declare function createLedgerHostForDmk(candidate: object, config: LedgerEvmConfig, requireDeviceSelection?: boolean): LedgerDmkHost;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LedgerDmkHost } from './dmk-host';
|
|
2
|
+
import type { LedgerEvmConfig } from './host-types';
|
|
3
|
+
/** A platform-owned transport and explicit user selection are required. */
|
|
4
|
+
export declare function createSelectedLedgerDmkHost(config: LedgerEvmConfig & {
|
|
5
|
+
dmk: object;
|
|
6
|
+
}): LedgerDmkHost;
|
|
7
|
+
export type { LedgerDmkHost } from './dmk-host';
|
|
@@ -30,8 +30,9 @@ export interface LedgerDmkOperation {
|
|
|
30
30
|
/** One owner and one semantic operation at a time, across EVM and UTXO apps. */
|
|
31
31
|
export declare class LedgerDmkSession {
|
|
32
32
|
readonly dmk: DeviceManagementKit;
|
|
33
|
+
private requireDeviceSelection;
|
|
33
34
|
private generation;
|
|
34
|
-
private
|
|
35
|
+
private connection;
|
|
35
36
|
private queue;
|
|
36
37
|
private activeCancel;
|
|
37
38
|
private activeAbort;
|
|
@@ -39,17 +40,24 @@ export declare class LedgerDmkSession {
|
|
|
39
40
|
private stateSubscription;
|
|
40
41
|
private connectionAttempt;
|
|
41
42
|
private connectionAbort;
|
|
43
|
+
private deviceSelection;
|
|
42
44
|
private readonly invalidationListeners;
|
|
43
|
-
constructor(dmk: DeviceManagementKit);
|
|
45
|
+
constructor(dmk: DeviceManagementKit, requireDeviceSelection?: boolean);
|
|
46
|
+
private get readyConnection();
|
|
44
47
|
getStatus(): {
|
|
45
48
|
connected: boolean;
|
|
46
49
|
};
|
|
47
50
|
onInvalidated(listener: () => void): () => void;
|
|
48
51
|
private invalidate;
|
|
52
|
+
/** The platform passes one candidate from its own current DMK picker. */
|
|
53
|
+
beginDeviceSelection(signal?: AbortSignal): (candidate: object) => Promise<void>;
|
|
49
54
|
/** Device selection belongs to the visible host, never to a dapp request. */
|
|
50
55
|
connect(request?: {
|
|
51
56
|
useGrantedDevices?: boolean;
|
|
52
57
|
}, options?: LedgerOperationOptions): Promise<void>;
|
|
58
|
+
private connectionBusy;
|
|
59
|
+
private startConnection;
|
|
60
|
+
private discoverDevice;
|
|
53
61
|
private connectDevice;
|
|
54
62
|
/** Cancel revokes the result and closes I/O; it cannot undo on-device approval. */
|
|
55
63
|
disconnect(): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
1
2
|
/** Serializable Ledger requests. This module must remain free of device SDK imports. */
|
|
2
3
|
export interface LedgerProgress {
|
|
3
4
|
status: 'not-started' | 'pending' | 'stopped' | 'completed' | 'error';
|
|
@@ -5,9 +6,11 @@ export interface LedgerProgress {
|
|
|
5
6
|
step?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface LedgerOperationOptions {
|
|
9
|
+
assertCurrent?: () => void;
|
|
8
10
|
signal?: AbortSignal;
|
|
9
11
|
onProgress?: (progress: LedgerProgress) => void;
|
|
10
12
|
}
|
|
13
|
+
export type LedgerPsbtAuthority = HardwareTransactionAuthority & Pick<LedgerOperationOptions, 'onProgress'>;
|
|
11
14
|
export interface LedgerUtxoAccount {
|
|
12
15
|
currency: string;
|
|
13
16
|
slip44: number;
|
|
@@ -106,7 +109,7 @@ export interface LedgerUtxoHost {
|
|
|
106
109
|
signPsbt(request: LedgerUtxoAccount & {
|
|
107
110
|
psbtBase64: string;
|
|
108
111
|
accountXpub: string;
|
|
109
|
-
},
|
|
112
|
+
}, authority: LedgerPsbtAuthority): Promise<{
|
|
110
113
|
fingerprint: string;
|
|
111
114
|
signatures: LedgerPartialSignature[];
|
|
112
115
|
}>;
|
package/types/ledger/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class LedgerKeyring {
|
|
|
15
15
|
ensureConnection: () => Promise<void>;
|
|
16
16
|
verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string>;
|
|
17
17
|
signUtxoMessage: (request: Parameters<LedgerUtxoHost["signMessage"]>[0]) => Promise<string>;
|
|
18
|
-
signPsbt: (request: Parameters<LedgerUtxoHost["signPsbt"]>[0]) => ReturnType<LedgerUtxoHost["signPsbt"]>;
|
|
18
|
+
signPsbt: (request: Parameters<LedgerUtxoHost["signPsbt"]>[0], authority: Parameters<LedgerUtxoHost["signPsbt"]>[1]) => ReturnType<LedgerUtxoHost["signPsbt"]>;
|
|
19
19
|
getStatus(): {
|
|
20
20
|
type: HardwareWalletType;
|
|
21
21
|
connected: boolean;
|
package/types/ledger/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SignTypedDataVersion } from '@metamask/eth-sig-util';
|
|
2
|
+
import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
2
3
|
export interface IUTXOMethods {
|
|
3
4
|
getUtxoAddress: ({ coin, index, slip44, }: {
|
|
4
5
|
coin: string;
|
|
@@ -27,11 +28,11 @@ export interface IEvmMethods {
|
|
|
27
28
|
address: string;
|
|
28
29
|
publicKey: string;
|
|
29
30
|
}>;
|
|
30
|
-
signEVMTransaction: (
|
|
31
|
+
signEVMTransaction: (request: {
|
|
31
32
|
accountIndex: number;
|
|
32
33
|
rawTx: string;
|
|
33
34
|
expectedAddress: string;
|
|
34
|
-
}) => Promise<{
|
|
35
|
+
}, authority: HardwareTransactionAuthority) => Promise<{
|
|
35
36
|
r: string;
|
|
36
37
|
s: string;
|
|
37
38
|
v: string;
|
package/types/ledger-host.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type LedgerDmkHost } from './ledger/dmk-host';
|
|
2
|
+
import type { LedgerEvmConfig } from './ledger/host-types';
|
|
2
3
|
export interface LedgerDmkHostConfig extends LedgerEvmConfig {
|
|
3
4
|
/** Platform-owned DMK, allowing a future host to register its own transports. */
|
|
4
5
|
dmk?: object;
|
|
6
|
+
/** Disable automatic discovery until the platform selects a device. */
|
|
7
|
+
requireDeviceSelection?: boolean;
|
|
5
8
|
}
|
|
6
|
-
export declare function createLedgerDmkHost(config?: LedgerDmkHostConfig):
|
|
9
|
+
export declare function createLedgerDmkHost(config?: LedgerDmkHostConfig): LedgerDmkHost;
|
|
10
|
+
export type { LedgerDmkHost } from './ledger/dmk-host';
|
|
7
11
|
export type { LedgerEvmConfig, LedgerBlindSigningIntent, LedgerHost, LedgerEvmHost, LedgerUtxoHost, LedgerUtxoAccount, LedgerPartialSignature, LedgerTypedData, LedgerOperationOptions, LedgerProgress, } from './ledger/host-types';
|