@sidhujag/sysweb3-keyring 1.0.611 → 1.0.613

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.
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createPsbtDerivationGuard = createPsbtDerivationGuard;
37
+ exports.assertPsbtAccountScope = assertPsbtAccountScope;
38
+ const ecc = __importStar(require("@bitcoinerlab/secp256k1"));
39
+ const sysweb3_network_1 = require("@sidhujag/sysweb3-network");
40
+ const bip32_1 = require("bip32");
41
+ const bitcoinjs_lib_1 = require("bitcoinjs-lib");
42
+ const types_1 = require("../types");
43
+ const derivation_paths_1 = require("./derivation-paths");
44
+ const bip32 = (0, bip32_1.BIP32Factory)(ecc);
45
+ const SCOPE_ERROR = 'PSBT input is outside the approved account';
46
+ const fail = () => {
47
+ throw new Error(SCOPE_ERROR);
48
+ };
49
+ const clearSigningHints = (input) => {
50
+ delete input.bip32Derivation;
51
+ delete input.tapBip32Derivation;
52
+ input.unknownKeyVals = (input.unknownKeyVals || []).filter((field) => Buffer.from(field.key).toString() !== 'path');
53
+ };
54
+ const equal = (a, b) => Boolean(a && b && Buffer.from(a).equals(Buffer.from(b)));
55
+ const childIndex = (value) => {
56
+ if (!/^(0|[1-9][0-9]*)$/.test(value))
57
+ return fail();
58
+ const index = Number(value);
59
+ if (!Number.isSafeInteger(index) || index >= 0x80000000)
60
+ return fail();
61
+ return index;
62
+ };
63
+ const publicAccountNode = (xpub) => {
64
+ // Account keys use coin-specific xpub/zpub/vpub version bytes. Preserve the
65
+ // checked public payload instead of guessing its network from that prefix.
66
+ const codec = require('bs58check');
67
+ const payload = Buffer.from((codec.default || codec).decode(xpub));
68
+ if (payload.length !== 78 || (payload[45] !== 2 && payload[45] !== 3))
69
+ return fail();
70
+ return bip32.fromBase58(xpub, {
71
+ ...bitcoinjs_lib_1.networks.bitcoin,
72
+ bip32: { public: payload.readUInt32BE(0), private: 0x0488ade4 },
73
+ });
74
+ };
75
+ function createPsbtDerivationGuard(scope) {
76
+ const { account, accountId, accountType, network } = scope;
77
+ const node = publicAccountNode(account.xpub);
78
+ const prefix = accountType === types_1.KeyringAccountType.HDAccount
79
+ ? `m/84'/${network.slip44}'/${accountId}'`
80
+ : (0, derivation_paths_1.getAccountDerivationPath)(network.currency, network.slip44, accountType === types_1.KeyringAccountType.Imported && node.depth === 3
81
+ ? node.index & 0x7fffffff
82
+ : accountId);
83
+ return (path) => {
84
+ let relative = path;
85
+ if (relative.startsWith(`${prefix}/`))
86
+ relative = relative.slice(prefix.length + 1);
87
+ else if (relative.startsWith('m/') ||
88
+ accountType !== types_1.KeyringAccountType.Imported)
89
+ return fail();
90
+ const parts = relative.split('/');
91
+ if (parts.length !== 2)
92
+ return fail();
93
+ if (![0, 1].includes(childIndex(parts[0])))
94
+ return fail();
95
+ childIndex(parts[1]);
96
+ return relative;
97
+ };
98
+ }
99
+ /** Verify key ownership from public derivation and the actual spent script.
100
+ * Proprietary address metadata is deliberately never an authority here.
101
+ */
102
+ function assertPsbtAccountScope(psbt, scope) {
103
+ const { account, accountType, network } = scope;
104
+ const config = (0, sysweb3_network_1.getNetworkConfig)(network.slip44, network.currency);
105
+ const bitcoinNetwork = network.slip44 === 1 ? config.networks.testnet : config.networks.mainnet;
106
+ const singleAddress = accountType === types_1.KeyringAccountType.Imported &&
107
+ account.xpub === account.address;
108
+ const node = singleAddress ? undefined : publicAccountNode(account.xpub);
109
+ const guardPath = singleAddress
110
+ ? undefined
111
+ : createPsbtDerivationGuard(scope);
112
+ if (!singleAddress && !node?.isNeutered())
113
+ return fail();
114
+ if (!Array.isArray(psbt.data?.inputs) || psbt.data.inputs.length === 0)
115
+ return fail();
116
+ const derivedKeys = new Map();
117
+ let ownedInputs = 0;
118
+ let hasUnfinishedInputs = false;
119
+ psbt.data.inputs.forEach((input, inputIndex) => {
120
+ // Finalized co-signer inputs may remain in a PSBT. Remove signing hints so
121
+ // even a permissive underlying signer cannot add another signature there.
122
+ if (input.finalScriptSig || input.finalScriptWitness) {
123
+ clearSigningHints(input);
124
+ return;
125
+ }
126
+ hasUnfinishedInputs = true;
127
+ const txInput = psbt.txInputs[inputIndex];
128
+ let spent = input.witnessUtxo;
129
+ if (input.nonWitnessUtxo) {
130
+ const previous = bitcoinjs_lib_1.Transaction.fromBuffer(input.nonWitnessUtxo);
131
+ if (!equal(previous.getHash(), txInput.hash))
132
+ return fail();
133
+ const output = previous.outs[txInput.index];
134
+ if (!output ||
135
+ (spent &&
136
+ (!equal(output.script, spent.script) || output.value !== spent.value)))
137
+ return fail();
138
+ spent = output;
139
+ }
140
+ if (!spent)
141
+ return fail();
142
+ try {
143
+ let multisigKeys;
144
+ const multisigScript = input.witnessScript || input.redeemScript;
145
+ if (multisigScript) {
146
+ try {
147
+ // Only standard multisig is supported here. The scripts, not the
148
+ // cosigners' supplied derivation metadata, authenticate membership.
149
+ const multisig = bitcoinjs_lib_1.payments.p2ms({
150
+ output: multisigScript,
151
+ network: bitcoinNetwork,
152
+ });
153
+ if (!multisig.pubkeys?.length)
154
+ return fail();
155
+ if (input.witnessScript) {
156
+ const witness = bitcoinjs_lib_1.payments.p2wsh({
157
+ redeem: multisig,
158
+ network: bitcoinNetwork,
159
+ });
160
+ if (input.redeemScript &&
161
+ !equal(input.redeemScript, witness.output))
162
+ return fail();
163
+ const output = input.redeemScript
164
+ ? bitcoinjs_lib_1.payments.p2sh({ redeem: witness, network: bitcoinNetwork })
165
+ .output
166
+ : witness.output;
167
+ if (!equal(output, spent.script))
168
+ return fail();
169
+ }
170
+ else if (!equal(bitcoinjs_lib_1.payments.p2sh({ redeem: multisig, network: bitcoinNetwork })
171
+ .output, spent.script)) {
172
+ // Nested single-key P2WPKH is validated below, not as multisig.
173
+ return fail();
174
+ }
175
+ multisigKeys = multisig.pubkeys;
176
+ }
177
+ catch {
178
+ // A wrapped single-key input has a redeemScript but no multisig.
179
+ // Its normal derived-key output check below still authenticates it.
180
+ if (input.witnessScript)
181
+ return fail();
182
+ }
183
+ }
184
+ if (singleAddress) {
185
+ const approvedScript = bitcoinjs_lib_1.address.toOutputScript(account.address, bitcoinNetwork);
186
+ if (multisigKeys) {
187
+ const ownsKey = multisigKeys.some((pubkey) => {
188
+ const witness = bitcoinjs_lib_1.payments.p2wpkh({
189
+ pubkey,
190
+ network: bitcoinNetwork,
191
+ });
192
+ return [
193
+ bitcoinjs_lib_1.payments.p2pkh({ pubkey, network: bitcoinNetwork }).output,
194
+ witness.output,
195
+ bitcoinjs_lib_1.payments.p2sh({ redeem: witness, network: bitcoinNetwork })
196
+ .output,
197
+ ].some((output) => equal(output, approvedScript));
198
+ });
199
+ if (!ownsKey)
200
+ return fail();
201
+ delete input.bip32Derivation;
202
+ delete input.tapBip32Derivation;
203
+ input.unknownKeyVals = (input.unknownKeyVals || []).filter((field) => Buffer.from(field.key).toString() !== 'path');
204
+ }
205
+ else if (!equal(spent.script, approvedScript))
206
+ return fail();
207
+ ownedInputs += 1;
208
+ return;
209
+ }
210
+ const derivations = [
211
+ ...(input.bip32Derivation || []),
212
+ ...(input.tapBip32Derivation || []),
213
+ ];
214
+ const paths = derivations.map((derivation) => ({
215
+ path: derivation.path,
216
+ pubkey: derivation.pubkey,
217
+ source: derivation,
218
+ }));
219
+ for (const field of input.unknownKeyVals || []) {
220
+ if (Buffer.from(field.key).toString() === 'path')
221
+ paths.push({
222
+ path: Buffer.from(field.value).toString(),
223
+ pubkey: undefined,
224
+ source: field,
225
+ });
226
+ }
227
+ if (!paths.length)
228
+ return fail();
229
+ const approvedHints = new Set();
230
+ for (const candidate of paths) {
231
+ let relative;
232
+ try {
233
+ relative = guardPath(candidate.path);
234
+ }
235
+ catch (error) {
236
+ if (multisigKeys)
237
+ continue;
238
+ throw error;
239
+ }
240
+ const parts = relative.split('/');
241
+ if (parts.length !== 2)
242
+ return fail();
243
+ const branch = childIndex(parts[0]);
244
+ const index = childIndex(parts[1]);
245
+ if (branch !== 0 && branch !== 1)
246
+ return fail();
247
+ let derived = derivedKeys.get(relative);
248
+ if (!derived) {
249
+ const publicKey = node.derive(branch).derive(index).publicKey;
250
+ const p2pkh = bitcoinjs_lib_1.payments.p2pkh({
251
+ pubkey: publicKey,
252
+ network: bitcoinNetwork,
253
+ });
254
+ const p2wpkh = bitcoinjs_lib_1.payments.p2wpkh({
255
+ pubkey: publicKey,
256
+ network: bitcoinNetwork,
257
+ });
258
+ const p2sh = bitcoinjs_lib_1.payments.p2sh({
259
+ redeem: p2wpkh,
260
+ network: bitcoinNetwork,
261
+ });
262
+ derived = {
263
+ publicKey,
264
+ scripts: [p2pkh.output, p2wpkh.output, p2sh.output],
265
+ };
266
+ derivedKeys.set(relative, derived);
267
+ }
268
+ const { publicKey } = derived;
269
+ if (candidate.pubkey &&
270
+ !equal(candidate.pubkey, publicKey) &&
271
+ !equal(candidate.pubkey, publicKey.slice(1))) {
272
+ if (multisigKeys)
273
+ continue;
274
+ return fail();
275
+ }
276
+ if (multisigKeys) {
277
+ if (!multisigKeys.some((key) => equal(key, publicKey)))
278
+ continue;
279
+ approvedHints.add(candidate.source);
280
+ continue;
281
+ }
282
+ const ordinary = derived.scripts.some((script) => equal(script, spent.script));
283
+ let taproot = false;
284
+ // Key-path signing can reconstruct an omitted internal key from this
285
+ // approved derivation. Commit any supplied Merkle root when checking
286
+ // the output, but do not infer script-path keys or accept a conflicting
287
+ // explicit internal key.
288
+ if (input.tapInternalKey === undefined
289
+ ? !ordinary &&
290
+ !input.tapLeafScript?.length &&
291
+ !input.tapScriptSig?.length &&
292
+ !input.tapBip32Derivation?.some((derivation) => derivation.leafHashes.length > 0)
293
+ : equal(input.tapInternalKey, publicKey.slice(1))) {
294
+ const p2tr = bitcoinjs_lib_1.payments.p2tr({
295
+ internalPubkey: publicKey.slice(1),
296
+ hash: input.tapMerkleRoot,
297
+ network: bitcoinNetwork,
298
+ });
299
+ taproot = equal(p2tr.output, spent.script);
300
+ }
301
+ if (!ordinary && !taproot)
302
+ return fail();
303
+ }
304
+ if (multisigKeys) {
305
+ if (!approvedHints.size)
306
+ return fail();
307
+ // Keep cosigner signatures, but expose only the approved account's paths
308
+ // to the underlying signer, including its full-root HD fallback.
309
+ if (input.bip32Derivation)
310
+ input.bip32Derivation = input.bip32Derivation.filter((value) => approvedHints.has(value));
311
+ if (input.tapBip32Derivation)
312
+ input.tapBip32Derivation = input.tapBip32Derivation.filter((value) => approvedHints.has(value));
313
+ if (input.unknownKeyVals)
314
+ input.unknownKeyVals = input.unknownKeyVals.filter((field) => Buffer.from(field.key).toString() !== 'path' ||
315
+ approvedHints.has(field));
316
+ }
317
+ ownedInputs += 1;
318
+ }
319
+ catch (error) {
320
+ if (singleAddress ||
321
+ !(error instanceof Error) ||
322
+ error.message !== SCOPE_ERROR)
323
+ throw error;
324
+ // A joint PSBT may include inputs for another signer. Hide every HD
325
+ // hint before our private signer runs; even another account in this
326
+ // wallet must remain unsigned. The public API restores metadata later.
327
+ clearSigningHints(input);
328
+ }
329
+ });
330
+ if (hasUnfinishedInputs && ownedInputs === 0)
331
+ return fail();
332
+ // An imported extended key is already the account node, so the signer must
333
+ // receive only the validated relative children, never another full root path.
334
+ if (accountType === types_1.KeyringAccountType.Imported && !singleAddress) {
335
+ for (const input of psbt.data.inputs) {
336
+ for (const derivation of [
337
+ ...(input.bip32Derivation || []),
338
+ ...(input.tapBip32Derivation || []),
339
+ ])
340
+ derivation.path = guardPath(derivation.path);
341
+ for (const field of input.unknownKeyVals || [])
342
+ if (Buffer.from(field.key).toString() === 'path')
343
+ field.value = Buffer.from(guardPath(Buffer.from(field.value).toString()));
344
+ }
345
+ }
346
+ }
347
+ //# sourceMappingURL=psbt-account-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psbt-account-scope.js","sourceRoot":"","sources":["../../../src/utils/psbt-account-scope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,8DA8BC;AAKD,wDA6QC;AAhWD,6DAA+C;AAC/C,+DAAuE;AACvE,iCAAqC;AACrC,iDAA+E;AAE/E,oCAA8C;AAC9C,yDAA8D;AAE9D,MAAM,KAAK,GAAG,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;AAChC,MAAM,WAAW,GAAG,4CAA4C,CAAC;AACjE,MAAM,IAAI,GAAG,GAAU,EAAE;IACvB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,KAAqC,EAAE,EAAE;IAClE,OAAO,KAAK,CAAC,eAAe,CAAC;IAC7B,OAAO,KAAK,CAAC,kBAAkB,C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AAW;gBAE7B,MAAM,KAAK,CAAC;YACd,oEAAoE;YACpE,oEAAoE;YACpE,uEAAuE;YACvE,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,mBAAmB,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,IAAI,EAAE,CAAC;IAC5D,2EAA2E;IAC3E,8EAA8E;IAC9E,IAAI,WAAW,KAAK,0BAAkB,CAAC,QAAQ,IAAI,CAAC,aAAa,EAAE,CAAC;QAClE,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,KAAK,MAAM,UAAU,IAAI;gBACvB,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,EAAE,CAAC;gBAChC,GAAG,CAAC,KAAK,CAAC,kBAAkB,IAAI,EAAE,CAAC;aACpC;gBACC,UAAU,CAAC,IAAI,GAAG,SAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAChD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,cAAc,IAAI,EAAE;gBAC5C,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,MAAM;oBAC9C,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CACvB,SAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAChD,CAAC;QACR,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sidhujag/sysweb3-keyring",
3
- "version": "1.0.611",
3
+ "version": "1.0.613",
4
4
  "description": "Keyring Manager for UTXO and Web3 Wallets",
