Skip to content

Commit 31a53eb

Browse files
authored
Merge pull request #12 from alexanderwiederin/btck_api
Refactor: Adapt to btckApi changes and implement Rust idioms
2 parents cd3c5a8 + a532d37 commit 31a53eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4705
-3927
lines changed

examples/src/silentpaymentscanner.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,22 @@ fn scan_tx(receiver: &Receiver, secret_scan_key: &SecretKey, scan_tx_helper: Sca
162162

163163
fn scan_txs(chainman: &ChainstateManager) {
164164
let (receiver, secret_scan_key) = parse_keys();
165-
let mut block_index = chainman.get_block_index_tip();
165+
let mut block_index = chainman.block_index_tip();
166166
loop {
167167
if block_index.height() <= 1 {
168168
break;
169169
}
170-
let undo = chainman.read_undo_data(&block_index).unwrap();
170+
let spent_outputs = chainman.read_spent_outputs(&block_index).unwrap();
171171
let raw_block: Vec<u8> = chainman.read_block_data(&block_index).unwrap().into();
172172
let block: bitcoin::Block = deserialize(&raw_block).unwrap();
173173
// Should be the same size minus the coinbase transaction
174-
assert_eq!(block.txdata.len() - 1, undo.n_tx_undo);
174+
assert_eq!(block.txdata.len() - 1, spent_outputs.count());
175175

176176
for i in 0..(block.txdata.len() - 1) {
177-
let transaction_undo_size: u64 = undo.get_transaction_undo_size(i.try_into().unwrap());
178-
let transaction_input_size: u64 = block.txdata[i + 1].input.len().try_into().unwrap();
179-
assert_eq!(transaction_input_size, transaction_undo_size);
177+
let tx_spent_outputs = spent_outputs.transaction_spent_outputs(i).unwrap();
178+
let coins_spent_count = tx_spent_outputs.count();
179+
let transaction_input_size = block.txdata[i + 1].input.len();
180+
assert_eq!(transaction_input_size, coins_spent_count);
180181
let mut scan_tx_helper = ScanTxHelper {
181182
ins: vec![],
182183
outs: block.txdata[i + 1]
@@ -186,21 +187,18 @@ fn scan_txs(chainman: &ChainstateManager) {
186187
.collect(),
187188
};
188189
for j in 0..transaction_input_size {
190+
let coin = tx_spent_outputs.coin(j).unwrap();
189191
scan_tx_helper.ins.push(Input {
190-
prevout: undo
191-
.get_prevout_by_index(i as u64, j)
192-
.unwrap()
193-
.get_script_pubkey()
194-
.get(),
195-
script_sig: block.txdata[i + 1].input[j as usize].script_sig.to_bytes(),
196-
witness: block.txdata[i + 1].input[j as usize].witness.to_vec(),
192+
prevout: coin.output().unwrap().script_pubkey().to_bytes(),
193+
script_sig: block.txdata[i + 1].input[j].script_sig.to_bytes(),
194+
witness: block.txdata[i + 1].input[j].witness.to_vec(),
197195
prevout_data: (
198-
block.txdata[i + 1].input[j as usize]
196+
block.txdata[i + 1].input[j]
199197
.previous_output
200198
.txid
201199
.to_byte_array()
202200
.to_vec(),
203-
block.txdata[i + 1].input[j as usize].previous_output.vout,
201+
block.txdata[i + 1].input[j].previous_output.vout,
204202
),
205203
});
206204
}
@@ -229,7 +227,6 @@ fn main() {
229227
let blocks_dir = data_dir.clone() + "/blocks";
230228
let chainman = ChainstateManager::new(
231229
ChainstateManagerOptions::new(&context, &data_dir, &blocks_dir).unwrap(),
232-
Arc::clone(&context),
233230
)
234231
.unwrap();
235232
chainman.import_blocks().unwrap();

fuzz/fuzz_targets/fuzz_target_chainman.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fuzz_target!(|data: ChainstateManagerInput| {
9191
.set_block_tree_db_in_memory(data.block_tree_db_in_memory)
9292
.set_chainstate_db_in_memory(data.chainstate_db_in_memory);
9393
chainman_opts.set_worker_threads(data.worker_threads);
94-
let chainman = match ChainstateManager::new(chainman_opts, Arc::clone(&context)) {
94+
let chainman = match ChainstateManager::new(chainman_opts) {
9595
Err(KernelError::Internal(_)) => {
9696
return;
9797
}

fuzz/fuzz_targets/fuzz_target_verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct VerifyInput {
1616
pub script_pubkey: Vec<u8>,
1717
pub amount: Option<i64>,
1818
pub tx_to: Vec<u8>,
19-
pub input_index: u32,
19+
pub input_index: usize,
2020
pub flags: Option<u32>,
2121
pub spent_outputs: Vec<UtxoWrapper>,
2222
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[main]
22
host = https://www.transifex.com
33

4-
[o:bitcoin:p:bitcoin:r:qt-translation-029x]
4+
[o:bitcoin:p:bitcoin:r:qt-translation-030x]
55
file_filter = src/qt/locale/bitcoin_<lang>.xlf
66
source_file = src/qt/locale/bitcoin_en.xlf
77
source_lang = en

libbitcoinkernel-sys/bitcoin/ci/lint/01_install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ ${CI_RETRY_EXE} pip3 install \
4646
ruff==0.5.5 \
4747
vulture==2.6
4848

49-
SHELLCHECK_VERSION=v0.8.0
49+
SHELLCHECK_VERSION=v0.11.0
5050
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | \
5151
tar --xz -xf - --directory /tmp/
5252
mv "/tmp/shellcheck-${SHELLCHECK_VERSION}/shellcheck" /usr/bin/
5353

54-
MLC_VERSION=v0.19.0
54+
MLC_VERSION=v1
5555
MLC_BIN=mlc-x86_64-linux
5656
curl -sL "https://github.com/becheran/mlc/releases/download/${MLC_VERSION}/${MLC_BIN}" -o "/usr/bin/mlc"
5757
chmod +x /usr/bin/mlc

libbitcoinkernel-sys/bitcoin/ci/test/03_test_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ if [ "$RUN_UNIT_TESTS" = "true" ]; then
163163
fi
164164

165165
if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
166-
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${BASE_OUTDIR}"/bin/test_bitcoin --catch_system_errors=no -l test_suite
166+
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${BASE_BUILD_DIR}"/bin/test_bitcoin --catch_system_errors=no -l test_suite
167167
fi
168168

169169
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then

libbitcoinkernel-sys/bitcoin/cmake/module/InstallBinaryComponent.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ include(GNUInstallDirs)
77

88
function(install_binary_component component)
99
cmake_parse_arguments(PARSE_ARGV 1
10-
IC # prefix
11-
"HAS_MANPAGE" # options
12-
"" # one_value_keywords
13-
"" # multi_value_keywords
10+
IC # prefix
11+
"HAS_MANPAGE;INTERNAL" # options
12+
"" # one_value_keywords
13+
"" # multi_value_keywords
1414
)
1515
set(target_name ${component})
16+
if(IC_INTERNAL)
17+
set(runtime_dest ${CMAKE_INSTALL_LIBEXECDIR})
18+
else()
19+
set(runtime_dest ${CMAKE_INSTALL_BINDIR})
20+
endif()
1621
install(TARGETS ${target_name}
17-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
22+
RUNTIME DESTINATION ${runtime_dest}
1823
COMPONENT ${component}
1924
)
2025
if(INSTALL_MAN AND IC_HAS_MANPAGE)

libbitcoinkernel-sys/bitcoin/contrib/guix/libexec/codesign.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mkdir -p "$DISTSRC"
110110

111111
# Apply detached codesignatures (in-place)
112112
signapple apply dist/Bitcoin-Qt.app codesignatures/osx/"${HOST}"/dist/Bitcoin-Qt.app
113-
find "${DISTNAME}" -wholename "*/bin/*" -type f | while read -r bin
113+
find "${DISTNAME}" \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f | while read -r bin
114114
do
115115
signapple apply "${bin}" "codesignatures/osx/${HOST}/${bin}.${ARCH}sign"
116116
done

libbitcoinkernel-sys/bitcoin/contrib/macdeploy/detached-sig-create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ${SIGNAPPLE} apply "${UNSIGNED_BUNDLE}" "${OUTROOT}/${BUNDLE_ROOT}/${BUNDLE_NAME
4444
${SIGNAPPLE} notarize --detach "${OUTROOT}/${BUNDLE_ROOT}" --passphrase "${api_key_pass}" "$2" "$3" "${UNSIGNED_BUNDLE}"
4545

4646
# Sign each binary
47-
find . -maxdepth 3 -wholename "*/bin/*" -type f -exec realpath --relative-to=. {} \; | while read -r bin
47+
find . -maxdepth 3 \( -wholename "*/bin/*" -o -wholename "*/libexec/*" \) -type f -exec realpath --relative-to=. {} \; | while read -r bin
4848
do
4949
bin_dir=$(dirname "${bin}")
5050
bin_name=$(basename "${bin}")

libbitcoinkernel-sys/bitcoin/doc/files.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
- [Berkeley DB database based wallets](#berkeley-db-database-based-wallets)
1818

19-
- [Notes](#notes)
19+
- [Installed Files](#installed-files)
2020

2121
## Data directory location
2222

@@ -83,7 +83,7 @@ Wallets are SQLite databases.
8383

8484
3. A wallet database path can be specified with the `-wallet` option.
8585

86-
4. `wallet.dat` files must not be shared across different node instances, as that can result in key-reuse and double-spends due the lack of synchronization between instances.
86+
4. `wallet.dat` files must not be shared across different node instances, as that can result in key-reuse and double-spends due to the lack of synchronization between instances.
8787

8888
5. Any copy or backup of the wallet should be done through a `backupwallet` call in order to update and lock the wallet, preventing any file corruption caused by updates during the copy.
8989

@@ -123,8 +123,40 @@ Subdirectory | File(s) | Description
123123
`./` | `wallet.dat` | Personal wallet (a BDB database) with keys and transactions
124124
`./` | `.walletlock` | BDB wallet lock file
125125

126-
## Notes
126+
### Notes
127127

128128
<a name="note1">1</a>. The `/` (slash, U+002F) is used as the platform-independent path component separator in this document.
129129

130130
<a name="note2">2</a>. `NNNNN` matches `[0-9]{5}` regex.
131+
132+
## Installed Files
133+
134+
This table describes the files installed by Bitcoin Core across different platforms.
135+
136+
| **Path** | **Description** |
137+
|------------------------------------------------------------|-----------------------------------------------------------------------------|
138+
| [README.md](README.md) or [readme.txt](README_windows.txt) | Project information and instructions |
139+
| bitcoin.conf | [Generated](../contrib/devtools/gen-bitcoin-conf.sh) configuration file |
140+
| bin/bitcoin | Command-line tool for interacting with Bitcoin. Calls other binaries below. |
141+
| bin/bitcoin-cli | Tool for making node and wallet RPC calls. |
142+
| bin/bitcoin-qt | Bitcoin node and wallet GUI |
143+
| bin/bitcoin-tx | Tool for creating and modifying transactions |
144+
| bin/bitcoin-util | Miscellaneous utilities |
145+
| bin/bitcoin-wallet | Bitcoin wallet tool |
146+
| bin/bitcoind | Bitcoin node and wallet daemon |
147+
| *lib/libbitcoinkernel.so* | Shared library containing core consensus and validation code |
148+
| *lib/pkgconfig/libbitcoinkernel.pc* | Pkg-config metadata for linking to `libbitcoinkernel` |
149+
| *libexec/bench_bitcoin* | Benchmarking tool for measuring node performance |
150+
| *libexec/bitcoin-chainstate* | Tool to validate and connect blocks |
151+
| *libexec/bitcoin-gui* | IPC-enabled alternative to `bitcoin-qt` |
152+
| *libexec/bitcoin-node* | IPC-enabled alternative to `bitcoind` |
153+
| libexec/test_bitcoin | Unit test binary |
154+
| *libexec/test_bitcoin-qt* | GUI-specific unit tests |
155+
| share/man/man1/ | Man pages for command-line tools like `bitcoin-cli`, `bitcoind`, and others |
156+
| share/rpcauth/ | Documentation and scripts for RPC authentication setup |
157+
158+
### Notes
159+
160+
- *Italicized* files are only installed in source builds if relevant CMake options are enabled. They are not included in binary releases.
161+
- README and bitcoin.conf files are included in binary releases but not installed in source builds.
162+
- On Windows, binaries have a `.exe` suffix (e.g., `bitcoin-cli.exe`).

0 commit comments

Comments
 (0)