Skip to content

Commit

Permalink
ci: run "make fmt"
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee17 committed Aug 8, 2022
1 parent 0c2b218 commit 610ec20
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 124 deletions.
4 changes: 3 additions & 1 deletion chain/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ func BackEnds() []string {
}

// Interface allows more than one backing blockchain source, such as a
// RPC chain server, or an SPV library, as long as we write a driver for
//
// RPC chain server, or an SPV library, as long as we write a driver for
//
// it.
type Interface interface {
Start() error
Expand Down
6 changes: 4 additions & 2 deletions chain/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func pipe(c1, c2 *conn) (*conn, *conn) {
// returns the root of the tree.
//
// This function was copied from:
// https://github.com/lbryio/lbcd/blob/36a96f6a0025b6aeaebe4106821c2d46ee4be8d4/blockchain/fullblocktests/generate.go#L303
//
// https://github.com/lbryio/lbcd/blob/36a96f6a0025b6aeaebe4106821c2d46ee4be8d4/blockchain/fullblocktests/generate.go#L303
func calcMerkleRoot(txns []*wire.MsgTx) chainhash.Hash {
if len(txns) == 0 {
return chainhash.Hash{}
Expand All @@ -86,7 +87,8 @@ func calcMerkleRoot(txns []*wire.MsgTx) chainhash.Hash {
// with the solution. False is returned if no solution exists.
//
// This function was copied from:
// https://github.com/lbryio/lbcd/blob/36a96f6a0025b6aeaebe4106821c2d46ee4be8d4/blockchain/fullblocktests/generate.go#L324
//
// https://github.com/lbryio/lbcd/blob/36a96f6a0025b6aeaebe4106821c2d46ee4be8d4/blockchain/fullblocktests/generate.go#L324
func solveBlock(header *wire.BlockHeader) bool {
// sbResult is used by the solver goroutines to send results.
type sbResult struct {
Expand Down
8 changes: 4 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,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 lbcwallet functioning properly without any config
// settings while still allowing the user to override settings with config files
Expand Down
6 changes: 4 additions & 2 deletions netparams/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ type Params struct {
}

// MainNetParams contains parameters specific running lbcwallet and
// on the main network (wire.MainNet).
//
// on the main network (wire.MainNet).
var MainNetParams = Params{
Params: &chaincfg.MainNetParams,
RPCClientPort: "9245",
RPCServerPort: "9244",
}

// TestNet3Params contains parameters specific running lbcwallet and
// on the test network (version 3) (wire.TestNet3).
//
// on the test network (version 3) (wire.TestNet3).
var TestNet3Params = Params{
Params: &chaincfg.TestNet3Params,
RPCClientPort: "19245",
Expand Down
36 changes: 21 additions & 15 deletions rpc/legacyrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,14 +1226,17 @@ func listLockUnspent(icmd interface{}, w *wallet.Wallet) (interface{}, error) {

// listReceivedByAccount handles a listreceivedbyaccount request by returning
// a slice of objects, each one containing:
// "account": the receiving account;
// "amount": total amount received by the account;
// "confirmations": number of confirmations of the most recent transaction.
//
// "account": the receiving account;
// "amount": total amount received by the account;
// "confirmations": number of confirmations of the most recent transaction.
//
// It takes two parameters:
// "minconf": minimum number of confirmations to consider a transaction -
// default: one;
// "includeempty": whether or not to include addresses that have no transactions -
// default: false.
//
// "minconf": minimum number of confirmations to consider a transaction -
// default: one;
// "includeempty": whether or not to include addresses that have no transactions -
// default: false.
func listReceivedByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
cmd := icmd.(*btcjson.ListReceivedByAccountCmd)

Expand All @@ -1257,15 +1260,18 @@ func listReceivedByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, err

// listReceivedByAddress handles a listreceivedbyaddress request by returning
// a slice of objects, each one containing:
// "account": the account of the receiving address;
// "address": the receiving address;
// "amount": total amount received by the address;
// "confirmations": number of confirmations of the most recent transaction.
//
// "account": the account of the receiving address;
// "address": the receiving address;
// "amount": total amount received by the address;
// "confirmations": number of confirmations of the most recent transaction.
//
// It takes two parameters:
// "minconf": minimum number of confirmations to consider a transaction -
// default: one;
// "includeempty": whether or not to include addresses that have no transactions -
// default: false.
//
// "minconf": minimum number of confirmations to consider a transaction -
// default: one;
// "includeempty": whether or not to include addresses that have no transactions -
// default: false.
func listReceivedByAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
cmd := icmd.(*btcjson.ListReceivedByAddressCmd)

Expand Down
2 changes: 1 addition & 1 deletion rpc/legacyrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,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
Expand Down
16 changes: 8 additions & 8 deletions rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// Full documentation of the API implemented by this package is maintained in a
// language-agnostic document:
//
// https://github.com/lbryio/lbcwallet/blob/master/rpc/documentation/api.md
// https://github.com/lbryio/lbcwallet/blob/master/rpc/documentation/api.md
//
// Any API changes must be performed according to the steps listed here:
//
// https://github.com/lbryio/lbcwallet/blob/master/rpc/documentation/serverchanges.md
// https://github.com/lbryio/lbcwallet/blob/master/rpc/documentation/serverchanges.md
package rpcserver

import (
Expand Down Expand Up @@ -487,12 +487,12 @@ func (s *walletServer) SignTransaction(ctx context.Context, req *pb.SignTransact
}

// BUGS:
// - The transaction is not inspected to be relevant before publishing using
// sendrawtransaction, so connection errors to could result in the tx
// never being added to the wallet database.
// - Once the above bug is fixed, wallet will require a way to purge invalid
// transactions from the database when they are rejected by the network, other
// than double spending them.
// - The transaction is not inspected to be relevant before publishing using
// sendrawtransaction, so connection errors to could result in the tx
// never being added to the wallet database.
// - Once the above bug is fixed, wallet will require a way to purge invalid
// transactions from the database when they are rejected by the network, other
// than double spending them.
func (s *walletServer) PublishTransaction(ctx context.Context, req *pb.PublishTransactionRequest) (
*pb.PublishTransactionResponse, error) {

Expand Down
2 changes: 2 additions & 0 deletions rpc/walletrpc/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions waddrmgr/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2383,9 +2383,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

Expand Down Expand Up @@ -2423,9 +2424,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 {
Expand Down
34 changes: 17 additions & 17 deletions waddrmgr/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -116,40 +116,40 @@ 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
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
6 changes: 4 additions & 2 deletions waddrmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,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'/<coin type>'/<account>'
//
// m/purpose'/<coin type>'/<account>'
func deriveAccountKey(coinTypeKey *hdkeychain.ExtendedKey,
account uint32) (*hdkeychain.ExtendedKey, error) {

Expand All @@ -1502,7 +1503,8 @@ func deriveAccountKey(coinTypeKey *hdkeychain.ExtendedKey,
// already derived accordingly.
//
// In particular this is the hierarchical deterministic extended key path:
// m/purpose'/<coin type>'/<account>'/<branch>
//
// m/purpose'/<coin type>'/<account>'/<branch>
//
// The branch is 0 for external addresses and 1 for internal addresses.
func checkBranchKeys(acctKey *hdkeychain.ExtendedKey) error {
Expand Down
1 change: 0 additions & 1 deletion wallet/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ Package wallet provides ...
TODO: Flesh out this section
Overview
*/
package wallet
20 changes: 10 additions & 10 deletions wallet/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 610ec20

Please sign in to comment.