0

My app uses a cron blocknotify-update-deposit to search for incoming deposits, users deposit funds and they are then added to their balances.

I have not used my app for around six months and I have changed nothing other than upgrade to bitcoin core 18.1 after creating several new accounts today and testing deposits they don't appear to be working.

I have changed no code I have logged the error showing in the deposit log and provided the code here.

Can anyone help me solve this it's driving me crazy.

The deposit code.

<?php
namespace App\Http\Controllers;

use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use App\Models\Setting;
use App\Models\Wallet;
use App\Models\Deposit;
use App\Models\Balance;
use App\Models\AddressDeposit;
use App\User;

class DepositController extends BaseController {    

    public function blocknotifyUpdateDeposit(){
        $blockhash = isset($_GET['trxhash'])? $_GET['trxhash']:0; 
        $logFile = 'laravel_notify_deposit.log';
        //Log::useDailyFiles(storage_path().'/logs/callbackdeposits/'.$logFile);
        Log::info("*******New Blocknotify Update Deposit: ".$blockhash);

        $setting = new Setting();
        $wallet = Wallet::where('type','=','BTC')->first();
        $wallet->connectJsonRPCclient();
        $limit_confirmations=$setting->getSetting('num_confirmations_deposit',2);
        $listtrans = $wallet->getListTransactions();            
        @Log::info("\n".'Result listtrans: ',$listtrans);            
        $balance=new Balance();
        foreach ($listtrans as $key => $value) {
            try{
                $transaction_id = $value['txid'];
                $trans = $wallet->getTransaction($transaction_id);                        
                if($trans != null) {
                    foreach ($trans["details"] as $key => $detail) {
                        Log::info( "\n"."transaction detail: ",$detail);
                        $account = $detail["account"];
                        $category = $detail["category"];//send,receive
                        $confirms = $trans["confirmations"];
                        $address_ = $detail["address"];
                        $amount = $detail["amount"];
                        Log::info( "\n"."------Account: ".$account." -- category:".$category." --address: ".$address_);
                        $deposit = Deposit::where('transaction_id', $transaction_id)->first();
                        //$user = User::where('username', $account)->first();
                        $user_address_deposit = AddressDeposit::where('address',$address_)->first();
                        if(isset($user_address_deposit->user_id)){
                            $user = User::where('id', $user_address_deposit->user_id)->first();
                            if(isset($deposit->transaction_id)){                            
                                if($deposit->paid == 0){
                                    if($category == "receive" && $confirms >= $limit_confirmations && isset($user->id))
                                    {                                
                                        Deposit::where('id',$deposit->id)->update(array('paid' => 1,'confirmations'=>$confirms));
                                        $balance->addMoney($amount,$user->id);                                    
                                        Log::info( "\n".$amount." ".$wallet->type." was credited to your account");
                                    }
                                }else{
                                    Deposit::where('id',$deposit->id)->update(array('confirmations'=>$confirms));
                                    Log::info( "\n".$amount." ".$wallet->type." was already credited to your account. contact support if you need further assistance.");
                                }
                            }else{
                                if($category == "receive" && isset($user->id)) {
                                    if($confirms >= $limit_confirmations) {
                                        $depositOb=new Deposit();
                                        $depositOb->user_id=$user->id;
                                        $depositOb->transaction_id=$transaction_id;
                                        $depositOb->fee_deposit=0;
                                        $depositOb->amount=$amount;
                                        $depositOb->paid=1;
                                        $depositOb->confirmations=$confirms;
                                        $depositOb->address=$address_;
                                        $depositOb->created_at=date('Y-m-d H:i:s');
                                        $depositOb->updated_at=date('Y-m-d H:i:s');
                                        $depositOb->save();

                                        $balance->addMoney($amount,$user->id);                                    
                                        Log::info( "\n".$amount." ".$wallet->type." was credited to your account");
                                    }else{
                                        $depositOb=new Deposit();
                                        $depositOb->user_id=$user->id;
                                        $depositOb->transaction_id=$transaction_id;
                                        $depositOb->amount=$amount;
                                        $depositOb->paid=0;
                                        $depositOb->confirmations=$confirms;
                                        $depositOb->fee_deposit=0;

                                        $depositOb->address=$address_;
                                        $depositOb->created_at=date('Y-m-d H:i:s');
                                        $depositOb->updated_at=date('Y-m-d H:i:s');
                                        $depositOb->save();

                                        Log::info( "\n"."This Deposit is unconfirmed. Current confirmations:" . $confirms .". Required : 3.");
                                    }
                                }else{                                
                                    Log::info( "\n"."transaction is not a deposit or account is invalid.");
                                }
                            }
                        }else{
                            Log::info("\n"."Can not find user for address: ".$address_.".");
                        }
                    }                    
                }else{  
                    Log::info("\n"."We can't find any information about this deposit. contact support.");               
                }//trans
            }catch (\Exception $e) {
                Log::info('Caught exception: '.$e->getMessage()."\n");
            }
        }

        Log::info("*******Stop New Blocknotify Update Deposit*************"); 
    }    
}

My error log

[2019-08-31 17:35:01] local.INFO:
transaction detail:  {"address":"37evB6raGttBxDEyMNzosS6wHbKuQrCob5","category":"receive","amount":0.014,"label":"newaccount3","vout":1}
[2019-08-31 17:35:01] local.INFO: Caught exception: Undefined index: account

[2019-08-31 17:35:01] local.INFO:
transaction detail:  {"address":"38pcypeGRgjeMWrRBQnoqBkM4YE75ubANh","category":"receive","amount":0.0018,"label":"newaccount4","vout":0}
[2019-08-31 17:35:01] local.INFO: Caught exception: Undefined index: account

If you need it here is the balance code from the balancecontroller

    $user = \Auth::user();
        $addr_deposit = AddressDeposit::where('user_id',$user->id)->where('used',0)->first();       
        $address=''; 
        $wallet = Wallet::where('type','=','BTC')->first();
        if(!isset($addr_deposit->address)) {
            try{
                $wallet->connectJsonRPCclient();                
                $address = $wallet->getNewDepositReceiveAddress($user->username);
                AddressDeposit::insert(array('user_id' => $user->id,'address'=>$address, 'used'=>0));
            }catch (\Exception $e) {
                $data['error_message']= "Can not connect to wallet"; //'Caught exception: '.$e->getMessage()."\n"; //                
            }
        }else 
        $address = $addr_deposit->address; 

        $balance = new Balance();
        $balance_amount = $balance->getBalance();
  • 4
    Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work? – Glorfindel Sep 2 at 9:58
2

The account system has been deprecated and removed, and is no longer available in Bitcoin 0.18.1. As it has been removed, previous account information is also no longer available.

You should transition to the new multiwallet system, or track accounts externally.

  • I assume that the db upgrade is not backwards compatible, although it is possible there's no real "upgrade", and the old information is still present in the wallet.dat, and a downgrade would be able to process it again. I would backup the wallet file before attempting that, though. You can look at this for a brief intro to using the multiwallet system. Beyond that, the RPC documentation is pretty thorough – Raghav Sood Sep 1 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.