diff --git a/.gitignore b/.gitignore index 961498f4e1..7bfb5c1573 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ libbitcoin.pc bin obj +build .*.swp *~ /*.kdev4 @@ -24,4 +25,4 @@ obj /config.* /configure /libtool -.dirstamp \ No newline at end of file +.dirstamp diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..b80ace3238 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,32 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/obj/nix-gnu-debug-static-without_icu/libbitcoin-system-test", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}/obj/nix-gnu-debug-static-without_icu", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..a5fabbe22c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,35 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "cmake", + "label": "CMake: build", + "command": "build", + "targets": [ + "bitcoin-system", + "libbitcoin-system-examples", + "libbitcoin-system-test" + ], + "preset": "${command:cmake.activeBuildPresetName}", + "group": "build", + "problemMatcher": [], + "detail": "CMake template build task" + }, + { + "type": "cmake", + "label": "CMake: clean", + "command": "clean", + "preset": "${command:cmake.activeBuildPresetName}", + "problemMatcher": [], + "detail": "CMake template clean task" + }, + { + "type": "cmake", + "label": "CMake: install", + "command": "install", + "preset": "${command:cmake.activeBuildPresetName}", + "problemMatcher": [], + "detail": "CMake template install task" + } + ] +} \ No newline at end of file diff --git a/builds/cmake/CMakePresets.json b/builds/cmake/CMakePresets.json index fa9af03ec2..ec1922b973 100644 --- a/builds/cmake/CMakePresets.json +++ b/builds/cmake/CMakePresets.json @@ -5,7 +5,7 @@ "name": "nix-base", "description": "Factored base settings for non-windows *nix based platforms.", "hidden": true, - "installDir": "${sourceParentDir}/../../prefix/${presetName}", + "installDir": "${sourceParentDir}/../../../prefix/${presetName}", "binaryDir": "${sourceParentDir}/../obj/${presetName}", "condition": { "type": "inList", @@ -18,11 +18,11 @@ "cacheVariables": { "CMAKE_PREFIX_PATH": { "type": "PATH", - "value": "${sourceParentDir}/../../prefix/${presetName}" + "value": "${sourceParentDir}/../../../prefix/${presetName}" }, "CMAKE_LIBRARY_PATH": { "type": "PATH", - "value": "${sourceParentDir}/../../prefix/${presetName}/lib:$env{CMAKE_LIBRARY_PATH}" + "value": "${sourceParentDir}/../../../prefix/${presetName}/lib:$env{CMAKE_LIBRARY_PATH}" } } }, diff --git a/src/chain/block.cpp b/src/chain/block.cpp index 1bff491f9b..137bc055c7 100644 --- a/src/chain/block.cpp +++ b/src/chain/block.cpp @@ -217,8 +217,8 @@ const inputs_cptr block::inputs_ptr() const NOEXCEPT const auto inputs = std::make_shared(); const auto append_ins = [&inputs](const auto& tx) NOEXCEPT { - const auto& tx_ins = *tx->inputs_ptr(); - inputs->insert(inputs->end(), tx_ins.begin(), tx_ins.end()); + const auto& tx_ins = tx->inputs_ptr(); + inputs->insert(inputs->end(), tx_ins->begin(), tx_ins->end()); }; std::for_each(txs_->begin(), txs_->end(), append_ins); @@ -377,8 +377,8 @@ bool block::is_forward_reference() const NOEXCEPT const auto spend = [&spent, &hashes](const auto& tx) NOEXCEPT { - const auto& ins = *tx->inputs_ptr(); - const auto forward = std::any_of(ins.begin(), ins.end(), spent); + const auto& ins = tx->inputs_ptr(); + const auto forward = std::any_of(ins->begin(), ins->end(), spent); hashes.emplace(tx->get_hash(false)); return forward; }; @@ -410,8 +410,8 @@ bool block::is_internal_double_spend() const NOEXCEPT const auto double_spent = [&spent](const auto& tx) NOEXCEPT { - const auto& ins = *tx->inputs_ptr(); - return std::any_of(ins.begin(), ins.end(), spent); + const auto& ins = tx->inputs_ptr(); + return std::any_of(ins->begin(), ins->end(), spent); }; return std::any_of(tx1, txs_->end(), double_spent); @@ -472,10 +472,10 @@ bool block::is_hash_limit_exceeded() const NOEXCEPT { // Insert the transaction hash. hashes.emplace((*tx)->get_hash(false)); - const auto& inputs = *(*tx)->inputs_ptr(); + const auto& inputs = (*tx)->inputs_ptr(); // Insert all input point hashes. - for (const auto& input: inputs) + for (const auto& input: *inputs) hashes.emplace(input->point().hash()); } @@ -585,16 +585,16 @@ bool block::is_invalid_witness_commitment() const NOEXCEPT if (txs_->empty()) return false; - const auto& coinbase = *txs_->front(); - if (coinbase.inputs_ptr()->empty()) + const auto& coinbase = txs_->front(); + if (coinbase->inputs_ptr()->empty()) return false; // If there is a valid commitment, return false (valid). // Coinbase input witness must be 32 byte witness reserved value (bip141). // Last output of commitment pattern holds the committed value (bip141). hash_digest reserved{}, committed{}; - if (coinbase.inputs_ptr()->front()->reserved_hash(reserved)) - for (const auto& output: views_reverse(*coinbase.outputs_ptr())) + if (coinbase->inputs_ptr()->front()->reserved_hash(reserved)) + for (const auto& output: views_reverse(*coinbase->outputs_ptr())) if (output->committed_hash(committed)) if (committed == sha256::double_hash( generate_merkle_root(true), reserved)) diff --git a/src/chain/transaction.cpp b/src/chain/transaction.cpp index 488531738a..0e16255368 100644 --- a/src/chain/transaction.cpp +++ b/src/chain/transaction.cpp @@ -520,8 +520,7 @@ hash_digest transaction::outputs_hash() const NOEXCEPT stream::out::fast stream{ digest }; hash::sha256x2::fast sink{ stream }; - const auto& outs = *outputs_; - for (const auto& output: outs) + for (const auto& output: *outputs_) output->to_data(sink); sink.flush(); @@ -540,8 +539,7 @@ hash_digest transaction::points_hash() const NOEXCEPT stream::out::fast stream{ digest }; hash::sha256x2::fast sink{ stream }; - const auto& ins = *inputs_; - for (const auto& input: ins) + for (const auto& input: *inputs_) input->point().to_data(sink); sink.flush(); @@ -560,8 +558,7 @@ hash_digest transaction::sequences_hash() const NOEXCEPT stream::out::fast stream{ digest }; hash::sha256x2::fast sink{ stream }; - const auto& ins = *inputs_; - for (const auto& input: ins) + for (const auto& input: *inputs_) sink.write_4_bytes_little_endian(input->sequence()); sink.flush(); @@ -616,7 +613,6 @@ void transaction::signature_hash_single(writer& sink, const auto write_inputs = [this, &input, &sub, sighash_flags]( writer& sink) NOEXCEPT { - const auto& self = **input; const auto anyone = to_bool(sighash_flags & coverage::anyone_can_pay); input_cptrs::const_iterator in; @@ -629,9 +625,9 @@ void transaction::signature_hash_single(writer& sink, sink.write_bytes(zero_sequence()); } - self.point().to_data(sink); + (*input)->point().to_data(sink); sub.to_data(sink, prefixed); - sink.write_4_bytes_little_endian(self.sequence()); + sink.write_4_bytes_little_endian((*input)->sequence()); for (++in; !anyone && in != inputs_->end(); ++in) { @@ -668,7 +664,6 @@ void transaction::signature_hash_none(writer& sink, const auto write_inputs = [this, &input, &sub, sighash_flags]( writer& sink) NOEXCEPT { - const auto& self = **input; const auto anyone = to_bool(sighash_flags & coverage::anyone_can_pay); input_cptrs::const_iterator in; @@ -681,9 +676,9 @@ void transaction::signature_hash_none(writer& sink, sink.write_bytes(zero_sequence()); } - self.point().to_data(sink); + (*input)->point().to_data(sink); sub.to_data(sink, prefixed); - sink.write_4_bytes_little_endian(self.sequence()); + sink.write_4_bytes_little_endian((*input)->sequence()); for (++in; !anyone && in != inputs_->end(); ++in) { @@ -707,7 +702,6 @@ void transaction::signature_hash_all(writer& sink, const auto write_inputs = [this, &input, &sub, flags]( writer& sink) NOEXCEPT { - const auto& self = **input; const auto anyone = to_bool(flags & coverage::anyone_can_pay); input_cptrs::const_iterator in; @@ -720,9 +714,9 @@ void transaction::signature_hash_all(writer& sink, sink.write_4_bytes_little_endian((*in)->sequence()); } - self.point().to_data(sink); + (*input)->point().to_data(sink); sub.to_data(sink, prefixed); - sink.write_4_bytes_little_endian(self.sequence()); + sink.write_4_bytes_little_endian((*input)->sequence()); for (++in; !anyone && in != inputs_->end(); ++in) { @@ -849,7 +843,6 @@ hash_digest transaction::version_0_signature_hash(const input_iterator& input, const auto flag = mask_sighash(sighash_flags); const auto all = (flag == coverage::hash_all); const auto single = (flag == coverage::hash_single); - const auto& self = **input; // Create hash writer. BC_PUSH_WARNING(LOCAL_VARIABLE_NOT_INITIALIZED) @@ -871,10 +864,10 @@ hash_digest transaction::version_0_signature_hash(const input_iterator& input, // sequences sink.write_bytes(!anyone && all ? sequences_hash() : null_hash); - self.point().to_data(sink); + (*input)->point().to_data(sink); sub.to_data(sink, prefixed); sink.write_little_endian(value); - sink.write_little_endian(self.sequence()); + sink.write_little_endian((*input)->sequence()); // outputs if (single) diff --git a/test/wallet/neutrino_filter.cpp b/test/wallet/neutrino_filter.cpp index d2bf212efe..239bd098a1 100644 --- a/test/wallet/neutrino_filter.cpp +++ b/test/wallet/neutrino_filter.cpp @@ -62,13 +62,13 @@ bool add_metadata(const prevout_data::list& metadata, const chain::block& block) for (auto& meta: metadata) { result = false; - const auto& txs = *block.transactions_ptr(); - for (const auto& tx: txs) + const auto& txs = block.transactions_ptr(); + for (const auto& tx: *txs) { if (tx->hash(false) == meta.block_tx) { - auto& inputs = *tx->inputs_ptr(); - auto& output = inputs[meta.input_index]->prevout; + auto& inputs = tx->inputs_ptr(); + auto& output = (*inputs)[meta.input_index]->prevout; output = to_shared(meta.output_value, chain::script{ meta.script, false }); result = true;