Commit Graph

3997 Commits

Author SHA1 Message Date
Calvin Kim
597b68c79e blockchain, workmath: refactor functions to workmath package
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.
2024-04-23 02:35:36 +09:00
Youngjoon Lee
569155bc6a
doc: fix config documentation for AgentWhitelist (#2140) 2024-04-10 15:37:44 -04:00
youngxhui
64c9011d72
Update developer_resources.md (#2158)
fix btcutil link error
2024-04-10 13:00:23 -04:00
goodfirm
9f93dc1842
chore: fix function names in comment (#2163)
Signed-off-by: goodfirm <fanyishang@yeah.net>
2024-04-10 12:59:42 -04:00
zhiqiangxu
2f4ff8447d
fix some typos and make OP_DATA_20 explicit in comment (#2080) 2024-04-10 10:08:30 -04:00
Olaoluwa Osuntokun
5d50f7c83e
Merge pull request #2153 from kcalvinalvin/2024-04-02-add-is-ancestor
blockchain: Add IsAncestor method to blockNode
2024-04-09 20:10:58 -07:00
Olaoluwa Osuntokun
e4b32e0ba9
Merge pull request #2156 from ffranr/add-pubkey-serialized-type
Add new serialized pubkey type
2024-04-09 20:06:05 -07:00
Olaoluwa Osuntokun
92b24d2ed3
Merge pull request #2150 from xiaoxianBoy/fix-typos
chore: fix typos
2024-04-09 20:05:14 -07:00
Calvin Kim
bc6396ddfd blockchain: Add IsAncestor method to blockNode
IsAncestor() provides functionality for testing if a block node is
an ancestor of anther block node.
2024-04-08 17:47:26 +09:00
Calvin Kim
c9c8795160 blockchain: add Equals method to blockNode
Helper function for the added IsAncestor in the follow up commit.
Returns true if all the fields (except for parent and ancestor) are
equal.
2024-04-08 17:47:08 +09:00
Olaoluwa Osuntokun
ae5533602c
Merge pull request #2142 from YusukeShimizu/feeRate-BTCkvB
btcclient+btcjson: defaultMaxFeeRate to BTC/kvB
2024-04-02 19:19:26 -07:00
ffranr
665eeb52b1
btcec: add new type SerializedKey
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.
2024-04-02 21:19:03 +01:00
ffranr
31647e46ec
btcec: add missing doc comments 2024-04-02 21:19:03 +01:00
snoppy
9851d96c06
chore: fix typos 2024-03-29 10:21:29 +08:00
xiaoxiangxianzi
95330bc1bb
chore: fix some comments (#2146)
Signed-off-by: xiaoxiangxianzi <zhaoyizheng@outlook.com>
2024-03-27 09:45:48 -04:00
bruwbird
80b27f5471
btcclient+btcjson: add type alias for BTC/kvB
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.
2024-03-27 17:58:12 +09:00
bruwbird
bbb6967247
btcclient+btcjson: feeRate to 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.
2024-03-27 17:58:12 +09:00
Oliver Gugger
a03259b26b
Merge pull request #1991 from ffranr/add-json-support
Convert `witnessToHex` into a method `ToHexStrings` on `TxWitness`
2024-03-26 13:03:46 -06:00
Oliver Gugger
429d00fe3b
Merge pull request #2091 from zhiqiangxu/rm_trailing_continue
chore: remove trailing continue
2024-03-26 02:36:00 -06:00
zhiqiangxu
6ae24a0693 mining: remove trailing continue 2024-03-26 13:21:01 +08:00
mattn
3cb9f602e8
fix typos (#2100) 2024-03-25 09:44:25 -04:00
ffranr
75fe7e4790
wire: make witnessToHex a TxWitness method called ToHexStrings 2024-03-25 12:56:12 +00:00
Oliver Gugger
e39d2eb63d
Merge pull request #2055 from ffranr/add-msgtx-txid
wire: add method TxID to MsgTx
2024-03-25 06:50:31 -06:00
ffranr
2a225e9d36
wire: add method TxID to MsgTx
This commit adds a method to MsgTx called TxID. This method returns the
transaction ID (txid) of the subject transaction.
2024-03-25 12:21:41 +00:00
Olaoluwa Osuntokun
8b2f43e9ce
Merge pull request #2136 from Roasbeef/btcd-24-0-2-rc1
build: bump version to v0.24.2-beta.rc1
2024-03-18 17:45:13 -04:00
Olaoluwa Osuntokun
a90d3d93e9
Merge pull request #2135 from SulaimanAminuBarkindo/improved-der-signature-validation
Add check for maximum signature length in ecdsa.ParseDERSignature
2024-03-18 17:44:26 -04:00
Oliver Gugger
2fc99e0496
Merge pull request #2138 from yyforyongyu/error-matching
rpcclient: add detailed error types
2024-03-18 09:17:28 -06:00
yyforyongyu
8abf969c3c
rpcserver: return the plain reject reason from btcd
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.
2024-03-18 23:08:48 +08:00
yyforyongyu
36683e0b96
rpcclient: define specific errors for chain backends
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.
2024-03-18 23:08:47 +08:00
Olaoluwa Osuntokun
aee2705f70
build: bump version to v0.24.2-beta.rc1 2024-03-08 17:58:53 -08:00
Olaoluwa Osuntokun
f0ec9fbcce
Merge pull request #2128 from kcalvinalvin/2024-02-27-no-panic-for-subscription-callback-errors
blockchain: always relock chainLock for subscription callbacks
2024-03-08 17:56:14 -08:00
Olaoluwa Osuntokun
8ed234b9f5
Merge pull request #2134 from kcalvinalvin/2024-03-07-make-duplicate-entries-on-mapslice-impossible
blockchain: fix a bug where a duplicate entry is possible in the mapslice
2024-03-08 17:54:08 -08:00
Olaoluwa Osuntokun
e63bf03d2a
Merge pull request #2123 from kcalvinalvin/2024-02-15-no-utxocache-loading-on-reorgs
blockchain: fix inconsistent utxocache and database on reorg
2024-03-08 17:52:57 -08:00
theedtron
b66f5b8379
multi: fix ioutil deprecated function
update i/o functions to use os / io package functions instead
2024-03-08 17:41:41 -08:00
Olaoluwa Osuntokun
447c95c9c2
Merge pull request #2122 from kcalvinalvin/2024-02-15-dont-rely-on-height-fetching
blockchain: don't rely on BlockHeightByHash for prune height calculations
2024-03-08 17:40:16 -08:00
SulaimanAminuBarkindo
9d2184eb2d Add check for maximum signature length in ecdsa.ParseDERSignature
* Updated the `ecdsa.ParseDERSignature` to include the MaxSigLen constant, which defines the maximum length of a DER encoded signature.
* The MaxSigLen constant is set to 72 bytes, as per the explanation in the comment.
* A new test case has been added to test the functionality with a long signature.
* The test case checks if signatures longer than the specified maximum length are properly handled.
* The test ensures that signatures exceeding the maximum length are correctly identified as invalid.
2024-03-07 09:03:20 +01:00
Calvin Kim
078815bcbc blockchain: remove utxoview from the argument in connectBlock
Since no code is now depending on accepting new blocks without the
cache, we get rid of the option to do so.
2024-03-07 15:43:48 +09:00
Calvin Kim
059a668e88 blockchain: check all the maps first before adding an entry
When attempting to insert an entry to the mapslice, we check all the
underlying maps to ensure that the entry doesn't exist.
2024-03-07 15:27:44 +09:00
Calvin Kim
8d1aa01c69 blockchain: add another mapslice duplicate entry case
Duplicate entries are currently possible in the following scenario:

1: Add entries to the mapslice.
2: 1st map is full. Move onto the 2nd map.
3: Delete any entry in the first map.
4: Attempt to add an entry in the 2nd map.

When attempting (4), the entry should just be overwritten but a
duplicate gets added.
2024-03-07 15:24:00 +09:00
Olaoluwa Osuntokun
a4f447006e
Merge pull request #2131 from kcalvinalvin/2024-03-05-fix-intermittent-addrmgr-bug
addrmgr: fix intermittent addrmanager_internal_test bug
2024-03-05 12:07:57 -06:00
Calvin Kim
99846b0805 blockchain: remove unused fetchUtxosMain() 2024-03-06 02:44:51 +09:00
Calvin Kim
78b158dc56 blockchain: get rid of database as an argument in fetchInputUtxos
Allowing the caller to fetch from either the database or the cache
resulted in inconsistencies if the cache were ever to be dirty.
Removing this option eliminates this problem.
2024-03-06 02:42:33 +09:00
Calvin Kim
a254998bc5 blockchain: change reorg utxo cache behavior
The assumption in the previous code was incorrect in that we were
assuming that the chainLock is held throughout the entire chain reorg.
This is not the case since the chainLock is let go of during the
callback to the subscribers.

Because of this, we need to ensure that the utxo set is consistent on
each block disconnect. To achieve this, additional flushes are added
during block disconnects.

Also the utxocache is no longer avoided during block connects and when
we're checking for the validity of the block connects and disconnects as
we can just use the cache instead of trying to avoid it.
2024-03-06 02:40:24 +09:00
Calvin Kim
f2caa8fadc blockchain: don't rely on BlockHeightByHash for prune height
calculations

Since BlockHeightByHash only returns the heights for blocks that are in
the main chain, when a block that is stale gets pruned, this will cause
an error in the block height lookup and cause an error in block
processing.

Look up the node directly from the index and if the node isn't found,
just skip that node. For utxoCache.lastFlushHash, if that isn't found,
just force a flush.
2024-03-06 02:15:39 +09:00
Calvin Kim
f9da3387f1 addrmgr: fix intermittent addrmanager_internal_test bug
Sometimes the tests in the addrmanager_internal_test will fail with:
"addrmanager_internal_test.go: expected to find 5 addresses, found 4"

This is because the generated address with randAddr() may not always
generate an address that's routable. If the address is not routable,
that address will not be added to the manager when calling AddAddress().

This bug is fixed by creating a new function routableRandAddr() that
always creates a routable random address.
2024-03-05 16:33:08 +09:00
Olaoluwa Osuntokun
1a2b599bf1
Merge pull request #2125 from yyforyongyu/add-gettxspendingprevout
Add `gettxspendingprevout` for `btcd` and fix version check
2024-03-01 15:04:20 -06:00
yyforyongyu
0d4ed16ed7
btcd: increase version number to 0.24.1 2024-02-28 16:40:11 +08:00
yyforyongyu
34721f02c1
rpcclient: replace ErrBitcoindVersion with ErrBackendVersion 2024-02-28 03:38:48 +08:00
yyforyongyu
4cf49bd72c
multi: turn BackendVersion into an interface
This commit adds a new interface, `BackendVersion`, to support checking
versions for multiple both btcd and bitcoind. Once neutrino version is
also pinned here, it should also be checked.
2024-02-27 23:04:47 +08:00
yyforyongyu
9e6070a707
rpcclient: start tracking btcd version 2024-02-27 23:04:46 +08:00