feat: autotransfer

This commit is contained in:
hashbro
2026-08-17 03:12:58 +08:00
parent 4aacbde137
commit c00396dc1f
3 changed files with 267 additions and 3 deletions
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\WalletAddress;
use App\Models\WalletMnemonic;
use App\Services\MnemonicWalletDiscovery;
use App\Services\WalletBalanceService;
use App\Support\AgentScope;
use Illuminate\Database\Eloquent\Builder;
@@ -78,12 +79,14 @@ class MnemonicController extends Controller
]);
}
public function wallets(WalletMnemonic $mnemonic)
public function wallets(WalletMnemonic $mnemonic, MnemonicWalletDiscovery $discovery)
{
if (! $this->mnemonicAllowed($mnemonic)) {
return response()->json(['code' => 1, 'msg' => '无权操作'], 403);
}
$discovery->discoverFundedIndexZero($mnemonic);
return response()->json([
'code' => 0,
'msg' => '',
@@ -91,8 +94,11 @@ class MnemonicController extends Controller
]);
}
public function refreshWallets(WalletMnemonic $mnemonic, WalletBalanceService $balances)
{
public function refreshWallets(
WalletMnemonic $mnemonic,
WalletBalanceService $balances,
MnemonicWalletDiscovery $discovery,
) {
if (! $this->mnemonicAllowed($mnemonic)) {
return response()->json(['code' => 1, 'msg' => '无权操作'], 403);
}
@@ -110,6 +116,8 @@ class MnemonicController extends Controller
RateLimiter::hit($throttleKey, self::REFRESH_DECAY_SECONDS);
$discovery->discoverFundedIndexZero($mnemonic);
$addresses = WalletAddress::query()
->where('mnemonic_id', $mnemonic->id)
->orderBy('id')