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
6 changes: 6 additions & 0 deletions include/bitcoin/client/proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class BCC_API proxy
typedef std::function<void(const chain::stealth::list&)> stealth_handler;
typedef std::function<void(const chain::transaction&)> transaction_handler;
typedef std::function<void(const chain::point::indexes&)> validate_handler;
typedef std::function<void(const chain::points_info&)> points_info_handler;


// Fetchers.
Expand Down Expand Up @@ -98,6 +99,11 @@ class BCC_API proxy
history_handler on_reply, const wallet::payment_address& address,
uint32_t from_height=0);

void address_fetch_unspent_outputs(error_handler on_error,
points_info_handler on_reply, const wallet::payment_address& address,
const uint64_t satoshi,
const wallet::select_outputs::algorithm algorithm);

// Subscribers.
//-------------------------------------------------------------------------

Expand Down
33 changes: 33 additions & 0 deletions src/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,39 @@ void proxy::address_fetch_history2(error_handler on_error,
_1, std::move(on_reply)));
}

void proxy::address_fetch_unspent_outputs(error_handler on_error,
points_info_handler on_reply, const wallet::payment_address& address,
const uint64_t satoshi, const wallet::select_outputs::algorithm algorithm)
{
static constexpr uint32_t from_height = 0;

const auto data = build_chunk(
{
to_array(address.version()),
address.hash(),
to_little_endian<uint32_t>(from_height)
});

history_handler parse_history = [on_reply, satoshi, algorithm](
const chain::history::list& rows)
{
chain::output_info::list unspent;
for(auto& row : rows)
if (row.spend.hash == null_hash)
unspent.push_back({row.output, row.value});

chain::points_info selected_utxos;
wallet::select_outputs::select(
selected_utxos, unspent, satoshi, algorithm);

on_reply(selected_utxos);
};

send_request("address.fetch_history2", data, std::move(on_error),
std::bind(decode_history,
_1, std::move(parse_history)));
}

// Subscribers.
//-----------------------------------------------------------------------------

Expand Down