Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/protocols/electrum/protocol_electrum_fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ void protocol_electrum::handle_blockchain_estimate_fee(const code& ec,
}

// TODO: integrate fee estimator.
send_code(error::not_implemented);
////send_code(error::not_implemented);

// If not enough information to make an estimate, -1 is returned.
send_result(-1, 42, BIND(complete, _1));
}

void protocol_electrum::handle_blockchain_relay_fee(const code& ec,
Expand Down
6 changes: 3 additions & 3 deletions src/protocols/electrum/protocol_electrum_headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,10 @@ void protocol_electrum::do_height(node::header_t link) NOEXCEPT
return;
}

// BUGBUG: Electrum expects a single value param (invalid json-rpc).
// We don't support sending invalid rpc, so this is offered only as array.
// Electrum expects singleton params (invalid json-rpc). This is enabled
// via the relaxed rpc model which accepts a value_t "params" value.
// electrum.readthedocs.io/en/latest/protocol.html#blockchain-numblocks-subscribe
send_notification("blockchain.numblocks.subscribe", array_t
send_notification("blockchain.numblocks.subscribe", value_t
{
height.value
}, 48, BIND(complete, _1));
Expand Down
8 changes: 3 additions & 5 deletions src/protocols/electrum/protocol_electrum_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ using namespace std::placeholders;

BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

// NOTE: undocumented change in v1.6 (mempool txs have a canonical ordering).

void protocol_electrum::handle_mempool_get_fee_histogram(const code& ec,
rpc_interface::mempool_get_fee_histogram) NOEXCEPT
{
Expand All @@ -44,9 +42,9 @@ void protocol_electrum::handle_mempool_get_fee_histogram(const code& ec,
return;
}

// TODO: Empty array (of tuples), could be simulated with block fees.
////send_result(array_t{}, 42, BIND(complete, _1));
send_code(error::not_implemented);
// TODO: could be simulated with block fees.
send_result(array_t{}, 42, BIND(complete, _1));
////send_code(error::not_implemented);
}

void protocol_electrum::handle_mempool_get_info(const code& ec,
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/electrum/protocol_electrum_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ using namespace std::placeholders;

BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

// BUGBUG: Electrum sends a single value param (invalid json-rpc).
// We don't support receiving invalid rpc, so requires array or object syntax.
// Electrum sends a single value param (invalid json-rpc). This is enabled via
// the lax json-rpc body value !strict option, mapping the singleton to array.
void protocol_electrum::handle_blockchain_transaction_broadcast(const code& ec,
rpc_interface::blockchain_transaction_broadcast,
const std::string& raw_tx) NOEXCEPT
Expand Down
14 changes: 7 additions & 7 deletions test/protocols/electrum/electrum_fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_estimate_fee__mode_invalid_version__in
BOOST_REQUIRE_EQUAL(result, invalid_argument.value());
}

BOOST_AUTO_TEST_CASE(electrum__blockchain_estimate_fee__valid__not_implemented)
{
BOOST_REQUIRE(handshake(electrum::version::v1_6));

const auto result = get_error(R"({"id":801,"method":"blockchain.estimatefee","params":[42,"mode"]})" "\n");
BOOST_REQUIRE_EQUAL(result, not_implemented.value());
}
////BOOST_AUTO_TEST_CASE(electrum__blockchain_estimate_fee__valid__not_implemented)
////{
//// BOOST_REQUIRE(handshake(electrum::version::v1_6));
////
//// const auto result = get_error(R"({"id":801,"method":"blockchain.estimatefee","params":[42,"mode"]})" "\n");
//// BOOST_REQUIRE_EQUAL(result, not_implemented.value());
////}

// blockchain.relayfee

Expand Down
16 changes: 6 additions & 10 deletions test/protocols/electrum/electrum_headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,15 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_number_of_blocks_subscribe__notificati

const auto notification1 = receive();
REQUIRE_NO_THROW_TRUE(notification1.at("method").is_string());
REQUIRE_NO_THROW_TRUE(notification1.at("params").is_array());
REQUIRE_NO_THROW_TRUE(notification1.at("params").is_int64());
BOOST_REQUIRE_EQUAL(notification1.at("method").as_string(), "blockchain.numblocks.subscribe");

const auto& params1 = notification1.at("params").as_array();
BOOST_REQUIRE_EQUAL(params1.size(), 1u);
BOOST_REQUIRE(params1.at(0).is_int64());
BOOST_CHECK_EQUAL(params1.at(0).as_int64(), 10);
BOOST_CHECK_EQUAL(notification1.at("params").as_int64(), 10);

const auto notification2 = receive();
const auto& params2 = notification2.at("params").as_array();
BOOST_REQUIRE_EQUAL(params2.size(), 1u);
BOOST_REQUIRE(params2.at(0).is_int64());
BOOST_CHECK_EQUAL(params2.at(0).as_int64(), 11);
REQUIRE_NO_THROW_TRUE(notification2.at("method").is_string());
REQUIRE_NO_THROW_TRUE(notification2.at("params").is_int64());
BOOST_REQUIRE_EQUAL(notification2.at("method").as_string(), "blockchain.numblocks.subscribe");
BOOST_CHECK_EQUAL(notification2.at("params").as_int64(), 11);
}

// blockchain.block.get_chunk
Expand Down
14 changes: 7 additions & 7 deletions test/protocols/electrum/electrum_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ BOOST_AUTO_TEST_CASE(electrum__mempool_get_fee_histogram__extra_param__dropped)
REQUIRE_NO_THROW_TRUE(response.at("dropped").as_bool());
}

BOOST_AUTO_TEST_CASE(electrum__mempool_get_fee_histogram__empty_params__not_implemented)
{
BOOST_REQUIRE(handshake(electrum::version::v1_2));

const auto result = get_error(R"({"id":603,"method":"mempool.get_fee_histogram","params":[]})" "\n");
BOOST_REQUIRE_EQUAL(result, not_implemented.value());
}
////BOOST_AUTO_TEST_CASE(electrum__mempool_get_fee_histogram__empty_params__not_implemented)
////{
//// BOOST_REQUIRE(handshake(electrum::version::v1_2));
////
//// const auto result = get_error(R"({"id":603,"method":"mempool.get_fee_histogram","params":[]})" "\n");
//// BOOST_REQUIRE_EQUAL(result, not_implemented.value());
////}

// mempool.get_info

Expand Down
Loading