@@ -64,8 +64,13 @@ void protocol_electrum::start() NOEXCEPT
6464 SUBSCRIBE_RPC (handle_blockchain_estimate_fee, _1, _2, _3, _4);
6565 SUBSCRIBE_RPC (handle_blockchain_relay_fee, _1, _2);
6666
67- // Address methods.
67+ // Output methods.
6868 SUBSCRIBE_RPC (handle_blockchain_utxo_get_address, _1, _2, _3, _4);
69+ SUBSCRIBE_RPC (handle_blockchain_outpoint_get_status, _1, _2, _3, _4, _5);
70+ SUBSCRIBE_RPC (handle_blockchain_outpoint_subscribe, _1, _2, _3, _4, _5);
71+ SUBSCRIBE_RPC (handle_blockchain_outpoint_unsubscribe, _1, _2, _3, _4);
72+
73+ // Address methods.
6974 SUBSCRIBE_RPC (handle_blockchain_address_get_balance, _1, _2, _3);
7075 SUBSCRIBE_RPC (handle_blockchain_address_get_history, _1, _2, _3);
7176 SUBSCRIBE_RPC (handle_blockchain_address_get_mempool, _1, _2, _3);
@@ -80,6 +85,14 @@ void protocol_electrum::start() NOEXCEPT
8085 SUBSCRIBE_RPC (handle_blockchain_scripthash_subscribe, _1, _2, _3);
8186 SUBSCRIBE_RPC (handle_blockchain_scripthash_unsubscribe, _1, _2, _3);
8287
88+ // Scriptpubkey methods.
89+ SUBSCRIBE_RPC (handle_blockchain_scriptpubkey_get_balance, _1, _2, _3);
90+ SUBSCRIBE_RPC (handle_blockchain_scriptpubkey_get_history, _1, _2, _3);
91+ SUBSCRIBE_RPC (handle_blockchain_scriptpubkey_get_mempool, _1, _2, _3);
92+ SUBSCRIBE_RPC (handle_blockchain_scriptpubkey_list_unspent, _1, _2, _3);
93+ SUBSCRIBE_RPC (handle_blockchain_scriptpubkey_subscribe, _1, _2, _3);
94+ SUBSCRIBE_RPC (handle_blockchain_scriptpubkey_unsubscribe, _1, _2, _3);
95+
8396 // Transaction methods.
8497 SUBSCRIBE_RPC (handle_blockchain_transaction_broadcast, _1, _2, _3);
8598 SUBSCRIBE_RPC (handle_blockchain_transaction_broadcast_package, _1, _2, _3, _4);
@@ -144,11 +157,29 @@ bool protocol_electrum::handle_event(const code&, node::chase event_,
144157 case node::chase::spent:
145158 case node::chase::received:
146159 {
160+ if (subscribed_outpoint_.load (relaxed))
161+ {
162+ BC_ASSERT (std::holds_alternative<node::address_t >(value));
163+ POST (do_outpoint, std::get<node::address_t >(value));
164+ }
165+
147166 if (subscribed_address_.load (relaxed))
148167 {
149168 BC_ASSERT (std::holds_alternative<node::address_t >(value));
150169 POST (do_address, std::get<node::address_t >(value));
151170 }
171+
172+ if (subscribed_scripthash_.load (relaxed))
173+ {
174+ BC_ASSERT (std::holds_alternative<node::address_t >(value));
175+ POST (do_scripthash, std::get<node::address_t >(value));
176+ }
177+
178+ if (subscribed_scriptpubkey_.load (relaxed))
179+ {
180+ BC_ASSERT (std::holds_alternative<node::address_t >(value));
181+ POST (do_scriptpubkey, std::get<node::address_t >(value));
182+ }
152183 }
153184 default :
154185 {
@@ -205,6 +236,19 @@ void protocol_electrum::do_header(node::header_t link) NOEXCEPT
205236 }, 64 , BIND (complete, _1));
206237}
207238
239+ // Notifier for blockchain_outpoint_subscribe events.
240+ void protocol_electrum::do_outpoint (node::address_t ) NOEXCEPT
241+ {
242+ chain::point point{};
243+
244+ // TODO: compute and return outpont status from a store query.
245+ send_notification (" blockchain.outpoint.subscribe" , array_t
246+ {
247+ array_t { encode_hash (point.hash ()), point.index () },
248+ object_t {}
249+ }, 128 , BIND (handle_send, _1));
250+ }
251+
208252// This struct is small and stack allocated (208 bytes).
209253// Writer holds stream ref to status and midstate via accumulator.
210254// Writer flush rewrites status via stream and resets accumulator.
@@ -218,7 +262,6 @@ struct midstate
218262};
219263
220264// Notifier for blockchain_address_subscribe events.
221- // Notifier for blockchain_scripthash_unsubscribe events.
222265void protocol_electrum::do_address (node::address_t ) NOEXCEPT
223266{
224267 std::string status_hash{};
@@ -229,13 +272,42 @@ void protocol_electrum::do_address(node::address_t ) NOEXCEPT
229272
230273 // EXAMPLE
231274 // script_hash is a payment address for address.
232- // //send_notification("blockchain.address.subscribe", array_t
275+ send_notification (" blockchain.address.subscribe" , array_t
276+ {
277+ script_hash,
278+ status_hash
279+ }, 128 , BIND (handle_send, _1));
280+ }
281+
282+ // Notifier for blockchain_scripthash_subscribe events.
283+ void protocol_electrum::do_scripthash (node::address_t ) NOEXCEPT
284+ {
285+ std::string status_hash{};
286+ std::string script_hash{};
287+
288+ // EXAMPLE
289+ // script_hash is a payment address for address.
233290 send_notification (" blockchain.scripthash.subscribe" , array_t
234291 {
235292 script_hash,
236293 status_hash
237294 }, 128 , BIND (handle_send, _1));
238295}
239296
297+ // Notifier for blockchain_scriptpubkey_subscribe events.
298+ void protocol_electrum::do_scriptpubkey (node::address_t ) NOEXCEPT
299+ {
300+ std::string status_hash{};
301+ std::string script_hash{};
302+
303+ // EXAMPLE
304+ // script_hash is a payment address for address.
305+ send_notification (" blockchain.scriptpubkey.subscribe" , array_t
306+ {
307+ script_hash,
308+ status_hash
309+ }, 128 , BIND (handle_send, _1));
310+ }
311+
240312} // namespace server
241313} // namespace libbitcoin
0 commit comments