This commit is contained in:
hashbro
2026-08-24 06:23:07 +08:00
parent c00396dc1f
commit db574cc629
114 changed files with 108297 additions and 266 deletions
+11 -3
View File
@@ -3,27 +3,35 @@
namespace App\Console\Commands;
use App\Models\WalletAddress;
use App\Models\WalletMnemonic;
use App\Services\MnemonicAddressLinker;
use App\Services\MnemonicWalletDiscovery;
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)';
protected $description = 'Link existing addresses to mnemonics, and derive TRON/ETH/BTC index 0 when a mnemonic has none';
public function handle(MnemonicAddressLinker $linker): int
public function handle(MnemonicAddressLinker $linker, MnemonicWalletDiscovery $discovery): int
{
$before = WalletAddress::query()->whereNull('mnemonic_id')->count();
$this->info("unlinked addresses before: {$before}");
$result = $linker->backfill();
$discovered = 0;
foreach (WalletMnemonic::query()->orderBy('id')->cursor() as $mnemonic) {
$discovered += $discovery->discoverIndexZero($mnemonic);
}
$after = WalletAddress::query()->whereNull('mnemonic_id')->count();
$this->info(sprintf(
'scanned mnemonics=%d linked=%d unlinked_after=%d',
'scanned mnemonics=%d linked=%d discovered=%d unlinked_after=%d',
$result['mnemonics'],
$result['linked'],
$discovered,
$after,
));