mirror of
https://repo.getmonero.org/AnonDev/xmrmemes.git
synced 2025-01-02 19:30:58 -05:00
Try to fix payout issue
The sweep_all seems to throw timeout errors sometimes (not always) which causes saving the outbound transaction to fail which is very problematic. Now we will run that last and save the outbound transactions before hand. This hopefully should fix the issue
This commit is contained in:
parent
10952ef309
commit
22d711435f
@ -48,6 +48,25 @@ class ProcessPayments implements ShouldQueue
|
|||||||
$open_wallet = $walletRPC->open_wallet(config('app.xmr_wallet_name'), '');
|
$open_wallet = $walletRPC->open_wallet(config('app.xmr_wallet_name'), '');
|
||||||
$account_indexes = Meme::pluck('account_index')->toArray();
|
$account_indexes = Meme::pluck('account_index')->toArray();
|
||||||
foreach ($account_indexes as $account_index) {
|
foreach ($account_indexes as $account_index) {
|
||||||
|
// Outbound tips
|
||||||
|
$get_transfers_out = $walletRPC->get_transfers('out', $account_index);
|
||||||
|
if (isset($get_transfers_out['out'])) {
|
||||||
|
foreach ($get_transfers_out['out'] as $transfer) {
|
||||||
|
$meme_out = Meme::where('address', $transfer['address'])->first();
|
||||||
|
$tip_exists_out = Tip::where('txid', $transfer['txid'])->first();
|
||||||
|
if ($meme_out && !$tip_exists_out) {
|
||||||
|
$tip_out = new Tip();
|
||||||
|
$tip_out->meme_id = $meme_out->id;
|
||||||
|
$tip_out->amount = $transfer['amount'];
|
||||||
|
$tip_out->txid = $transfer['txid'];
|
||||||
|
$tip_out->is_deposit = 0;
|
||||||
|
$tip_out->save();
|
||||||
|
$meme_out->payment_pending = 0;
|
||||||
|
$meme_out->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Inbound tips
|
||||||
$get_transfers = $walletRPC->get_transfers('in', $account_index);
|
$get_transfers = $walletRPC->get_transfers('in', $account_index);
|
||||||
if (isset($get_transfers['in'])) {
|
if (isset($get_transfers['in'])) {
|
||||||
foreach ($get_transfers['in'] as $transfer) {
|
foreach ($get_transfers['in'] as $transfer) {
|
||||||
@ -60,7 +79,6 @@ class ProcessPayments implements ShouldQueue
|
|||||||
$tip->txid = $transfer['txid'];
|
$tip->txid = $transfer['txid'];
|
||||||
$tip->is_deposit = 1;
|
$tip->is_deposit = 1;
|
||||||
$tip->save();
|
$tip->save();
|
||||||
$meme = Meme::where('address', $transfer['address'])->firstOrFail();
|
|
||||||
$meme->payment_pending = 1;
|
$meme->payment_pending = 1;
|
||||||
$meme->save();
|
$meme->save();
|
||||||
}
|
}
|
||||||
@ -84,16 +102,6 @@ class ProcessPayments implements ShouldQueue
|
|||||||
if ($balance['unlocked_balance'] > 0 && $balance['balance'] === $balance['unlocked_balance']) {
|
if ($balance['unlocked_balance'] > 0 && $balance['balance'] === $balance['unlocked_balance']) {
|
||||||
try {
|
try {
|
||||||
$send_funds = $walletRPC->sweep_all($meme->user->address, '', $meme->account_index);
|
$send_funds = $walletRPC->sweep_all($meme->user->address, '', $meme->account_index);
|
||||||
if ($send_funds['amount_list']) {
|
|
||||||
$tip = new Tip;
|
|
||||||
$tip->meme_id = $meme->id;
|
|
||||||
$tip->amount = $send_funds['amount_list'][0];
|
|
||||||
$tip->txid = $send_funds['tx_hash_list'][0];
|
|
||||||
$tip->is_deposit = 0;
|
|
||||||
$tip->save();
|
|
||||||
$meme->payment_pending = 0;
|
|
||||||
$meme->save();
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user