From 23316621c8ac07876218b0451547b8871c6d7913 Mon Sep 17 00:00:00 2001 From: quest Date: Fri, 20 Dec 2024 14:17:04 -1000 Subject: [PATCH] Update all libs/deps and fixes for 0.11.0-rc1 --- boot/config.go | 8 ++-- boot/signalsigterm.go | 1 + boot/version.go | 4 +- chain/bitcoind_client.go | 1 + go.mod | 4 +- go.sum | 2 + goclean.sh | 7 ++-- internal/legacy/rename/rename_unix.go | 1 + internal/rpchelp/helpdescs_en_US.go | 3 +- internal/rpchelp/methods.go | 3 +- rpc/legacyrpc/server.go | 2 +- votingpool/doc.go | 17 ++++---- waddrmgr/db.go | 14 ++++--- waddrmgr/doc.go | 34 +++++++-------- waddrmgr/manager.go | 6 ++- wallet/doc.go | 1 - wallet/recovery.go | 20 ++++----- wallet/wallet.go | 14 +++---- wallet/wallet_test.go | 2 +- wtxmgr/db.go | 60 +++++++++++++-------------- 20 files changed, 106 insertions(+), 98 deletions(-) diff --git a/boot/config.go b/boot/config.go index 8f0b92b..1624a1a 100644 --- a/boot/config.go +++ b/boot/config.go @@ -248,10 +248,10 @@ func parseAndSetDebugLevels(debugLevel string) error { // line options. // // The configuration proceeds as follows: -// 1) Start with a default config with sane settings -// 2) Pre-parse the command line to check for an alternative config file -// 3) Load configuration file overwriting defaults with any specified options -// 4) Parse CLI options and overwrite/add any specified options +// 1. Start with a default config with sane settings +// 2. Pre-parse the command line to check for an alternative config file +// 3. Load configuration file overwriting defaults with any specified options +// 4. Parse CLI options and overwrite/add any specified options // // The above results in bchwallet functioning properly without any config // settings while still allowing the user to override settings with config files diff --git a/boot/signalsigterm.go b/boot/signalsigterm.go index 31d2a8c..2c9323d 100644 --- a/boot/signalsigterm.go +++ b/boot/signalsigterm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package boot diff --git a/boot/version.go b/boot/version.go index c13e60b..4c674e0 100644 --- a/boot/version.go +++ b/boot/version.go @@ -17,12 +17,12 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr // versioning 2.0.0 spec (http://semver.org/). const ( appMajor uint = 0 - appMinor uint = 10 + appMinor uint = 11 appPatch uint = 0 // appPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec. - appPreRelease = "" + appPreRelease = "rc1" ) // appBuild is defined as a variable so it can be overridden during the build diff --git a/chain/bitcoind_client.go b/chain/bitcoind_client.go index c2371d0..ca9673d 100644 --- a/chain/bitcoind_client.go +++ b/chain/bitcoind_client.go @@ -315,6 +315,7 @@ func (c *BitcoindClient) shouldNotifyBlocks() bool { // is used to reset the current filters. // // The current filters supported are of the following types: +// // []bchutil.Address // []wire.OutPoint // []*wire.OutPoint diff --git a/go.mod b/go.mod index 30ddea3..5771a4a 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/gcash/bchd v0.20.0-rc1 github.com/gcash/bchlog v0.0.0-20180913005452-b4f036f92fa6 github.com/gcash/bchutil v0.0.0-20241220024231-3d67040d3361 - github.com/gcash/bchwallet/walletdb v0.0.0-20220509175733-0c2270788e43 - github.com/gcash/neutrino v0.0.0-20210524114821-3b1878290cf9 + github.com/gcash/bchwallet/walletdb v0.0.0-20241220234253-0350bbbbc8e3 + github.com/gcash/neutrino v0.0.0-20241221000643-3237163c15d5 github.com/golang/protobuf v1.5.4 github.com/jarcoal/httpmock v1.0.8 github.com/jessevdk/go-flags v1.6.1 diff --git a/go.sum b/go.sum index 56efac7..52fbf64 100644 --- a/go.sum +++ b/go.sum @@ -429,6 +429,8 @@ github.com/gcash/neutrino v0.0.0-20210524105223-4cec86bbd8a4 h1:CFXcaAlSkzKSsXph github.com/gcash/neutrino v0.0.0-20210524105223-4cec86bbd8a4/go.mod h1:YBR6T+ZT02eR1S7JGqJ2gVPxZlfjWswTCXB4HZafp/U= github.com/gcash/neutrino v0.0.0-20210524114821-3b1878290cf9 h1:V5UNzi/5pZxE5s6kfCe59VjJRmfkyI+npZizMcAvEdI= github.com/gcash/neutrino v0.0.0-20210524114821-3b1878290cf9/go.mod h1:MshBO/Xf8SCndZFetZ8yg79db/JghnOiMmPiY1Eatlw= +github.com/gcash/neutrino v0.0.0-20241221000643-3237163c15d5 h1:tyuaq7lnu/KP5NpsNv9qI4opaRnxOXi4K2vnIWNhn98= +github.com/gcash/neutrino v0.0.0-20241221000643-3237163c15d5/go.mod h1:T9na18kE3DjeeKpiG4ffnsGiHzAoCzCoFt83s9tGJ5E= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= diff --git a/goclean.sh b/goclean.sh index fe17380..fa7a007 100755 --- a/goclean.sh +++ b/goclean.sh @@ -20,8 +20,7 @@ fi test -z "$(golangci-lint run --disable-all \ --enable=gofmt \ --enable=revive \ ---enable=vet \ +--enable=govet \ --enable=gosimple \ ---enable=unconvert \ ---deadline=10m | grep -v 'ALL_CAPS\|OP_' 2>&1 | tee /dev/stderr)" -go test -tags rpctest ./... \ No newline at end of file +--enable=unconvert | grep -v 'ALL_CAPS\|OP_' 2>&1 | tee /dev/stderr)" +go test -tags rpctest ./... diff --git a/internal/legacy/rename/rename_unix.go b/internal/legacy/rename/rename_unix.go index 00a1523..fc04441 100644 --- a/internal/legacy/rename/rename_unix.go +++ b/internal/legacy/rename/rename_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. +//go:build !windows && !plan9 // +build !windows,!plan9 package rename diff --git a/internal/rpchelp/helpdescs_en_US.go b/internal/rpchelp/helpdescs_en_US.go index c3ed54c..e9cdd39 100644 --- a/internal/rpchelp/helpdescs_en_US.go +++ b/internal/rpchelp/helpdescs_en_US.go @@ -2,7 +2,8 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -//+build !generate +//go:build !generate +// +build !generate package rpchelp diff --git a/internal/rpchelp/methods.go b/internal/rpchelp/methods.go index 2edf471..d0da2e7 100644 --- a/internal/rpchelp/methods.go +++ b/internal/rpchelp/methods.go @@ -2,7 +2,8 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -//+build !generate +//go:build !generate +// +build !generate package rpchelp diff --git a/rpc/legacyrpc/server.go b/rpc/legacyrpc/server.go index f98d9a5..eb8778a 100644 --- a/rpc/legacyrpc/server.go +++ b/rpc/legacyrpc/server.go @@ -167,7 +167,7 @@ func NewServer(opts *Options, walletLoader *wallet.Loader, listeners []net.Liste // httpBasicAuth returns the UTF-8 bytes of the HTTP Basic authentication // string: // -// "Basic " + base64(username + ":" + password) +// "Basic " + base64(username + ":" + password) func httpBasicAuth(username, password string) []byte { const header = "Basic " base64 := base64.StdEncoding diff --git a/votingpool/doc.go b/votingpool/doc.go index 83aee9f..322f5dc 100644 --- a/votingpool/doc.go +++ b/votingpool/doc.go @@ -5,7 +5,7 @@ /* Package votingpool provides voting pool functionality for bchwallet. -Overview +# Overview The purpose of the voting pool package is to make it possible to store bitcoins using m-of-n multisig transactions. A pool can have multiple @@ -20,25 +20,25 @@ be found at http://opentransactions.org/wiki/index.php?title=Category:Voting_Poo This package depends on the waddrmgr and walletdb packages. -Creating a voting pool +# Creating a voting pool A voting pool is created via the Create function. This function accepts a database namespace which will be used to store all information related to that pool under a bucket whose key is the pool's ID. -Loading an existing pool +# Loading an existing pool An existing voting pool is loaded via the Load function, which accepts the database name used when creating the pool as well as the poolID. -Creating a series +# Creating a series A series can be created via the CreateSeries method, which accepts a version number, a series identifier, a number of required signatures (m in m-of-n multisig), and a set of public keys. -Deposit Addresses +# Deposit Addresses A deposit address can be created via the DepositScriptAddress method, which returns a series-specific P2SH address from the multi-sig @@ -47,19 +47,19 @@ sorted according to the given branch. The procedure to construct multi-sig deposit addresses is described in detail at http://opentransactions.org/wiki/index.php/Deposit_Address_(voting_pools) -Replacing a series +# Replacing a series A series can be replaced via the ReplaceSeries method. It accepts the same parameters as the CreateSeries method. -Empowering a series +# Empowering a series For security reasons, most private keys will be maintained offline and only brought online when they're needed. In order to bring a key online, one must use the EmpowerSeries method, which takes just the series ID and a raw private key matching one of the series' public keys. -Starting withdrawals +# Starting withdrawals When withdrawing coins from the pool, we employ a deterministic process in order to minimise the cost of coordinating transaction signing. For @@ -82,6 +82,5 @@ that fulfill the output requests. It returns a WithdrawalStatus containing the state of every requested output, the raw signatures for the constructed transactions, the network fees included in those transactions and the input range to use in the next withdrawal. - */ package votingpool diff --git a/waddrmgr/db.go b/waddrmgr/db.go index 0bc75c8..77d1c2f 100644 --- a/waddrmgr/db.go +++ b/waddrmgr/db.go @@ -2027,9 +2027,10 @@ func putBirthday(ns walletdb.ReadWriteBucket, t time.Time) error { // FetchBirthdayBlock retrieves the birthday block from the database. // // The block is serialized as follows: -// [0:4] block height -// [4:36] block hash -// [36:44] block timestamp +// +// [0:4] block height +// [4:36] block hash +// [36:44] block timestamp func FetchBirthdayBlock(ns walletdb.ReadBucket) (BlockStamp, error) { var block BlockStamp @@ -2067,9 +2068,10 @@ func DeleteBirthdayBlock(ns walletdb.ReadWriteBucket) error { // PutBirthdayBlock stores the provided birthday block to the database. // // The block is serialized as follows: -// [0:4] block height -// [4:36] block hash -// [36:44] block timestamp +// +// [0:4] block height +// [4:36] block hash +// [36:44] block timestamp // // NOTE: This does not alter the birthday block verification state. func PutBirthdayBlock(ns walletdb.ReadWriteBucket, block BlockStamp) error { diff --git a/waddrmgr/doc.go b/waddrmgr/doc.go index aa14430..1439b65 100644 --- a/waddrmgr/doc.go +++ b/waddrmgr/doc.go @@ -6,7 +6,7 @@ Package waddrmgr provides a secure hierarchical deterministic wallet address manager. -Overview +# Overview One of the fundamental jobs of a wallet is to manage addresses, private keys, and script data associated with them. At a high level, this package provides @@ -52,14 +52,14 @@ used to decrypt private keys and scripts on demand. Relocking the address manager actively zeros all private material from memory. In addition, temp private key material used internally is zeroed as soon as it's used. -Locking and Unlocking +# Locking and Unlocking As previously mentioned, this package provide facilities for locking and unlocking the address manager to protect access to private material and remove it from memory when locked. The Lock, Unlock, and IsLocked functions are used for this purpose. -Creating a New Address Manager +# Creating a New Address Manager A new address manager is created via the Create function. This function accepts a wallet database namespace, passphrases, network, and perhaps most importantly, @@ -69,28 +69,28 @@ to be recovered with only the seed. The GenerateSeed function in the hdkeychain package can be used as a convenient way to create a random seed for use with this function. The address manager is locked immediately upon being created. -Opening an Existing Address Manager +# Opening an Existing Address Manager An existing address manager is opened via the Open function. This function accepts an existing wallet database namespace, the public passphrase, and network. The address manager is opened locked as expected since the open function does not take the private passphrase to unlock it. -Closing the Address Manager +# Closing the Address Manager The Close method should be called on the address manager when the caller is done with it. While it is not required, it is recommended because it sanely shuts down the database and ensures all private and public key material is purged from memory. -Managed Addresses +# Managed Addresses Each address returned by the address manager satisifies the ManagedAddress interface as well as either the ManagedPubKeyAddress or ManagedScriptAddress interfaces. These interfaces provide the means to obtain relevant information about the addresses such as their private keys and scripts. -Chained Addresses +# Chained Addresses Most callers will make use of the chained addresses for normal operations. Internal addresses are intended for internal wallet uses such as change outputs, @@ -101,13 +101,13 @@ been provided. In addition, the LastInternalAddress and LastExternalAddress functions can be used to get the most recently provided internal and external address, respectively. -Requesting Existing Addresses +# Requesting Existing Addresses In addition to generating new addresses, access to old addresses is often required. Most notably, to sign transactions in order to redeem them. The Address function provides this capability and returns a ManagedAddress. -Importing Addresses +# Importing Addresses While the recommended approach is to use the chained addresses discussed above because they can be deterministically regenerated to avoid losing funds as long @@ -116,27 +116,27 @@ and as a result, this package provides the ability to import existing private keys in Wallet Import Format (WIF) and hence the associated public key and address. -Importing Scripts +# Importing Scripts In order to support pay-to-script-hash transactions, the script must be securely stored as it is needed to redeem the transaction. This can be useful for a variety of scenarios, however the most common use is currently multi-signature transactions. -Syncing +# Syncing The address manager also supports storing and retrieving a block hash and height which the manager is known to have all addresses synced through. The manager itself does not have any notion of which addresses are synced or not. It only provides the storage as a convenience for the caller. -Network +# Network The address manager must be associated with a given network in order to provide appropriate addresses and reject imported addresses and scripts which don't apply to the associated network. -Errors +# Errors All errors returned from this package are of type ManagerError. This allows the caller to programmatically ascertain the specific reasons for failure by @@ -144,12 +144,12 @@ examining the ErrorCode field of the type asserted ManagerError. For certain error codes, as documented by the specific error codes, the underlying error will be contained in the Err field. -Bitcoin Improvement Proposals +# Bitcoin Improvement Proposals This package includes concepts outlined by the following BIPs: - BIP0032 (https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) - BIP0043 (https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki) - BIP0044 (https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) + BIP0032 (https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) + BIP0043 (https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki) + BIP0044 (https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) */ package waddrmgr diff --git a/waddrmgr/manager.go b/waddrmgr/manager.go index 083104f..72f1f29 100644 --- a/waddrmgr/manager.go +++ b/waddrmgr/manager.go @@ -1341,7 +1341,8 @@ func deriveCoinTypeKey(masterNode *hdkeychain.ExtendedKey, // hierarchy described by BIP0044 given the master node. // // In particular this is the hierarchical deterministic extended key path: -// m/purpose'/'/' +// +// m/purpose'/'/' func deriveAccountKey(coinTypeKey *hdkeychain.ExtendedKey, account uint32) (*hdkeychain.ExtendedKey, error) { @@ -1362,7 +1363,8 @@ func deriveAccountKey(coinTypeKey *hdkeychain.ExtendedKey, // already derived accordingly. // // In particular this is the hierarchical deterministic extended key path: -// m/purpose'/'/'/ +// +// m/purpose'/'/'/ // // The branch is 0 for external addresses and 1 for internal addresses. func checkBranchKeys(acctKey *hdkeychain.ExtendedKey) error { diff --git a/wallet/doc.go b/wallet/doc.go index f99a856..c562d58 100644 --- a/wallet/doc.go +++ b/wallet/doc.go @@ -7,6 +7,5 @@ Package wallet provides ... TODO: Flesh out this section Overview - */ package wallet diff --git a/wallet/recovery.go b/wallet/recovery.go index ca4e9e8..c5832f6 100644 --- a/wallet/recovery.go +++ b/wallet/recovery.go @@ -189,11 +189,11 @@ func (rm *RecoveryManager) State() *RecoveryState { // // These are defined as: // - Inter-Block Gap: The maximum difference between the derived child indexes -// of the last addresses used in any block and the next address consumed -// by a later block. +// of the last addresses used in any block and the next address consumed +// by a later block. // - Intra-Block Gap: The maximum difference between the derived child indexes -// of the first address used in any block and the last address used in the -// same block. +// of the first address used in any block and the last address used in the +// same block. type RecoveryState struct { // recoveryWindow defines the key-derivation lookahead used when // attempting to recover the set of used addresses. This value will be @@ -282,12 +282,12 @@ func NewScopeRecoveryState(recoveryWindow uint32) *ScopeRecoveryState { // derivation branch. // // A branch recovery state supports operations for: -// - Expanding the look-ahead horizon based on which indexes have been found. -// - Registering derived addresses with indexes within the horizon. -// - Reporting an invalid child index that falls into the horizon. -// - Reporting that an address has been found. -// - Retrieving all currently derived addresses for the branch. -// - Looking up a particular address by its child index. +// - Expanding the look-ahead horizon based on which indexes have been found. +// - Registering derived addresses with indexes within the horizon. +// - Reporting an invalid child index that falls into the horizon. +// - Reporting that an address has been found. +// - Retrieving all currently derived addresses for the branch. +// - Looking up a particular address by its child index. type BranchRecoveryState struct { // recoveryWindow defines the key-derivation lookahead used when // attempting to recover the set of addresses on this branch. diff --git a/wallet/wallet.go b/wallet/wallet.go index 0ae3db5..8dfdfa2 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -841,13 +841,13 @@ func (w *Wallet) recoverDefaultScopes( // recoverAccountAddresses scans a range of blocks in attempts to recover any // previously used addresses for a particular account derivation path. At a high // level, the algorithm works as follows: -// 1) Ensure internal and external branch horizons are fully expanded. -// 2) Filter the entire range of blocks, stopping if a non-zero number of -// address are contained in a particular block. -// 3) Record all internal and external addresses found in the block. -// 4) Record any outpoints found in the block that should be watched for spends -// 5) Trim the range of blocks up to and including the one reporting the addrs. -// 6) Repeat from (1) if there are still more blocks in the range. +// 1. Ensure internal and external branch horizons are fully expanded. +// 2. Filter the entire range of blocks, stopping if a non-zero number of +// address are contained in a particular block. +// 3. Record all internal and external addresses found in the block. +// 4. Record any outpoints found in the block that should be watched for spends +// 5. Trim the range of blocks up to and including the one reporting the addrs. +// 6. Repeat from (1) if there are still more blocks in the range. func (w *Wallet) recoverScopedAddresses( chainClient chain.Interface, tx walletdb.ReadWriteTx, diff --git a/wallet/wallet_test.go b/wallet/wallet_test.go index f70f43c..408c2f4 100644 --- a/wallet/wallet_test.go +++ b/wallet/wallet_test.go @@ -6,7 +6,7 @@ import ( ) // TestLocateBirthdayBlock ensures we can properly map a block in the chain to a -//timestamp. +// timestamp. func TestLocateBirthdayBlock(t *testing.T) { t.Parallel() diff --git a/wtxmgr/db.go b/wtxmgr/db.go index 62893ac..869b601 100644 --- a/wtxmgr/db.go +++ b/wtxmgr/db.go @@ -678,21 +678,21 @@ func deleteRawCredit(ns walletdb.ReadWriteBucket, k []byte) error { // // Example usage: // -// prefix := keyTxRecord(txHash, block) -// it := makeCreditIterator(ns, prefix) -// for it.next() { -// // Use it.elem -// // If necessary, read additional details from it.ck, it.cv -// } -// if it.err != nil { -// // Handle error -// } +// prefix := keyTxRecord(txHash, block) +// it := makeCreditIterator(ns, prefix) +// for it.next() { +// // Use it.elem +// // If necessary, read additional details from it.ck, it.cv +// } +// if it.err != nil { +// // Handle error +// } // // The elem's Spent field is not set to true if the credit is spent by an // unmined transaction. To check for this case: // -// k := canonicalOutPoint(&txHash, it.elem.Index) -// it.elem.Spent = existsRawUnminedInput(ns, k) != nil +// k := canonicalOutPoint(&txHash, it.elem.Index) +// it.elem.Spent = existsRawUnminedInput(ns, k) != nil type creditIterator struct { c walletdb.ReadWriteCursor // Set to nil after final iteration prefix []byte @@ -918,15 +918,15 @@ func deleteRawDebit(ns walletdb.ReadWriteBucket, k []byte) error { // // Example usage: // -// prefix := keyTxRecord(txHash, block) -// it := makeDebitIterator(ns, prefix) -// for it.next() { -// // Use it.elem -// // If necessary, read additional details from it.ck, it.cv -// } -// if it.err != nil { -// // Handle error -// } +// prefix := keyTxRecord(txHash, block) +// it := makeDebitIterator(ns, prefix) +// for it.next() { +// // Use it.elem +// // If necessary, read additional details from it.ck, it.cv +// } +// if it.err != nil { +// // Handle error +// } type debitIterator struct { c walletdb.ReadWriteCursor // Set to nil after final iteration prefix []byte @@ -1095,22 +1095,22 @@ func deleteRawUnminedCredit(ns walletdb.ReadWriteBucket, k []byte) error { // unminedCreditIterator allows for cursor iteration over all credits, in order, // from a single unmined transaction. // -// Example usage: +// Example usage: // -// it := makeUnminedCreditIterator(ns, txHash) -// for it.next() { -// // Use it.elem, it.ck and it.cv -// // Optionally, use it.delete() to remove this k/v pair -// } -// if it.err != nil { -// // Handle error -// } +// it := makeUnminedCreditIterator(ns, txHash) +// for it.next() { +// // Use it.elem, it.ck and it.cv +// // Optionally, use it.delete() to remove this k/v pair +// } +// if it.err != nil { +// // Handle error +// } // // The spentness of the credit is not looked up for performance reasons (because // for unspent credits, it requires another lookup in another bucket). If this // is needed, it may be checked like this: // -// spent := existsRawUnminedInput(ns, it.ck) != nil +// spent := existsRawUnminedInput(ns, it.ck) != nil type unminedCreditIterator struct { c walletdb.ReadWriteCursor prefix []byte