private function processUserAddress(Transaction $transaction_model = null, Address $address_model, array $common_data, $satoshi_amount) { $this->user = $address_model->user; DB::beginTransaction(); // 0 conf, just hit mempool, not 1-st confirmation if (!$transaction_model) { // first callback, because no transaction initially found in db Log::info('Received address ' . $address_model->address . ' label: ' . $address_model->label . ', user guid: ' . $this->user->guid . ', email: ' . $this->user->email); $common_data['transaction_type'] = TX_RECEIVE; $new_address_balance = bcadd($address_model->balance, $satoshi_amount); $initialUserBalance = Balance::getBalance($this->user->id, $this->crypto_type_id); /* add data that is related to user address only */ $common_data['balance'] = $new_address_balance; $common_data['user_balance'] = bcadd($initialUserBalance->balance, $satoshi_amount); $common_data['previous_balance'] = $address_model->balance; $common_data['bitcoind_balance'] = bcmul($this->bitcoin_core->getbalance(), SATOSHIS_FRACTION); // insert new transaction $transaction_model = Transaction::insertNewTransaction($common_data); // update address balance Address::updateBalance($address_model, $satoshi_amount); /* update API user balance */ Balance::updateUserBalance($this->user, $satoshi_amount); /* send to to application the response! */ $response = $this->sendUrl($common_data, $satoshi_amount, TX_API_USER, $this->user->callback_url, $this->user->secret); // if we get back an *ok* from the script then update the transactions status Transaction::updateTxOnAppResponse($transaction_model, $response['app_response'], $response['callback_url'], $response['callback_status'], $response['external_user_id']); } else { /* bitcoind sent 2nd callback for the transaction which is 1st confirmation * no need to shoot to the application, since application is updating first confirmation anyway on block-notify */ Transaction::updateTxConfirmation($transaction_model, $common_data); } DB::commit(); }