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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ install:
- if [[ $LINUX && $GCC && $DYNAMIC ]]; then export CC=gcc-4.8; export CXX=g++-4.8; fi

# Download and install packages.
- if [[ $OSX && $CLANG && $DYNAMIC ]]; then brew install boost; fi
- if [[ $OSX && $CLANG && $DYNAMIC ]]; then brew install bash-completion; fi

script:
Expand Down
12 changes: 10 additions & 2 deletions data/bs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ threads = 0
protocol_maximum = 70013
# The minimum network protocol version, defaults to 31402.
protocol_minimum = 31402
# The services exposed by network connections, defaults to 1 (full node).
services = 1
# The services exposed by network connections, defaults to 9 (full node, witness).
services = 9
# The advertised services that cause a peer to be dropped, defaults to 160.
invalid_services = 160
# The magic number for message headers, defaults to 3652501241 (use 118034699 for testnet).
identifier = 3652501241
# Validate the checksum of network messages, defaults to false.
Expand Down Expand Up @@ -158,6 +160,12 @@ bip68 = true
bip112 = true
# Use median time past for locktime, defaults to true (soft fork).
bip113 = true
# Segregated witness consensus layer, defaults to true (soft fork).
bip141 = true
# Version 0 transaction digest, defaults to true (soft fork).
bip143 = true
# Prevent dummy value malleability, defaults to true (soft fork).
bip147 = true

[node]
# The time to wait for a requested block, defaults to 60.
Expand Down
4 changes: 4 additions & 0 deletions include/bitcoin/server/interface/blockchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class BCS_API blockchain
static void fetch_transaction(server_node& node,
const message& request, send_handler handler);

/// Fetch a transaction with witness from the blockchain by its hash.
static void fetch_transaction2(server_node& node,
const message& request, send_handler handler);

/// Fetch the current height of the blockchain.
static void fetch_last_height(server_node& node,
const message& request, send_handler handler);
Expand Down
4 changes: 4 additions & 0 deletions include/bitcoin/server/interface/transaction_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class BCS_API transaction_pool
static void fetch_transaction(server_node& node, const message& request,
send_handler handler);

/// Fetch a transaction with witness from tx pool (or chain), by its hash.
static void fetch_transaction2(server_node& node, const message& request,
send_handler handler);

/// Save to tx pool and announce to all connected peers.
static void broadcast(server_node& node, const message& request,
send_handler handler);
Expand Down
24 changes: 23 additions & 1 deletion src/interface/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,29 @@ void blockchain::fetch_transaction(server_node& node, const message& request,
const auto hash = deserial.read_hash();

// The response is restricted to confirmed transactions.
node.chain().fetch_transaction(hash, true,
// This response excludes witness data so as not to break old parsers.
node.chain().fetch_transaction(hash, true, false,
std::bind(&blockchain::transaction_fetched,
_1, _2, _3, _4, request, handler));
}

void blockchain::fetch_transaction2(server_node& node, const message& request,
send_handler handler)
{
const auto& data = request.data();

if (data.size() != hash_size)
{
handler(message(request, error::bad_stream));
return;
}

auto deserial = make_safe_deserializer(data.begin(), data.end());
const auto hash = deserial.read_hash();

// The response is restricted to confirmed transactions.
// This response includes witness data so may break old parsers.
node.chain().fetch_transaction(hash, true, true,
std::bind(&blockchain::transaction_fetched,
_1, _2, _3, _4, request, handler));
}
Expand Down
24 changes: 23 additions & 1 deletion src/interface/transaction_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,29 @@ void transaction_pool::fetch_transaction(server_node& node,
const auto hash = deserial.read_hash();

// The response allows confirmed and unconfirmed transactions.
node.chain().fetch_transaction(hash, false,
// This response excludes witness data so as not to break old parsers.
node.chain().fetch_transaction(hash, false, false,
std::bind(&transaction_pool::transaction_fetched,
_1, _2, _3, _4, request, handler));
}

void transaction_pool::fetch_transaction2(server_node& node,
const message& request, send_handler handler)
{
const auto& data = request.data();

if (data.size() != hash_size)
{
handler(message(request, error::bad_stream));
return;
}

auto deserial = make_safe_deserializer(data.begin(), data.end());
const auto hash = deserial.read_hash();

// The response allows confirmed and unconfirmed transactions.
// This response includes witness data so may break old parsers.
node.chain().fetch_transaction(hash, false, true,
std::bind(&transaction_pool::transaction_fetched,
_1, _2, _3, _4, request, handler));
}
Expand Down
28 changes: 25 additions & 3 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ parser::parser(const configuration& defaults)
parser::parser(bc::config::settings context)
: configured(context)
{
using serve = message::version::service;

// Logs will slow things if not rotated.
configured.network.rotation_size = 10000000;

Expand All @@ -58,8 +60,8 @@ parser::parser(bc::config::settings context)
// A node allows 1000 host names by default.
configured.network.host_pool_capacity = 1000;

// A node exposes full node (1) network services by default.
configured.network.services = message::version::service::node_network;
// Expose full node (1) and witness (8) network services by default.
configured.network.services = serve::node_network | serve::node_witness;

// TODO: set this independently on each public endpoint.
configured.protocol.message_size_limit = max_block_size + 100;
Expand Down Expand Up @@ -195,7 +197,12 @@ options_metadata parser::load_settings()
(
"network.services",
value<uint64_t>(&configured.network.services),
"The services exposed by network connections, defaults to 1 (full node)."
"The services exposed by network connections, defaults to 9 (full node, witness)."
)
(
"network.invalid_services",
value<uint64_t>(&configured.network.invalid_services),
"The advertised services that cause a peer to be dropped, defaults to 160."
)
(
"network.validate_checksum",
Expand Down Expand Up @@ -418,6 +425,21 @@ options_metadata parser::load_settings()
value<bool>(&configured.chain.bip113),
"Use median time past for locktime, defaults to true (soft fork)."
)
(
"fork.bip141",
value<bool>(&configured.chain.bip141),
"Segregated witness consensus layer, defaults to true (soft fork)."
)
(
"fork.bip143",
value<bool>(&configured.chain.bip143),
"Version 0 transaction digest, defaults to true (soft fork)."
)
(
"fork.bip147",
value<bool>(&configured.chain.bip147),
"Prevent dummy value malleability, defaults to true (soft fork)."
)

/* [node] */
////(
Expand Down
4 changes: 3 additions & 1 deletion src/workers/query_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void query_worker::attach_interface()
ATTACH(blockchain, fetch_block_transaction_hashes, node_); // original
ATTACH(blockchain, fetch_last_height, node_); // original
ATTACH(blockchain, fetch_transaction, node_); // original
ATTACH(blockchain, fetch_transaction2, node_); // new (3.4)
ATTACH(blockchain, fetch_transaction_index, node_); // original
ATTACH(blockchain, fetch_spend, node_); // original
ATTACH(blockchain, fetch_history3, node_); // new (3.1)
Expand All @@ -264,7 +265,8 @@ void query_worker::attach_interface()
ATTACH(blockchain, validate, node_); // new (3.0)

////ATTACH(transaction_pool, validate, node_); // obsoleted
ATTACH(transaction_pool, fetch_transaction, node_); // enhanced
ATTACH(transaction_pool, fetch_transaction, node_); // enhanced (3.0)
ATTACH(transaction_pool, fetch_transaction2, node_); // new (3.4)
ATTACH(transaction_pool, broadcast, node_); // new (3.0)
ATTACH(transaction_pool, validate2, node_); // new (3.0)

Expand Down