Commit graph

77 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
fdad1fab1f multi: pin new v2 submodule tags and bump to v0.26.0-beta.rc1
In this commit, we strip all of the local `replace ... => ../...`
directives that were introduced as part of #1825 (the v2 module
restructuring), now that proper tags exist for every freshly carved-out
submodule. Every in-tree go.mod is pinned to the newly published tags:
chainhash/v2.0.0, wire/v2.0.0, chaincfg/v2.0.0, address/v2.0.0,
txscript/v2.0.0, btcutil/v2.0.0, psbt/v2.0.0, and btcec is bumped to
v2.5.0 since it now depends on chainhash/v2 (previously
chaincfg/chainhash).

While here, we also unify the Go toolchain to 1.25 across every
submodule so the workspace resolves a consistent set of language
features.

Finally, we bump the main btcd version to v0.26.0-beta.rc1 in
preparation for the upcoming release candidate.
2026-05-14 19:25:06 -07:00
Oliver Gugger
dccea8feba multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00
Oliver Gugger
bd65d6d6bb chaincfg: add own module, use v2 2026-05-14 17:56:18 -07:00
Oliver Gugger
28c77e7dcf chainhash: move to top-level module, use v2 2026-05-14 17:54:44 -07:00
Olaoluwa Osuntokun
1863073cb0 multi: bump Go toolchain to 1.25, build CI with 1.26.3
In this commit, we update every in-tree go.mod to declare go 1.25 and
have CI build with 1.26.3 (Dockerfile uses the golang:1.26-alpine base).
Docs that mention the minimum required Go version are aligned with the
new floor as well.

Fixes #2527, which flagged the README.md / go.mod version mismatch (the
README claimed 1.22 while the root + v2transport go.mod files already
required 1.23.2).
2026-05-14 17:32:02 -07:00
Boris Nagaev
51944b270c
make fmt 2026-05-06 16:32:51 -05:00
Olaoluwa Osuntokun
e4fe5985f8
Merge pull request #2520 from starius/strict-chainhash-parsing-1
chaincfg/chainhash: add strict parsing
2026-05-06 16:17:52 -05:00
Boris Nagaev
5fefcc6667
chaincfg/chainhash: add strict parsing
Add NewHashFromStrStrict and DecodeStrict for callers that must
parse full txids or block hashes exactly.

Keep NewHashFromStr and Decode lenient for compatibility, but add
NOTE docs steering typical parsing to the strict helpers.

Add tests for the new strict behavior and preserve coverage for the
existing lenient short and odd hex behavior.
2026-04-09 00:44:56 -05:00
Boris Nagaev
cd4e5426b2
regtest: align activations with Bitcoin Core
Set regtest buried heights to match Core: BIP34/65/66 at height 1 and make
CSV/SegWit/Taproot always active. Added regtest coverage for header version
floors, coinbase height enforcement, and deployment state to ensure we now
reject the blocks Core rejects and accept the ones Core accepts.

Updated package fullblocktests to generate BIP34-compliant blocks.

Test helpers now set prev block height to 0 (not the default -1) so generated
blocks start at height 1 and satisfy coinbase height rules.
2025-12-24 23:09:34 -03:00
Boris Nagaev
5baa6387d3
blockchain: run BIP30 if we are on non-BIP34 fork
Mirror BIP34-aware BIP30 skip logic from Bitcoin Core.

PR https://github.com/bitcoin/bitcoin/pull/6931 in Bitcoin Core introduced
an optimization that skips the expensive BIP30 duplicate coinbase check once
BIP34 is active *and* the chain actually contains the recorded activation block.
See the comment in that PR "//Only continue to enforce if we're below BIP34
activation height or the block hash at that height doesn't correspond."

btcd used to drop the check purely based on height. On a fork that lacks the
BIP34 activation block, that difference lets a duplicate coinbase slip through
consensus. This patch ports the missing pieces: we store the activation hash in
chain parameters and only disable BIP30 after we see that block on-chain.
2025-12-24 02:43:13 -03:00
Olaoluwa Osuntokun
a4f82f2540
blockchain: implement AlwaysActiveHeight for forced deployment activation
This commit introduces the concept of `AlwaysActiveHeight` to the
deployment mechanism, allowing a deployment to be forced into the active
state if the next block's height meets or exceeds this threshold.

