This is to mitigate CVE-2017-12842. Along the way, also error when
deserializing transactions that have the witness marker flag set
but have no witnesses. This matches Bitcoin Core's behaviour initially
introduced here https://github.com/bitcoin/bitcoin/pull/14039. Allowing
such transactions is benign, but this makes sure that our parsing code
matches Core's exactly.
This exposes publicly the ability to decode arbitrary-length bech32
strings and return the bech32 version that was used in the encoding. It
provides the underlying functionality for both DecodeNoLimit and
DecodeGeneric.
InvalidateBlock() invalidates a given block and marks all its
descendents as invalid as well. The active chain tip changes if the
invalidated block is part of the best chain.
* 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.
The block generating functions here allow for a test to create mock
blocks. This is useful for testing invalidateblock and reconsiderblock
methods on blockchain that will be added in later commits.
createSpendTx is moved to testhelper so that the function can be used
for callers in package blockchain without introducing import cycles.
The test code for invalidateblock and reconsiderblock that are going to
be added in later commits make use of this code.
createCoinbaseTx's code is refactored out and placed in testhelper
package and is exported so that callers in package blockchain can reuse
the code without introducing import cycles. The test code for
invalidateblock and reconsiderblock that'll be added in later commits
make use of this code.
standardCoinbaseScript is moved to testhelper and is exported. This
allows test code in package blockchain to reuse the code without
introducing an import cycle. This code is used in the testing code
for invalidateblock and reconsiderblock that's added in the later
commits.
uniqueOpReturnScript is moved to testhelper and is exported so that the
code and be reused in package blockchain without introducing import
cycles. The test code for invalidateblock and reconsiderblock that are
gonna be added in later commits uses the functions.
The variables are moved to testhelper so that they can be reused in the
blockchain package without introducing an import cycle. The testing
code for invalidateblock and reconsiderblock that will be added in later
commits will be using these variables.
solveBlock is moved to testhelper and is exported. This is done so that
the code can be reused without introducing import cycles. The testing
code to be added in alter commits for invalidateblock and reconsider
block will use SolveBlock.
spendableOut and the functions related to it are is moved to package
testhelper and are exported. This is done to make the code reusable
without introducing an import cycle when the testing code for
invalidateblock and reconsiderblock are added in follow up commits.
Some of the functions in difficulty.go are not dependent on any external
functions and they are needed to introduce testing code for the
invalidateblock and reconsiderblock methods that are to be added on in
later commits. Having the workmath package let's us reuse the code and
avoid dependency cycles.
The existing functions that were exported already (HashToBig,
CompactToBig, BigToCompact, CalcWork) are still kept in difficulty.go
to avoid breaking external code that depends on those exported
functions.
This commit adds a new type called `SerializedKey`.
A serialized type is useful when using public keys as map keys. This is
because functionally identical public keys can have different internal
representations. These differences would cause the map to treat them as
different keys.
Added type alias BTC/kvB to explicitly indicate that
it represents the fee in BTC for a transaction size of 1 kB.
Because bitcoind uses its own fee rate type
(BTC/kvB instead of sat/kWU we use in lnd),
define the type in btcjson package,
as it's the only place where we actually use BTC/kvB.
defaultMaxFeeRate was set to 1e8 / 10(sat/kb) as a parameter.
But BTC/kvB is the expected value, so the units was wrong.
This commit updates defaultMaxFeeRate to BTC/kvB and sets it to 0.1,
which is the default value of Bitcoin Core.
This commit also updates the comment to reflect the change.
Because maxFeeRate sanity check has been added in
bitcoin core v27.0 or later,
sendrawtransaction cannot be executed without this change.
This commit changes the `RejectReason` resulted from calling
btcd's `testmempoolaccept` to be un-matched, leaving it to the caller to
decide when and where to match it.
This commit adds detailed errors for all possible errors returned from
`sendrawtransaction` or `testmempoolaccept`, enabling upstream callers
to have refined control over the actions to be taken.