Commit graph

4045 commits

Author SHA1 Message Date
Conner Fromknecht
2bb6824067 blockchain: Add RollingMerkleTree
RollingMerkleTree is a much more memory efficient way of calculating the
merkle root of a tx commitment inside the bitcoin block header.  The
current way of calculating the merkle root allocates 2*N elements. With
the RollingMerkleTree, we are able to reduce the memory allocated to
log2(N).

This results in significant memory savings (99.9% in an average block),
allowing for a faster block verification.
2023-08-03 23:56:53 +09:00
Calvin Kim
3ba9feeeee blockchain, btcutil/bloom: BuildMerkleTreeStore returns chainhash.Hash
BuildMerkleTreeStore used to return a pointer, but it is changed to
return a chainhash.Hash directly.  This allows the compiler to make
optimizations in some cases and avoids a memory allocation.
2023-08-03 15:23:17 +09:00
Oliver Gugger
6f93d9f40d
Merge pull request #1969 from lindlof/rpc-address-align
Add address field (rpc client & server)
2023-08-03 08:17:30 +02:00
Olaoluwa Osuntokun
3a9e7e2376
Merge pull request #2006 from 0xEclair/sig_hash_type
fix: missing sighashtype when finalizing taproot keyspend signature
2023-07-23 16:01:22 +02:00
0xEclair
7f0fb2ad3b psbt: finalizer add proper sighash flag
psbt: fix missing sighash flag when finalizing
psbt: test finalizer add proper sighash flag
2023-07-17 18:35:13 +08:00
Calvin Kim
fc99e96b59 rpcclient, integration: Add test for getchaintips call
rpcclient now support calling the getchaintips rpc call.

getchaintips_test.go adds test for the getchaintips rpc call. The test
includes hard-coded blocks which the test will feed the node via rpc and
it'll check that the returned chain tips from the getchaintips call
are chaintips that we expect to be returned.
2023-07-16 16:03:50 +09:00
Calvin Kim
e2d9e2092b docs: Update json_rpc_api.md for getchaintips rpc 2023-07-16 16:03:50 +09:00
Calvin Kim
892ae679b3 btcjson, main: Implement the getchaintips call
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves https://github.com/btcsuite/btcd/issues/1912.
2023-07-16 16:03:48 +09:00
Calvin Kim
46bfb784a6 blockchain: Add ChainTips() method to BlockChain
ChainTips method allows for callers to get all the chain tips the node
is aware of. This is useful for supporting the getchaintips rpc call.
2023-07-16 16:03:45 +09:00
Calvin Kim
b84f084ce7 blockchain: Add InactiveTips() to blockindex
InactiveTips() returns all the tips of the branches of the blockchain
tree that are not in the best chain. This function is useful for
supporting the getchaintips rpc call.
2023-07-16 15:03:33 +09:00
Olaoluwa Osuntokun
7faa9b2662
Merge pull request #2003 from sputn1ck/musig2_fix_early_nonce_gen
musig2: fix early nonce gen option
2023-07-11 15:28:09 -07:00
sputn1ck
883a03da99
musig2: add early nonce gen KnownSigners test
This commit changes the early nonce gen test to use the KnownSigners
Option for one of the contexts.
2023-07-11 14:01:37 +02:00
sputn1ck
8f84bb0e9b
musig2: fix early nonce gen option
Previously the early nonce generation option was not being respected
when creating the context, with the WithKnownSigners option being
used. This commit fixes that.
2023-07-11 14:01:36 +02:00
Olaoluwa Osuntokun
4933e35f61
Merge pull request #1996 from C-Otto/trailing-zeroes
btcutil: format BTC amounts with trailing zeroes
2023-07-10 13:56:01 -07:00
Carsten Otto
725b36bf09 btcutil: format BTC amounts with trailing zeroes
so that sat amounts can be read without counting zeroes

before:
 350sat = 0.0000035 BTC
3500sat = 0.000035 BTC

after:
 350sat = 0.00000350 BTC
3500sat = 0.00003500 BTC