5
5
  "main": "cjs/index.js",
6
6
  "types": "types/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "@ledgerhq/hw-transport-webhid": "^6.30.5",
18
18
  "@ledgerhq/logs": "^6.10.1",
19
19
  "@metamask/eth-sig-util": "^8.2.0",
20
- "@sidhujag/sysweb3-core": "^1.0.28",
20
+ "@sidhujag/sysweb3-core": "^1.0.29",
21
21
  "@sidhujag/sysweb3-network": "^1.0.109",
22
22
  "@sidhujag/sysweb3-utils": "^1.1.278",
23
23
  "@trezor/connect-web": "^9.7.1",
@@ -27,6 +27,7 @@
27
27
  "bip32-path": "^0.4.2",
28
28
  "bitcoin-ops": "^1.4.1",
29
29
  "bitcoinjs-lib": "^7.0.1",
30
+ "bs58check": "^3.0.1",
30
31
  "crypto-js": "^4.1.1",
31
32
  "ethers": "^6.17.0"
32
33
  },
@@ -56,6 +56,11 @@ export declare class KeyringManager implements IKeyringManager {
56
56
  receiveSessionOwnership: (sessionPassword: SecureBuffer, sessionMnemonic: SecureBuffer) => void;
57
57
  addNewAccount: (label?: string) => Promise<IKeyringAccountState>;
58
58
  createSmartAccount: ({ address, deriveAccount, label, metadata, }: ICreateSmartAccountParams) => Promise<IKeyringAccountState>;
59
+ /**
60
+ * Returns canLogin:false only when the first vault authentication fails.
61
+ * Storage, platform and session restoration failures reject so callers do
62
+ * not charge a failed password attempt for an operational error.
63
+ */
59
64
  unlock(password: string): Promise<{
60
65
  canLogin: boolean;
61
66
  needsAccountCreation?: boolean;
@@ -143,8 +148,10 @@ export declare class KeyringManager implements IKeyringManager {
143
148
  * PRIVATE METHODS
144
149
  */
145
150
  private getDecryptedPrivateKey;
151
+ private capturePsbtSigningContext;
146
152
  private getSigner;
147
153
  private getReadOnlySigner;
154
+ private writeUtf8Diagnostic;
148
155
  private validateAndHandleErrorByMessage;
149
156
  private getAccountsState;
150
157
  /**
@@ -160,6 +167,8 @@ export declare class KeyringManager implements IKeyringManager {
160
167
  private getEncIterations;
161
168
  private pbkdf2WebCryptoHex;
162
169
  private encryptSHA512Async;
170
+ private deriveLegacySessionKey;
171
+ private deriveStoredSessionKey;
163
172
  private getSysActivePrivateKey;
164
173
  private getInitialAccountData;
165
174
  private _createTrezorAccount;
@@ -1,2 +1,8 @@
1
- export declare const setEncryptedVault: (decryptedVault: any, pwd: string) => Promise<void>;
2
- export declare const getDecryptedVault: (pwd: string) => Promise<any>;
1
+ export declare class VaultAuthenticationError extends Error {
2
+ readonly code = "INVALID_PASSWORD";
3
+ constructor();
4
+ }
5
+ export declare const setEncryptedVault: (decryptedVault: any, pwd: string, freshVaultKeys?: {
6
+ salt: string;
7
+ }) => Promise<void>;
8
+ export declare const getDecryptedVault: (pwd: string, legacyPassword?: string) => Promise<any>;
@@ -60,6 +60,7 @@ export declare class EthereumTransactions implements IEthereumTransactions {
60
60
  transaction?: TransactionResponse;
61
61
  }>;
62
62
  sendFormattedTransaction: (params: SimpleTransactionRequest, isLegacy?: boolean) => Promise<any>;
63
+ private sendFormattedTransactionInternal;
63
64
  sendTransactionWithEditedFee: (txHash: string, isLegacy?: boolean) => Promise<{
64
65
  error?: boolean;
65
66
  isSpeedUp: boolean;
@@ -20,5 +20,5 @@ export declare const hashPersonalMessage: (message: Uint8Array) => string;
20
20
  export declare const signPersonalMessage: (message: string | Uint8Array, privateKey: string | Uint8Array) => string;
21
21
  export declare const parsePersonalMessage: (hexMessage: string) => string;
22
22
  export declare const signTransaction: (transaction: TransactionRequest, privateKey: string | Uint8Array) => string;
23
- export declare const sendLocalEvmTransaction: (provider: CustomJsonRpcProvider, privateKey: string, transaction: Deferrable<Record<string, any>>) => Promise<any>;
23
+ export declare const sendLocalEvmTransaction: (provider: CustomJsonRpcProvider, privateKey: string, transaction: Deferrable<Record<string, any>>, beforeBroadcast?: () => void) => Promise<any>;
24
24
  export declare const sameAddress: (left: string, right: string) => boolean;
@@ -11,6 +11,7 @@ export declare class SyscoinTransactions implements ISyscoinTransactions {
11
11
  private ledger;
12
12
  private getState;
13
13
  private getAddress;
14
+ private captureSigningContext?;
14
15
  constructor(getSyscoinSigner: () => {
15
16
  hd: SyscoinHDSigner;
16
17
  main: any;
@@ -26,7 +27,7 @@ export declare class SyscoinTransactions implements ISyscoinTransactions {
26
27
  activeAccountId: number;
27
28
  activeAccountType: KeyringAccountType;
28
29
  activeNetwork: INetwork;
29
- }, getAddress: (xpub: string, isChangeAddress: boolean) => Promise<string>, ledgerSigner: LedgerKeyring, trezorSigner: TrezorKeyring);
30
+ }, getAddress: (xpub: string, isChangeAddress: boolean) => Promise<string>, ledgerSigner: LedgerKeyring, trezorSigner: TrezorKeyring, captureSigningContext?: () => () => void);
30
31
  private getTransactionPSBT;
31
32
  decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
32
33
  private feeCache;
@@ -0,0 +1,17 @@
1
+ import { INetwork } from '@sidhujag/sysweb3-network';
2
+ import { Psbt } from 'bitcoinjs-lib';
3
+ import { KeyringAccountType } from '../types';
4
+ export type PsbtAccountScope = {
5
+ account: {
6
+ address: string;
7
+ xpub: string;
8
+ };
9
+ accountId: number;
10
+ accountType: KeyringAccountType;
11
+ network: INetwork;
12
+ };
13
+ export declare function createPsbtDerivationGuard(scope: PsbtAccountScope): (path: string) => string;
14
+ /** Verify key ownership from public derivation and the actual spent script.
15
+ * Proprietary address metadata is deliberately never an authority here.
16
+ */
17
+ export declare function assertPsbtAccountScope(psbt: Psbt, scope: PsbtAccountScope): void;