@@ -181,41 +181,30 @@ bool protocol_electrum::send_get_status(const std::string& tx_hash,
181181 }
182182
183183 const auto & query = archive ();
184- const auto tx = query.to_tx (hash);
185- const auto output = query.to_output (tx, index);
186- if (output.is_terminal ())
184+ const auto out = query.get_tx_history (hash);
185+ if (!out.tx .is_valid ())
187186 {
188187 send_code (error::not_found);
189188 return false ;
190189 }
191190
192- // TODO: database query.///////////////////////////////////////////////////
193- size_t height{ database::history::rooted_height };
194- if (const auto block = query.find_confirmed_block (tx); block.is_terminal ())
195- {
196- if (!query.is_confirmed_all_prevouts (tx))
197- height = database::history::unrooted_height;
198- }
199- else if (!query.get_height (height, block))
191+ if (const auto ins = query.get_spenders_history (hash, index); ins.empty ())
200192 {
201- send_code (error::server_error);
202- return false ;
193+ send_result (object_t
194+ {
195+ { " height" , to_unsigned (out.tx .height ()) }
196+ } , 64 , BIND (complete, _1));
203197 }
204- // /////////////////////////////////////////////////////////////////////////
205-
206- // TODO: query tx spenders sorted history./////////////////////////////////
207- const database::histories spenders{};
208- // /////////////////////////////////////////////////////////////////////////
209-
210- auto result = object_t { { " height" , to_unsigned (height) } };
211- if (!spenders.empty ())
198+ else
212199 {
213- const auto & spender = spenders.front ().tx ;
214- result[" spender_txhash" ] = encode_hash (spender.hash ());
215- result[" spender_height" ] = to_unsigned (spender.height ());
200+ send_result (object_t
201+ {
202+ { " height" , to_unsigned (out.tx .height ()) },
203+ { " spender_txhash" , encode_hash (ins.front ().tx .hash ()) },
204+ { " spender_height" , to_unsigned (ins.front ().tx .height ()) }
205+ }, 128 , BIND (complete, _1));
216206 }
217207
218- send_result (std::move (result), 128 , BIND (complete, _1));
219208 return true ;
220209}
221210
0 commit comments