feat: ds
This commit is contained in:
@@ -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,
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user