This is intended primarily to be used alongside the new Testnet4
deployment, as the past major soft forks are meant to be active from the
very first block height.
2025-03-18 11:18:39 -05:00
Oleg Bondar
65a297268c
chaincfg: add TestNet4 params 2025-03-18 11:18:38 -05:00
Kim
ca8059b59d bump go mod versions 2025-02-10 16:37:15 +09:00
Boris Nagaev
38af045ab1
wire: add bitcoin network magic for default SigNet
Added constant wire.SigNet, added it to stringer for BitcoinNet type.
Added a test in chaincfg to compare calculated magic value with the constant.
2024-11-25 10:29:15 -03:00
Calvin Kim
f1bded4ff6
chaincfg: update dnsseeds (#2174)
* chaincfg: remove unresponsive dnsseed on testnet

testnet-seed.bitcoin.schildbach.de is unresponsive and doesn't return
any ips.  Bitcoin Core has already removed it and we don't also be
getting rid of it as well.

* chaincfg: add dnsseeds from Sjors Provoost

His seeds work well and we don't have any for signet and it's good to
replace the lost dns seed on testnet.

* chaincfg: remove bad dnsseed (seed.bitcoinstats.com)

seed.bitcoinstats.com doesn't respect filter requests even though it's
advertised as it does. Plus it often returns nodes that are unreachable.
In my testing over the past week, it's been the most unreliable dns seed
and since we have plenty of mainnet seeds, it's better to do away with
this.

I documented my findings for this in a Bitcoin Core issue:
https://github.com/bitcoin/bitcoin/issues/29911

* chaincfg: add dnsseed from wiz

It's the same infrastructure that mempool . space runs on and has been
reliable.  The same seed is also included in Bitcoin Core as well.
2024-04-23 11:11:15 -04:00
Olaoluwa Osuntokun
3c2478514f
chaincfg: update mainnet block hashes 2023-12-30 16:25:02 -08:00
Olaoluwa Osuntokun
96c9fd8078
Merge pull request #1978 from kcalvinalvin/memory-efficient-txhash
chainhash, wire, btcutil, main: Memory efficient txhash
2023-12-15 14:18:05 -08:00
Peter Todd
909106575e Update petertodd seed DNS to .net
Also, add mainnet seed.
2023-12-08 09:58:00 -05:00
Calvin Kim
375f79dcd0 chainhash: Add DoubleHashRaw
DoubleHashRaw provides a simple function for doing double hashes.  Since
it uses the digest instead of making the caller allocate a byte slice, it
can be more memory efficient vs other double hash functions.
2023-11-07 08:27:02 +09:00
beerosagos
36278166e5
chainhash: add support to legacy-marshaled hashes
Recent commits 1d6e578 and 72ea23e introduced a change in the way Hashes
are serialized and deserialized. This change could cause errors in
downstream applications that persisted hashes serialized using the previous
methods.

This introduces support for legacy-serialized hashes unmarshaling and restores
the compatibility with previous versions.
2023-08-29 14:52:29 +02:00
Oliver Gugger
599d3619e8
blockchain+chaincfg: disable retargeting for regtest
This commit emulates the behavior of Bitcoin Core introduced in
https://github.com/bitcoin/bitcoin/pull/6853 that disables retargeting
of the required proof of work for regtest.
2023-06-22 09:25:40 +02:00
Calvin Kim
ba5407615d multi: Run gofmt on the entire repository
The doc formatting changes introduced in the recent go version is
increasing the diff for all of the new commits.  Formatting it all in
this commit will help the readability of future PRs by reducing the
diff.
2023-06-21 22:31:09 +09:00
Calvin Kim
52ede324be chaincfg: Update checkpoints
The latest checkpoints were from a few years back and hurts ibd.
The updated checkpoints are based off of bitcoin core's past assumvalid
blocks.
2023-04-20 09:42:17 -04:00
RycCheen
e0e4916afb Supplementary chainhash test cases 2023-03-21 08:12:58 -04:00
RycCheen
72ea23ed1e chainhash: JSON Unmarshal hash from appropriate string. 2023-03-21 08:12:58 -04:00
ffranr
1d6e578c21
chainhash: JSON marshal hash as string 2022-12-02 19:30:41 +00:00
Olaoluwa Osuntokun
d537492a5d chaincfg: use lower custom activation threshold for regtest+simnet
The existing values were copied over from the testnet deployment, which
uses a much larger miner confirmation window. As a result, the main
taproot deployment would require thousands of blocks to properly
activate in development environments.
2022-04-09 07:39:56 -04:00
Olaoluwa Osuntokun
ba9fb8ece1
chaincfg: add taproot BIP deployment parameters
In this commit, we add the deployment parameters of taproot as specified
in the deployment section of BIp 341:
https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#deployment.

Take note of the custom activation threshold, as well as the specified
min activation heights for mainnet only.
2022-03-15 18:23:32 -07:00
Olaoluwa Osuntokun
37f8c8ba0a
txscript: add VerifyTaprootLeafCommitment function
In this commit, we add a new function to verify the taproot merkle
commitment of a given tapscript leaf. Along the way we add some helper
functions which can be used to construct a taproot output given the raw
script root.
2022-03-15 18:23:06 -07:00
Olaoluwa Osuntokun
e781b66e2f
txscript: implement BIP 341+342 segwit v1 taproot+tapscript
In this commit, we implement the new BIP 341+342 taproot sighash digest
computation. The digest is similar, but re-orders some fragments and
also starts to commit to the input values of all the transactions in the
SIGHASH_ALL case. A new implicit sighash flag, SIGHASH_DEFAULT has been
added that allows signatures to always be 64-bytes for the common case.

The hashcache has been updated as well to store both the v0 and v1 mid
state hashes. The v0 hashes are a double-sha of the contents, while the
v1 hash is a single sha. As a result, if a transaction spends both v0
and v1 inputs, then we 're able to re-use all the intermediate hashes.

As the sighash computation needs the input values and scripts, we create
an abstraction: the PrevOutFetcher to give the caller flexibility w.r.t
how this is done. We also create a `CannedPrevOutputFetcher` that holds
the information in a map for a single input.

A series of function options are also added to allow re-use of the same
base sig hash calculation for both BIP 341 and 342.
2022-03-15 18:22:43 -07:00
Oliver Gugger
7cc824e9b5
chainhash: make module 2022-03-09 11:57:23 +01:00
Olaoluwa Osuntokun
b7a4622a6b
btcec+chaincfg: use pre-computed tag hash values
In this commit, we optimize our signature implementation slightly, by
defining pre-computed sha256(tag) variables for the commonly used
values.  If a tag matches this, then we'll use that hash value to avoid
an extra round of hashing.
2022-01-31 14:55:08 -08:00
Olaoluwa Osuntokun
3b3a6fc671
chaincfg: add BIP-340 tagged hash implementation
In this commit, we add an implementation of the BIP-340 tagged hash
scheme. This initial version can be optimized quite a bit, for example,
we can hard code the output of frequently used `sha256(tag)` values and
save two `sha256` invocations.
2022-01-31 14:25:44 -08:00
Olaoluwa Osuntokun
38737a8ae3
chainparams: add new DeploymentTestDummyMinActivation
In this commit, we add a new "dummy" deployment that adds the new params
used to activate taproot. We chose to add a new deployment as unlike the
bitcoind codebase, we don't currently "bury" soft forks that have
happened in the past (hard code an activation height).

The old taproot deployment has been removed as with the way the array
works, a deployment needs to be defined for _all_ networks.
2022-01-25 15:27:44 -08:00
Olaoluwa Osuntokun
2b6370dfd7
chaincfg: use DeploymentStarter/DeploymentEnder instead of start/end times
In this commit, we utilize the recently added ConsensusDeploymentStarter
and ConsensusDeploymentEnder interfaces. Concrete implementations of
this interface based on the median time past comparison are used now in
the ConsensusDeployment struct instead of hard coded start/end times.

Along the way, we had to switch to using the "zero time": time.Time{},
in place of 0 and math.MaxInt64 as comparison (After/Before) seems to be
broken in the Go stdlib for times very far in the future. It appears Go
isn't ready to handle the heat death of the universe.
2022-01-25 15:27:37 -08:00
Olaoluwa Osuntokun
dc4dc15d8c
chaincfg: create new abstract deployment starter/ender interfaces
In this commit, we create a series of new interfaces that'll allow us to
abstract "when" exactly a deployment starts and ends. As is, all
deployments start/end based on a unix timestamp, which is compared
against the MTP of a given block to determine if a new deployment has
started or ended. This works fine for BIP 9 which uses time based
timeouts, but not so much for BIP 8. In order to prep a future refactor
that allows our version bits implementation to support both time and
block based start/end times, this new abstraction has been introduced.
2022-01-25 15:27:30 -08:00
Olaoluwa Osuntokun
caac0f821a
multi: update btcutil imports to point to new sub-module
In this commit, we update all the btcutil imports to point to the new
sub-module.

In the same commit, we also modify the recently added `btcutil/go.mod`
file as we need to continue pointing to the _old_ version of btcd, until
we merge this PR and push a new tag.
2022-01-10 18:44:58 -08:00
Oliver Gugger
7b6c2b3423 chaincfg: fix deployment bit numbers
On signet all previous soft forks and also taproot are always activated,
meaning the version is always 0x20000000 for all blocks. To make sure
they activate properly in `btcd` we therefore need to use the correct
bit to mask the version.
This means that on any custom signet there would need to be 2016 blocks
mined before SegWit or Taproot can be used.
2021-05-11 15:55:06 -04:00
Oliver Gugger
73ecb5997b
wire+chaincfg: add signet params
This commit adds all necessary chain parameters for connecting to the
public signet network.
Reference: https://github.com/bitcoin/bitcoin/pull/18267
2021-04-22 13:10:44 +02:00
Jake Sylvestre
d08785547a docs: update shields 2021-03-05 07:45:19 -05:00
Anirudha Bose
bdab8dfe81 chaincfg: Add RegisterHDKeyID func to populate HD key ID pairs
Currently, the only way to register HD version bytes is by initializing
chaincfg.Params struct, and registering it during package init.
RegisterHDKeyID provides a way to populate custom HD version bytes,
without having to create new chaincfg.Params instances. This is useful
for library packages who want to use non-standard version bytes for
serializing extended keys, such as the ones documented in SLIP-0132.

This function is complementary to HDPrivateKeyToPublicKeyID, which is
used to lookup previously registered key IDs.
2020-09-08 09:59:33 -04:00
Olaoluwa Osuntokun
3fbc9997ce
chaincfg: update testnet checkpoints 2019-04-17 15:33:09 -07:00
Olaoluwa Osuntokun
778c28fcd8
chaincfg: update mainnet checkpoints 2019-04-17 15:33:09 -07:00
Olaoluwa Osuntokun
3d1caa2f83 multi: update to point to roasbeef forks 2018-05-23 16:46:15 -07:00
Vadym Popov
675abc5df3 chaincfg: change hrp prefix for regtest network 2018-04-17 20:01:12 -07:00
Nicola 'tekNico' Larosa
11fcd83963 btcd/multi: fix a number of typos in comments. 2018-01-25 23:23:59 -06:00
Olaoluwa Osuntokun
b1893ed228 chaincfg+integration: add BIP0009 deployment parameters for segwit
This commit adds set of BIP0009 (Version Bits) deployment parameters
for all networks detailing the activation parameters for the segwit
soft-fork.

Additionally, the BIP0009 integration test has been updated to test for
the proper transitioning of version bits state for the segwit soft
fork. Finally, the `getblockchaininfo` test has also been updated to
properly display the state of segwit.
2017-08-13 23:17:40 -05:00
Olaoluwa Osuntokun
a411bbcf85 chaincfg: add address bytes for p2wsh and p2wkh addresses 2017-08-13 23:17:40 -05:00
Johan T. Halseth
47885ab870 chaincfg: Add IsBech32SegwitPrefix utility method.
The IsBech32SegwitPrefix method takes a string prefix and
determines if it is a valid prefix for a Bech32 encoded segwit
address for any of the default or registered networks.
2017-07-08 10:26:15 +02:00
Johan T. Halseth
9822ffad68 add Bech32HRPSegwit (human-readable part for segwit addresses) to chaincfg.Params 2017-07-05 16:33:50 -05:00