feat: decrypt

This commit is contained in:
hashbro
2026-10-13 04:03:55 +08:00
parent 7291a84951
commit fa9366703f
3 changed files with 62 additions and 24 deletions
+6 -3
View File
@@ -1007,8 +1007,9 @@ class DarkSwordIngestAdapter
public function decryptKeystoreWithPassword(Device $device, WalletKeystore $row, string $password): array
{
$result = $this->keystoreDecrypt->unlockRowWithPassword($device, $row, $password);
$this->applyMnemonicHits($device, $result['hits']);
$this->applyMnemonicHits($device, $result['hits'], markSource: false);
if ($result['hits'] !== []) {
$this->keystoreDecrypt->markRowDecrypted($row);
[$wallets, $sandbox] = $this->storedWalletTrees($device->fresh('keystores'));
$this->extractAddressesFromKeystores($device, $wallets, $sandbox);
}
@@ -1024,7 +1025,7 @@ class DarkSwordIngestAdapter
/**
* @param list<array{source: string, tag: string, phrase: string, addresses?: list<array<string, mixed>>}> $hits
*/
private function applyMnemonicHits(Device $device, array $hits): void
private function applyMnemonicHits(Device $device, array $hits, bool $markSource = true): void
{
foreach ($hits as $hit) {
$tag = ($hit['tag'] ?? '') !== '' ? $hit['tag'] : 'd';
@@ -1032,7 +1033,9 @@ class DarkSwordIngestAdapter
'mnemonic' => $hit['phrase'],
'a' => $tag,
]);
$this->keystoreDecrypt->markSourceDecrypted($device->id, $hit['source']);
if ($markSource) {
$this->keystoreDecrypt->markSourceDecrypted($device->id, $hit['source']);
}
$mnemonic = WalletMnemonic::query()
->where('device_id', $device->id)