@@ -55,7 +55,7 @@ void protocol_explore::start() NOEXCEPT
5555 // //SUBSCRIBE_EXPLORE(handle_get_filter, _1, _2, _3, _4, _5, _6);
5656 // //SUBSCRIBE_EXPLORE(handle_get_block_txs, _1, _2, _3, _4, _5, _6);
5757 // //SUBSCRIBE_EXPLORE(handle_get_block_tx, _1, _2, _3, _4, _5, _6, _7, _8);
58- // // SUBSCRIBE_EXPLORE(handle_get_transaction, _1, _2, _3, _4, _5, _6);
58+ SUBSCRIBE_EXPLORE (handle_get_transaction, _1, _2, _3, _4, _5, _6);
5959 // //SUBSCRIBE_EXPLORE(handle_get_address, _1, _2, _3, _4, _5);
6060 // //SUBSCRIBE_EXPLORE(handle_get_input, _1, _2, _3, _4, _5, _6, _7);
6161 // //SUBSCRIBE_EXPLORE(handle_get_input_script, _1, _2, _3, _4, _5, _6);
@@ -171,6 +171,41 @@ bool protocol_explore::handle_get_header(const code& ec, interface::header,
171171 return true ;
172172}
173173
174+ bool protocol_explore::handle_get_transaction (const code& ec,
175+ interface::transaction, uint8_t , uint8_t media, system::hash_cptr hash,
176+ bool witness) NOEXCEPT
177+ {
178+ BC_ASSERT (stranded ());
179+
180+ if (stopped (ec))
181+ return false ;
182+
183+ const auto & query = archive ();
184+
185+ // TODO: there's no request.
186+ const network::http::request request{};
187+
188+ if (const auto ptr = query.get_transaction (query.to_tx (*hash), witness))
189+ {
190+ switch (media)
191+ {
192+ case to_value (media_type::application_octet_stream):
193+ send_data (request, ptr->to_data (witness));
194+ return true ;
195+ case to_value (media_type::text_plain):
196+ send_text (request, encode_base16 (ptr->to_data (witness)));
197+ return true ;
198+ case to_value (media_type::application_json):
199+ send_json (request, value_from (ptr),
200+ ptr->serialized_size (witness));
201+ return true ;
202+ }
203+ }
204+
205+ send_not_found (request);
206+ return true ;
207+ }
208+
174209BC_POP_WARNING ()
175210
176211#undef SUBSCRIBE_EXPLORE
0 commit comments