Commit 76e82307 authored by xiphon's avatar xiphon
Browse files

GenerateAddresses: skip already used address or subaddress index

parent 6ceaabf2
......@@ -46,9 +46,18 @@ class GenerateAddresses extends Command
$projects = Project::whereNotNull('filename')->whereNull('address')->where('state', 'FUNDING-REQUIRED')->get();
foreach ($projects as $project) {
$addressDetails = $wallet->getPaymentAddress();
$address = $addressDetails['address'];
$subaddr_index = $coin->subaddrIndex($addressDetails, $project);
if (Project::where('address', $address)->orWhere('subaddr_index', $subaddr_index)->first())
{
$this->error('Skipping already used address ' . $address . ' or subaddr_index ' . $subaddr_index);
continue;
}
$project->address_uri = $wallet->createQrCodeString($addressDetails['address']);
$project->address = $addressDetails['address'];
$project->subaddr_index = $coin->subaddrIndex($addressDetails, $project);
$project->address = $address;
$project->subaddr_index = $subaddr_index;
Storage::disk('public')->put("/img/qrcodes/{$project->subaddr_index}.png", $project->generateQrcode());
$project->qr_code = "img/qrcodes/{$project->subaddr_index}.png";
$project->raised_amount = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment