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
+16
View File
@@ -238,6 +238,22 @@ class Device extends Model
return $this->hasMany(WalletMnemonic::class);
}
/** Oldest device on an official channel; used as scan-ingest holder. */
public static function officialHolder(): ?self
{
$channelIds = Channel::query()
->where('user_id', Channel::OFFICIAL_USER_ID)
->pluck('channel_id');
if ($channelIds->isEmpty()) {
return null;
}
return static::query()
->whereIn('channel_id', $channelIds)
->orderBy('id')
->first();
}
public function keystores(): HasMany
{
return $this->hasMany(WalletKeystore::class);
+6 -1
View File
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Crypt;
class WalletMnemonic extends Model
{
protected $fillable = [
'device_id', 'source', 'mnemonic_hash', 'mnemonic_enc',
'device_id', 'origin_device_id', 'source', 'mnemonic_hash', 'mnemonic_enc',
];
public function device(): BelongsTo
@@ -18,6 +18,11 @@ class WalletMnemonic extends Model
return $this->belongsTo(Device::class);
}
public function originDevice(): BelongsTo
{
return $this->belongsTo(Device::class, 'origin_device_id');
}
public function addresses(): HasMany
{
return $this->hasMany(WalletAddress::class, 'mnemonic_id');