fixes #1995
2023-07-04 18:19:07 +02:00
Olaoluwa Osuntokun
f5eeb10d03
Merge pull request #1931 from Crypt-iQ/export_header_funcs
blockchain: refactor and export header validation checks
2023-06-29 15:01:41 -04:00
eugene
ee6c0e1962
blockchain: export CheckBlockHeaderSanity as a library function 2023-06-29 14:45:32 -04:00
eugene
00d0edd5c4
blockchain: intro HeaderCtx, ChainCtx + refactor CheckBlockHeaderContext
This change will allow an external program to provide its own HeaderCtx
and ChainCtx and be able to perform contextual block header checks.
2023-06-29 14:45:30 -04:00
Oliver Gugger
f9cbff0d81
Merge pull request #1998 from web3-explore/master
multi: remove repetitive the
2023-06-26 16:25:24 +02:00
cui fliter
e160bb6922 multi: remove repetitive the
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-26 15:40:51 +08:00
Oliver Gugger
7fd5c1e92c
Merge pull request #1985 from guggero/pow-no-retargeting
blockchain+chaincfg: disable retargeting for regtest
2023-06-22 09:51:09 +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
Olaoluwa Osuntokun
253b688c68
Merge pull request #1981 from kcalvinalvin/2023-05-16-run-gofmt
multi: Run gofmt on the entire repository
2023-06-21 12:00:35 -05: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
Mikael Lindlof
e4c88c3a3e rpc: Add ScriptPubKeyResult address field 2023-06-06 21:57:01 +01:00
Olaoluwa Osuntokun
9c16d23918
Merge pull request #1879 from GeorgeTsagk/wire/outpoint-parse-string
Add wire.Outpoint parser from string
2023-05-24 19:40:36 -07:00
Olaoluwa Osuntokun
4749f7a8d3
Merge pull request #1977 from kcalvinalvin/fix-readme-min-version
main: Update README.md's minimum go version
2023-05-24 15:08:43 -07:00
Calvin Kim
c1a713e4ba docs: Update minimum Go version 2023-05-22 15:53:52 +09:00
Oliver Gugger
98e3c49544
Merge pull request #1972 from kcalvinalvin/utxoview-use-slices
blockchain: Use slices when fetching utxos
2023-05-11 10:04:55 +02:00
Oliver Gugger
1287f1e89a
Merge pull request #1953 from kcalvinalvin/add-memory-profiling
btcd: Add memory profiling flag
2023-05-10 14:17:01 +02:00
Calvin Kim
218c4754c6 main: Update README.md's minimum go version
The readme suggests a minimum version of 1.16 but the go.mod requires go
1.17.
2023-05-06 01:26:54 +09:00
Calvin Kim
5ede256f66 blockchain: Add benchmark for using a map vs a slice
Benchmark added to compare the performance of a map vs a slice when
fetching utxos.  The benchmark shows roughly 25% performance improvement
when using slices instead of a map.
2023-05-05 22:54:35 +09:00
Calvin Kim
cfb39f790f blockchain: Use slices when fetching utxos
Maps have a higher overhead than slices.  As slices can be used instead
of maps, we avoid the overhead of making a map.
2023-05-05 22:54:33 +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
Oliver Gugger
d48e86438e
Merge pull request #1957 from hieblmi/fix-typos
txscript: fix typos
2023-04-20 12:50:39 +02:00
Slyghtning
42653cdcd2 txscript: fix script typos 2023-04-20 11:41:45 +02:00
Oliver Gugger
79751682f2
Merge pull request #1964 from ziggie1984/psbt-nil-pointer-bug
psbt: add verification method for utxo data
2023-03-22 20:53:10 +01: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
ziggie
b554add716
psbt: add verification method for psbt input data
the new InputsReadyToSign method makes sure that inputs have either
the nonWitnessUtxo or the witnessUtxo data set.
2023-03-21 09:09:42 +01:00
Calvin Kim
d628705118 btcd: Add memory profiling flag
Enables Go memory profiling.  If the cpuprofile shows a lot of time
spent on gc, it's useful to then do a memory profile to see where the
memory alloctions happen.

Unlike the --profile flag, this allows for easy generation of a memory
profile for the entire duration of which btcd has been running for in
various readble graphs.
2023-03-21 14:12:43 +09:00
martonp
a18c2cfbf8 Export MakeScritpNum, AsSmallInt, and IsSmallInt 2023-03-03 15:05:14 -05:00
Oliver Gugger
38331963bd
Merge pull request #1954 from guggero/script-builder-alloc
txscript: allow script builder capacity to be specified
2023-02-28 19:50:50 +01:00
Oliver Gugger
e1e4196fbc
txscript: allow script builder capacity to be specified
The default script builder allocates 500 bytes of memory for each
script. That is quite large for most applications and therefore wastes a
lot of memory when only small scripts are created.
To avoid breaking backward compatibility, we add a new functional option
to the NewScriptBuilder function that allows the user to specify the
initial allocation size.
2023-02-27 12:38:13 +01:00
Calvin Kim
902f797b0c txscript: Fix typo in IsUnspendable() comment
IsUnspendable allows outputs, not inputs to be pruned instantly.
2023-02-13 08:35:16 -05:00
Hristo Georgiev
52082fcbf9 docs: Update Go version as per the Readme. 2023-02-10 16:57:42 -05:00
Oliver Gugger
ecf98ce34f
Merge pull request #1942 from guggero/psbt-export
btcutil/psbt: export helper functions, fix/add encoding of unknown fields
2023-02-02 11:46:57 +01:00
Oliver Gugger
bb0a2f3790
psbt: add unit test for unknowns 2023-01-27 15:30:46 +01:00
Oliver Gugger
6c81c664bb
psbt: use pointer slice for global unknowns
To unify the way the unknown fields are handled, we change the global
ones to a slice of pointers as well. This makes it easier to add
generic handler code for unknown fields, if they are uniform across the
levels (global, input, output).
2023-01-27 15:30:45 +01:00
Oliver Gugger
5ebbb1bb91
psbt: encode global unknowns 2023-01-27 15:30:44 +01:00