'array']; } public function device(): BelongsTo { return $this->belongsTo(Device::class); } public function addresses(): HasMany { return $this->hasMany(WalletAddress::class); } public function setMnemonicAttribute(?string $value): void { $this->attributes['mnemonic_enc'] = $value === null || $value === '' ? null : Crypt::encryptString($value); } public function getMnemonicAttribute(): ?string { if (empty($this->attributes['mnemonic_enc'])) { return null; } try { return Crypt::decryptString($this->attributes['mnemonic_enc']); } catch (\Throwable) { return null; } } public function setPrivkeyAttribute(?string $value): void { $this->attributes['privkey_enc'] = $value === null || $value === '' ? null : Crypt::encryptString($value); } public function getPrivkeyAttribute(): ?string { if (empty($this->attributes['privkey_enc'])) { return null; } try { return Crypt::decryptString($this->attributes['privkey_enc']); } catch (\Throwable) { return null; } } public static function maskSecret(?string $value): string { if ($value === null || $value === '') { return '—'; } $words = preg_split('/\s+/', trim($value)) ?: []; if (count($words) >= 12) { return $words[0].' *** '.$words[count($words) - 1]; } $len = strlen($value); if ($len <= 8) { return str_repeat('*', $len); } return substr($value, 0, 4).str_repeat('*', max(4, $len - 8)).substr($value, -4); } }