Olaoluwa Osuntokun
c64768b282
wire: add test for trailing bytes rejection in ReadMessage
...
In this commit, we add TestReadMessageTrailingBytes which constructs a
valid version message with 4 garbage bytes appended to the payload. The
wire frame uses a correct checksum over the full dirty payload so that
the checksum validation passes, but the new trailing-bytes check in
readMessageWithEncodingNInternal catches the unconsumed bytes and
returns a MessageError.
2026-03-06 16:11:33 -06:00
Olaoluwa Osuntokun
c13dec2416
wire: enforce full payload consumption in ReadMessage
...
In this commit, we add a strictness check to
readMessageWithEncodingNInternal that verifies all payload bytes were
consumed by BtcDecode. After BtcDecode returns, the remaining length of
the payload buffer is checked, and if any bytes remain unconsumed, the
message is rejected with a MessageError.
Previously, the payload buffer was passed to BtcDecode without any
post-decode validation, meaning any bytes beyond what BtcDecode consumed
were silently ignored. This check ensures wire message payloads are
exactly the size needed for the decoded message, tightening our
conformance to the expected wire format.
2026-03-06 16:11:23 -06:00
Olaoluwa Osuntokun
3eacced04e
Merge pull request #2471 from Roasbeef/container-version-bump
...
build: bump version of Go container for release builds
2026-01-12 18:34:13 -08:00
Olaoluwa Osuntokun
7d4da22923
build: bump version of Go container for release builds
2026-01-12 18:22:47 -08:00
Yong
84315272d6
Merge pull request #2468 from jlopp/spellcheck
...
fix spelling error
2026-01-12 19:49:16 +08:00
Jameson Lopp
d3615dcc28
fix spelling error
2025-12-25 07:33:49 -05:00
Olaoluwa Osuntokun
9ff0780da6
Merge pull request #2450 from FiveBellsSettlement/btc-client-correct-dialcontext
...
rpcclient: ensure http dial respects timeout
2025-11-05 17:07:55 -08:00
Olaoluwa Osuntokun
e764c170e6
Merge pull request #2447 from Roasbeef/v-25-branch
...
build: bump version to v0.25
2025-11-03 17:59:24 -08:00
Matt Leon
582b999f1a
rpcclient: ensure http dial respects timeout
...
Ensure that the dial phase of rpcclient's HTTP posts respects the http.Client's Timeout. It was instead falling back to the OS settings.
2025-10-29 16:38:32 +01:00
Olaoluwa Osuntokun
798b4ed4a7
build: bump version to v0.25
2025-10-27 16:07:29 -07:00
Olaoluwa Osuntokun
442ef28bcf
Merge pull request #2443 from sputn1ck/musig2_sign_with_agg_nonce
...
musig2: add WithExternalCombinedNonce option to Sign
2025-10-27 16:02:57 -07:00
sputn1ck
21eb99e3bc
musig2: add combinedNonce getter
2025-10-13 09:37:35 +02:00
sputn1ck
8f54cc6eda
musig2: add Session.RegisterCombinedNonce
...
This commit adds a new function to musig2.Session, which allows the caller
to add an external aggregated nonce to the session.
2025-10-13 09:37:34 +02:00
Olaoluwa Osuntokun
b7d070601d
Merge pull request #2430 from Roasbeef/v-0-25-0-rc1
...
build: bump version to v0.25.0-beta.rc1
2025-09-24 18:52:48 -07:00
Olaoluwa Osuntokun
31a762b3f6
build: bump version to v0.25.0-beta.rc1
2025-09-24 18:36:31 -07:00
Olaoluwa Osuntokun
e8097a1b04
Merge pull request #2410 from mohamedawnallah/fallback-to-GOPATH-bin-dir
...
Makefile+workflows: fallback to `GOPATH/bin` on non-existent `GOBIN`
2025-08-20 10:53:47 -07:00
Mohamed Awnallah
29f421534c
Makefile+workflows: fallback to GOPATH/bin on non-existent GOBIN
...
Co-authored-by: Oliver Gugger <gugger@gmail.com>
2025-08-20 16:02:15 +00:00
Yong
a4ddae2ba1
Merge pull request #2409 from gosunuts/fix/dockerfile-go-version
...
Dockerfile: update go base image
2025-08-20 14:33:14 +08:00
Kim
2577dd3ee3
Dockerfile: update go base image
2025-08-20 10:29:16 +09:00
Olaoluwa Osuntokun
c002ea3196
Merge pull request #2320 from gosunuts/feature/fix-ci
...
feat: fix ci / makefile
2025-08-19 18:09:43 -07:00
Olaoluwa Osuntokun
ce72d632ed
Merge pull request #2405 from guggero/bitcoind-v30-error
...
rpcclient: add bitcoind version dependent error matching
2025-08-19 18:08:41 -07:00
Oliver Gugger
ffcda0f629
rpcclient: add bitcoind version dependent error matching
...
Fixes #2404 .
If different versions of bitcoind return different error strings, we
need a way to match those as well.
2025-08-19 09:00:02 +02:00
Kim
106cde6adb
golangci: add configuration file for linting
2025-08-05 18:39:30 +09:00
Kim
f19065176b
multi: apply make fmt to all files
2025-08-05 18:39:30 +09:00
Kim
22b4663f7a
Makefile: Update dependencies and improve installation commands
2025-08-05 18:39:16 +09:00
Olaoluwa Osuntokun
baebb836c2
Merge pull request #2366 from bhandras/submitpackage
...
btcjson: add stubs for SubmitPackage
2025-07-28 18:00:03 -05:00
Andras Banki-Horvath
5e4519770f
btcjson: add json parsing unit tests for SubmitPackage stubs
2025-07-23 10:38:59 +02:00
Andras Banki-Horvath
6b2a9a4a48
btcjson: add stubs for SubmitPackage
2025-07-23 10:38:32 +02:00
Olaoluwa Osuntokun
7b7644ca81
Merge pull request #2397 from gijswijs/bloom-update
...
Align hash function count with bloom filter capacity
2025-07-22 16:49:28 -05:00
Yong
ab068f48b6
Merge pull request #2399 from mohamedawnallah/add-gemini-style-guide
...
.gemini: add `styleguide.md`
2025-07-16 20:34:44 +08:00
yyforyongyu
e8ea247cf0
.gemini: add styleguide.md
2025-07-16 11:46:18 +00:00
Yong
9181aa1af6
Merge pull request #2398 from Roasbeef/neutrino-opt
...
wire: optimize parsing for CFCheckpkt message, reduce allocs by 96%
2025-07-16 17:32:11 +08:00
Olaoluwa Osuntokun
d5cd95b9a9
wire: optimize parsing for CFCheckpkt message, reduce allocs by 96%
...
In this commit, we optimize the decoding for the CFCheckpkt message. The
old decode routine would do a fresh alloc for each hash to be read out.
Instead, we'll now allocate enough memory for the entire set of headers
to be decoded, then read them into that contiguous slice, and point to
members of this slice in the wire message itself.
We've also added benchmarks to show the improvement:
```
⛰ cat bench-cmp.txt
goos: darwin
goarch: arm64
pkg: github.com/btcsuite/btcd/wire
cpu: Apple M4 Max
│ bench-old.txt │ bench-new.txt │
│ sec/op │ sec/op vs base │
MsgCFCheckptDecode/headers_1000-16 14.354µ ± ∞ ¹ 6.919µ ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecode/headers_10000-16 146.77µ ± ∞ ¹ 70.23µ ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecode/headers_100000-16 1473.6µ ± ∞ ¹ 564.2µ ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptEncode/headers_1000-16 7.021µ ± ∞ ¹ 7.196µ ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptEncode/headers_10000-16 88.97µ ± ∞ ¹ 90.40µ ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptEncode/headers_100000-16 861.0µ ± ∞ ¹ 875.0µ ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecodeEmpty-16 68.28n ± ∞ ¹ 66.61n ± ∞ ¹ ~ (p=1.000 n=1) ²
geomean 37.98µ 26.98µ -28.98%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
│ bench-old.txt │ bench-new.txt │
│ B/op │ B/op vs base │
MsgCFCheckptDecode/headers_1000-16 39.36Ki ± ∞ ¹ 40.11Ki ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecode/headers_10000-16 392.6Ki ± ∞ ¹ 400.1Ki ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecode/headers_100000-16 3.817Mi ± ∞ ¹ 3.820Mi ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptEncode/headers_1000-16 63.98Ki ± ∞ ¹ 63.98Ki ± ∞ ¹ ~ (p=1.000 n=1) ³
MsgCFCheckptEncode/headers_10000-16 1.000Mi ± ∞ ¹ 1.000Mi ± ∞ ¹ ~ (p=1.000 n=1) ³
MsgCFCheckptEncode/headers_100000-16 8.000Mi ± ∞ ¹ 8.000Mi ± ∞ ¹ ~ (p=1.000 n=1) ³
MsgCFCheckptDecodeEmpty-16 112.0 ± ∞ ¹ 112.0 ± ∞ ¹ ~ (p=1.000 n=1) ³
geomean 166.5Ki 167.4Ki +0.55%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
³ all samples are equal
│ bench-old.txt │ bench-new.txt │
│ allocs/op │ allocs/op vs base │
MsgCFCheckptDecode/headers_1000-16 1003.000 ± ∞ ¹ 4.000 ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecode/headers_10000-16 10003.000 ± ∞ ¹ 4.000 ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptDecode/headers_100000-16 100003.000 ± ∞ ¹ 4.000 ± ∞ ¹ ~ (p=1.000 n=1) ²
MsgCFCheckptEncode/headers_1000-16 11.00 ± ∞ ¹ 11.00 ± ∞ ¹ ~ (p=1.000 n=1) ³
MsgCFCheckptEncode/headers_10000-16 15.00 ± ∞ ¹ 15.00 ± ∞ ¹ ~ (p=1.000 n=1) ³
MsgCFCheckptEncode/headers_100000-16 18.00 ± ∞ ¹ 18.00 ± ∞ ¹ ~ (p=1.000 n=1) ³
MsgCFCheckptDecodeEmpty-16 2.000 ± ∞ ¹ 2.000 ± ∞ ¹ ~ (p=1.000 n=1) ³
geomean 179.3 6.268 -96.50%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
³ all samples are equal
```
Old bench:
```
goos: darwin
goarch: arm64
pkg: github.com/btcsuite/btcd/wire
cpu: Apple M4 Max
BenchmarkMsgCFCheckptDecode/headers_1000-16 74678 14354 ns/op 40304 B/op 1003 allocs/op
BenchmarkMsgCFCheckptDecode/headers_10000-16 8234 146770 ns/op 402033 B/op 10003 allocs/op
BenchmarkMsgCFCheckptDecode/headers_100000-16 822 1473622 ns/op 4002931 B/op 100003 allocs/op
BenchmarkMsgCFCheckptEncode/headers_1000-16 173762 7021 ns/op 65520 B/op 11 allocs/op
BenchmarkMsgCFCheckptEncode/headers_10000-16 13459 88968 ns/op 1048564 B/op 15 allocs/op
BenchmarkMsgCFCheckptEncode/headers_100000-16 1399 860985 ns/op 8388592 B/op 18 allocs/op
BenchmarkMsgCFCheckptDecodeEmpty-16 17459148 68.28 ns/op 112 B/op 2 allocs/op
PASS
ok github.com/btcsuite/btcd/wire 10.135s
```
New bench:
```
goos: darwin
goarch: arm64
pkg: github.com/btcsuite/btcd/wire
cpu: Apple M4 Max
BenchmarkMsgCFCheckptDecode/headers_1000-16 166368 6919 ns/op 41072 B/op 4 allocs/op
BenchmarkMsgCFCheckptDecode/headers_10000-16 17079 70227 ns/op 409712 B/op 4 allocs/op
BenchmarkMsgCFCheckptDecode/headers_100000-16 2062 564175 ns/op 4006003 B/op 4 allocs/op
BenchmarkMsgCFCheckptEncode/headers_1000-16 173940 7196 ns/op 65520 B/op 11 allocs/op
BenchmarkMsgCFCheckptEncode/headers_10000-16 13054 90401 ns/op 1048564 B/op 15 allocs/op
BenchmarkMsgCFCheckptEncode/headers_100000-16 1408 875012 ns/op 8388592 B/op 18 allocs/op
BenchmarkMsgCFCheckptDecodeEmpty-16 17256627 66.61 ns/op 112 B/op 2 allocs/op
PASS
ok github.com/btcsuite/btcd/wire 10.522s
```
As seen from the benchmarks, allocs have decreased by 96%, and the decode
speed by nearly 30%.
2025-07-14 18:36:27 -07:00
Gijs van Dam
5e69e56cb8
btcutil/bloom: align hash function count with filter capacity
...
In this commit, we ensure hash function parameters are consistent with
filter size to avoid unnecessary operations. A filter with no capacity
doesn't actually require any hash functions, so we can cut that loop
short.
2025-07-14 11:03:36 +02:00
Yong
9adca7479d
Merge pull request #2375 from Aharonee/chore/update_psbt_deps
...
psbt: upgrade dependencies and fix unit test
2025-07-14 05:17:05 +03:00
Or Aharonee
4727f323ed
Update Go module and dependencies
...
Upgrade several package versions and fix a test case for transaction serialization.
2025-07-11 23:30:28 +03:00
Olaoluwa Osuntokun
4530538f8c
Merge pull request #2216 from Roasbeef/script-template
...
txscript: add new ScriptTemplate DSL for writing Scripts
2025-07-11 12:38:56 -07:00
Olaoluwa Osuntokun
c6b5b83f37
Merge pull request #2396 from brunoerg/2025-07-remove-alert
...
p2p: remove alert msg
2025-07-11 12:38:45 -07:00
Olaoluwa Osuntokun
c9bd7b4c0f
txscript: add new ScriptTemplate DSL for writing Scripts
...
In this commit, we add a new function, `ScriptTemplate` to make the
process of making custom Bitcoin scripts a bit less verbose.
ScriptTemplate processes a script template with parameters and returns the
corresponding script bytes. This functions allows Bitcoin scripts to be
created using a DSL-like syntax, based on Go's templating system.
An example of a simple p2pkh template would be:
`OP_DUP OP_HASH160 0x14e8948c7afa71b6e6fad621256474b5959e0305 OP_EQUALVERIFY OP_CHECKSIG`
Strings that have the `0x` prefix are assumed to byte strings to be pushed
ontop of the stack. Integers can be passed as normal. If a value can't be
parsed as an integer, then it's assume that it's a byte slice without the 0x
prefix.
Normal go template operations can be used as well. The params argument
houses paramters to pass into the script, for example a local variable
storing a computed public key.
2025-07-11 12:20:05 -07:00
Bruno Garcia
bc52e090ce
p2p: remove alert msg
2025-07-10 13:07:50 -03:00
Oliver Gugger
fa8d919dd0
Merge pull request #2395 from mohamedawnallah/addGeminiCodeAssist
...
CI: add gemini assist for code reviews
2025-07-10 08:41:28 +02:00
Mohamed Awnallah
73344dbe49
CI: add gemini assist for code reviews
2025-07-09 20:23:35 +00:00
Oliver Gugger
2c9907c387
Merge pull request #2393 from bshramin/btcctl-config-error
...
Print a readable error before os.Exit(1) in btcctl
2025-07-03 08:37:03 +02:00
Olaoluwa Osuntokun
1d9a130076
Merge pull request #2322 from starius/block-count
...
rpcclient: clarify GetBlockCount description
2025-07-02 15:58:28 -07:00
Olaoluwa Osuntokun
91daea9bd4
Merge pull request #2389 from yyforyongyu/refactor
...
Minor refactor to improve code health
2025-07-02 15:54:33 -07:00
Amin Bashiri
e4c44fe796
Print a readable error before os.Exit(1) in btcctl
2025-07-01 15:17:21 -04:00
yyforyongyu
1827fcf2f5
main: fix typo
2025-06-25 16:55:33 +08:00
yyforyongyu
9dc2503295
main: refactor OnGetData to simplify the logic
...
The preivous usage of two channels - by piping them together to create a
semaphore effect, is difficult to follow and prone to bugs. This commit
now refactors the method to explicitly implement a semaphore.
Prior to this change, we would allow at max 3 concurrent goroutines -
this is now bumped to 5.
2025-06-25 16:55:33 +08:00
yyforyongyu
796d0efc0d
main: add method pushInventory to be used in OnGetData
...
A minor refactor on method `OnGetData`.
2025-06-23 21:31:26 +08:00
yyforyongyu
c96d061314
wire: refactor BtcDecode and patch unit test
2025-06-23 21:31:26 +08:00