From fc7ce0e8093a5f37de7082702fe959931ac44c04 Mon Sep 17 00:00:00 2001 From: genjix Date: Sun, 22 Apr 2012 14:12:32 +0100 Subject: [PATCH] handle invalid address, and address with no activity --- backends/libbitcoin/h1.py | 7 +++++-- backends/libbitcoin/history.cpp | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backends/libbitcoin/h1.py b/backends/libbitcoin/h1.py index 460ba53..6a49710 100644 --- a/backends/libbitcoin/h1.py +++ b/backends/libbitcoin/h1.py @@ -1,5 +1,6 @@ import bitcoin import history1 as history +import membuf def blockchain_started(ec, chain): print "Blockchain initialisation:", ec @@ -16,7 +17,9 @@ a = bitcoin.async_service(1) chain = bitcoin.bdb_blockchain(a, "/home/genjix/libbitcoin/database", blockchain_started) txpool = bitcoin.transaction_pool(a, chain) -address = "1FpES68UNcxnXeoaFciqvUSGiKGZ33gbfQ" -history.payment_history(a, chain, txpool, address, finish) +mbuff = membuf.memory_buffer(a.internal_ptr, chain.internal_ptr, + txpool.internal_ptr) +address = "132nrVeRYd99TEx3y4Lu87wjkEzkh3CoJJ" +history.payment_history(a, chain, txpool, mbuff, address, finish) raw_input() diff --git a/backends/libbitcoin/history.cpp b/backends/libbitcoin/history.cpp index a1b5bbc..4baaa84 100644 --- a/backends/libbitcoin/history.cpp +++ b/backends/libbitcoin/history.cpp @@ -77,7 +77,12 @@ public: void start(const std::string& address, finish_handler handle_finish) { - address_.set_encoded(address); + if (!address_.set_encoded(address)) + { + handle_finish(make_error_code(std::errc::address_not_available), + statement_entry()); + return; + } handle_finish_ = handle_finish; chain_->fetch_outputs(address_, strand_.wrap(std::bind(&query_history::start_loading, @@ -107,6 +112,11 @@ private: { if (stop_on_error(ec)) return; + else if (outpoints.empty()) + { + handle_finish_(std::error_code(), statement_entry()); + return; + } for (auto outpoint: outpoints) { auto entry = std::make_shared(); -- 1.7.1