Skip to content

Commit

Permalink
Merge branch 'master' into fix/cleanup-interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Tíghearnán Carroll committed Sep 24, 2021
2 parents 468ad12 + 25661c5 commit 08684a8
Show file tree
Hide file tree
Showing 32 changed files with 107 additions and 107 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion CODE_STANDARDS.md → .github/CODE_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ View the [effective go](https://golang.org/doc/effective_go.html) standards docu
### *golangci-lint* specifications
The package [golangci-lint](https://golangci-lint.run/usage/quick-start) runs several linters in one package/cmd.

View the active linters in the [configuration file](.golangci.yml).
View the active linters in the [configuration file](../.golangci.yml).

Install via macOS:
```shell
Expand Down
File renamed without changes.
Binary file modified .github/IMAGES/github-share-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
9 changes: 9 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ pull_request_rules:
- check-success='build (1.14.x, ubuntu-latest)'
- check-success='build (1.15.x, ubuntu-latest)'
- check-success='build (1.16.x, ubuntu-latest)'
- check-success='build (1.17.x, ubuntu-latest)'
- check-success='build (1.14.x, macos-latest)'
- check-success='build (1.15.x, macos-latest)'
- check-success='build (1.16.x, macos-latest)'
- check-success='build (1.17.x, macos-latest)'
- check-success='lint (1.15.x, ubuntu-latest)'
- check-success='lint (1.16.x, ubuntu-latest)'
- check-success='lint (1.15.x, macos-latest)'
- check-success='lint (1.16.x, macos-latest)'
- check-success='lint (1.17.x, macos-latest)'
- check-success='Analyze (go)'
- title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
Expand All @@ -32,13 +35,16 @@ pull_request_rules:
- check-success='build (1.14.x, ubuntu-latest)'
- check-success='build (1.15.x, ubuntu-latest)'
- check-success='build (1.16.x, ubuntu-latest)'
- check-success='build (1.17.x, ubuntu-latest)'
- check-success='build (1.14.x, macos-latest)'
- check-success='build (1.15.x, macos-latest)'
- check-success='build (1.16.x, macos-latest)'
- check-success='build (1.17.x, macos-latest)'
- check-success='lint (1.15.x, ubuntu-latest)'
- check-success='lint (1.16.x, ubuntu-latest)'
- check-success='lint (1.15.x, macos-latest)'
- check-success='lint (1.16.x, macos-latest)'
- check-success='lint (1.17.x, macos-latest)'
- check-success='Analyze (go)'
- -title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
actions:
Expand All @@ -56,13 +62,16 @@ pull_request_rules:
- check-success='build (1.14.x, ubuntu-latest)'
- check-success='build (1.15.x, ubuntu-latest)'
- check-success='build (1.16.x, ubuntu-latest)'
- check-success='build (1.17.x, ubuntu-latest)'
- check-success='build (1.14.x, macos-latest)'
- check-success='build (1.15.x, macos-latest)'
- check-success='build (1.16.x, macos-latest)'
- check-success='build (1.17.x, macos-latest)'
- check-success='lint (1.15.x, ubuntu-latest)'
- check-success='lint (1.16.x, ubuntu-latest)'
- check-success='lint (1.15.x, macos-latest)'
- check-success='lint (1.16.x, macos-latest)'
- check-success='lint (1.17.x, macos-latest)'
- check-success='Analyze (go)'
- label!=work-in-progress
- -draft
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
golangci:
strategy:
matrix:
go-version: [1.15.x,1.16.x]
go-version: [1.15.x, 1.16.x, 1.17.x]
os: [macos-latest, ubuntu-latest]
name: lint
runs-on: ${{ matrix.os }}
Expand All @@ -26,7 +26,7 @@ jobs:
build:
strategy:
matrix:
go-version: [ 1.14.x, 1.15.x, 1.16.x ]
go-version: [ 1.14.x, 1.15.x, 1.16.x, 1.17.x ]
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
28 changes: 10 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

# options for analysis running
run:
# default concurrency is a available CPU number
# default concurrency is an available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 1m
timeout: 4m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand All @@ -22,7 +22,7 @@ run:
# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
Expand Down Expand Up @@ -192,14 +192,11 @@ linters-settings:
# See the License for the specific language governing permissions and
# limitations under the License.
template-path:
# also as alternative of directive 'template' you may put the path to file with the template source
# also, as alternative of directive 'template' you may put the path to file with the template source
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/org/project
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gomnd:
settings:
mnd:
Expand Down Expand Up @@ -251,7 +248,7 @@ linters-settings:
- bsv
- bitcoin
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
# make an issue if func has more lines of code than this setting, and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
Expand Down Expand Up @@ -296,7 +293,7 @@ linters-settings:
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types on line above. Default is true.
# matching variables, fields or types on the line above. Default is true.
strict-append: true
# Allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types. Default is true.
Expand All @@ -314,7 +311,7 @@ linters-settings:
# Allow leading comments to be separated with empty liens
allow-separated-leading-comment: false
gofumpt:
# Choose whether or not to use the extra rules that are disabled
# Choose whether to use the extra rules that are disabled
# by default
extra-rules: false

Expand All @@ -336,7 +333,6 @@ linters:
- govet
- gosec
- bodyclose
- golint
- unconvert
- dupl
- misspell
Expand Down Expand Up @@ -372,7 +368,7 @@ linters:

issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
Expand Down Expand Up @@ -408,7 +404,7 @@ issues:
- lll
source: "^//go:generate "

# Independently from option `exclude` we use default exclude patterns,
# Independently of option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
Expand All @@ -418,10 +414,6 @@ issues:
# regular expressions become case sensitive.
exclude-case-sensitive: false

# The list of ids of default excludes to include or disable. By default it's empty.
include:
- EXC0002 # disable excluding of issues about comments from golint

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

Expand Down Expand Up @@ -454,7 +446,7 @@ severity:
default-severity: error

# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
# If set to true severity-rules regular expressions become case-sensitive.
case-sensitive: false

# Default value is empty list.
Expand Down
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ For more information around the technical aspects of Bitcoin, please see the upd

### Features

- Full Featured Bitcoin Transactions
- Auto-Fee Calculations for Change Address
- Bitcoin Transaction [Script](bscript/) Functionality
- Full featured Bitcoin transactions and transaction manipulation/functionality
- Auto-fee calculations for change outputs
- Transaction fee calculation and related checks
- Interfaced signing/unlocking of transaction inputs for easy adaptation/custimisation and extendability for any use case
- Bitcoin Transaction [Script](bscript) functionality
- Bitcoin script engine ([interpreter](bscript/interpreter))
- P2PKH (base58 addresses)
- Data (OP_RETURN)
- [BIP276](https://github.com/moneybutton/bips/blob/master/bip-0276.mediawiki)

- Transaction Signing Extendability

#### Coming Soon! (18 months<sup>TM</sup>)

- Complete SigHash Flag Capability
Expand Down Expand Up @@ -123,7 +124,7 @@ vet Run the Go vet application
## Examples & Tests

All unit tests and [examples](examples) run via [Github Actions](https://github.com/libsv/go-bt/actions) and
uses [Go version 1.15.x](https://golang.org/doc/go1.15). View the [configuration file](.github/workflows/run-tests.yml).
uses [Go version 1.16.x](https://golang.org/doc/go1.16). View the [configuration file](.github/workflows/run-tests.yml).

Run all tests (including integration tests)

Expand Down Expand Up @@ -151,7 +152,7 @@ make bench

## Code Standards

Read more about this Go project's [code standards](CODE_STANDARDS.md).
Read more about this Go project's [code standards](.github/CODE_STANDARDS.md).

<br/>

Expand All @@ -161,17 +162,9 @@ View the [examples](examples)

<br/>

## Maintainers

| [<img src="https://github.com/HaddadJoe.png" height="50" alt="JH" />](https://github.com/HaddadJoe) | [<img src="https://github.com/jadwahab.png" height="50" alt="JW" />](https://github.com/jadwahab) | [<img src="https://github.com/mrz1836.png" height="50" alt="MrZ" />](https://github.com/mrz1836) |
|:---:|:---:|:---:|
| [JH](https://github.com/HaddadJoe)| [JW](https://github.com/jadwahab) | [MrZ](https://github.com/mrz1836) |

<br/>

## Contributing

View the [contributing guidelines](CONTRIBUTING.md) and please follow the [code of conduct](CODE_OF_CONDUCT.md).
View the [contributing guidelines](.github/CONTRIBUTING.md) and please follow the [code of conduct](.github/CODE_OF_CONDUCT.md).

### How can I help?

Expand All @@ -180,8 +173,10 @@ The most basic way to show your support is to star :star2: the project, or to ra
You can also support this project by [becoming a sponsor on GitHub](https://github.com/sponsors/libsv) :clap:
or by making a [**bitcoin donation**](https://gobitcoinsv.com/#sponsor) to ensure this journey continues indefinitely! :rocket:

[![Stars](https://img.shields.io/github/stars/libsv/go-bt?label=Please%20like%20us&style=social)](https://github.com/libsv/go-bt/stargazers)

<br/>

## License

![License](https://img.shields.io/github/license/libsv/go-bt.svg?style=flat&v=1)
[![License](https://img.shields.io/github/license/libsv/go-bt.svg?style=flat&v=1)](LICENSE)
14 changes: 7 additions & 7 deletions bscript/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const (
hashTestNetP2SH = 0xc4
)

// An Address struct contains the address string as well as the hash160 hexstring of the public key.
// The address string will be human readable and specific to the network type, but the public key hash
// An Address struct contains the address string as well as the hash160 hex string of the public key.
// The address string will be human-readable and specific to the network type, but the public key hash
// is useful because it stays the same regardless of the network type (mainnet, testnet).
type Address struct {
AddressString string
Expand Down Expand Up @@ -62,7 +62,7 @@ func addressToPubKeyHashStr(address string) (string, error) {

// NewAddressFromPublicKeyString takes a public key string and returns an Address struct pointer.
// If mainnet parameter is true it will return a mainnet address (starting with a 1).
// Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
// Otherwise, (mainnet is false) it will return a testnet address (starting with an m or n).
func NewAddressFromPublicKeyString(pubKey string, mainnet bool) (*Address, error) {
pubKeyBytes, err := hex.DecodeString(pubKey)
if err != nil {
Expand All @@ -73,7 +73,7 @@ func NewAddressFromPublicKeyString(pubKey string, mainnet bool) (*Address, error

// NewAddressFromPublicKeyHash takes a public key hash in bytes and returns an Address struct pointer.
// If mainnet parameter is true it will return a mainnet address (starting with a 1).
// Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
// Otherwise, (mainnet is false) it will return a testnet address (starting with an m or n).
func NewAddressFromPublicKeyHash(hash []byte, mainnet bool) (*Address, error) {

// regtest := 111
Expand All @@ -83,7 +83,7 @@ func NewAddressFromPublicKeyHash(hash []byte, mainnet bool) (*Address, error) {
if !mainnet {
bb[0] = 111
}
// nolint: makezero // we need to setup the array with 1
// nolint: makezero // we need to set up the array with 1
bb = append(bb, hash...)

return &Address{
Expand All @@ -94,7 +94,7 @@ func NewAddressFromPublicKeyHash(hash []byte, mainnet bool) (*Address, error) {

// NewAddressFromPublicKey takes a bec public key and returns an Address struct pointer.
// If mainnet parameter is true it will return a mainnet address (starting with a 1).
// Otherwise (mainnet is false) it will return a testnet address (starting with an m or n).
// Otherwise, (mainnet is false) it will return a testnet address (starting with an m or n).
func NewAddressFromPublicKey(pubKey *bec.PublicKey, mainnet bool) (*Address, error) {
hash := crypto.Hash160(pubKey.SerialiseCompressed())

Expand All @@ -105,7 +105,7 @@ func NewAddressFromPublicKey(pubKey *bec.PublicKey, mainnet bool) (*Address, err
if !mainnet {
bb[0] = 111
}
// nolint: makezero // we need to setup the array with 1
// nolint: makezero // we need to set up the array with 1
bb = append(bb, hash...)

return &Address{
Expand Down
2 changes: 1 addition & 1 deletion bscript/bip276.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/libsv/go-bk/crypto"
)

// BIP276 proposes a scheme for encoding typed bitcoin related data in a user friendly way
// BIP276 proposes a scheme for encoding typed bitcoin related data in a user-friendly way
// see https://github.com/moneybutton/bips/blob/master/bip-0276.mediawiki
type BIP276 struct {
Prefix string
Expand Down
2 changes: 1 addition & 1 deletion bscript/interpreter/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ to right and intentionally do not provide loops.
The vast majority of Bitcoin scripts at the time of this writing are of several
standard forms which consist of a spender providing a public key and a signature
which proves the spender owns the associated private key. This information
is used to prove the the spender is authorized to perform the transaction.
is used to prove the spender is authorized to perform the transaction.
One benefit of using a scripting language is added flexibility in specifying
what conditions must be met in order to spend bitcoins.
Expand Down
2 changes: 1 addition & 1 deletion bscript/interpreter/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestBadPC(t *testing.T) {
}
}

// TestCheckErrorCondition tests the execute early test in CheckErrorCondition()
// TestCheckErrorCondition tests to execute early test in CheckErrorCondition()
// since most code paths are tested elsewhere.
func TestCheckErrorCondition(t *testing.T) {
t.Parallel()
Expand Down
10 changes: 5 additions & 5 deletions bscript/interpreter/errs/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const (
// a script that has not finished executing.
ErrScriptUnfinished

// ErrScriptDone is returned when an attempt to execute an opcode is
// ErrInvalidProgramCounter is returned when an attempt to execute an opcode is
// made once all of them have already been executed. This can happen
// due to things such as a second call to Execute or calling Step after
// all opcodes have already been executed.
Expand All @@ -97,7 +97,7 @@ const (
ErrStackOverflow

// ErrInvalidPubKeyCount is returned when the number of public keys
// specified for a multsig is either negative or greater than
// specified for a multisig is either negative or greater than
// MaxPubKeysPerMultiSig.
ErrInvalidPubKeyCount

Expand Down Expand Up @@ -148,7 +148,7 @@ const (
// true.
ErrCheckSigVerify

// ErrCheckSigVerify is returned when OP_CHECKMULTISIGVERIFY is
// ErrCheckMultiSigVerify is returned when OP_CHECKMULTISIGVERIFY is
// encountered in a script and the top item on the data stack does not
// evaluate to true.
ErrCheckMultiSigVerify
Expand Down Expand Up @@ -288,7 +288,7 @@ const (
ErrPubKeyType

// ErrCleanStack is returned when the ScriptVerifyCleanStack flag
// is set, and after evalution, the stack does not contain only a
// is set, and after evaluation, the stack does not contain only a
// single element.
ErrCleanStack

Expand Down Expand Up @@ -424,7 +424,7 @@ func NewError(c ErrorCode, desc string, fmtArgs ...interface{}) Error {
return Error{ErrorCode: c, Description: fmt.Sprintf(desc, fmtArgs...)}
}

// IsErrorCode returns whether or not the provided error is a script error with
// IsErrorCode returns whether the provided error is a script error with
// the provided error code.
func IsErrorCode(err error, c ErrorCode) bool {
e := &Error{}
Expand Down
2 changes: 1 addition & 1 deletion bscript/interpreter/opcodeparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ParsedOp struct {
Data []byte
}

// Name returns the human readible name for the current opcode
// Name returns the human readable name for the current opcode
func (o *ParsedOp) Name() string {
return o.Op.name
}
Expand Down
Loading

0 comments on commit 08684a8

Please sign in to comment.