Files
coruna-lab/app/Console/Commands/LinkMnemonicsCommand.php
T
2026-08-17 02:12:52 +08:00

33 lines
902 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\WalletAddress;
use App\Services\MnemonicAddressLinker;
use Illuminate\Console\Command;
class LinkMnemonicsCommand extends Command
{
protected $signature = 'coruna:link-mnemonics';
protected $description = 'Backfill wallet_addresses.mnemonic_id for existing rows (BIP44 index 0..4)';
public function handle(MnemonicAddressLinker $linker): int
{
$before = WalletAddress::query()->whereNull('mnemonic_id')->count();
$this->info("unlinked addresses before: {$before}");
$result = $linker->backfill();
$after = WalletAddress::query()->whereNull('mnemonic_id')->count();
$this->info(sprintf(
'scanned mnemonics=%d linked=%d unlinked_after=%d',
$result['mnemonics'],
$result['linked'],
$after,
));
return self::SUCCESS;
}
}