From 0d49e4d0c857d32f32ce0d202e20d020dadde354 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Fri, 21 Dec 2018 16:53:55 +0100 Subject: [PATCH] Claim address in tx page --- src/Controller/MainController.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index b484c32..0d405da 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -362,18 +362,19 @@ class MainController extends AppController { } $outputs = $this->Outputs->find()->select($this->Outputs)->select(['spend_input_hash' => 'I.transaction_hash', 'spend_input_id' => 'I.id'])->where(['Outputs.transaction_id' => $tx->id])->leftJoin(['I' => 'input'], ['I.id = Outputs.spent_by_input_id'])->order(['Outputs.vout' => 'asc'])->toArray(); - for ($i = 0; $i < count($outputs); $i++) { - debug($outputs[$i]); - $output_address = trim($outputs[$i]->address_list, '[""]'); - debug($output_address); - $address = $this->Addresses->find()->select(['address'])->where(['address' => $output_address])->first(); - $outputs[$i]->output_addresses = [$address]; - + for ($i = 0; $i < count($outputs); $i++) { $outputs[$i]->IsClaim = (strpos($outputs[$i]->script_pub_key_asm, 'CLAIM') > -1); $outputs[$i]->IsSupportClaim = (strpos($outputs[$i]->script_pub_key_asm, 'SUPPORT_CLAIM') > -1); $outputs[$i]->IsUpdateClaim = (strpos($outputs[$i]->script_pub_key_asm, 'UPDATE_CLAIM') > -1); - $claim = $this->Claims->find()->select(['id', 'claim_id', 'vout', 'transaction_hash_id'])->where(['transaction_hash_id' => $tx->hash, 'vout' => $outputs[$i]->vout])->first(); + $claim = $this->Claims->find()->select(['id', 'claim_id', 'claim_address', 'vout', 'transaction_hash_id'])->where(['transaction_hash_id' => $tx->hash, 'vout' => $outputs[$i]->vout])->first(); $outputs[$i]->Claim = $claim; + + $output_address = trim($outputs[$i]->address_list, '[""]'); + if(!$output_address && $claim) { + $output_address = $claim->claim_address; + } + $address = $this->Addresses->find()->select(['address'])->where(['address' => $output_address])->first(); + $outputs[$i]->output_addresses = [$address]; } $totalIn = 0;