open_wallet(config('app.xmr_wallet_name'), ''); $get_transfers = $walletRPC->get_transfers('all', true); // dd($get_transfers); // dd($walletRPC->get_balance()); foreach ($get_transfers['in'] as $transfer) { $address = Address::where('address', $transfer['address'])->first(); $tip_exists = Tip::where('txid', $transfer['txid'])->first(); if ($address && !$tip_exists) { $tip = new Tip(); $tip->address_id = $address->id; $tip->amount = $transfer['amount']; $tip->txid = $transfer['txid']; $tip->height = $transfer['height']; $tip->save(); } } $walletRPC->close_wallet(); } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } public function payout() { ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); try { $walletRPC = new walletRPC('127.0.0.1', config('app.xmr_network_port')); // Change to match your wallet (monero-wallet-rpc) IP address and port; 18083 is the customary port for mainnet, 28083 for testnet, 38083 for stagenet $open_wallet = $walletRPC->open_wallet(config('app.xmr_wallet_name'), ''); $tip = Tip::where('is_sent', 0)->firstOrFail(); $meme = Meme::where('address_id', $tip->address_id)->first(); if ($meme->user->address) { $send_funds = $walletRPC->sweep_all($meme->user->address, $tip->address->address_index); $tip->is_sent = 1; $tip->save(); } $walletRPC->close_wallet(); } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // } /** * Display the specified resource. * * @param \App\Models\Tip $tip * @return \Illuminate\Http\Response */ public function show(Tip $tip) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\Tip $tip * @return \Illuminate\Http\Response */ public function edit(Tip $tip) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Tip $tip * @return \Illuminate\Http\Response */ public function update(Request $request, Tip $tip) { // } /** * Remove the specified resource from storage. * * @param \App\Models\Tip $tip * @return \Illuminate\Http\Response */ public function destroy(Tip $tip) { // } }