Compare commits

...

17 commits

Author SHA1 Message Date
Roy Lee
da9486f408 [lbry] go module: update dependencies 2021-12-14 22:08:58 -08:00
Brannon King
be580c28b7 [lbry] repaired a few unit tests 2021-12-14 22:08:54 -08:00
Roy Lee
38a9f69d1e [lbry] ci: add golangci-lint action 2021-12-14 22:08:54 -08:00
Roy Lee
44869b8b01 [lbry] ci: fix linting errors 2021-12-14 22:08:54 -08:00
Brannon King
ee79ce7992 [lbry] remove pbst submodule 2021-12-14 22:08:50 -08:00
Brannon King
bea5c62644 [lbry] renamed package to lbcutil, updated refs to it 2021-12-14 22:08:50 -08:00
Roy Lee
0ef993d30c lbry: enlarge MaxSatoshi from 2e6 to 2e9 2021-12-14 22:08:50 -08:00
Olaoluwa Osuntokun
9c4bbabe7a
Merge pull request #206 from guggero/makefile
ci: add Makefile, use golangci-lint, parallelize CI actions
2021-11-29 10:29:20 -08:00
Olaoluwa Osuntokun
9cdf59f60c
Merge pull request #205 from guggero/schnorr-taproot
address: add AddressTaproot
2021-09-29 16:32:59 -07:00
Oliver Gugger
12d7d04b31
multi: fix linter issues 2021-09-28 10:30:21 +02:00
Oliver Gugger
97c3fdfaa2
ci: add Makefile, use golangci-lint
With this commit we add a Makefile with the goal of removing the
goclean.sh script. We also use the more powerful golangci-lint linter
and split the GitHub actions into multiple sections to parallelize them.
2021-09-28 10:30:21 +02:00
Oliver Gugger
c5b2b0b979
address: add AddressTaproot 2021-09-27 13:40:07 +02:00
Oliver Gugger
4a0c04f989
address: refactor common code into AddressSegWit
To avoid a lot of code duplication, we extract the common parts of the
AddressWitnessPubKeyHash and AddressWitnessScriptHash types into a
common base type called AddressSegWit.
2021-09-27 13:40:05 +02:00
Olaoluwa Osuntokun
43b172ec93
Merge pull request #202 from Roasbeef/bech32m
bech32: add new EncodeM and DecodeGeneric functions for bech32
2021-09-21 17:25:32 -07:00
Olaoluwa Osuntokun
23db973afa
bech32: add new EncodeM and DecodeGeneric functions for bech32
In this commit, we add two new package level functions: `EncodeM`, and
`DecodeGeneric`. The new encode method is intended to allow callers to
specify that they want to use the new bech32m checksum. This should be
used when encoding segwit addresses with version 1 and beyond. The new
`DecodeGeneric` function allows a caller to decode a bech32 and bech32m
string with a single function. A new return value is added which is the
version of the returned bech32 string, which allows callers to perform
additional segwit addr validation (v1+ should use bech32m etc).

We opted to add new functions rather than modifying the existing
functions to not cause a breaking API change, as most uses in the wild
can just use the existing functions, and only taproot related logic/code
needs to worry about the new methods.

A series of tests have been added to ensure that `DecodeGeneric`
extracts the proper bech version, and we've also adopted the bech32m
tests from BIP 350.
2021-09-21 17:11:48 -07:00
Olaoluwa Osuntokun
14f90e5946
bech32: add additional field to ErrInvalidChecksum (bech32m version)
In this commit, we add an additional field to the ErrInvalidChecksum,
the bech32m version of a checksum. When decoding, we don't now what
version they actually _intended_ to use, so we'll opt to include both
checksums to aide in debugging and error reporting.
2021-09-21 17:11:43 -07:00
Olaoluwa Osuntokun
3ecfc35771
bech32: add new set of constants/versions to be used for bech32m 2021-09-21 17:11:38 -07:00
86 changed files with 1985 additions and 1147 deletions

View file

@ -6,26 +6,24 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
go: [1.14, 1.15] go: [1.17]
steps: steps:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Check out source - name: Check out source
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Linters
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0"
- name: Build - name: Build
env:
GO111MODULE: "on"
run: go build ./... run: go build ./...
- name: Test - name: Test
env:
GO111MODULE: "on"
run: | run: |
sh ./goclean.sh sh ./goclean.sh
- name: Send btcutil coverage
- name: Send lbcutil coverage
uses: shogo82148/actions-goveralls@v1 uses: shogo82148/actions-goveralls@v1
with: with:
path-to-profile: profile.cov path-to-profile: profile.cov

57
.github/workflows/golangci-lint.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: golangci-lint
env:
# go needs absolute directories, using the $HOME variable doesn't work here.
GOCACHE: /home/runner/work/go/pkg/build
GOPATH: /home/runner/work/go
GO_VERSION: '^1.17.0'
on:
push:
tags:
- v*
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: '${{ env.GO_VERSION }}'
- name: checkout source
uses: actions/checkout@v2
- name: compile code
run: go install -v ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true then the action will use pre-installed Go.
skip-go-installation: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true

2
.gitignore vendored
View file

@ -26,3 +26,5 @@ _cgo_export.*
_testmain.go _testmain.go
*.exe *.exe
coverage.txt
psbt/coverage.txt

152
.golangci.yml Normal file
View file

@ -0,0 +1,152 @@
linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
local-prefixes: github.com/golangci/golangci-lint
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
linters:
disable-all: true
enable:
- asciicheck
- bodyclose
# - deadcode
- depguard
# - dogsled
# - dupl
# - errcheck
# - exhaustive
- exportloopref
# - funlen
# - gochecknoglobals
# - gochecknoinits
# - gocognit
# - goconst
# - gocritic
# - gocyclo
# - godot
# - godox
# - goerr113
- gofmt
- goimports
# - gomnd
- goprintffuncname
# - gosec
# - gosimple
# - govet
# - ineffassign
# - interfacer
# - lll
# - maligned
# - misspell
- nakedret
# - nestif
# - noctx
# - nolintlint
# - prealloc
- rowserrcheck
# - revive
# - scopelint
# - staticcheck
# - structcheck
# - stylecheck
# - testpackage
# - typecheck
- unconvert
# - unparam
# - unused
# - varcheck
# - whitespace
# - wsl
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- path: pkg/golinters/errcheck.go
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
# TODO must be removed after the release of the next version (v1.41.0)
- path: pkg/commands/run.go
linters:
- gomnd
# TODO must be removed after the release of the next version (v1.41.0)
- path: pkg/golinters/nolintlint/nolintlint.go
linters:
- gomnd
# TODO must be removed after the release of the next version (v1.41.0)
- path: pkg/printers/tab.go
linters:
- gomnd
run:
skip-dirs:
- test/testdata_etc
- internal/cache
- internal/renameio
- internal/robustio

116
Makefile Normal file
View file

@ -0,0 +1,116 @@
PKG := github.com/btcsuite/btcutil
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
GOACC_PKG := github.com/ory/go-acc
GOIMPORTS_PKG := golang.org/x/tools/cmd/goimports
GO_BIN := ${GOPATH}/bin
LINT_BIN := $(GO_BIN)/golangci-lint
GOACC_BIN := $(GO_BIN)/go-acc
LINT_COMMIT := v1.18.0
GOACC_COMMIT := 80342ae2e0fcf265e99e76bcc4efd022c7c3811b
DEPGET := cd /tmp && GO111MODULE=on go get -v
GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOTEST := GO111MODULE=on go test
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
RM := rm -f
CP := cp
MAKE := make
XARGS := xargs -L 1
# Linting uses a lot of memory, so keep it under control by limiting the number
# of workers if requested.
ifneq ($(workers),)
LINT_WORKERS = --concurrency=$(workers)
endif
LINT = $(LINT_BIN) run -v $(LINT_WORKERS)
GREEN := "\\033[0;32m"
NC := "\\033[0m"
define print
echo $(GREEN)$1$(NC)
endef
default: build
all: build check
# ============
# DEPENDENCIES
# ============
$(LINT_BIN):
@$(call print, "Fetching linter")
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
$(GOACC_BIN):
@$(call print, "Fetching go-acc")
$(DEPGET) $(GOACC_PKG)@$(GOACC_COMMIT)
goimports:
@$(call print, "Installing goimports.")
$(DEPGET) $(GOIMPORTS_PKG)
# ============
# INSTALLATION
# ============
build:
@$(call print, "Compiling btcutil.")
$(GOBUILD) $(PKG)/...
# =======
# TESTING
# =======
check: unit
unit:
@$(call print, "Running unit tests.")
$(GOTEST) ./... -test.timeout=20m
cd psbt; $(GOTEST) ./... -test.timeout=20m
unit-cover: $(GOACC_BIN)
@$(call print, "Running unit coverage tests.")
$(GOACC_BIN) ./...
cd psbt; $(GOACC_BIN) ./...
unit-race:
@$(call print, "Running unit race tests.")
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
cd psbt; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
# =========
# UTILITIES
# =========
fmt: goimports
@$(call print, "Fixing imports.")
goimports -w $(GOFILES_NOVENDOR)
@$(call print, "Formatting source.")
gofmt -l -w -s $(GOFILES_NOVENDOR)
lint: $(LINT_BIN)
@$(call print, "Linting source.")
$(LINT)
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) coverage.txt psbt/coverage.txt
.PHONY: all \
default \
build \
check \
unit \
unit-cover \
unit-race \
fmt \
lint \
clean

View file

@ -1,49 +1,11 @@
btcutil lbcutil
======= =======
[![Build Status](https://github.com/btcsuite/btcutil/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcutil/actions)
[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcutil)
Package btcutil provides bitcoin-specific convenience functions and types.
A comprehensive suite of tests is provided to ensure proper functionality. See
`test_coverage.txt` for the gocov coverage report. Alternatively, if you are
running a POSIX OS, you can run the `cov_report.sh` script for a real-time
report.
Package lbcutil provides convenience functions and types.
This package was developed for btcd, an alternative full-node implementation of This package was developed for btcd, an alternative full-node implementation of
bitcoin which is under active development by Conformal. Although it was bitcoin which is under active development by Conformal. Although it was
primarily written for btcd, this package has intentionally been designed so it primarily written for btcd, this package has intentionally been designed so it
can be used as a standalone package for any projects needing the functionality can be used as a standalone package for any projects needing the functionality
provided. provided. It has been modified to support lbcd.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil
```
## GPG Verification Key
All official release tags are signed by Conformal so users can ensure the code
has not been tampered with and is coming from the btcsuite developers. To
verify the signature perform the following:
- Download the public key from the Conformal website at
https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt
- Import the public key into your GPG keyring:
```bash
gpg --import GIT-GPG-KEY-conformal.txt
```
- Verify the release tag with the following command where `TAG_NAME` is a
placeholder for the specific tag:
```bash
git tag -v TAG_NAME
```
## License
Package btcutil is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"bytes" "bytes"
@ -11,10 +11,10 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/btcsuite/btcd/btcec" "github.com/lbryio/lbcd/btcec"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
"github.com/btcsuite/btcutil/bech32" "github.com/lbryio/lbcutil/bech32"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
) )
@ -41,7 +41,7 @@ var (
// ErrUnknownAddressType describes an error where an address can not // ErrUnknownAddressType describes an error where an address can not
// decoded as a specific address type due to the string encoding // decoded as a specific address type due to the string encoding
// begining with an identifier byte unknown to any standard or // beginning with an identifier byte unknown to any standard or
// registered (via chaincfg.Register) network. // registered (via chaincfg.Register) network.
ErrUnknownAddressType = errors.New("unknown address type") ErrUnknownAddressType = errors.New("unknown address type")
@ -64,8 +64,8 @@ func encodeAddress(hash160 []byte, netID byte) string {
return base58.CheckEncode(hash160[:ripemd160.Size], netID) return base58.CheckEncode(hash160[:ripemd160.Size], netID)
} }
// encodeSegWitAddress creates a bech32 encoded address string representation // encodeSegWitAddress creates a bech32 (or bech32m for SegWit v1) encoded
// from witness version and witness program. // address string representation from witness version and witness program.
func encodeSegWitAddress(hrp string, witnessVersion byte, witnessProgram []byte) (string, error) { func encodeSegWitAddress(hrp string, witnessVersion byte, witnessProgram []byte) (string, error) {
// Group the address bytes into 5 bit groups, as this is what is used to // Group the address bytes into 5 bit groups, as this is what is used to
// encode each character in the address string. // encode each character in the address string.
@ -79,7 +79,19 @@ func encodeSegWitAddress(hrp string, witnessVersion byte, witnessProgram []byte)
combined := make([]byte, len(converted)+1) combined := make([]byte, len(converted)+1)
combined[0] = witnessVersion combined[0] = witnessVersion
copy(combined[1:], converted) copy(combined[1:], converted)
bech, err := bech32.Encode(hrp, combined)
var bech string
switch witnessVersion {
case 0:
bech, err = bech32.Encode(hrp, combined)
case 1:
bech, err = bech32.EncodeM(hrp, combined)
default:
return "", fmt.Errorf("unsupported witness version %d",
witnessVersion)
}
if err != nil { if err != nil {
return "", err return "", err
} }
@ -149,8 +161,9 @@ func DecodeAddress(addr string, defaultNet *chaincfg.Params) (Address, error) {
} }
// We currently only support P2WPKH and P2WSH, which is // We currently only support P2WPKH and P2WSH, which is
// witness version 0. // witness version 0 and P2TR which is witness version
if witnessVer != 0 { // 1.
if witnessVer != 0 && witnessVer != 1 {
return nil, UnsupportedWitnessVerError(witnessVer) return nil, UnsupportedWitnessVerError(witnessVer)
} }
@ -161,6 +174,10 @@ func DecodeAddress(addr string, defaultNet *chaincfg.Params) (Address, error) {
case 20: case 20:
return newAddressWitnessPubKeyHash(hrp, witnessProg) return newAddressWitnessPubKeyHash(hrp, witnessProg)
case 32: case 32:
if witnessVer == 1 {
return newAddressTaproot(hrp, witnessProg)
}
return newAddressWitnessScriptHash(hrp, witnessProg) return newAddressWitnessScriptHash(hrp, witnessProg)
default: default:
return nil, UnsupportedWitnessProgLenError(len(witnessProg)) return nil, UnsupportedWitnessProgLenError(len(witnessProg))
@ -210,7 +227,7 @@ func DecodeAddress(addr string, defaultNet *chaincfg.Params) (Address, error) {
// returns the witness version and witness program byte representation. // returns the witness version and witness program byte representation.
func decodeSegWitAddress(address string) (byte, []byte, error) { func decodeSegWitAddress(address string) (byte, []byte, error) {
// Decode the bech32 encoded address. // Decode the bech32 encoded address.
_, data, err := bech32.Decode(address) _, data, bech32version, err := bech32.DecodeGeneric(address)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
@ -246,6 +263,18 @@ func decodeSegWitAddress(address string) (byte, []byte, error) {
"version 0: %v", len(regrouped)) "version 0: %v", len(regrouped))
} }
// For witness version 0, the bech32 encoding must be used.
if version == 0 && bech32version != bech32.Version0 {
return 0, nil, fmt.Errorf("invalid checksum expected bech32 " +
"encoding for address with witness version 0")
}
// For witness version 1, the bech32m encoding must be used.
if version == 1 && bech32version != bech32.VersionM {
return 0, nil, fmt.Errorf("invalid checksum expected bech32m " +
"encoding for address with witness version 1")
}
return version, regrouped, nil return version, regrouped, nil
} }
@ -265,7 +294,7 @@ func NewAddressPubKeyHash(pkHash []byte, net *chaincfg.Params) (*AddressPubKeyHa
// newAddressPubKeyHash is the internal API to create a pubkey hash address // newAddressPubKeyHash is the internal API to create a pubkey hash address
// with a known leading identifier byte for a network, rather than looking // with a known leading identifier byte for a network, rather than looking
// it up through its parameters. This is useful when creating a new address // it up through its parameters. This is useful when creating a new address
// structure from a string encoding where the identifer byte is already // structure from a string encoding where the identifier byte is already
// known. // known.
func newAddressPubKeyHash(pkHash []byte, netID byte) (*AddressPubKeyHash, error) { func newAddressPubKeyHash(pkHash []byte, netID byte) (*AddressPubKeyHash, error) {
// Check for a valid pubkey hash length. // Check for a valid pubkey hash length.
@ -304,7 +333,7 @@ func (a *AddressPubKeyHash) String() string {
} }
// Hash160 returns the underlying array of the pubkey hash. This can be useful // Hash160 returns the underlying array of the pubkey hash. This can be useful
// when an array is more appropiate than a slice (for example, when used as map // when an array is more appropriate than a slice (for example, when used as map
// keys). // keys).
func (a *AddressPubKeyHash) Hash160() *[ripemd160.Size]byte { func (a *AddressPubKeyHash) Hash160() *[ripemd160.Size]byte {
return &a.hash return &a.hash
@ -332,7 +361,7 @@ func NewAddressScriptHashFromHash(scriptHash []byte, net *chaincfg.Params) (*Add
// newAddressScriptHashFromHash is the internal API to create a script hash // newAddressScriptHashFromHash is the internal API to create a script hash
// address with a known leading identifier byte for a network, rather than // address with a known leading identifier byte for a network, rather than
// looking it up through its parameters. This is useful when creating a new // looking it up through its parameters. This is useful when creating a new
// address structure from a string encoding where the identifer byte is already // address structure from a string encoding where the identifier byte is already
// known. // known.
func newAddressScriptHashFromHash(scriptHash []byte, netID byte) (*AddressScriptHash, error) { func newAddressScriptHashFromHash(scriptHash []byte, netID byte) (*AddressScriptHash, error) {
// Check for a valid script hash length. // Check for a valid script hash length.
@ -371,7 +400,7 @@ func (a *AddressScriptHash) String() string {
} }
// Hash160 returns the underlying array of the script hash. This can be useful // Hash160 returns the underlying array of the script hash. This can be useful
// when an array is more appropiate than a slice (for example, when used as map // when an array is more appropriate than a slice (for example, when used as map
// keys). // keys).
func (a *AddressScriptHash) Hash160() *[ripemd160.Size]byte { func (a *AddressScriptHash) Hash160() *[ripemd160.Size]byte {
return &a.hash return &a.hash
@ -506,25 +535,88 @@ func (a *AddressPubKey) PubKey() *btcec.PublicKey {
return a.pubKey return a.pubKey
} }
// AddressSegWit is the base address type for all SegWit addresses.
type AddressSegWit struct {
hrp string
witnessVersion byte
witnessProgram []byte
}
// EncodeAddress returns the bech32 (or bech32m for SegWit v1) string encoding
// of an AddressSegWit.
//
// NOTE: This method is part of the Address interface.
func (a *AddressSegWit) EncodeAddress() string {
str, err := encodeSegWitAddress(
a.hrp, a.witnessVersion, a.witnessProgram[:],
)
if err != nil {
return ""
}
return str
}
// ScriptAddress returns the witness program for this address.
//
// NOTE: This method is part of the Address interface.
func (a *AddressSegWit) ScriptAddress() []byte {
return a.witnessProgram[:]
}
// IsForNet returns whether the AddressSegWit is associated with the passed
// bitcoin network.
//
// NOTE: This method is part of the Address interface.
func (a *AddressSegWit) IsForNet(net *chaincfg.Params) bool {
return a.hrp == net.Bech32HRPSegwit
}
// String returns a human-readable string for the AddressWitnessPubKeyHash.
// This is equivalent to calling EncodeAddress, but is provided so the type
// can be used as a fmt.Stringer.
//
// NOTE: This method is part of the Address interface.
func (a *AddressSegWit) String() string {
return a.EncodeAddress()
}
// Hrp returns the human-readable part of the bech32 (or bech32m for SegWit v1)
// encoded AddressSegWit.
func (a *AddressSegWit) Hrp() string {
return a.hrp
}
// WitnessVersion returns the witness version of the AddressSegWit.
func (a *AddressSegWit) WitnessVersion() byte {
return a.witnessVersion
}
// WitnessProgram returns the witness program of the AddressSegWit.
func (a *AddressSegWit) WitnessProgram() []byte {
return a.witnessProgram[:]
}
// AddressWitnessPubKeyHash is an Address for a pay-to-witness-pubkey-hash // AddressWitnessPubKeyHash is an Address for a pay-to-witness-pubkey-hash
// (P2WPKH) output. See BIP 173 for further details regarding native segregated // (P2WPKH) output. See BIP 173 for further details regarding native segregated
// witness address encoding: // witness address encoding:
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki // https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
type AddressWitnessPubKeyHash struct { type AddressWitnessPubKeyHash struct {
hrp string AddressSegWit
witnessVersion byte
witnessProgram [20]byte
} }
// NewAddressWitnessPubKeyHash returns a new AddressWitnessPubKeyHash. // NewAddressWitnessPubKeyHash returns a new AddressWitnessPubKeyHash.
func NewAddressWitnessPubKeyHash(witnessProg []byte, net *chaincfg.Params) (*AddressWitnessPubKeyHash, error) { func NewAddressWitnessPubKeyHash(witnessProg []byte,
net *chaincfg.Params) (*AddressWitnessPubKeyHash, error) {
return newAddressWitnessPubKeyHash(net.Bech32HRPSegwit, witnessProg) return newAddressWitnessPubKeyHash(net.Bech32HRPSegwit, witnessProg)
} }
// newAddressWitnessPubKeyHash is an internal helper function to create an // newAddressWitnessPubKeyHash is an internal helper function to create an
// AddressWitnessPubKeyHash with a known human-readable part, rather than // AddressWitnessPubKeyHash with a known human-readable part, rather than
// looking it up through its parameters. // looking it up through its parameters.
func newAddressWitnessPubKeyHash(hrp string, witnessProg []byte) (*AddressWitnessPubKeyHash, error) { func newAddressWitnessPubKeyHash(hrp string,
witnessProg []byte) (*AddressWitnessPubKeyHash, error) {
// Check for valid program length for witness version 0, which is 20 // Check for valid program length for witness version 0, which is 20
// for P2WPKH. // for P2WPKH.
if len(witnessProg) != 20 { if len(witnessProg) != 20 {
@ -533,68 +625,22 @@ func newAddressWitnessPubKeyHash(hrp string, witnessProg []byte) (*AddressWitnes
} }
addr := &AddressWitnessPubKeyHash{ addr := &AddressWitnessPubKeyHash{
hrp: strings.ToLower(hrp), AddressSegWit{
witnessVersion: 0x00, hrp: strings.ToLower(hrp),
witnessVersion: 0x00,
witnessProgram: witnessProg,
},
} }
copy(addr.witnessProgram[:], witnessProg)
return addr, nil return addr, nil
} }
// EncodeAddress returns the bech32 string encoding of an
// AddressWitnessPubKeyHash.
// Part of the Address interface.
func (a *AddressWitnessPubKeyHash) EncodeAddress() string {
str, err := encodeSegWitAddress(a.hrp, a.witnessVersion,
a.witnessProgram[:])
if err != nil {
return ""
}
return str
}
// ScriptAddress returns the witness program for this address.
// Part of the Address interface.
func (a *AddressWitnessPubKeyHash) ScriptAddress() []byte {
return a.witnessProgram[:]
}
// IsForNet returns whether or not the AddressWitnessPubKeyHash is associated
// with the passed bitcoin network.
// Part of the Address interface.
func (a *AddressWitnessPubKeyHash) IsForNet(net *chaincfg.Params) bool {
return a.hrp == net.Bech32HRPSegwit
}
// String returns a human-readable string for the AddressWitnessPubKeyHash.
// This is equivalent to calling EncodeAddress, but is provided so the type
// can be used as a fmt.Stringer.
// Part of the Address interface.
func (a *AddressWitnessPubKeyHash) String() string {
return a.EncodeAddress()
}
// Hrp returns the human-readable part of the bech32 encoded
// AddressWitnessPubKeyHash.
func (a *AddressWitnessPubKeyHash) Hrp() string {
return a.hrp
}
// WitnessVersion returns the witness version of the AddressWitnessPubKeyHash.
func (a *AddressWitnessPubKeyHash) WitnessVersion() byte {
return a.witnessVersion
}
// WitnessProgram returns the witness program of the AddressWitnessPubKeyHash.
func (a *AddressWitnessPubKeyHash) WitnessProgram() []byte {
return a.witnessProgram[:]
}
// Hash160 returns the witness program of the AddressWitnessPubKeyHash as a // Hash160 returns the witness program of the AddressWitnessPubKeyHash as a
// byte array. // byte array.
func (a *AddressWitnessPubKeyHash) Hash160() *[20]byte { func (a *AddressWitnessPubKeyHash) Hash160() *[20]byte {
return &a.witnessProgram var pubKeyHashWitnessProgram [20]byte
copy(pubKeyHashWitnessProgram[:], a.witnessProgram)
return &pubKeyHashWitnessProgram
} }
// AddressWitnessScriptHash is an Address for a pay-to-witness-script-hash // AddressWitnessScriptHash is an Address for a pay-to-witness-script-hash
@ -602,20 +648,22 @@ func (a *AddressWitnessPubKeyHash) Hash160() *[20]byte {
// witness address encoding: // witness address encoding:
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki // https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
type AddressWitnessScriptHash struct { type AddressWitnessScriptHash struct {
hrp string AddressSegWit
witnessVersion byte
witnessProgram [32]byte
} }
// NewAddressWitnessScriptHash returns a new AddressWitnessPubKeyHash. // NewAddressWitnessScriptHash returns a new AddressWitnessPubKeyHash.
func NewAddressWitnessScriptHash(witnessProg []byte, net *chaincfg.Params) (*AddressWitnessScriptHash, error) { func NewAddressWitnessScriptHash(witnessProg []byte,
net *chaincfg.Params) (*AddressWitnessScriptHash, error) {
return newAddressWitnessScriptHash(net.Bech32HRPSegwit, witnessProg) return newAddressWitnessScriptHash(net.Bech32HRPSegwit, witnessProg)
} }
// newAddressWitnessScriptHash is an internal helper function to create an // newAddressWitnessScriptHash is an internal helper function to create an
// AddressWitnessScriptHash with a known human-readable part, rather than // AddressWitnessScriptHash with a known human-readable part, rather than
// looking it up through its parameters. // looking it up through its parameters.
func newAddressWitnessScriptHash(hrp string, witnessProg []byte) (*AddressWitnessScriptHash, error) { func newAddressWitnessScriptHash(hrp string,
witnessProg []byte) (*AddressWitnessScriptHash, error) {
// Check for valid program length for witness version 0, which is 32 // Check for valid program length for witness version 0, which is 32
// for P2WSH. // for P2WSH.
if len(witnessProg) != 32 { if len(witnessProg) != 32 {
@ -624,60 +672,49 @@ func newAddressWitnessScriptHash(hrp string, witnessProg []byte) (*AddressWitnes
} }
addr := &AddressWitnessScriptHash{ addr := &AddressWitnessScriptHash{
hrp: strings.ToLower(hrp), AddressSegWit{
witnessVersion: 0x00, hrp: strings.ToLower(hrp),
witnessVersion: 0x00,
witnessProgram: witnessProg,
},
} }
copy(addr.witnessProgram[:], witnessProg)
return addr, nil return addr, nil
} }
// EncodeAddress returns the bech32 string encoding of an // AddressTaproot is an Address for a pay-to-taproot (P2TR) output. See BIP 341
// AddressWitnessScriptHash. // for further details.
// Part of the Address interface. type AddressTaproot struct {
func (a *AddressWitnessScriptHash) EncodeAddress() string { AddressSegWit
str, err := encodeSegWitAddress(a.hrp, a.witnessVersion, }
a.witnessProgram[:])
if err != nil { // NewAddressTaproot returns a new AddressTaproot.
return "" func NewAddressTaproot(witnessProg []byte,
net *chaincfg.Params) (*AddressTaproot, error) {
return newAddressTaproot(net.Bech32HRPSegwit, witnessProg)
}
// newAddressWitnessScriptHash is an internal helper function to create an
// AddressWitnessScriptHash with a known human-readable part, rather than
// looking it up through its parameters.
func newAddressTaproot(hrp string,
witnessProg []byte) (*AddressTaproot, error) {
// Check for valid program length for witness version 1, which is 32
// for P2TR.
if len(witnessProg) != 32 {
return nil, errors.New("witness program must be 32 bytes for " +
"p2tr")
} }
return str
}
// ScriptAddress returns the witness program for this address. addr := &AddressTaproot{
// Part of the Address interface. AddressSegWit{
func (a *AddressWitnessScriptHash) ScriptAddress() []byte { hrp: strings.ToLower(hrp),
return a.witnessProgram[:] witnessVersion: 0x01,
} witnessProgram: witnessProg,
},
}
// IsForNet returns whether or not the AddressWitnessScriptHash is associated return addr, nil
// with the passed bitcoin network.
// Part of the Address interface.
func (a *AddressWitnessScriptHash) IsForNet(net *chaincfg.Params) bool {
return a.hrp == net.Bech32HRPSegwit
}
// String returns a human-readable string for the AddressWitnessScriptHash.
// This is equivalent to calling EncodeAddress, but is provided so the type
// can be used as a fmt.Stringer.
// Part of the Address interface.
func (a *AddressWitnessScriptHash) String() string {
return a.EncodeAddress()
}
// Hrp returns the human-readable part of the bech32 encoded
// AddressWitnessScriptHash.
func (a *AddressWitnessScriptHash) Hrp() string {
return a.hrp
}
// WitnessVersion returns the witness version of the AddressWitnessScriptHash.
func (a *AddressWitnessScriptHash) WitnessVersion() byte {
return a.witnessVersion
}
// WitnessProgram returns the witness program of the AddressWitnessScriptHash.
func (a *AddressWitnessScriptHash) WitnessProgram() []byte {
return a.witnessProgram[:]
} }

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"bytes" "bytes"
@ -12,9 +12,9 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
) )
@ -50,8 +50,8 @@ func TestAddresses(t *testing.T) {
addr string addr string
encoded string encoded string
valid bool valid bool
result btcutil.Address result lbcutil.Address
f func() (btcutil.Address, error) f func() (lbcutil.Address, error)
net *chaincfg.Params net *chaincfg.Params
}{ }{
// Positive P2PKH tests. // Positive P2PKH tests.
@ -60,16 +60,16 @@ func TestAddresses(t *testing.T) {
addr: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", addr: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX",
encoded: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", encoded: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX",
valid: true, valid: true,
result: btcutil.TstAddressPubKeyHash( result: lbcutil.TstAddressPubKeyHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc,
0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84}, 0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84},
chaincfg.MainNetParams.PubKeyHashAddrID), chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc,
0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84} 0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84}
return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -78,16 +78,16 @@ func TestAddresses(t *testing.T) {
addr: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG", addr: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG",
encoded: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG", encoded: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG",
valid: true, valid: true,
result: btcutil.TstAddressPubKeyHash( result: lbcutil.TstAddressPubKeyHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4,
0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa}, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa},
chaincfg.MainNetParams.PubKeyHashAddrID), chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4,
0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa} 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa}
return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -96,16 +96,16 @@ func TestAddresses(t *testing.T) {
addr: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1", addr: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1",
encoded: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1", encoded: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1",
valid: true, valid: true,
result: btcutil.TstAddressPubKeyHash( result: lbcutil.TstAddressPubKeyHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c, 0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c,
0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1}, 0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1},
CustomParams.PubKeyHashAddrID), CustomParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c, 0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c,
0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1} 0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1}
return btcutil.NewAddressPubKeyHash(pkHash, &customParams) return lbcutil.NewAddressPubKeyHash(pkHash, &customParams)
}, },
net: &customParams, net: &customParams,
}, },
@ -114,16 +114,16 @@ func TestAddresses(t *testing.T) {
addr: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz", addr: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz",
encoded: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz", encoded: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz",
valid: true, valid: true,
result: btcutil.TstAddressPubKeyHash( result: lbcutil.TstAddressPubKeyHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83, 0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83,
0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f}, 0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f},
chaincfg.TestNet3Params.PubKeyHashAddrID), chaincfg.TestNet3Params.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83, 0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83,
0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f} 0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f}
return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.TestNet3Params) return lbcutil.NewAddressPubKeyHash(pkHash, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -133,12 +133,12 @@ func TestAddresses(t *testing.T) {
name: "p2pkh wrong hash length", name: "p2pkh wrong hash length",
addr: "", addr: "",
valid: false, valid: false,
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x00, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0x00, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b,
0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad,
0xaa} 0xaa}
return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -158,12 +158,12 @@ func TestAddresses(t *testing.T) {
addr: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC", addr: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC",
encoded: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC", encoded: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC",
valid: true, valid: true,
result: btcutil.TstAddressScriptHash( result: lbcutil.TstAddressScriptHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2, 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2,
0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10}, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10},
chaincfg.MainNetParams.ScriptHashAddrID), chaincfg.MainNetParams.ScriptHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
script := []byte{ script := []byte{
0x52, 0x41, 0x04, 0x91, 0xbb, 0xa2, 0x51, 0x09, 0x12, 0xa5, 0x52, 0x41, 0x04, 0x91, 0xbb, 0xa2, 0x51, 0x09, 0x12, 0xa5,
0xbd, 0x37, 0xda, 0x1f, 0xb5, 0xb1, 0x67, 0x30, 0x10, 0xe4, 0xbd, 0x37, 0xda, 0x1f, 0xb5, 0xb1, 0x67, 0x30, 0x10, 0xe4,
@ -186,7 +186,7 @@ func TestAddresses(t *testing.T) {
0xdb, 0xfb, 0x1e, 0x75, 0x4e, 0x35, 0xfa, 0x1c, 0x78, 0x44, 0xdb, 0xfb, 0x1e, 0x75, 0x4e, 0x35, 0xfa, 0x1c, 0x78, 0x44,
0xc4, 0x1f, 0x32, 0x2a, 0x18, 0x63, 0xd4, 0x62, 0x13, 0x53, 0xc4, 0x1f, 0x32, 0x2a, 0x18, 0x63, 0xd4, 0x62, 0x13, 0x53,
0xae} 0xae}
return btcutil.NewAddressScriptHash(script, &chaincfg.MainNetParams) return lbcutil.NewAddressScriptHash(script, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -195,16 +195,16 @@ func TestAddresses(t *testing.T) {
addr: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9", addr: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9",
encoded: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9", encoded: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9",
valid: true, valid: true,
result: btcutil.TstAddressScriptHash( result: lbcutil.TstAddressScriptHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0xee, 0x34, 0xac, 0x67, 0x6b, 0xda, 0xf6, 0xe3, 0x70, 0xc8, 0xee, 0x34, 0xac, 0x67, 0x6b, 0xda, 0xf6, 0xe3, 0x70, 0xc8,
0xc8, 0x20, 0xb9, 0x48, 0xed, 0xfa, 0xd3, 0xa8, 0x73, 0xd8}, 0xc8, 0x20, 0xb9, 0x48, 0xed, 0xfa, 0xd3, 0xa8, 0x73, 0xd8},
CustomParams.ScriptHashAddrID), CustomParams.ScriptHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0xEE, 0x34, 0xAC, 0x67, 0x6B, 0xDA, 0xF6, 0xE3, 0x70, 0xC8, 0xEE, 0x34, 0xAC, 0x67, 0x6B, 0xDA, 0xF6, 0xE3, 0x70, 0xC8,
0xC8, 0x20, 0xB9, 0x48, 0xED, 0xFA, 0xD3, 0xA8, 0x73, 0xD8} 0xC8, 0x20, 0xB9, 0x48, 0xED, 0xFA, 0xD3, 0xA8, 0x73, 0xD8}
return btcutil.NewAddressScriptHashFromHash(pkHash, &customParams) return lbcutil.NewAddressScriptHashFromHash(pkHash, &customParams)
}, },
net: &customParams, net: &customParams,
}, },
@ -216,16 +216,16 @@ func TestAddresses(t *testing.T) {
addr: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8", addr: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8",
encoded: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8", encoded: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8",
valid: true, valid: true,
result: btcutil.TstAddressScriptHash( result: lbcutil.TstAddressScriptHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37,
0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4}, 0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4},
chaincfg.MainNetParams.ScriptHashAddrID), chaincfg.MainNetParams.ScriptHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
hash := []byte{ hash := []byte{
0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37,
0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4} 0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4}
return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) return lbcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -235,16 +235,16 @@ func TestAddresses(t *testing.T) {
addr: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", addr: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n",
encoded: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", encoded: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n",
valid: true, valid: true,
result: btcutil.TstAddressScriptHash( result: lbcutil.TstAddressScriptHash(
[ripemd160.Size]byte{ [ripemd160.Size]byte{
0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e, 0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e,
0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a}, 0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a},
chaincfg.TestNet3Params.ScriptHashAddrID), chaincfg.TestNet3Params.ScriptHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
hash := []byte{ hash := []byte{
0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e, 0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e,
0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a} 0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a}
return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.TestNet3Params) return lbcutil.NewAddressScriptHashFromHash(hash, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -254,12 +254,12 @@ func TestAddresses(t *testing.T) {
name: "p2sh wrong hash length", name: "p2sh wrong hash length",
addr: "", addr: "",
valid: false, valid: false,
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
hash := []byte{ hash := []byte{
0x00, 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0x00, 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9,
0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55,
0x10} 0x10}
return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) return lbcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -270,20 +270,20 @@ func TestAddresses(t *testing.T) {
addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4", addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4",
encoded: "13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg", encoded: "13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
0x52, 0xc6, 0xb4}, 0x52, 0xc6, 0xb4},
btcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), lbcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
0x52, 0xc6, 0xb4} 0x52, 0xc6, 0xb4}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -292,20 +292,20 @@ func TestAddresses(t *testing.T) {
addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65", addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65",
encoded: "15sHANNUBSh6nDp8XkDPmQcW6n3EFwmvE6", encoded: "15sHANNUBSh6nDp8XkDPmQcW6n3EFwmvE6",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
0xb1, 0x6e, 0x65}, 0xb1, 0x6e, 0x65},
btcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), lbcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
0xb1, 0x6e, 0x65} 0xb1, 0x6e, 0x65}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -315,7 +315,7 @@ func TestAddresses(t *testing.T) {
"e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", "e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3",
encoded: "12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S", encoded: "12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b,
0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38,
@ -324,8 +324,8 @@ func TestAddresses(t *testing.T) {
0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b,
0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43,
0xf6, 0x56, 0xb4, 0x12, 0xa3}, 0xf6, 0x56, 0xb4, 0x12, 0xa3},
btcutil.PKFUncompressed, chaincfg.MainNetParams.PubKeyHashAddrID), lbcutil.PKFUncompressed, chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b,
0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38,
@ -334,7 +334,7 @@ func TestAddresses(t *testing.T) {
0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b,
0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43,
0xf6, 0x56, 0xb4, 0x12, 0xa3} 0xf6, 0x56, 0xb4, 0x12, 0xa3}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -344,7 +344,7 @@ func TestAddresses(t *testing.T) {
"0d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e", "0d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e",
encoded: "1Ja5rs7XBZnK88EuLVcFqYGMEbBitzchmX", encoded: "1Ja5rs7XBZnK88EuLVcFqYGMEbBitzchmX",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
@ -353,8 +353,8 @@ func TestAddresses(t *testing.T) {
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73, 0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
0x44, 0xd3, 0x3f, 0x45, 0x3e}, 0x44, 0xd3, 0x3f, 0x45, 0x3e},
btcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID), lbcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
@ -363,7 +363,7 @@ func TestAddresses(t *testing.T) {
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73, 0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
0x44, 0xd3, 0x3f, 0x45, 0x3e} 0x44, 0xd3, 0x3f, 0x45, 0x3e}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -373,7 +373,7 @@ func TestAddresses(t *testing.T) {
"37a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b", "37a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b",
encoded: "1ExqMmf6yMxcBMzHjbj41wbqYuqoX6uBLG", encoded: "1ExqMmf6yMxcBMzHjbj41wbqYuqoX6uBLG",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
@ -382,8 +382,8 @@ func TestAddresses(t *testing.T) {
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71, 0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
0x1e, 0x09, 0x08, 0xef, 0x7b}, 0x1e, 0x09, 0x08, 0xef, 0x7b},
btcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID), lbcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
@ -392,7 +392,7 @@ func TestAddresses(t *testing.T) {
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71, 0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
0x1e, 0x09, 0x08, 0xef, 0x7b} 0x1e, 0x09, 0x08, 0xef, 0x7b}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -401,20 +401,20 @@ func TestAddresses(t *testing.T) {
addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4", addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4",
encoded: "mhiDPVP2nJunaAgTjzWSHCYfAqxxrxzjmo", encoded: "mhiDPVP2nJunaAgTjzWSHCYfAqxxrxzjmo",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
0x52, 0xc6, 0xb4}, 0x52, 0xc6, 0xb4},
btcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), lbcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
0x52, 0xc6, 0xb4} 0x52, 0xc6, 0xb4}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -423,20 +423,20 @@ func TestAddresses(t *testing.T) {
addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65", addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65",
encoded: "mkPETRTSzU8MZLHkFKBmbKppxmdw9qT42t", encoded: "mkPETRTSzU8MZLHkFKBmbKppxmdw9qT42t",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
0xb1, 0x6e, 0x65}, 0xb1, 0x6e, 0x65},
btcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), lbcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
0xb1, 0x6e, 0x65} 0xb1, 0x6e, 0x65}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -446,7 +446,7 @@ func TestAddresses(t *testing.T) {
"cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3",
encoded: "mh8YhPYEAYs3E7EVyKtB5xrcfMExkkdEMF", encoded: "mh8YhPYEAYs3E7EVyKtB5xrcfMExkkdEMF",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b,
0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38,
@ -455,8 +455,8 @@ func TestAddresses(t *testing.T) {
0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b,
0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43,
0xf6, 0x56, 0xb4, 0x12, 0xa3}, 0xf6, 0x56, 0xb4, 0x12, 0xa3},
btcutil.PKFUncompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), lbcutil.PKFUncompressed, chaincfg.TestNet3Params.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b,
0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38,
@ -465,7 +465,7 @@ func TestAddresses(t *testing.T) {
0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b,
0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43,
0xf6, 0x56, 0xb4, 0x12, 0xa3} 0xf6, 0x56, 0xb4, 0x12, 0xa3}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -475,7 +475,7 @@ func TestAddresses(t *testing.T) {
"40d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e", "40d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e",
encoded: "my639vCVzbDZuEiX44adfTUg6anRomZLEP", encoded: "my639vCVzbDZuEiX44adfTUg6anRomZLEP",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
@ -484,8 +484,8 @@ func TestAddresses(t *testing.T) {
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73, 0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
0x44, 0xd3, 0x3f, 0x45, 0x3e}, 0x44, 0xd3, 0x3f, 0x45, 0x3e},
btcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID), lbcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
@ -494,7 +494,7 @@ func TestAddresses(t *testing.T) {
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73, 0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
0x44, 0xd3, 0x3f, 0x45, 0x3e} 0x44, 0xd3, 0x3f, 0x45, 0x3e}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -504,7 +504,7 @@ func TestAddresses(t *testing.T) {
"537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b", "537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b",
encoded: "muUnepk5nPPrxUTuTAhRqrpAQuSWS5fVii", encoded: "muUnepk5nPPrxUTuTAhRqrpAQuSWS5fVii",
valid: true, valid: true,
result: btcutil.TstAddressPubKey( result: lbcutil.TstAddressPubKey(
[]byte{ []byte{
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
@ -513,8 +513,8 @@ func TestAddresses(t *testing.T) {
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71, 0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
0x1e, 0x09, 0x08, 0xef, 0x7b}, 0x1e, 0x09, 0x08, 0xef, 0x7b},
btcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID), lbcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
serializedPubKey := []byte{ serializedPubKey := []byte{
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
@ -523,7 +523,7 @@ func TestAddresses(t *testing.T) {
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71, 0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
0x1e, 0x09, 0x08, 0xef, 0x7b} 0x1e, 0x09, 0x08, 0xef, 0x7b}
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -533,17 +533,17 @@ func TestAddresses(t *testing.T) {
addr: "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4", addr: "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4",
encoded: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", encoded: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
valid: true, valid: true,
result: btcutil.TstAddressWitnessPubKeyHash( result: lbcutil.TstAddressWitnessPubKeyHash(
0, 0,
[20]byte{ [20]byte{
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94,
0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6},
chaincfg.MainNetParams.Bech32HRPSegwit), chaincfg.MainNetParams.Bech32HRPSegwit),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94,
0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}
return btcutil.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.MainNetParams) return lbcutil.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -552,7 +552,7 @@ func TestAddresses(t *testing.T) {
addr: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", addr: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3",
encoded: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", encoded: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3",
valid: true, valid: true,
result: btcutil.TstAddressWitnessScriptHash( result: lbcutil.TstAddressWitnessScriptHash(
0, 0,
[32]byte{ [32]byte{
0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68,
@ -560,13 +560,13 @@ func TestAddresses(t *testing.T) {
0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1,
0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62},
chaincfg.MainNetParams.Bech32HRPSegwit), chaincfg.MainNetParams.Bech32HRPSegwit),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
scriptHash := []byte{ scriptHash := []byte{
0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68,
0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13,
0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1,
0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62} 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}
return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.MainNetParams) return lbcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.MainNetParams)
}, },
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
@ -575,17 +575,17 @@ func TestAddresses(t *testing.T) {
addr: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", addr: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx",
encoded: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", encoded: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx",
valid: true, valid: true,
result: btcutil.TstAddressWitnessPubKeyHash( result: lbcutil.TstAddressWitnessPubKeyHash(
0, 0,
[20]byte{ [20]byte{
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94,
0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6},
chaincfg.TestNet3Params.Bech32HRPSegwit), chaincfg.TestNet3Params.Bech32HRPSegwit),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94,
0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}
return btcutil.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.TestNet3Params) return lbcutil.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -594,7 +594,7 @@ func TestAddresses(t *testing.T) {
addr: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", addr: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7",
encoded: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", encoded: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7",
valid: true, valid: true,
result: btcutil.TstAddressWitnessScriptHash( result: lbcutil.TstAddressWitnessScriptHash(
0, 0,
[32]byte{ [32]byte{
0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68,
@ -602,13 +602,13 @@ func TestAddresses(t *testing.T) {
0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1,
0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62},
chaincfg.TestNet3Params.Bech32HRPSegwit), chaincfg.TestNet3Params.Bech32HRPSegwit),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
scriptHash := []byte{ scriptHash := []byte{
0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68,
0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13,
0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1,
0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62} 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}
return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) return lbcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -617,7 +617,7 @@ func TestAddresses(t *testing.T) {
addr: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", addr: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy",
encoded: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", encoded: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy",
valid: true, valid: true,
result: btcutil.TstAddressWitnessScriptHash( result: lbcutil.TstAddressWitnessScriptHash(
0, 0,
[32]byte{ [32]byte{
0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62,
@ -625,13 +625,13 @@ func TestAddresses(t *testing.T) {
0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2, 0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2,
0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33}, 0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33},
chaincfg.TestNet3Params.Bech32HRPSegwit), chaincfg.TestNet3Params.Bech32HRPSegwit),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
scriptHash := []byte{ scriptHash := []byte{
0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62,
0x21, 0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66, 0x21, 0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66,
0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2, 0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2,
0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33} 0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33}
return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) return lbcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params)
}, },
net: &chaincfg.TestNet3Params, net: &chaincfg.TestNet3Params,
}, },
@ -640,28 +640,138 @@ func TestAddresses(t *testing.T) {
addr: "LTC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KGMN4N9", addr: "LTC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KGMN4N9",
encoded: "ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9", encoded: "ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9",
valid: true, valid: true,
result: btcutil.TstAddressWitnessPubKeyHash( result: lbcutil.TstAddressWitnessPubKeyHash(
0, 0,
[20]byte{ [20]byte{
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94,
0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6},
CustomParams.Bech32HRPSegwit, CustomParams.Bech32HRPSegwit,
), ),
f: func() (btcutil.Address, error) { f: func() (lbcutil.Address, error) {
pkHash := []byte{ pkHash := []byte{
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94,
0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}
return btcutil.NewAddressWitnessPubKeyHash(pkHash, &customParams) return lbcutil.NewAddressWitnessPubKeyHash(pkHash, &customParams)
}, },
net: &customParams, net: &customParams,
}, },
// Unsupported witness versions (version 0 only supported at this point)
// P2TR address tests.
{ {
name: "segwit mainnet witness v1", name: "segwit v1 mainnet p2tr",
addr: "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx", addr: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c",
encoded: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c",
valid: true,
result: lbcutil.TstAddressTaproot(
1, [32]byte{
0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33,
0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9,
0x7c, 0x26, 0x70, 0xda, 0xa9, 0x1e, 0x9f, 0x3a,
0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6,
}, chaincfg.MainNetParams.Bech32HRPSegwit,
),
f: func() (lbcutil.Address, error) {
scriptHash := []byte{
0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33,
0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9,
0x7c, 0x26, 0x70, 0xda, 0xa9, 0x1e, 0x9f, 0x3a,
0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6,
}
return lbcutil.NewAddressTaproot(
scriptHash, &chaincfg.MainNetParams,
)
},
net: &chaincfg.MainNetParams,
},
// Invalid bech32m tests. Source:
// https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki
{
name: "segwit v1 invalid human-readable part",
addr: "tc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq5zuyut",
valid: false, valid: false,
net: &chaincfg.MainNetParams, net: &chaincfg.MainNetParams,
}, },
{
name: "segwit v1 mainnet bech32 instead of bech32m",
addr: "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqh2y7hd",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v1 testnet bech32 instead of bech32m",
addr: "tb1z0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqglt7rf",
valid: false,
net: &chaincfg.TestNet3Params,
},
{
name: "segwit v1 mainnet bech32 instead of bech32m upper case",
addr: "BC1S0XLXVLHEMJA6C4DQV22UAPCTQUPFHLXM9H8Z3K2E72Q4K9HCZ7VQ54WELL",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v0 mainnet bech32m instead of bech32",
addr: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kemeawh",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v1 testnet bech32 instead of bech32m second test",
addr: "tb1q0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq24jc47",
valid: false,
net: &chaincfg.TestNet3Params,
},
{
name: "segwit v1 mainnet bech32m invalid character in checksum",
addr: "bc1p38j9r5y49hruaue7wxjce0updqjuyyx0kh56v8s25huc6995vvpql3jow4",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit mainnet witness v17",
addr: "BC130XLXVLHEMJA6C4DQV22UAPCTQUPFHLXM9H8Z3K2E72Q4K9HCZ7VQ7ZWS8R",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v1 mainnet bech32m invalid program length (1 byte)",
addr: "bc1pw5dgrnzv",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v1 mainnet bech32m invalid program length (41 bytes)",
addr: "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7v8n0nx0muaewav253zgeav",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v1 testnet bech32m mixed case",
addr: "tb1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vq47Zagq",
valid: false,
net: &chaincfg.TestNet3Params,
},
{
name: "segwit v1 mainnet bech32m zero padding of more than 4 bits",
addr: "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7v07qwwzcrf",
valid: false,
net: &chaincfg.MainNetParams,
},
{
name: "segwit v1 mainnet bech32m non-zero padding in 8-to-5-conversion",
addr: "tb1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vpggkg4j",
valid: false,
net: &chaincfg.TestNet3Params,
},
{
name: "segwit v1 mainnet bech32m empty data section",
addr: "bc1gmk9yu",
valid: false,
net: &chaincfg.MainNetParams,
},
// Unsupported witness versions (version 0 and 1 only supported at this point)
{ {
name: "segwit mainnet witness v16", name: "segwit mainnet witness v16",
addr: "BC1SW50QA3JX3S", addr: "BC1SW50QA3JX3S",
@ -737,7 +847,7 @@ func TestAddresses(t *testing.T) {
for _, test := range tests { for _, test := range tests {
// Decode addr and compare error against valid. // Decode addr and compare error against valid.
decoded, err := btcutil.DecodeAddress(test.addr, test.net) decoded, err := lbcutil.DecodeAddress(test.addr, test.net)
if (err == nil) != test.valid { if (err == nil) != test.valid {
t.Errorf("%v: decoding test failed: %v", test.name, err) t.Errorf("%v: decoding test failed: %v", test.name, err)
return return
@ -766,7 +876,7 @@ func TestAddresses(t *testing.T) {
// Encode again and compare against the original. // Encode again and compare against the original.
encoded := decoded.EncodeAddress() encoded := decoded.EncodeAddress()
if test.encoded != encoded { if test.encoded != encoded {
t.Errorf("%v: decoding and encoding produced different addressess: %v != %v", t.Errorf("%v: decoding and encoding produced different addresses: %v != %v",
test.name, test.encoded, encoded) test.name, test.encoded, encoded)
return return
} }
@ -774,20 +884,22 @@ func TestAddresses(t *testing.T) {
// Perform type-specific calculations. // Perform type-specific calculations.
var saddr []byte var saddr []byte
switch d := decoded.(type) { switch d := decoded.(type) {
case *btcutil.AddressPubKeyHash: case *lbcutil.AddressPubKeyHash:
saddr = btcutil.TstAddressSAddr(encoded) saddr = lbcutil.TstAddressSAddr(encoded)
case *btcutil.AddressScriptHash: case *lbcutil.AddressScriptHash:
saddr = btcutil.TstAddressSAddr(encoded) saddr = lbcutil.TstAddressSAddr(encoded)
case *btcutil.AddressPubKey: case *lbcutil.AddressPubKey:
// Ignore the error here since the script // Ignore the error here since the script
// address is checked below. // address is checked below.
saddr, _ = hex.DecodeString(d.String()) saddr, _ = hex.DecodeString(d.String())
case *btcutil.AddressWitnessPubKeyHash: case *lbcutil.AddressWitnessPubKeyHash:
saddr = btcutil.TstAddressSegwitSAddr(encoded) saddr = lbcutil.TstAddressSegwitSAddr(encoded)
case *btcutil.AddressWitnessScriptHash: case *lbcutil.AddressWitnessScriptHash:
saddr = btcutil.TstAddressSegwitSAddr(encoded) saddr = lbcutil.TstAddressSegwitSAddr(encoded)
case *lbcutil.AddressTaproot:
saddr = lbcutil.TstAddressTaprootSAddr(encoded)
} }
// Check script address, as well as the Hash160 method for P2PKH and // Check script address, as well as the Hash160 method for P2PKH and
@ -798,28 +910,28 @@ func TestAddresses(t *testing.T) {
return return
} }
switch a := decoded.(type) { switch a := decoded.(type) {
case *btcutil.AddressPubKeyHash: case *lbcutil.AddressPubKeyHash:
if h := a.Hash160()[:]; !bytes.Equal(saddr, h) { if h := a.Hash160()[:]; !bytes.Equal(saddr, h) {
t.Errorf("%v: hashes do not match:\n%x != \n%x", t.Errorf("%v: hashes do not match:\n%x != \n%x",
test.name, saddr, h) test.name, saddr, h)
return return
} }
case *btcutil.AddressScriptHash: case *lbcutil.AddressScriptHash:
if h := a.Hash160()[:]; !bytes.Equal(saddr, h) { if h := a.Hash160()[:]; !bytes.Equal(saddr, h) {
t.Errorf("%v: hashes do not match:\n%x != \n%x", t.Errorf("%v: hashes do not match:\n%x != \n%x",
test.name, saddr, h) test.name, saddr, h)
return return
} }
case *btcutil.AddressWitnessPubKeyHash: case *lbcutil.AddressWitnessPubKeyHash:
if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp { if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp {
t.Errorf("%v: hrps do not match:\n%x != \n%x", t.Errorf("%v: hrps do not match:\n%x != \n%x",
test.name, test.net.Bech32HRPSegwit, hrp) test.name, test.net.Bech32HRPSegwit, hrp)
return return
} }
expVer := test.result.(*btcutil.AddressWitnessPubKeyHash).WitnessVersion() expVer := test.result.(*lbcutil.AddressWitnessPubKeyHash).WitnessVersion()
if v := a.WitnessVersion(); v != expVer { if v := a.WitnessVersion(); v != expVer {
t.Errorf("%v: witness versions do not match:\n%x != \n%x", t.Errorf("%v: witness versions do not match:\n%x != \n%x",
test.name, expVer, v) test.name, expVer, v)
@ -832,14 +944,14 @@ func TestAddresses(t *testing.T) {
return return
} }
case *btcutil.AddressWitnessScriptHash: case *lbcutil.AddressWitnessScriptHash:
if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp { if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp {
t.Errorf("%v: hrps do not match:\n%x != \n%x", t.Errorf("%v: hrps do not match:\n%x != \n%x",
test.name, test.net.Bech32HRPSegwit, hrp) test.name, test.net.Bech32HRPSegwit, hrp)
return return
} }
expVer := test.result.(*btcutil.AddressWitnessScriptHash).WitnessVersion() expVer := test.result.(*lbcutil.AddressWitnessScriptHash).WitnessVersion()
if v := a.WitnessVersion(); v != expVer { if v := a.WitnessVersion(); v != expVer {
t.Errorf("%v: witness versions do not match:\n%x != \n%x", t.Errorf("%v: witness versions do not match:\n%x != \n%x",
test.name, expVer, v) test.name, expVer, v)

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"errors" "errors"
@ -29,23 +29,23 @@ const (
// String returns the unit as a string. For recognized units, the SI // String returns the unit as a string. For recognized units, the SI
// prefix is used, or "Satoshi" for the base unit. For all unrecognized // prefix is used, or "Satoshi" for the base unit. For all unrecognized
// units, "1eN BTC" is returned, where N is the AmountUnit. // units, "1eN LBC" is returned, where N is the AmountUnit.
func (u AmountUnit) String() string { func (u AmountUnit) String() string {
switch u { switch u {
case AmountMegaBTC: case AmountMegaBTC:
return "MBTC" return "MLBC"
case AmountKiloBTC: case AmountKiloBTC:
return "kBTC" return "kLBC"
case AmountBTC: case AmountBTC:
return "BTC" return "LBC"
case AmountMilliBTC: case AmountMilliBTC:
return "mBTC" return "mLBC"
case AmountMicroBTC: case AmountMicroBTC:
return BTC" return LBC"
case AmountSatoshi: case AmountSatoshi:
return "Satoshi" return "Satoshi"
default: default:
return "1e" + strconv.FormatInt(int64(u), 10) + " BTC" return "1e" + strconv.FormatInt(int64(u), 10) + " LBC"
} }
} }
@ -72,7 +72,7 @@ func round(f float64) Amount {
// NewAmount is for specifically for converting BTC to Satoshi. // NewAmount is for specifically for converting BTC to Satoshi.
// For creating a new Amount with an int64 value which denotes a quantity of Satoshi, // For creating a new Amount with an int64 value which denotes a quantity of Satoshi,
// do a simple type conversion from type int64 to Amount. // do a simple type conversion from type int64 to Amount.
// See GoDoc for example: http://godoc.org/github.com/btcsuite/btcutil#example-Amount // See GoDoc for example: http://godoc.org/github.com/lbryio/lbcutil#example-Amount
func NewAmount(f float64) (Amount, error) { func NewAmount(f float64) (Amount, error) {
// The amount is only considered invalid if it cannot be represented // The amount is only considered invalid if it cannot be represented
// as an integer type. This may happen if f is NaN or +-Infinity. // as an integer type. This may happen if f is NaN or +-Infinity.
@ -82,7 +82,7 @@ func NewAmount(f float64) (Amount, error) {
case math.IsInf(f, 1): case math.IsInf(f, 1):
fallthrough fallthrough
case math.IsInf(f, -1): case math.IsInf(f, -1):
return 0, errors.New("invalid bitcoin amount") return 0, errors.New("invalid coin amount")
} }
return round(f * SatoshiPerBitcoin), nil return round(f * SatoshiPerBitcoin), nil
@ -101,7 +101,7 @@ func (a Amount) ToBTC() float64 {
// Format formats a monetary amount counted in bitcoin base units as a // Format formats a monetary amount counted in bitcoin base units as a
// string for a given unit. The conversion will succeed for any unit, // string for a given unit. The conversion will succeed for any unit,
// however, known units will be formated with an appended label describing // however, known units will be formatted with an appended label describing
// the units with SI notation, or "Satoshi" for the base unit. // the units with SI notation, or "Satoshi" for the base unit.
func (a Amount) Format(u AmountUnit) string { func (a Amount) Format(u AmountUnit) string {
units := " " + u.String() units := " " + u.String()

View file

@ -2,13 +2,13 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"math" "math"
"testing" "testing"
. "github.com/btcsuite/btcutil" . "github.com/lbryio/lbcutil"
) )
func TestAmountCreation(t *testing.T) { func TestAmountCreation(t *testing.T) {
@ -27,25 +27,25 @@ func TestAmountCreation(t *testing.T) {
}, },
{ {
name: "max producible", name: "max producible",
amount: 21e6, amount: 21e9,
valid: true, valid: true,
expected: MaxSatoshi, expected: MaxSatoshi,
}, },
{ {
name: "min producible", name: "min producible",
amount: -21e6, amount: -21e9,
valid: true, valid: true,
expected: -MaxSatoshi, expected: -MaxSatoshi,
}, },
{ {
name: "exceeds max producible", name: "exceeds max producible",
amount: 21e6 + 1e-8, amount: 21e9 + 1e-8,
valid: true, valid: true,
expected: MaxSatoshi + 1, expected: MaxSatoshi + 1,
}, },
{ {
name: "exceeds min producible", name: "exceeds min producible",
amount: -21e6 - 1e-8, amount: -21e9 - 1e-8,
valid: true, valid: true,
expected: -MaxSatoshi - 1, expected: -MaxSatoshi - 1,
}, },
@ -119,40 +119,40 @@ func TestAmountUnitConversions(t *testing.T) {
s string s string
}{ }{
{ {
name: "MBTC", name: "MLBC",
amount: MaxSatoshi, amount: MaxSatoshi,
unit: AmountMegaBTC, unit: AmountMegaBTC,
converted: 21, converted: 21000,
s: "21 MBTC", s: "21000 MLBC",
}, },
{ {
name: "kBTC", name: "kLBC",
amount: 44433322211100, amount: 44433322211100,
unit: AmountKiloBTC, unit: AmountKiloBTC,
converted: 444.33322211100, converted: 444.33322211100,
s: "444.333222111 kBTC", s: "444.333222111 kLBC",
}, },
{ {
name: "BTC", name: "LBC",
amount: 44433322211100, amount: 44433322211100,
unit: AmountBTC, unit: AmountBTC,
converted: 444333.22211100, converted: 444333.22211100,
s: "444333.222111 BTC", s: "444333.222111 LBC",
}, },
{ {
name: "mBTC", name: "mLBC",
amount: 44433322211100, amount: 44433322211100,
unit: AmountMilliBTC, unit: AmountMilliBTC,
converted: 444333222.11100, converted: 444333222.11100,
s: "444333222.111 mBTC", s: "444333222.111 mLBC",
}, },
{ {
name: BTC", name: LBC",
amount: 44433322211100, amount: 44433322211100,
unit: AmountMicroBTC, unit: AmountMicroBTC,
converted: 444333222111.00, converted: 444333222111.00,
s: "444333222111 μBTC", s: "444333222111 μLBC",
}, },
{ {
@ -168,7 +168,7 @@ func TestAmountUnitConversions(t *testing.T) {
amount: 44433322211100, amount: 44433322211100,
unit: AmountUnit(-1), unit: AmountUnit(-1),
converted: 4443332.2211100, converted: 4443332.2211100,
s: "4443332.22111 1e-1 BTC", s: "4443332.22111 1e-1 LBC",
}, },
} }

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"os" "os"

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"os" "os"
@ -12,7 +12,7 @@ import (
"testing" "testing"
"unicode" "unicode"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
) )
// TestAppDataDir tests the API for AppDataDir to ensure it gives expected // TestAppDataDir tests the API for AppDataDir to ensure it gives expected
@ -122,7 +122,7 @@ func TestAppDataDir(t *testing.T) {
t.Logf("Running %d tests", len(tests)) t.Logf("Running %d tests", len(tests))
for i, test := range tests { for i, test := range tests {
ret := btcutil.TstAppDataDir(test.goos, test.appName, test.roaming) ret := lbcutil.TstAppDataDir(test.goos, test.appName, test.roaming)
if ret != test.want { if ret != test.want {
t.Errorf("appDataDir #%d (%s) does not match - "+ t.Errorf("appDataDir #%d (%s) does not match - "+
"expected got %s, want %s", i, test.goos, ret, "expected got %s, want %s", i, test.goos, ret,

View file

@ -1,9 +1,7 @@
base58 base58
========== ==========
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcutil/base58)
Package base58 provides an API for encoding and decoding to and from the Package base58 provides an API for encoding and decoding to and from the
modified base58 encoding. It also provides an API to do Base58Check encoding, modified base58 encoding. It also provides an API to do Base58Check encoding,
@ -11,24 +9,13 @@ as described [here](https://en.bitcoin.it/wiki/Base58Check_encoding).
A comprehensive suite of tests is provided to ensure proper functionality. A comprehensive suite of tests is provided to ensure proper functionality.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/base58
```
## Examples ## Examples
* [Decode Example](http://godoc.org/github.com/btcsuite/btcutil/base58#example-Decode) * [Decode Example](http://godoc.org/github.com/lbryio/lbcutil/base58#example-Decode)
Demonstrates how to decode modified base58 encoded data. Demonstrates how to decode modified base58 encoded data.
* [Encode Example](http://godoc.org/github.com/btcsuite/btcutil/base58#example-Encode) * [Encode Example](http://godoc.org/github.com/lbryio/lbcutil/base58#example-Encode)
Demonstrates how to encode data using the modified base58 encoding scheme. Demonstrates how to encode data using the modified base58 encoding scheme.
* [CheckDecode Example](http://godoc.org/github.com/btcsuite/btcutil/base58#example-CheckDecode) * [CheckDecode Example](http://godoc.org/github.com/lbryio/lbcutil/base58#example-CheckDecode)
Demonstrates how to decode Base58Check encoded data. Demonstrates how to decode Base58Check encoded data.
* [CheckEncode Example](http://godoc.org/github.com/btcsuite/btcutil/base58#example-CheckEncode) * [CheckEncode Example](http://godoc.org/github.com/lbryio/lbcutil/base58#example-CheckEncode)
Demonstrates how to encode data using the Base58Check encoding scheme. Demonstrates how to encode data using the Base58Check encoding scheme.
## License
Package base58 is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -9,7 +9,7 @@ import (
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
) )
var stringTests = []struct { var stringTests = []struct {

View file

@ -8,7 +8,7 @@ import (
"bytes" "bytes"
"testing" "testing"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
) )
var ( var (

View file

@ -28,7 +28,7 @@ func checksum(input []byte) (cksum [4]byte) {
func CheckEncode(input []byte, version byte) string { func CheckEncode(input []byte, version byte) string {
b := make([]byte, 0, 1+len(input)+4) b := make([]byte, 0, 1+len(input)+4)
b = append(b, version) b = append(b, version)
b = append(b, input[:]...) b = append(b, input...)
cksum := checksum(b) cksum := checksum(b)
b = append(b, cksum[:]...) b = append(b, cksum[:]...)
return Encode(b) return Encode(b)

View file

@ -7,7 +7,7 @@ package base58_test
import ( import (
"testing" "testing"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
) )
var checkEncodingStringTests = []struct { var checkEncodingStringTests = []struct {
@ -37,11 +37,14 @@ func TestBase58Check(t *testing.T) {
// test decoding // test decoding
res, version, err := base58.CheckDecode(test.out) res, version, err := base58.CheckDecode(test.out)
if err != nil { switch {
case err != nil:
t.Errorf("CheckDecode test #%d failed with err: %v", x, err) t.Errorf("CheckDecode test #%d failed with err: %v", x, err)
} else if version != test.version {
case version != test.version:
t.Errorf("CheckDecode test #%d failed: got version: %d want: %d", x, version, test.version) t.Errorf("CheckDecode test #%d failed: got version: %d want: %d", x, version, test.version)
} else if string(res) != test.in {
case string(res) != test.in:
t.Errorf("CheckDecode test #%d failed: got: %s want: %s", x, res, test.in) t.Errorf("CheckDecode test #%d failed: got: %s want: %s", x, res, test.in)
} }
} }
@ -56,7 +59,7 @@ func TestBase58Check(t *testing.T) {
// bytes are missing). // bytes are missing).
testString := "" testString := ""
for len := 0; len < 4; len++ { for len := 0; len < 4; len++ {
testString = testString + "x" testString += "x"
_, _, err = base58.CheckDecode(testString) _, _, err = base58.CheckDecode(testString)
if err != base58.ErrInvalidFormat { if err != base58.ErrInvalidFormat {
t.Error("Checkdecode test failed, expected ErrInvalidFormat") t.Error("Checkdecode test failed, expected ErrInvalidFormat")

View file

@ -7,7 +7,7 @@ package base58_test
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
) )
// This example demonstrates how to decode modified base58 encoded data. // This example demonstrates how to decode modified base58 encoded data.

View file

@ -1,29 +1,16 @@
bech32 bech32
========== ==========
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://godoc.org/github.com/btcsuite/btcutil/bech32?status.png)](http://godoc.org/github.com/btcsuite/btcutil/bech32)
Package bech32 provides a Go implementation of the bech32 format specified in Package bech32 provides a Go implementation of the bech32 format specified in
[BIP 173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki). [BIP 173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki).
Test vectors from BIP 173 are added to ensure compatibility with the BIP. Test vectors from BIP 173 are added to ensure compatibility with the BIP.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/bech32
```
## Examples ## Examples
* [Bech32 decode Example](http://godoc.org/github.com/btcsuite/btcutil/bech32#example-Bech32Decode) * [Bech32 decode Example](http://godoc.org/github.com/lbryio/lbcutil/bech32#example-Bech32Decode)
Demonstrates how to decode a bech32 encoded string. Demonstrates how to decode a bech32 encoded string.
* [Bech32 encode Example](http://godoc.org/github.com/btcsuite/btcutil/bech32#example-BechEncode) * [Bech32 encode Example](http://godoc.org/github.com/lbryio/lbcutil/bech32#example-BechEncode)
Demonstrates how to encode data into a bech32 string. Demonstrates how to encode data into a bech32 string.
## License
Package bech32 is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -123,8 +123,11 @@ func bech32Polymod(hrp string, values, checksum []byte) int {
// and 126), otherwise the results are undefined. // and 126), otherwise the results are undefined.
// //
// For more details on the checksum calculation, please refer to BIP 173. // For more details on the checksum calculation, please refer to BIP 173.
func writeBech32Checksum(hrp string, data []byte, bldr *strings.Builder) { func writeBech32Checksum(hrp string, data []byte, bldr *strings.Builder,
polymod := bech32Polymod(hrp, data, nil) ^ 1 version Version) {
bech32Const := int(VersionToConsts[version])
polymod := bech32Polymod(hrp, data, nil) ^ bech32Const
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
b := byte((polymod >> uint(5*(5-i))) & 31) b := byte((polymod >> uint(5*(5-i))) & 31)
@ -137,38 +140,47 @@ func writeBech32Checksum(hrp string, data []byte, bldr *strings.Builder) {
// bech32VerifyChecksum verifies whether the bech32 string specified by the // bech32VerifyChecksum verifies whether the bech32 string specified by the
// provided hrp and payload data (encoded as 5 bits per element byte slice) has // provided hrp and payload data (encoded as 5 bits per element byte slice) has
// the correct checksum suffix. // the correct checksum suffix. The version of bech32 used (bech32 OG, or
// bech32m) is also returned to allow the caller to perform proper address
// validation (segwitv0 should use bech32, v1+ should use bech32m).
// //
// Data MUST have more than 6 elements, otherwise this function panics. // Data MUST have more than 6 elements, otherwise this function panics.
// //
// For more details on the checksum verification, please refer to BIP 173. // For more details on the checksum verification, please refer to BIP 173.
func bech32VerifyChecksum(hrp string, data []byte) bool { func bech32VerifyChecksum(hrp string, data []byte) (Version, bool) {
checksum := data[len(data)-6:] checksum := data[len(data)-6:]
values := data[:len(data)-6] values := data[:len(data)-6]
polymod := bech32Polymod(hrp, values, checksum) polymod := bech32Polymod(hrp, values, checksum)
return polymod == 1
// Before BIP-350, we'd always check this against a static constant of
// 1 to know if the checksum was computed properly. As we want to
// generically support decoding for bech32m as well as bech32, we'll
// look up the returned value and compare it to the set of defined
// constants.
bech32Version, ok := ConstsToVersion[ChecksumConst(polymod)]
if ok {
return bech32Version, true
}
return VersionUnknown, false
} }
// DecodeNoLimit decodes a bech32 encoded string, returning the human-readable // DecodeNoLimit is a bech32 checksum version aware arbitrary string length
// part and the data part excluding the checksum. This function does NOT // decoder. This function will return the version of the decoded checksum
// validate against the BIP-173 maximum length allowed for bech32 strings and // constant so higher level validation can be performed to ensure the correct
// is meant for use in custom applications (such as lightning network payment // version of bech32 was used when encoding.
// requests), NOT on-chain addresses. func decodeNoLimit(bech string) (string, []byte, Version, error) {
//
// Note that the returned data is 5-bit (base32) encoded and the human-readable
// part will be lowercase.
func DecodeNoLimit(bech string) (string, []byte, error) {
// The minimum allowed size of a bech32 string is 8 characters, since it // The minimum allowed size of a bech32 string is 8 characters, since it
// needs a non-empty HRP, a separator, and a 6 character checksum. // needs a non-empty HRP, a separator, and a 6 character checksum.
if len(bech) < 8 { if len(bech) < 8 {
return "", nil, ErrInvalidLength(len(bech)) return "", nil, VersionUnknown, ErrInvalidLength(len(bech))
} }
// Only ASCII characters between 33 and 126 are allowed. // Only ASCII characters between 33 and 126 are allowed.
var hasLower, hasUpper bool var hasLower, hasUpper bool
for i := 0; i < len(bech); i++ { for i := 0; i < len(bech); i++ {
if bech[i] < 33 || bech[i] > 126 { if bech[i] < 33 || bech[i] > 126 {
return "", nil, ErrInvalidCharacter(bech[i]) return "", nil, VersionUnknown, ErrInvalidCharacter(bech[i])
} }
// The characters must be either all lowercase or all uppercase. Testing // The characters must be either all lowercase or all uppercase. Testing
@ -176,7 +188,7 @@ func DecodeNoLimit(bech string) (string, []byte, error) {
hasLower = hasLower || (bech[i] >= 97 && bech[i] <= 122) hasLower = hasLower || (bech[i] >= 97 && bech[i] <= 122)
hasUpper = hasUpper || (bech[i] >= 65 && bech[i] <= 90) hasUpper = hasUpper || (bech[i] >= 65 && bech[i] <= 90)
if hasLower && hasUpper { if hasLower && hasUpper {
return "", nil, ErrMixedCase{} return "", nil, VersionUnknown, ErrMixedCase{}
} }
} }
@ -191,7 +203,7 @@ func DecodeNoLimit(bech string) (string, []byte, error) {
// last 6 characters of the string (since checksum cannot contain '1'). // last 6 characters of the string (since checksum cannot contain '1').
one := strings.LastIndexByte(bech, '1') one := strings.LastIndexByte(bech, '1')
if one < 1 || one+7 > len(bech) { if one < 1 || one+7 > len(bech) {
return "", nil, ErrInvalidSeparatorIndex(one) return "", nil, VersionUnknown, ErrInvalidSeparatorIndex(one)
} }
// The human-readable part is everything before the last '1'. // The human-readable part is everything before the last '1'.
@ -202,12 +214,13 @@ func DecodeNoLimit(bech string) (string, []byte, error) {
// 'charset'. // 'charset'.
decoded, err := toBytes(data) decoded, err := toBytes(data)
if err != nil { if err != nil {
return "", nil, err return "", nil, VersionUnknown, err
} }
// Verify if the checksum (stored inside decoded[:]) is valid, given the // Verify if the checksum (stored inside decoded[:]) is valid, given the
// previously decoded hrp. // previously decoded hrp.
if !bech32VerifyChecksum(hrp, decoded) { bech32Version, ok := bech32VerifyChecksum(hrp, decoded)
if !ok {
// Invalid checksum. Calculate what it should have been, so that the // Invalid checksum. Calculate what it should have been, so that the
// error contains this information. // error contains this information.
@ -215,21 +228,42 @@ func DecodeNoLimit(bech string) (string, []byte, error) {
actual := bech[len(bech)-6:] actual := bech[len(bech)-6:]
payload := decoded[:len(decoded)-6] payload := decoded[:len(decoded)-6]
// Calculate the expected checksum, given the hrp and payload data. // Calculate the expected checksum, given the hrp and payload
// data. We'll actually compute _both_ possibly valid checksum
// to further aide in debugging.
var expectedBldr strings.Builder var expectedBldr strings.Builder
expectedBldr.Grow(6) expectedBldr.Grow(6)
writeBech32Checksum(hrp, payload, &expectedBldr) writeBech32Checksum(hrp, payload, &expectedBldr, Version0)
expected := expectedBldr.String() expectedVersion0 := expectedBldr.String()
var b strings.Builder
b.Grow(6)
writeBech32Checksum(hrp, payload, &expectedBldr, VersionM)
expectedVersionM := expectedBldr.String()
err = ErrInvalidChecksum{ err = ErrInvalidChecksum{
Expected: expected, Expected: expectedVersion0,
Actual: actual, ExpectedM: expectedVersionM,
Actual: actual,
} }
return "", nil, err return "", nil, VersionUnknown, err
} }
// We exclude the last 6 bytes, which is the checksum. // We exclude the last 6 bytes, which is the checksum.
return hrp, decoded[:len(decoded)-6], nil return hrp, decoded[:len(decoded)-6], bech32Version, nil
}
// DecodeNoLimit decodes a bech32 encoded string, returning the human-readable
// part and the data part excluding the checksum. This function does NOT
// validate against the BIP-173 maximum length allowed for bech32 strings and
// is meant for use in custom applications (such as lightning network payment
// requests), NOT on-chain addresses.
//
// Note that the returned data is 5-bit (base32) encoded and the human-readable
// part will be lowercase.
func DecodeNoLimit(bech string) (string, []byte, error) {
hrp, data, _, err := decodeNoLimit(bech)
return hrp, data, err
} }
// Decode decodes a bech32 encoded string, returning the human-readable part and // Decode decodes a bech32 encoded string, returning the human-readable part and
@ -243,16 +277,31 @@ func Decode(bech string) (string, []byte, error) {
return "", nil, ErrInvalidLength(len(bech)) return "", nil, ErrInvalidLength(len(bech))
} }
return DecodeNoLimit(bech) hrp, data, _, err := decodeNoLimit(bech)
return hrp, data, err
} }
// Encode encodes a byte slice into a bech32 string with the given // DecodeGeneric is identical to the existing Decode method, but will also
// human-readable part (HRP). The HRP will be converted to lowercase if needed // return bech32 version that matches the decoded checksum. This method should
// since mixed cased encodings are not permitted and lowercase is used for // be used when decoding segwit addresses, as it enables additional
// checksum purposes. Note that the bytes must each encode 5 bits (base32). // verification to ensure the proper checksum is used.
func Encode(hrp string, data []byte) (string, error) { func DecodeGeneric(bech string) (string, []byte, Version, error) {
// The resulting bech32 string is the concatenation of the lowercase hrp, // The maximum allowed length for a bech32 string is 90.
// the separator 1, data and the 6-byte checksum. if len(bech) > 90 {
return "", nil, VersionUnknown, ErrInvalidLength(len(bech))
}
return decodeNoLimit(bech)
}
// encodeGeneric is the base bech32 encoding function that is aware of the
// existence of the checksum versions. This method is private, as the Encode
// and EncodeM methods are intended to be used instead.
func encodeGeneric(hrp string, data []byte,
version Version) (string, error) {
// The resulting bech32 string is the concatenation of the lowercase
// hrp, the separator 1, data and the 6-byte checksum.
hrp = strings.ToLower(hrp) hrp = strings.ToLower(hrp)
var bldr strings.Builder var bldr strings.Builder
bldr.Grow(len(hrp) + 1 + len(data) + 6) bldr.Grow(len(hrp) + 1 + len(data) + 6)
@ -268,11 +317,26 @@ func Encode(hrp string, data []byte) (string, error) {
} }
// Calculate and write the checksum of the data. // Calculate and write the checksum of the data.
writeBech32Checksum(hrp, data, &bldr) writeBech32Checksum(hrp, data, &bldr, version)
return bldr.String(), nil return bldr.String(), nil
} }
// Encode encodes a byte slice into a bech32 string with the given
// human-readable part (HRP). The HRP will be converted to lowercase if needed
// since mixed cased encodings are not permitted and lowercase is used for
// checksum purposes. Note that the bytes must each encode 5 bits (base32).
func Encode(hrp string, data []byte) (string, error) {
return encodeGeneric(hrp, data, Version0)
}
// EncodeM is the exactly same as the Encode method, but it uses the new
// bech32m constant instead of the original one. It should be used whenever one
// attempts to encode a segwit address of v1 and beyond.
func EncodeM(hrp string, data []byte) (string, error) {
return encodeGeneric(hrp, data, VersionM)
}
// ConvertBits converts a byte slice where each byte is encoding fromBits bits, // ConvertBits converts a byte slice where each byte is encoding fromBits bits,
// to a byte slice where each byte is encoding toBits bits. // to a byte slice where each byte is encoding toBits bits.
func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error) { func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error) {
@ -298,7 +362,7 @@ func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error)
for _, b := range data { for _, b := range data {
// Discard unused bits. // Discard unused bits.
b = b << (8 - fromBits) b <<= 8 - fromBits
// How many bits remaining to extract from the input data. // How many bits remaining to extract from the input data.
remFromBits := fromBits remFromBits := fromBits
@ -319,7 +383,7 @@ func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error)
// Discard the bits we just extracted and get ready for // Discard the bits we just extracted and get ready for
// next iteration. // next iteration.
b = b << toExtract b <<= toExtract
remFromBits -= toExtract remFromBits -= toExtract
filledBits += toExtract filledBits += toExtract
@ -335,7 +399,7 @@ func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error)
// We pad any unfinished group if specified. // We pad any unfinished group if specified.
if pad && filledBits > 0 { if pad && filledBits > 0 {
nextByte = nextByte << (toBits - filledBits) nextByte <<= toBits - filledBits
regrouped = append(regrouped, nextByte) regrouped = append(regrouped, nextByte)
filledBits = 0 filledBits = 0
nextByte = 0 nextByte = 0

View file

@ -22,17 +22,18 @@ func TestBech32(t *testing.T) {
expectedError error expectedError error
}{ }{
{"A12UEL5L", nil}, {"A12UEL5L", nil},
{"a12uel5l", nil},
{"an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs", nil}, {"an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs", nil},
{"abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw", nil}, {"abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw", nil},
{"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", nil}, {"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", nil},
{"split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", nil}, {"split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", nil},
{"split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", ErrInvalidChecksum{"2y9e3w", "2y9e2w"}}, // invalid checksum {"split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", ErrInvalidChecksum{"2y9e3w", "2y9e3wlc445v", "2y9e2w"}}, // invalid checksum
{"s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p", ErrInvalidCharacter(' ')}, // invalid character (space) in hrp {"s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p", ErrInvalidCharacter(' ')}, // invalid character (space) in hrp
{"spl\x7Ft1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", ErrInvalidCharacter(127)}, // invalid character (DEL) in hrp {"spl\x7Ft1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", ErrInvalidCharacter(127)}, // invalid character (DEL) in hrp
{"split1cheo2y9e2w", ErrNonCharsetChar('o')}, // invalid character (o) in data part {"split1cheo2y9e2w", ErrNonCharsetChar('o')}, // invalid character (o) in data part
{"split1a2y9w", ErrInvalidSeparatorIndex(5)}, // too short data part {"split1a2y9w", ErrInvalidSeparatorIndex(5)}, // too short data part
{"1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", ErrInvalidSeparatorIndex(0)}, // empty hrp {"1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", ErrInvalidSeparatorIndex(0)}, // empty hrp
{"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", ErrInvalidLength(91)}, // too long {"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", ErrInvalidLength(91)}, // too long
// Additional test vectors used in bitcoin core // Additional test vectors used in bitcoin core
{" 1nwldj5", ErrInvalidCharacter(' ')}, {" 1nwldj5", ErrInvalidCharacter(' ')},
@ -44,7 +45,7 @@ func TestBech32(t *testing.T) {
{"x1b4n0q5v", ErrNonCharsetChar(98)}, {"x1b4n0q5v", ErrNonCharsetChar(98)},
{"li1dgmt3", ErrInvalidSeparatorIndex(2)}, {"li1dgmt3", ErrInvalidSeparatorIndex(2)},
{"de1lg7wt\xff", ErrInvalidCharacter(0xff)}, {"de1lg7wt\xff", ErrInvalidCharacter(0xff)},
{"A1G7SGD8", ErrInvalidChecksum{"2uel5l", "g7sgd8"}}, {"A1G7SGD8", ErrInvalidChecksum{"2uel5l", "2uel5llqfn3a", "g7sgd8"}},
{"10a06t8", ErrInvalidLength(7)}, {"10a06t8", ErrInvalidLength(7)},
{"1qzzfhee", ErrInvalidSeparatorIndex(0)}, {"1qzzfhee", ErrInvalidSeparatorIndex(0)},
{"a12UEL5L", ErrMixedCase{}}, {"a12UEL5L", ErrMixedCase{}},
@ -86,6 +87,127 @@ func TestBech32(t *testing.T) {
} }
} }
// TestBech32M tests that the following set of strings, based on the test
// vectors in BIP-350 are either valid or invalid using the new bech32m
// checksum algo. Some of these strings are similar to the set of above test
// vectors, but end up with different checksums.
func TestBech32M(t *testing.T) {
tests := []struct {
str string
expectedError error
}{
{"A1LQFN3A", nil},
{"a1lqfn3a", nil},
{"an83characterlonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11sg7hg6", nil},
{"abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx", nil},
{"11llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllludsr8", nil},
{"split1checkupstagehandshakeupstreamerranterredcaperredlc445v", nil},
{"?1v759aa", nil},
// Additional test vectors used in bitcoin core
{"\x201xj0phk", ErrInvalidCharacter('\x20')},
{"\x7f1g6xzxy", ErrInvalidCharacter('\x7f')},
{"\x801vctc34", ErrInvalidCharacter('\x80')},
{"an84characterslonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11d6pts4", ErrInvalidLength(91)},
{"qyrz8wqd2c9m", ErrInvalidSeparatorIndex(-1)},
{"1qyrz8wqd2c9m", ErrInvalidSeparatorIndex(0)},
{"y1b0jsk6g", ErrNonCharsetChar(98)},
{"lt1igcx5c0", ErrNonCharsetChar(105)},
{"in1muywd", ErrInvalidSeparatorIndex(2)},
{"mm1crxm3i", ErrNonCharsetChar(105)},
{"au1s5cgom", ErrNonCharsetChar(111)},
{"M1VUXWEZ", ErrInvalidChecksum{"mzl49c", "mzl49cw70eq6", "vuxwez"}},
{"16plkw9", ErrInvalidLength(7)},
{"1p2gdwpf", ErrInvalidSeparatorIndex(0)},
{" 1nwldj5", ErrInvalidCharacter(' ')},
{"\x7f" + "1axkwrx", ErrInvalidCharacter(0x7f)},
{"\x801eym55h", ErrInvalidCharacter(0x80)},
}
for i, test := range tests {
str := test.str
hrp, decoded, err := Decode(str)
if test.expectedError != err {
t.Errorf("%d: (%v) expected decoding error %v "+
"instead got %v", i, str, test.expectedError,
err)
continue
}
if err != nil {
// End test case here if a decoding error was expected.
continue
}
// Check that it encodes to the same string, using bech32 m.
encoded, err := EncodeM(hrp, decoded)
if err != nil {
t.Errorf("encoding failed: %v", err)
}
if encoded != strings.ToLower(str) {
t.Errorf("expected data to encode to %v, but got %v",
str, encoded)
}
// Flip a bit in the string an make sure it is caught.
pos := strings.LastIndexAny(str, "1")
flipped := str[:pos+1] + string((str[pos+1] ^ 1)) + str[pos+2:]
_, _, err = Decode(flipped)
if err == nil {
t.Error("expected decoding to fail")
}
}
}
// TestBech32DecodeGeneric tests that given a bech32 string, or a bech32m
// string, the proper checksum version is returned so that callers can perform
// segwit addr validation.
func TestBech32DecodeGeneric(t *testing.T) {
tests := []struct {
str string
version Version
}{
{"A1LQFN3A", VersionM},
{"a1lqfn3a", VersionM},
{"an83characterlonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11sg7hg6", VersionM},
{"abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx", VersionM},
{"11llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllludsr8", VersionM},
{"split1checkupstagehandshakeupstreamerranterredcaperredlc445v", VersionM},
{"?1v759aa", VersionM},
{"A12UEL5L", Version0},
{"a12uel5l", Version0},
{"an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs", Version0},
{"abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw", Version0},
{"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", Version0},
{"split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", Version0},
{"BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4", Version0},
{"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", Version0},
{"bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kt5nd6y", VersionM},
{"BC1SW50QGDZ25J", VersionM},
{"bc1zw508d6qejxtdg4y5r3zarvaryvaxxpcs", VersionM},
{"tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", Version0},
{"tb1pqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesf3hn0c", VersionM},
{"bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0", VersionM},
}
for i, test := range tests {
_, _, version, err := DecodeGeneric(test.str)
if err != nil {
t.Errorf("%d: (%v) unexpected error during "+
"decoding: %v", i, test.str, err)
continue
}
if version != test.version {
t.Errorf("(%v): invalid version: expected %v, got %v",
test.str, test.version, version)
}
}
}
// TestMixedCaseEncode ensures mixed case HRPs are converted to lowercase as // TestMixedCaseEncode ensures mixed case HRPs are converted to lowercase as
// expected when encoding and that decoding the produced encoding when converted // expected when encoding and that decoding the produced encoding when converted
// to all uppercase produces the lowercase HRP and original data. // to all uppercase produces the lowercase HRP and original data.
@ -242,7 +364,7 @@ func TestBech32Base256(t *testing.T) {
}, { }, {
name: "same as previous but with checksum invalidated", name: "same as previous but with checksum invalidated",
encoded: "split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", encoded: "split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w",
err: ErrInvalidChecksum{"2y9e3w", "2y9e2w"}, err: ErrInvalidChecksum{"2y9e3w", "2y9e3wlc445v", "2y9e2w"},
}, { }, {
name: "hrp with invalid character (space)", name: "hrp with invalid character (space)",
encoded: "s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p", encoded: "s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p",

View file

@ -65,15 +65,17 @@ func (e ErrNonCharsetChar) Error() string {
} }
// ErrInvalidChecksum is returned when the extracted checksum of the string // ErrInvalidChecksum is returned when the extracted checksum of the string
// is different than what was expected. // is different than what was expected. Both the original version, as well as
// the new bech32m checksum may be specified.
type ErrInvalidChecksum struct { type ErrInvalidChecksum struct {
Expected string Expected string
Actual string ExpectedM string
Actual string
} }
func (e ErrInvalidChecksum) Error() string { func (e ErrInvalidChecksum) Error() string {
return fmt.Sprintf("invalid checksum (expected %v got %v)", return fmt.Sprintf("invalid checksum (expected (bech32=%v, "+
e.Expected, e.Actual) "bech32m=%v), got %v)", e.Expected, e.ExpectedM, e.Actual)
} }
// ErrInvalidDataByte is returned when a byte outside the range required for // ErrInvalidDataByte is returned when a byte outside the range required for

View file

@ -8,7 +8,7 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/btcsuite/btcutil/bech32" "github.com/lbryio/lbcutil/bech32"
) )
// This example demonstrates how to decode a bech32 encoded string. // This example demonstrates how to decode a bech32 encoded string.

43
bech32/version.go Normal file
View file

@ -0,0 +1,43 @@
package bech32
// ChecksumConst is a type that represents the currently defined bech32
// checksum constants.
type ChecksumConst int
const (
// Version0Const is the original constant used in the checksum
// verification for bech32.
Version0Const ChecksumConst = 1
// VersionMConst is the new constant used for bech32m checksum
// verification.
VersionMConst ChecksumConst = 0x2bc830a3
)
// Version defines the current set of bech32 versions.
type Version uint8
const (
// Version0 defines the original bech version.
Version0 Version = iota
// VersionM is the new bech32 version defined in BIP-350, also known as
// bech32m.
VersionM
// VersionUnknown denotes an unknown bech version.
VersionUnknown
)
// VersionToConsts maps bech32 versions to the checksum constant to be used
// when encoding, and asserting a particular version when decoding.
var VersionToConsts = map[Version]ChecksumConst{
Version0: Version0Const,
VersionM: VersionMConst,
}
// ConstsToVersion maps a bech32 constant to the version it's associated with.
var ConstsToVersion = map[ChecksumConst]Version{
Version0Const: Version0,
VersionMConst: VersionM,
}

View file

@ -2,15 +2,15 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// OutOfRangeError describes an error due to accessing an element that is out // OutOfRangeError describes an error due to accessing an element that is out
@ -105,7 +105,7 @@ func (b *Block) Hash() *chainhash.Hash {
return &hash return &hash
} }
// Tx returns a wrapped transaction (btcutil.Tx) for the transaction at the // Tx returns a wrapped transaction (lbcutil.Tx) for the transaction at the
// specified index in the Block. The supplied index is 0 based. That is to // specified index in the Block. The supplied index is 0 based. That is to
// say, the first transaction in the block is txNum 0. This is nearly // say, the first transaction in the block is txNum 0. This is nearly
// equivalent to accessing the raw transaction (wire.MsgTx) from the // equivalent to accessing the raw transaction (wire.MsgTx) from the
@ -137,10 +137,10 @@ func (b *Block) Tx(txNum int) (*Tx, error) {
return newTx, nil return newTx, nil
} }
// Transactions returns a slice of wrapped transactions (btcutil.Tx) for all // Transactions returns a slice of wrapped transactions (lbcutil.Tx) for all
// transactions in the Block. This is nearly equivalent to accessing the raw // transactions in the Block. This is nearly equivalent to accessing the raw
// transactions (wire.MsgTx) in the underlying wire.MsgBlock, however it // transactions (wire.MsgTx) in the underlying wire.MsgBlock, however it
// instead provides easy access to wrapped versions (btcutil.Tx) of them. // instead provides easy access to wrapped versions (lbcutil.Tx) of them.
func (b *Block) Transactions() []*Tx { func (b *Block) Transactions() []*Tx {
// Return transactions if they have ALL already been generated. This // Return transactions if they have ALL already been generated. This
// flag is necessary because the wrapped transactions are lazily // flag is necessary because the wrapped transactions are lazily

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"bytes" "bytes"
@ -11,15 +11,15 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/lbryio/lbcd/wire"
"github.com/lbryio/lbcutil"
) )
// TestBlock tests the API for Block. // TestBlock tests the API for Block.
func TestBlock(t *testing.T) { func TestBlock(t *testing.T) {
b := btcutil.NewBlock(&Block100000) b := lbcutil.NewBlock(&Block100000)
// Ensure we get the same data back out. // Ensure we get the same data back out.
if msgBlock := b.MsgBlock(); !reflect.DeepEqual(msgBlock, &Block100000) { if msgBlock := b.MsgBlock(); !reflect.DeepEqual(msgBlock, &Block100000) {
@ -60,7 +60,7 @@ func TestBlock(t *testing.T) {
} }
// Create a new block to nuke all cached data. // Create a new block to nuke all cached data.
b = btcutil.NewBlock(&Block100000) b = lbcutil.NewBlock(&Block100000)
// Request hash for all transactions one at a time via Tx. // Request hash for all transactions one at a time via Tx.
for i, txHash := range wantTxHashes { for i, txHash := range wantTxHashes {
@ -88,7 +88,7 @@ func TestBlock(t *testing.T) {
} }
// Create a new block to nuke all cached data. // Create a new block to nuke all cached data.
b = btcutil.NewBlock(&Block100000) b = lbcutil.NewBlock(&Block100000)
// Request slice of all transactions multiple times to test generation // Request slice of all transactions multiple times to test generation
// and caching. // and caching.
@ -175,7 +175,7 @@ func TestNewBlockFromBytes(t *testing.T) {
block100000Bytes := block100000Buf.Bytes() block100000Bytes := block100000Buf.Bytes()
// Create a new block from the serialized bytes. // Create a new block from the serialized bytes.
b, err := btcutil.NewBlockFromBytes(block100000Bytes) b, err := lbcutil.NewBlockFromBytes(block100000Bytes)
if err != nil { if err != nil {
t.Errorf("NewBlockFromBytes: %v", err) t.Errorf("NewBlockFromBytes: %v", err)
return return
@ -212,7 +212,7 @@ func TestNewBlockFromBlockAndBytes(t *testing.T) {
block100000Bytes := block100000Buf.Bytes() block100000Bytes := block100000Buf.Bytes()
// Create a new block from the serialized bytes. // Create a new block from the serialized bytes.
b := btcutil.NewBlockFromBlockAndBytes(&Block100000, block100000Bytes) b := lbcutil.NewBlockFromBlockAndBytes(&Block100000, block100000Bytes)
// Ensure we get the same data back out. // Ensure we get the same data back out.
serializedBytes, err := b.Bytes() serializedBytes, err := b.Bytes()
@ -235,7 +235,7 @@ func TestNewBlockFromBlockAndBytes(t *testing.T) {
func TestBlockErrors(t *testing.T) { func TestBlockErrors(t *testing.T) {
// Ensure out of range errors are as expected. // Ensure out of range errors are as expected.
wantErr := "transaction index -1 is out of range - max 3" wantErr := "transaction index -1 is out of range - max 3"
testErr := btcutil.OutOfRangeError(wantErr) testErr := lbcutil.OutOfRangeError(wantErr)
if testErr.Error() != wantErr { if testErr.Error() != wantErr {
t.Errorf("OutOfRangeError: wrong error - got %v, want %v", t.Errorf("OutOfRangeError: wrong error - got %v, want %v",
testErr.Error(), wantErr) testErr.Error(), wantErr)
@ -250,7 +250,7 @@ func TestBlockErrors(t *testing.T) {
block100000Bytes := block100000Buf.Bytes() block100000Bytes := block100000Buf.Bytes()
// Create a new block from the serialized bytes. // Create a new block from the serialized bytes.
b, err := btcutil.NewBlockFromBytes(block100000Bytes) b, err := lbcutil.NewBlockFromBytes(block100000Bytes)
if err != nil { if err != nil {
t.Errorf("NewBlockFromBytes: %v", err) t.Errorf("NewBlockFromBytes: %v", err)
return return
@ -258,7 +258,7 @@ func TestBlockErrors(t *testing.T) {
// Truncate the block byte buffer to force errors. // Truncate the block byte buffer to force errors.
shortBytes := block100000Bytes[:80] shortBytes := block100000Bytes[:80]
_, err = btcutil.NewBlockFromBytes(shortBytes) _, err = lbcutil.NewBlockFromBytes(shortBytes)
if err != io.EOF { if err != io.EOF {
t.Errorf("NewBlockFromBytes: did not get expected error - "+ t.Errorf("NewBlockFromBytes: did not get expected error - "+
"got %v, want %v", err, io.EOF) "got %v, want %v", err, io.EOF)
@ -266,26 +266,26 @@ func TestBlockErrors(t *testing.T) {
// Ensure TxHash returns expected error on invalid indices. // Ensure TxHash returns expected error on invalid indices.
_, err = b.TxHash(-1) _, err = b.TxHash(-1)
if _, ok := err.(btcutil.OutOfRangeError); !ok { if _, ok := err.(lbcutil.OutOfRangeError); !ok {
t.Errorf("TxHash: wrong error - got: %v <%T>, "+ t.Errorf("TxHash: wrong error - got: %v <%T>, "+
"want: <%T>", err, err, btcutil.OutOfRangeError("")) "want: <%T>", err, err, lbcutil.OutOfRangeError(""))
} }
_, err = b.TxHash(len(Block100000.Transactions)) _, err = b.TxHash(len(Block100000.Transactions))
if _, ok := err.(btcutil.OutOfRangeError); !ok { if _, ok := err.(lbcutil.OutOfRangeError); !ok {
t.Errorf("TxHash: wrong error - got: %v <%T>, "+ t.Errorf("TxHash: wrong error - got: %v <%T>, "+
"want: <%T>", err, err, btcutil.OutOfRangeError("")) "want: <%T>", err, err, lbcutil.OutOfRangeError(""))
} }
// Ensure Tx returns expected error on invalid indices. // Ensure Tx returns expected error on invalid indices.
_, err = b.Tx(-1) _, err = b.Tx(-1)
if _, ok := err.(btcutil.OutOfRangeError); !ok { if _, ok := err.(lbcutil.OutOfRangeError); !ok {
t.Errorf("Tx: wrong error - got: %v <%T>, "+ t.Errorf("Tx: wrong error - got: %v <%T>, "+
"want: <%T>", err, err, btcutil.OutOfRangeError("")) "want: <%T>", err, err, lbcutil.OutOfRangeError(""))
} }
_, err = b.Tx(len(Block100000.Transactions)) _, err = b.Tx(len(Block100000.Transactions))
if _, ok := err.(btcutil.OutOfRangeError); !ok { if _, ok := err.(lbcutil.OutOfRangeError); !ok {
t.Errorf("Tx: wrong error - got: %v <%T>, "+ t.Errorf("Tx: wrong error - got: %v <%T>, "+
"want: <%T>", err, err, btcutil.OutOfRangeError("")) "want: <%T>", err, err, lbcutil.OutOfRangeError(""))
} }
// Ensure TxLoc returns expected error with short byte buffer. // Ensure TxLoc returns expected error with short byte buffer.

View file

@ -1,9 +1,7 @@
bloom bloom
===== =====
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcutil/bloom)
Package bloom provides an API for dealing with bitcoin-specific bloom filters. Package bloom provides an API for dealing with bitcoin-specific bloom filters.
@ -12,19 +10,8 @@ A comprehensive suite of tests is provided to ensure proper functionality. See
running a POSIX OS, you can run the `cov_report.sh` script for a real-time running a POSIX OS, you can run the `cov_report.sh` script for a real-time
report. report.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/bloom
```
## Examples ## Examples
* [NewFilter Example](http://godoc.org/github.com/btcsuite/btcutil/bloom#example-NewFilter) * [NewFilter Example](http://godoc.org/github.com/lbryio/lbcutil/bloom#example-NewFilter)
Demonstrates how to create a new bloom filter, add a transaction hash to it, Demonstrates how to create a new bloom filter, add a transaction hash to it,
and check if the filter matches the transaction. and check if the filter matches the transaction.
## License
Package bloom is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -9,9 +9,9 @@ import (
"math/rand" "math/rand"
"time" "time"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil/bloom" "github.com/lbryio/lbcutil/bloom"
) )
// This example demonstrates how to create a new bloom filter, add a transaction // This example demonstrates how to create a new bloom filter, add a transaction

View file

@ -9,10 +9,10 @@ import (
"math" "math"
"sync" "sync"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
) )
// ln2Squared is simply the square of the natural log of 2. // ln2Squared is simply the square of the natural log of 2.
@ -270,7 +270,7 @@ func (bf *Filter) maybeAddOutpoint(pkScript []byte, outHash *chainhash.Hash, out
// update flags set via the loaded filter if needed. // update flags set via the loaded filter if needed.
// //
// This function MUST be called with the filter lock held. // This function MUST be called with the filter lock held.
func (bf *Filter) matchTxAndUpdate(tx *btcutil.Tx) bool { func (bf *Filter) matchTxAndUpdate(tx *lbcutil.Tx) bool {
// Check if the filter matches the hash of the transaction. // Check if the filter matches the hash of the transaction.
// This is useful for finding transactions when they appear in a block. // This is useful for finding transactions when they appear in a block.
matched := bf.matches(tx.Hash()[:]) matched := bf.matches(tx.Hash()[:])
@ -335,7 +335,7 @@ func (bf *Filter) matchTxAndUpdate(tx *btcutil.Tx) bool {
// update flags set via the loaded filter if needed. // update flags set via the loaded filter if needed.
// //
// This function is safe for concurrent access. // This function is safe for concurrent access.
func (bf *Filter) MatchTxAndUpdate(tx *btcutil.Tx) bool { func (bf *Filter) MatchTxAndUpdate(tx *lbcutil.Tx) bool {
bf.mtx.Lock() bf.mtx.Lock()
match := bf.matchTxAndUpdate(tx) match := bf.matchTxAndUpdate(tx)
bf.mtx.Unlock() bf.mtx.Unlock()

View file

@ -9,10 +9,10 @@ import (
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
"github.com/btcsuite/btcutil/bloom" "github.com/lbryio/lbcutil/bloom"
) )
// TestFilterLarge ensures a maximum sized filter can be created. // TestFilterLarge ensures a maximum sized filter can be created.
@ -214,7 +214,7 @@ func TestFilterInsertWithTweak(t *testing.T) {
func TestFilterInsertKey(t *testing.T) { func TestFilterInsertKey(t *testing.T) {
secret := "5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C" secret := "5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C"
wif, err := btcutil.DecodeWIF(secret) wif, err := lbcutil.DecodeWIF(secret)
if err != nil { if err != nil {
t.Errorf("TestFilterInsertKey DecodeWIF failed: %v", err) t.Errorf("TestFilterInsertKey DecodeWIF failed: %v", err)
return return
@ -222,7 +222,7 @@ func TestFilterInsertKey(t *testing.T) {
f := bloom.NewFilter(2, 0, 0.001, wire.BloomUpdateAll) f := bloom.NewFilter(2, 0, 0.001, wire.BloomUpdateAll)
f.Add(wif.SerializePubKey()) f.Add(wif.SerializePubKey())
f.Add(btcutil.Hash160(wif.SerializePubKey())) f.Add(lbcutil.Hash160(wif.SerializePubKey()))
want, err := hex.DecodeString("038fc16b080000000000000001") want, err := hex.DecodeString("038fc16b080000000000000001")
if err != nil { if err != nil {
@ -258,7 +258,7 @@ func TestFilterBloomMatch(t *testing.T) {
t.Errorf("TestFilterBloomMatch DecodeString failure: %v", err) t.Errorf("TestFilterBloomMatch DecodeString failure: %v", err)
return return
} }
tx, err := btcutil.NewTxFromBytes(strBytes) tx, err := lbcutil.NewTxFromBytes(strBytes)
if err != nil { if err != nil {
t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err) t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err)
return return
@ -293,7 +293,7 @@ func TestFilterBloomMatch(t *testing.T) {
0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70,
0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00} 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}
spendingTx, err := btcutil.NewTxFromBytes(spendingTxBytes) spendingTx, err := lbcutil.NewTxFromBytes(spendingTxBytes)
if err != nil { if err != nil {
t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err) t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err)
return return
@ -492,158 +492,6 @@ func TestFilterInsertUpdateNone(t *testing.T) {
} }
} }
func TestFilterInsertP2PubKeyOnly(t *testing.T) {
blockStr := "0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc" +
"880670100000000007f16c5962e8bd963659c793ce370d95f093bc7e367" +
"117b3c30c1f8fdd0d9728776381b4d4c86041b554b85290701000000010" +
"00000000000000000000000000000000000000000000000000000000000" +
"0000ffffffff07044c86041b0136ffffffff0100f2052a0100000043410" +
"4eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2" +
"c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a22522" +
"47d97a46a91ac000000000100000001bcad20a6a29827d1424f08989255" +
"120bf7f3e9e3cdaaa6bb31b0737fe048724300000000494830450220356" +
"e834b046cadc0f8ebb5a8a017b02de59c86305403dad52cd77b55af062e" +
"a10221009253cd6c119d4729b77c978e1e2aa19f5ea6e0e52b3f16e32fa" +
"608cd5bab753901ffffffff02008d380c010000001976a9142b4b8072ec" +
"bba129b6453c63e129e643207249ca88ac0065cd1d000000001976a9141" +
"b8dd13b994bcfc787b32aeadf58ccb3615cbd5488ac0000000001000000" +
"03fdacf9b3eb077412e7a968d2e4f11b9a9dee312d666187ed77ee7d26a" +
"f16cb0b000000008c493046022100ea1608e70911ca0de5af51ba57ad23" +
"b9a51db8d28f82c53563c56a05c20f5a87022100a8bdc8b4a8acc8634c6" +
"b420410150775eb7f2474f5615f7fccd65af30f310fbf01410465fdf49e" +
"29b06b9a1582287b6279014f834edc317695d125ef623c1cc3aaece245b" +
"d69fcad7508666e9c74a49dc9056d5fc14338ef38118dc4afae5fe2c585" +
"caffffffff309e1913634ecb50f3c4f83e96e70b2df071b497b8973a3e7" +
"5429df397b5af83000000004948304502202bdb79c596a9ffc24e96f438" +
"6199aba386e9bc7b6071516e2b51dda942b3a1ed022100c53a857e76b72" +
"4fc14d45311eac5019650d415c3abb5428f3aae16d8e69bec2301ffffff" +
"ff2089e33491695080c9edc18a428f7d834db5b6d372df13ce2b1b0e0cb" +
"cb1e6c10000000049483045022100d4ce67c5896ee251c810ac1ff9cecc" +
"d328b497c8f553ab6e08431e7d40bad6b5022033119c0c2b7d792d31f11" +
"87779c7bd95aefd93d90a715586d73801d9b47471c601ffffffff010071" +
"4460030000001976a914c7b55141d097ea5df7a0ed330cf794376e53ec8" +
"d88ac0000000001000000045bf0e214aa4069a3e792ecee1e1bf0c1d397" +
"cde8dd08138f4b72a00681743447000000008b48304502200c45de8c4f3" +
"e2c1821f2fc878cba97b1e6f8807d94930713aa1c86a67b9bf1e4022100" +
"8581abfef2e30f957815fc89978423746b2086375ca8ecf359c85c2a5b7" +
"c88ad01410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf64852" +
"61c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d" +
"3ae37079b794a92d7ec95ffffffffd669f7d7958d40fc59d2253d88e0f2" +
"48e29b599c80bbcec344a83dda5f9aa72c000000008a473044022078124" +
"c8beeaa825f9e0b30bff96e564dd859432f2d0cb3b72d3d5d93d38d7e93" +
"0220691d233b6c0f995be5acb03d70a7f7a65b6bc9bdd426260f38a1346" +
"669507a3601410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6" +
"485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270e" +
"fb1d3ae37079b794a92d7ec95fffffffff878af0d93f5229a68166cf051" +
"fd372bb7a537232946e0a46f53636b4dafdaa4000000008c49304602210" +
"0c717d1714551663f69c3c5759bdbb3a0fcd3fab023abc0e522fe6440de" +
"35d8290221008d9cbe25bffc44af2b18e81c58eb37293fd7fe1c2e7b46f" +
"c37ee8c96c50ab1e201410462bb73f76ca0994fcb8b4271e6fb7561f5c0" +
"f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f" +
"4d87270efb1d3ae37079b794a92d7ec95ffffffff27f2b668859cd7f2f8" +
"94aa0fd2d9e60963bcd07c88973f425f999b8cbfd7a1e2000000008c493" +
"046022100e00847147cbf517bcc2f502f3ddc6d284358d102ed20d47a8a" +
"a788a62f0db780022100d17b2d6fa84dcaf1c95d88d7e7c30385aecf415" +
"588d749afd3ec81f6022cecd701410462bb73f76ca0994fcb8b4271e6fb" +
"7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018" +
"ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff0100c817a8" +
"040000001976a914b6efd80d99179f4f4ff6f4dd0a007d018c385d2188a" +
"c000000000100000001834537b2f1ce8ef9373a258e10545ce5a50b758d" +
"f616cd4356e0032554ebd3c4000000008b483045022100e68f422dd7c34" +
"fdce11eeb4509ddae38201773dd62f284e8aa9d96f85099d0b002202243" +
"bd399ff96b649a0fad05fa759d6a882f0af8c90cf7632c2840c29070aec" +
"20141045e58067e815c2f464c6a2a15f987758374203895710c2d452442" +
"e28496ff38ba8f5fd901dc20e29e88477167fe4fc299bf818fd0d9e1632" +
"d467b2a3d9503b1aaffffffff0280d7e636030000001976a914f34c3e10" +
"eb387efe872acb614c89e78bfca7815d88ac404b4c00000000001976a91" +
"4a84e272933aaf87e1715d7786c51dfaeb5b65a6f88ac00000000010000" +
"000143ac81c8e6f6ef307dfe17f3d906d999e23e0189fda838c5510d850" +
"927e03ae7000000008c4930460221009c87c344760a64cb8ae6685a3eec" +
"2c1ac1bed5b88c87de51acd0e124f266c16602210082d07c037359c3a25" +
"7b5c63ebd90f5a5edf97b2ac1c434b08ca998839f346dd40141040ba7e5" +
"21fa7946d12edbb1d1e95a15c34bd4398195e86433c92b431cd315f455f" +
"e30032ede69cad9d1e1ed6c3c4ec0dbfced53438c625462afb792dcb098" +
"544bffffffff0240420f00000000001976a9144676d1b820d63ec272f19" +
"00d59d43bc6463d96f888ac40420f00000000001976a914648d04341d00" +
"d7968b3405c034adc38d4d8fb9bd88ac00000000010000000248cc91750" +
"1ea5c55f4a8d2009c0567c40cfe037c2e71af017d0a452ff705e3f10000" +
"00008b483045022100bf5fdc86dc5f08a5d5c8e43a8c9d5b1ed8c65562e" +
"280007b52b133021acd9acc02205e325d613e555f772802bf413d36ba80" +
"7892ed1a690a77811d3033b3de226e0a01410429fa713b124484cb2bd7b" +
"5557b2c0b9df7b2b1fee61825eadc5ae6c37a9920d38bfccdc7dc3cb0c4" +
"7d7b173dbc9db8d37db0a33ae487982c59c6f8606e9d1791ffffffff41e" +
"d70551dd7e841883ab8f0b16bf04176b7d1480e4f0af9f3d4c3595768d0" +
"68000000008b4830450221008513ad65187b903aed1102d1d0c47688127" +
"658c51106753fed0151ce9c16b80902201432b9ebcb87bd04ceb2de6603" +
"5fbbaf4bf8b00d1cfe41f1a1f7338f9ad79d210141049d4cf80125bf50b" +
"e1709f718c07ad15d0fc612b7da1f5570dddc35f2a352f0f27c978b0682" +
"0edca9ef982c35fda2d255afba340068c5035552368bc7200c1488fffff" +
"fff0100093d00000000001976a9148edb68822f1ad580b043c7b3df2e40" +
"0f8699eb4888ac00000000"
blockBytes, err := hex.DecodeString(blockStr)
if err != nil {
t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err)
return
}
block, err := btcutil.NewBlockFromBytes(blockBytes)
if err != nil {
t.Errorf("TestFilterInsertP2PubKeyOnly NewBlockFromBytes failed: %v", err)
return
}
f := bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateP2PubkeyOnly)
// Generation pubkey
inputStr := "04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c" +
"876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a" +
"2252247d97a46a91"
inputBytes, err := hex.DecodeString(inputStr)
if err != nil {
t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err)
return
}
f.Add(inputBytes)
// Output address of 4th transaction
inputStr = "b6efd80d99179f4f4ff6f4dd0a007d018c385d21"
inputBytes, err = hex.DecodeString(inputStr)
if err != nil {
t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err)
return
}
f.Add(inputBytes)
// Ignore return value -- this is just used to update the filter.
_, _ = bloom.NewMerkleBlock(block, f)
// We should match the generation pubkey
inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"
hash, err := chainhash.NewHashFromStr(inputStr)
if err != nil {
t.Errorf("TestMerkleBlockP2PubKeyOnly NewHashFromStr failed: %v", err)
return
}
outpoint := wire.NewOutPoint(hash, 0)
if !f.MatchesOutPoint(outpoint) {
t.Errorf("TestMerkleBlockP2PubKeyOnly didn't match the generation "+
"outpoint %s", inputStr)
return
}
// We should not match the 4th transaction, which is not p2pk
inputStr = "02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041"
hash, err = chainhash.NewHashFromStr(inputStr)
if err != nil {
t.Errorf("TestMerkleBlockP2PubKeyOnly NewHashFromStr failed: %v", err)
return
}
outpoint = wire.NewOutPoint(hash, 0)
if f.MatchesOutPoint(outpoint) {
t.Errorf("TestMerkleBlockP2PubKeyOnly matched outpoint %s", inputStr)
return
}
}
func TestFilterReload(t *testing.T) { func TestFilterReload(t *testing.T) {
f := bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateAll) f := bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateAll)

View file

@ -5,10 +5,10 @@
package bloom package bloom
import ( import (
"github.com/btcsuite/btcd/blockchain" "github.com/lbryio/lbcd/blockchain"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
) )
// merkleBlock is used to house intermediate information needed to generate a // merkleBlock is used to house intermediate information needed to generate a
@ -79,7 +79,7 @@ func (m *merkleBlock) traverseAndBuild(height, pos uint32) {
// NewMerkleBlock returns a new *wire.MsgMerkleBlock and an array of the matched // NewMerkleBlock returns a new *wire.MsgMerkleBlock and an array of the matched
// transaction index numbers based on the passed block and filter. // transaction index numbers based on the passed block and filter.
func NewMerkleBlock(block *btcutil.Block, filter *Filter) (*wire.MsgMerkleBlock, []uint32) { func NewMerkleBlock(block *lbcutil.Block, filter *Filter) (*wire.MsgMerkleBlock, []uint32) {
numTx := uint32(len(block.Transactions())) numTx := uint32(len(block.Transactions()))
mBlock := merkleBlock{ mBlock := merkleBlock{
numTx: numTx, numTx: numTx,
@ -116,7 +116,7 @@ func NewMerkleBlock(block *btcutil.Block, filter *Filter) (*wire.MsgMerkleBlock,
Flags: make([]byte, (len(mBlock.bits)+7)/8), Flags: make([]byte, (len(mBlock.bits)+7)/8),
} }
for _, hash := range mBlock.finalHashes { for _, hash := range mBlock.finalHashes {
msgMerkleBlock.AddTxHash(hash) _ = msgMerkleBlock.AddTxHash(hash)
} }
for i := uint32(0); i < uint32(len(mBlock.bits)); i++ { for i := uint32(0); i < uint32(len(mBlock.bits)); i++ {
msgMerkleBlock.Flags[i/8] |= mBlock.bits[i] << (i % 8) msgMerkleBlock.Flags[i/8] |= mBlock.bits[i] << (i % 8)

View file

@ -9,10 +9,10 @@ import (
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
"github.com/btcsuite/btcutil/bloom" "github.com/lbryio/lbcutil/bloom"
) )
func TestMerkleBlock3(t *testing.T) { func TestMerkleBlock3(t *testing.T) {
@ -29,7 +29,7 @@ func TestMerkleBlock3(t *testing.T) {
t.Errorf("TestMerkleBlock3 DecodeString failed: %v", err) t.Errorf("TestMerkleBlock3 DecodeString failed: %v", err)
return return
} }
blk, err := btcutil.NewBlockFromBytes(blockBytes) blk, err := lbcutil.NewBlockFromBytes(blockBytes)
if err != nil { if err != nil {
t.Errorf("TestMerkleBlock3 NewBlockFromBytes failed: %v", err) t.Errorf("TestMerkleBlock3 NewBlockFromBytes failed: %v", err)
return return

View file

@ -7,7 +7,7 @@ package bloom_test
import ( import (
"testing" "testing"
"github.com/btcsuite/btcutil/bloom" "github.com/lbryio/lbcutil/bloom"
) )
// TestMurmurHash3 ensure the MurmurHash3 function produces the correct hash // TestMurmurHash3 ensure the MurmurHash3 function produces the correct hash

View file

@ -1,28 +1,28 @@
github.com/conformal/btcutil/bloom/murmurhash3.go MurmurHash3 100.00% (31/31) github.com/conformal/lbcutil/bloom/murmurhash3.go MurmurHash3 100.00% (31/31)
github.com/conformal/btcutil/bloom/merkleblock.go NewMerkleBlock 100.00% (19/19) github.com/conformal/lbcutil/bloom/merkleblock.go NewMerkleBlock 100.00% (19/19)
github.com/conformal/btcutil/bloom/merkleblock.go merkleBlock.traverseAndBuild 100.00% (10/10) github.com/conformal/lbcutil/bloom/merkleblock.go merkleBlock.traverseAndBuild 100.00% (10/10)
github.com/conformal/btcutil/bloom/merkleblock.go merkleBlock.calcHash 100.00% (8/8) github.com/conformal/lbcutil/bloom/merkleblock.go merkleBlock.calcHash 100.00% (8/8)
github.com/conformal/btcutil/bloom/filter.go Filter.maybeAddOutpoint 100.00% (7/7) github.com/conformal/lbcutil/bloom/filter.go Filter.maybeAddOutpoint 100.00% (7/7)
github.com/conformal/btcutil/bloom/filter.go Filter.addOutPoint 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.addOutPoint 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.IsLoaded 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.IsLoaded 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.MsgFilterLoad 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.MsgFilterLoad 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.matchesOutPoint 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.matchesOutPoint 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.MatchesOutPoint 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.MatchesOutPoint 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.MatchTxAndUpdate 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.MatchTxAndUpdate 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.Matches 100.00% (4/4) github.com/conformal/lbcutil/bloom/filter.go Filter.Matches 100.00% (4/4)
github.com/conformal/btcutil/bloom/filter.go Filter.Add 100.00% (3/3) github.com/conformal/lbcutil/bloom/filter.go Filter.Add 100.00% (3/3)
github.com/conformal/btcutil/bloom/filter.go Filter.Reload 100.00% (3/3) github.com/conformal/lbcutil/bloom/filter.go Filter.Reload 100.00% (3/3)
github.com/conformal/btcutil/bloom/filter.go Filter.Unload 100.00% (3/3) github.com/conformal/lbcutil/bloom/filter.go Filter.Unload 100.00% (3/3)
github.com/conformal/btcutil/bloom/filter.go Filter.AddShaHash 100.00% (3/3) github.com/conformal/lbcutil/bloom/filter.go Filter.AddShaHash 100.00% (3/3)
github.com/conformal/btcutil/bloom/filter.go Filter.AddOutPoint 100.00% (3/3) github.com/conformal/lbcutil/bloom/filter.go Filter.AddOutPoint 100.00% (3/3)
github.com/conformal/btcutil/bloom/filter.go minUint32 100.00% (3/3) github.com/conformal/lbcutil/bloom/filter.go minUint32 100.00% (3/3)
github.com/conformal/btcutil/bloom/filter.go Filter.hash 100.00% (2/2) github.com/conformal/lbcutil/bloom/filter.go Filter.hash 100.00% (2/2)
github.com/conformal/btcutil/bloom/merkleblock.go merkleBlock.calcTreeWidth 100.00% (1/1) github.com/conformal/lbcutil/bloom/merkleblock.go merkleBlock.calcTreeWidth 100.00% (1/1)
github.com/conformal/btcutil/bloom/filter.go LoadFilter 100.00% (1/1) github.com/conformal/lbcutil/bloom/filter.go LoadFilter 100.00% (1/1)
github.com/conformal/btcutil/bloom/filter.go Filter.matchTxAndUpdate 91.30% (21/23) github.com/conformal/lbcutil/bloom/filter.go Filter.matchTxAndUpdate 91.30% (21/23)
github.com/conformal/btcutil/bloom/filter.go Filter.matches 85.71% (6/7) github.com/conformal/lbcutil/bloom/filter.go Filter.matches 85.71% (6/7)
github.com/conformal/btcutil/bloom/filter.go NewFilter 81.82% (9/11) github.com/conformal/lbcutil/bloom/filter.go NewFilter 81.82% (9/11)
github.com/conformal/btcutil/bloom/filter.go Filter.add 80.00% (4/5) github.com/conformal/lbcutil/bloom/filter.go Filter.add 80.00% (4/5)
github.com/conformal/btcutil/bloom ---------------------------- 96.49% (165/171) github.com/conformal/lbcutil/bloom ---------------------------- 96.49% (165/171)

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"bytes" "bytes"
@ -61,7 +61,7 @@ func NewTLSCertPair(organization string, validUntil time.Time, extraHosts []stri
addIP := func(ipAddr net.IP) { addIP := func(ipAddr net.IP) {
for _, ip := range ipAddresses { for _, ip := range ipAddresses {
if bytes.Equal(ip, ipAddr) { if ip.Equal(ipAddr) {
return return
} }
} }

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"crypto/x509" "crypto/x509"
@ -11,7 +11,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
//"github.com/davecgh/go-spew/spew" //"github.com/davecgh/go-spew/spew"
) )
@ -23,7 +23,7 @@ func TestNewTLSCertPair(t *testing.T) {
validUntil := time.Unix(time.Now().Add(10*365*24*time.Hour).Unix(), 0) validUntil := time.Unix(time.Now().Add(10*365*24*time.Hour).Unix(), 0)
org := "test autogenerated cert" org := "test autogenerated cert"
extraHosts := []string{"testtlscert.bogus", "localhost", "127.0.0.1"} extraHosts := []string{"testtlscert.bogus", "localhost", "127.0.0.1"}
cert, key, err := btcutil.NewTLSCertPair(org, validUntil, extraHosts) cert, key, err := lbcutil.NewTLSCertPair(org, validUntil, extraHosts)
if err != nil { if err != nil {
t.Fatalf("failed with unexpected error: %v", err) t.Fatalf("failed with unexpected error: %v", err)
} }

View file

@ -1,9 +1,7 @@
coinset coinset
======= =======
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcutil/coinset)
Package coinset provides bitcoin-specific convenience functions for selecting Package coinset provides bitcoin-specific convenience functions for selecting
from and managing sets of unspent transaction outpoints (UTXOs). from and managing sets of unspent transaction outpoints (UTXOs).
@ -13,12 +11,6 @@ A comprehensive suite of tests is provided to ensure proper functionality. See
running a POSIX OS, you can run the `cov_report.sh` script for a real-time running a POSIX OS, you can run the `cov_report.sh` script for a real-time
report. report.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/coinset
```
## Usage ## Usage
Each unspent transaction outpoint is represented by the Coin interface. An Each unspent transaction outpoint is represented by the Coin interface. An
@ -64,8 +56,3 @@ msgTx := coinset.NewMsgTxWithInputCoins(selectedCoins)
The user can then create the msgTx.TxOut's as required, then sign the The user can then create the msgTx.TxOut's as required, then sign the
transaction and transmit it to the network. transaction and transmit it to the network.
## License
Package coinset is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -9,16 +9,16 @@ import (
"errors" "errors"
"sort" "sort"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
) )
// Coin represents a spendable transaction outpoint // Coin represents a spendable transaction outpoint
type Coin interface { type Coin interface {
Hash() *chainhash.Hash Hash() *chainhash.Hash
Index() uint32 Index() uint32
Value() btcutil.Amount Value() lbcutil.Amount
PkScript() []byte PkScript() []byte
NumConfs() int64 NumConfs() int64
ValueAge() int64 ValueAge() int64
@ -39,7 +39,7 @@ type Coins interface {
// the CoinSet, otherwise the cached values will be incorrect. // the CoinSet, otherwise the cached values will be incorrect.
type CoinSet struct { type CoinSet struct {
coinList *list.List coinList *list.List
totalValue btcutil.Amount totalValue lbcutil.Amount
totalValueAge int64 totalValueAge int64
} }
@ -70,7 +70,7 @@ func (cs *CoinSet) Coins() []Coin {
} }
// TotalValue returns the total value of the coins in the set. // TotalValue returns the total value of the coins in the set.
func (cs *CoinSet) TotalValue() (value btcutil.Amount) { func (cs *CoinSet) TotalValue() (value lbcutil.Amount) {
return cs.totalValue return cs.totalValue
} }
@ -149,7 +149,7 @@ var (
// satisfiesTargetValue checks that the totalValue is either exactly the targetValue // satisfiesTargetValue checks that the totalValue is either exactly the targetValue
// or is greater than the targetValue by at least the minChange amount. // or is greater than the targetValue by at least the minChange amount.
func satisfiesTargetValue(targetValue, minChange, totalValue btcutil.Amount) bool { func satisfiesTargetValue(targetValue, minChange, totalValue lbcutil.Amount) bool {
return (totalValue == targetValue || totalValue >= targetValue+minChange) return (totalValue == targetValue || totalValue >= targetValue+minChange)
} }
@ -165,7 +165,7 @@ func satisfiesTargetValue(targetValue, minChange, totalValue btcutil.Amount) boo
// It is important to note that the Coins being used as inputs need to have // It is important to note that the Coins being used as inputs need to have
// a constant ValueAge() during the execution of CoinSelect. // a constant ValueAge() during the execution of CoinSelect.
type CoinSelector interface { type CoinSelector interface {
CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) CoinSelect(targetValue lbcutil.Amount, coins []Coin) (Coins, error)
} }
// MinIndexCoinSelector is a CoinSelector that attempts to construct a // MinIndexCoinSelector is a CoinSelector that attempts to construct a
@ -173,12 +173,12 @@ type CoinSelector interface {
// any number of lower indexes (as in the ordered array) over higher ones. // any number of lower indexes (as in the ordered array) over higher ones.
type MinIndexCoinSelector struct { type MinIndexCoinSelector struct {
MaxInputs int MaxInputs int
MinChangeAmount btcutil.Amount MinChangeAmount lbcutil.Amount
} }
// CoinSelect will attempt to select coins using the algorithm described // CoinSelect will attempt to select coins using the algorithm described
// in the MinIndexCoinSelector struct. // in the MinIndexCoinSelector struct.
func (s MinIndexCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { func (s MinIndexCoinSelector) CoinSelect(targetValue lbcutil.Amount, coins []Coin) (Coins, error) {
cs := NewCoinSet(nil) cs := NewCoinSet(nil)
for n := 0; n < len(coins) && n < s.MaxInputs; n++ { for n := 0; n < len(coins) && n < s.MaxInputs; n++ {
cs.PushCoin(coins[n]) cs.PushCoin(coins[n])
@ -194,12 +194,12 @@ func (s MinIndexCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coi
// that uses as few of the inputs as possible. // that uses as few of the inputs as possible.
type MinNumberCoinSelector struct { type MinNumberCoinSelector struct {
MaxInputs int MaxInputs int
MinChangeAmount btcutil.Amount MinChangeAmount lbcutil.Amount
} }
// CoinSelect will attempt to select coins using the algorithm described // CoinSelect will attempt to select coins using the algorithm described
// in the MinNumberCoinSelector struct. // in the MinNumberCoinSelector struct.
func (s MinNumberCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { func (s MinNumberCoinSelector) CoinSelect(targetValue lbcutil.Amount, coins []Coin) (Coins, error) {
sortedCoins := make([]Coin, 0, len(coins)) sortedCoins := make([]Coin, 0, len(coins))
sortedCoins = append(sortedCoins, coins...) sortedCoins = append(sortedCoins, coins...)
sort.Sort(sort.Reverse(byAmount(sortedCoins))) sort.Sort(sort.Reverse(byAmount(sortedCoins)))
@ -216,12 +216,12 @@ func (s MinNumberCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Co
// block. // block.
type MaxValueAgeCoinSelector struct { type MaxValueAgeCoinSelector struct {
MaxInputs int MaxInputs int
MinChangeAmount btcutil.Amount MinChangeAmount lbcutil.Amount
} }
// CoinSelect will attempt to select coins using the algorithm described // CoinSelect will attempt to select coins using the algorithm described
// in the MaxValueAgeCoinSelector struct. // in the MaxValueAgeCoinSelector struct.
func (s MaxValueAgeCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { func (s MaxValueAgeCoinSelector) CoinSelect(targetValue lbcutil.Amount, coins []Coin) (Coins, error) {
sortedCoins := make([]Coin, 0, len(coins)) sortedCoins := make([]Coin, 0, len(coins))
sortedCoins = append(sortedCoins, coins...) sortedCoins = append(sortedCoins, coins...)
sort.Sort(sort.Reverse(byValueAge(sortedCoins))) sort.Sort(sort.Reverse(byValueAge(sortedCoins)))
@ -241,13 +241,13 @@ func (s MaxValueAgeCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []
// //
type MinPriorityCoinSelector struct { type MinPriorityCoinSelector struct {
MaxInputs int MaxInputs int
MinChangeAmount btcutil.Amount MinChangeAmount lbcutil.Amount
MinAvgValueAgePerInput int64 MinAvgValueAgePerInput int64
} }
// CoinSelect will attempt to select coins using the algorithm described // CoinSelect will attempt to select coins using the algorithm described
// in the MinPriorityCoinSelector struct. // in the MinPriorityCoinSelector struct.
func (s MinPriorityCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { func (s MinPriorityCoinSelector) CoinSelect(targetValue lbcutil.Amount, coins []Coin) (Coins, error) {
possibleCoins := make([]Coin, 0, len(coins)) possibleCoins := make([]Coin, 0, len(coins))
possibleCoins = append(possibleCoins, coins...) possibleCoins = append(possibleCoins, coins...)
@ -343,10 +343,10 @@ func (a byAmount) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byAmount) Less(i, j int) bool { return a[i].Value() < a[j].Value() } func (a byAmount) Less(i, j int) bool { return a[i].Value() < a[j].Value() }
// SimpleCoin defines a concrete instance of Coin that is backed by a // SimpleCoin defines a concrete instance of Coin that is backed by a
// btcutil.Tx, a specific outpoint index, and the number of confirmations // lbcutil.Tx, a specific outpoint index, and the number of confirmations
// that transaction has had. // that transaction has had.
type SimpleCoin struct { type SimpleCoin struct {
Tx *btcutil.Tx Tx *lbcutil.Tx
TxIndex uint32 TxIndex uint32
TxNumConfs int64 TxNumConfs int64
} }
@ -370,8 +370,8 @@ func (c *SimpleCoin) txOut() *wire.TxOut {
} }
// Value returns the value of the Coin // Value returns the value of the Coin
func (c *SimpleCoin) Value() btcutil.Amount { func (c *SimpleCoin) Value() lbcutil.Amount {
return btcutil.Amount(c.txOut().Value) return lbcutil.Amount(c.txOut().Value)
} }
// PkScript returns the outpoint script of the Coin. // PkScript returns the outpoint script of the Coin.

View file

@ -11,29 +11,29 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
"github.com/btcsuite/btcutil/coinset" "github.com/lbryio/lbcutil/coinset"
) )
type TestCoin struct { type TestCoin struct {
TxHash *chainhash.Hash TxHash *chainhash.Hash
TxIndex uint32 TxIndex uint32
TxValue btcutil.Amount TxValue lbcutil.Amount
TxNumConfs int64 TxNumConfs int64
} }
func (c *TestCoin) Hash() *chainhash.Hash { return c.TxHash } func (c *TestCoin) Hash() *chainhash.Hash { return c.TxHash }
func (c *TestCoin) Index() uint32 { return c.TxIndex } func (c *TestCoin) Index() uint32 { return c.TxIndex }
func (c *TestCoin) Value() btcutil.Amount { return c.TxValue } func (c *TestCoin) Value() lbcutil.Amount { return c.TxValue }
func (c *TestCoin) PkScript() []byte { return nil } func (c *TestCoin) PkScript() []byte { return nil }
func (c *TestCoin) NumConfs() int64 { return c.TxNumConfs } func (c *TestCoin) NumConfs() int64 { return c.TxNumConfs }
func (c *TestCoin) ValueAge() int64 { return int64(c.TxValue) * c.TxNumConfs } func (c *TestCoin) ValueAge() int64 { return int64(c.TxValue) * c.TxNumConfs }
func NewCoin(index int64, value btcutil.Amount, numConfs int64) coinset.Coin { func NewCoin(index int64, value lbcutil.Amount, numConfs int64) coinset.Coin {
h := sha256.New() h := sha256.New()
h.Write([]byte(fmt.Sprintf("%d", index))) _, _ = h.Write([]byte(fmt.Sprintf("%d", index)))
hash, _ := chainhash.NewHash(h.Sum(nil)) hash, _ := chainhash.NewHash(h.Sum(nil))
c := &TestCoin{ c := &TestCoin{
TxHash: hash, TxHash: hash,
@ -47,7 +47,7 @@ func NewCoin(index int64, value btcutil.Amount, numConfs int64) coinset.Coin {
type coinSelectTest struct { type coinSelectTest struct {
selector coinset.CoinSelector selector coinset.CoinSelector
inputCoins []coinset.Coin inputCoins []coinset.Coin
targetValue btcutil.Amount targetValue lbcutil.Amount
expectedCoins []coinset.Coin expectedCoins []coinset.Coin
expectedError error expectedError error
} }
@ -225,12 +225,12 @@ var (
testSimpleCoinNumConfs = int64(1) testSimpleCoinNumConfs = int64(1)
testSimpleCoinTxHash = "9b5965c86de51d5dc824e179a05cf232db78c80ae86ca9d7cb2a655b5e19c1e2" testSimpleCoinTxHash = "9b5965c86de51d5dc824e179a05cf232db78c80ae86ca9d7cb2a655b5e19c1e2"
testSimpleCoinTxHex = "0100000001a214a110f79e4abe073865ea5b3745c6e82c913bad44be70652804a5e4003b0a010000008c493046022100edd18a69664efa57264be207100c203e6cade1888cbb88a0ad748548256bb2f0022100f1027dc2e6c7f248d78af1dd90027b5b7d8ec563bb62aa85d4e74d6376f3868c0141048f3757b65ed301abd1b0e8942d1ab5b50594d3314cff0299f300c696376a0a9bf72e74710a8af7a5372d4af4bb519e2701a094ef48c8e48e3b65b28502452dceffffffff02e0673500000000001976a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ace86ef102000000001976a914ac3f995655e81b875b38b64351d6f896ddbfc68588ac00000000" testSimpleCoinTxHex = "0100000001a214a110f79e4abe073865ea5b3745c6e82c913bad44be70652804a5e4003b0a010000008c493046022100edd18a69664efa57264be207100c203e6cade1888cbb88a0ad748548256bb2f0022100f1027dc2e6c7f248d78af1dd90027b5b7d8ec563bb62aa85d4e74d6376f3868c0141048f3757b65ed301abd1b0e8942d1ab5b50594d3314cff0299f300c696376a0a9bf72e74710a8af7a5372d4af4bb519e2701a094ef48c8e48e3b65b28502452dceffffffff02e0673500000000001976a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ace86ef102000000001976a914ac3f995655e81b875b38b64351d6f896ddbfc68588ac00000000"
testSimpleCoinTxValue0 = btcutil.Amount(3500000) testSimpleCoinTxValue0 = lbcutil.Amount(3500000)
testSimpleCoinTxValueAge0 = int64(testSimpleCoinTxValue0) * testSimpleCoinNumConfs testSimpleCoinTxValueAge0 = int64(testSimpleCoinTxValue0) * testSimpleCoinNumConfs
testSimpleCoinTxPkScript0Hex = "76a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ac" testSimpleCoinTxPkScript0Hex = "76a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ac"
testSimpleCoinTxPkScript0Bytes, _ = hex.DecodeString(testSimpleCoinTxPkScript0Hex) testSimpleCoinTxPkScript0Bytes, _ = hex.DecodeString(testSimpleCoinTxPkScript0Hex)
testSimpleCoinTxBytes, _ = hex.DecodeString(testSimpleCoinTxHex) testSimpleCoinTxBytes, _ = hex.DecodeString(testSimpleCoinTxHex)
testSimpleCoinTx, _ = btcutil.NewTxFromBytes(testSimpleCoinTxBytes) testSimpleCoinTx, _ = lbcutil.NewTxFromBytes(testSimpleCoinTxBytes)
testSimpleCoin = &coinset.SimpleCoin{ testSimpleCoin = &coinset.SimpleCoin{
Tx: testSimpleCoinTx, Tx: testSimpleCoinTx,
TxIndex: 0, TxIndex: 0,

View file

@ -1,31 +1,31 @@
github.com/conformal/btcutil/coinset/coins.go MinPriorityCoinSelector.CoinSelect 100.00% (39/39) github.com/conformal/lbcutil/coinset/coins.go MinPriorityCoinSelector.CoinSelect 100.00% (39/39)
github.com/conformal/btcutil/coinset/coins.go NewMsgTxWithInputCoins 100.00% (6/6) github.com/conformal/lbcutil/coinset/coins.go NewMsgTxWithInputCoins 100.00% (6/6)
github.com/conformal/btcutil/coinset/coins.go MinIndexCoinSelector.CoinSelect 100.00% (6/6) github.com/conformal/lbcutil/coinset/coins.go MinIndexCoinSelector.CoinSelect 100.00% (6/6)
github.com/conformal/btcutil/coinset/coins.go CoinSet.removeElement 100.00% (5/5) github.com/conformal/lbcutil/coinset/coins.go CoinSet.removeElement 100.00% (5/5)
github.com/conformal/btcutil/coinset/coins.go NewCoinSet 100.00% (4/4) github.com/conformal/lbcutil/coinset/coins.go NewCoinSet 100.00% (4/4)
github.com/conformal/btcutil/coinset/coins.go CoinSet.Coins 100.00% (4/4) github.com/conformal/lbcutil/coinset/coins.go CoinSet.Coins 100.00% (4/4)
github.com/conformal/btcutil/coinset/coins.go CoinSet.PopCoin 100.00% (4/4) github.com/conformal/lbcutil/coinset/coins.go CoinSet.PopCoin 100.00% (4/4)
github.com/conformal/btcutil/coinset/coins.go CoinSet.ShiftCoin 100.00% (4/4) github.com/conformal/lbcutil/coinset/coins.go CoinSet.ShiftCoin 100.00% (4/4)
github.com/conformal/btcutil/coinset/coins.go MinNumberCoinSelector.CoinSelect 100.00% (4/4) github.com/conformal/lbcutil/coinset/coins.go MinNumberCoinSelector.CoinSelect 100.00% (4/4)
github.com/conformal/btcutil/coinset/coins.go MaxValueAgeCoinSelector.CoinSelect 100.00% (4/4) github.com/conformal/lbcutil/coinset/coins.go MaxValueAgeCoinSelector.CoinSelect 100.00% (4/4)
github.com/conformal/btcutil/coinset/coins.go CoinSet.PushCoin 100.00% (3/3) github.com/conformal/lbcutil/coinset/coins.go CoinSet.PushCoin 100.00% (3/3)
github.com/conformal/btcutil/coinset/coins.go CoinSet.TotalValueAge 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go CoinSet.TotalValueAge 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.NumConfs 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.NumConfs 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.ValueAge 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.ValueAge 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go CoinSet.TotalValue 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go CoinSet.TotalValue 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go byValueAge.Len 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go byValueAge.Len 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go byValueAge.Swap 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go byValueAge.Swap 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go byValueAge.Less 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go byValueAge.Less 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go byAmount.Len 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go byAmount.Len 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go byAmount.Swap 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go byAmount.Swap 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go byAmount.Less 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go byAmount.Less 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.Hash 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.Hash 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.Index 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.Index 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.txOut 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.txOut 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.Value 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.Value 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go SimpleCoin.PkScript 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.PkScript 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go CoinSet.Num 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go CoinSet.Num 100.00% (1/1)
github.com/conformal/btcutil/coinset/coins.go satisfiesTargetValue 100.00% (1/1) github.com/conformal/lbcutil/coinset/coins.go satisfiesTargetValue 100.00% (1/1)
github.com/conformal/btcutil/coinset ---------------------------------- 100.00% (100/100) github.com/conformal/lbcutil/coinset ---------------------------------- 100.00% (100/100)

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
const ( const (
// SatoshiPerBitcent is the number of satoshi in one bitcoin cent. // SatoshiPerBitcent is the number of satoshi in one bitcoin cent.
@ -12,5 +12,5 @@ const (
SatoshiPerBitcoin = 1e8 SatoshiPerBitcoin = 1e8
// MaxSatoshi is the maximum transaction amount allowed in satoshi. // MaxSatoshi is the maximum transaction amount allowed in satoshi.
MaxSatoshi = 21e6 * SatoshiPerBitcoin MaxSatoshi = 21e9 * SatoshiPerBitcoin
) )

6
doc.go
View file

@ -3,7 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
/* /*
Package btcutil provides bitcoin-specific convenience functions and types. Package lbcutil provides bitcoin-specific convenience functions and types.
Block Overview Block Overview
@ -36,11 +36,11 @@ To decode/encode an address:
"e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d57" + "e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d57" +
"8a4c702b6bf11d5f" "8a4c702b6bf11d5f"
defaultNet := &chaincfg.MainNetParams defaultNet := &chaincfg.MainNetParams
addr, err := btcutil.DecodeAddress(addrString, defaultNet) addr, err := lbcutil.DecodeAddress(addrString, defaultNet)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(addr.EncodeAddress()) fmt.Println(addr.EncodeAddress())
*/ */
package btcutil package lbcutil

View file

@ -1,76 +1,76 @@
package btcutil_test package lbcutil_test
import ( import (
"fmt" "fmt"
"math" "math"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
) )
func ExampleAmount() { func ExampleAmount() {
a := btcutil.Amount(0) a := lbcutil.Amount(0)
fmt.Println("Zero Satoshi:", a) fmt.Println("Zero Satoshi:", a)
a = btcutil.Amount(1e8) a = lbcutil.Amount(1e8)
fmt.Println("100,000,000 Satoshis:", a) fmt.Println("100,000,000 Satoshis:", a)
a = btcutil.Amount(1e5) a = lbcutil.Amount(1e5)
fmt.Println("100,000 Satoshis:", a) fmt.Println("100,000 Satoshis:", a)
// Output: // Output:
// Zero Satoshi: 0 BTC // Zero Satoshi: 0 LBC
// 100,000,000 Satoshis: 1 BTC // 100,000,000 Satoshis: 1 LBC
// 100,000 Satoshis: 0.001 BTC // 100,000 Satoshis: 0.001 LBC
} }
func ExampleNewAmount() { func ExampleNewAmount() {
amountOne, err := btcutil.NewAmount(1) amountOne, err := lbcutil.NewAmount(1)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(amountOne) //Output 1 fmt.Println(amountOne) //Output 1
amountFraction, err := btcutil.NewAmount(0.01234567) amountFraction, err := lbcutil.NewAmount(0.01234567)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(amountFraction) //Output 2 fmt.Println(amountFraction) //Output 2
amountZero, err := btcutil.NewAmount(0) amountZero, err := lbcutil.NewAmount(0)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(amountZero) //Output 3 fmt.Println(amountZero) //Output 3
amountNaN, err := btcutil.NewAmount(math.NaN()) amountNaN, err := lbcutil.NewAmount(math.NaN())
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println(amountNaN) //Output 4 fmt.Println(amountNaN) //Output 4
// Output: 1 BTC // Output: 1 LBC
// 0.01234567 BTC // 0.01234567 LBC
// 0 BTC // 0 LBC
// invalid bitcoin amount // invalid coin amount
} }
func ExampleAmount_unitConversions() { func ExampleAmount_unitConversions() {
amount := btcutil.Amount(44433322211100) amount := lbcutil.Amount(44433322211100)
fmt.Println("Satoshi to kBTC:", amount.Format(btcutil.AmountKiloBTC)) fmt.Println("Satoshi to kLBC:", amount.Format(lbcutil.AmountKiloBTC))
fmt.Println("Satoshi to BTC:", amount) fmt.Println("Satoshi to LBC:", amount)
fmt.Println("Satoshi to MilliBTC:", amount.Format(btcutil.AmountMilliBTC)) fmt.Println("Satoshi to MilliLBC:", amount.Format(lbcutil.AmountMilliBTC))
fmt.Println("Satoshi to MicroBTC:", amount.Format(btcutil.AmountMicroBTC)) fmt.Println("Satoshi to MicroLBC:", amount.Format(lbcutil.AmountMicroBTC))
fmt.Println("Satoshi to Satoshi:", amount.Format(btcutil.AmountSatoshi)) fmt.Println("Satoshi to Satoshi:", amount.Format(lbcutil.AmountSatoshi))
// Output: // Output:
// Satoshi to kBTC: 444.333222111 kBTC // Satoshi to kLBC: 444.333222111 kLBC
// Satoshi to BTC: 444333.222111 BTC // Satoshi to LBC: 444333.222111 LBC
// Satoshi to MilliBTC: 444333222.111 mBTC // Satoshi to MilliLBC: 444333222.111 mLBC
// Satoshi to MicroBTC: 444333222111 μBTC // Satoshi to MicroLBC: 444333222111 μLBC
// Satoshi to Satoshi: 44433322211100 Satoshi // Satoshi to Satoshi: 44433322211100 Satoshi
} }

View file

@ -1,24 +1,9 @@
gcs gcs
========== ==========
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)] [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
(https://travis-ci.org/btcsuite/btcutil) [![ISC License]
(http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://godoc.org/github.com/btcsuite/btcutil/gcs?status.png)]
(http://godoc.org/github.com/btcsuite/btcutil/gcs)
Package gcs provides an API for building and using a Golomb-coded set filter Package gcs provides an API for building and using a Golomb-coded set filter
similar to that described [here](http://giovanni.bajo.it/post/47119962313/golomb-coded-sets-smaller-than-bloom-filters). similar to that described [here](http://giovanni.bajo.it/post/47119962313/golomb-coded-sets-smaller-than-bloom-filters).
A comprehensive suite of tests is provided to ensure proper functionality. A comprehensive suite of tests is provided to ensure proper functionality.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/gcs
```
## License
Package gcs is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -10,10 +10,10 @@ import (
"fmt" "fmt"
"math" "math"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil/gcs" "github.com/lbryio/lbcutil/gcs"
) )
const ( const (
@ -54,7 +54,7 @@ func RandomKey() ([gcs.KeySize]byte, error) {
} }
// Copy the byte slice to a [gcs.KeySize]byte array and return it. // Copy the byte slice to a [gcs.KeySize]byte array and return it.
copy(key[:], randKey[:]) copy(key[:], randKey)
return key, nil return key, nil
} }
@ -62,7 +62,7 @@ func RandomKey() ([gcs.KeySize]byte, error) {
// truncating the bytes of the hash to the appopriate key size. // truncating the bytes of the hash to the appopriate key size.
func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte { func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte {
var key [gcs.KeySize]byte var key [gcs.KeySize]byte
copy(key[:], keyHash.CloneBytes()[:]) copy(key[:], keyHash.CloneBytes())
return key return key
} }

View file

@ -9,19 +9,16 @@ import (
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
"github.com/btcsuite/btcutil/gcs" "github.com/lbryio/lbcutil/gcs"
"github.com/btcsuite/btcutil/gcs/builder" "github.com/lbryio/lbcutil/gcs/builder"
) )
var ( var (
// No need to allocate an err variable in every test
err error
// List of values for building a filter // List of values for building a filter
contents = [][]byte{ contents = [][]byte{
[]byte("Alex"), []byte("Alex"),
@ -79,8 +76,8 @@ func TestUseBlockHash(t *testing.T) {
Index: 4321, Index: 4321,
} }
// btcutil.Address // lbcutil.Address
addr, err := btcutil.DecodeAddress(testAddr, &chaincfg.MainNetParams) addr, err := lbcutil.DecodeAddress(testAddr, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Fatalf("Address decode failed: %s", err.Error()) t.Fatalf("Address decode failed: %s", err.Error())
} }

View file

@ -12,8 +12,8 @@ import (
"sort" "sort"
"github.com/aead/siphash" "github.com/aead/siphash"
"github.com/btcsuite/btcd/wire"
"github.com/kkdai/bstream" "github.com/kkdai/bstream"
"github.com/lbryio/lbcd/wire"
) )
// Inspired by https://github.com/rasky/gcs // Inspired by https://github.com/rasky/gcs
@ -91,7 +91,7 @@ type Filter struct {
// BuildGCSFilter builds a new GCS filter with the collision probability of // BuildGCSFilter builds a new GCS filter with the collision probability of
// `1/(2**P)`, key `key`, and including every `[]byte` in `data` as a member of // `1/(2**P)`, key `key`, and including every `[]byte` in `data` as a member of
// the set. // the set.
func BuildGCSFilter(P uint8, M uint64, key [KeySize]byte, data [][]byte) (*Filter, error) { func BuildGCSFilter(P uint8, M uint64, key [KeySize]byte, data [][]byte) (*Filter, error) { // nolint:gocritic
// Some initial parameter checks: make sure we have data from which to // Some initial parameter checks: make sure we have data from which to
// build the filter, and make sure our parameters will fit the hash // build the filter, and make sure our parameters will fit the hash
// function we're using. // function we're using.
@ -174,7 +174,7 @@ func BuildGCSFilter(P uint8, M uint64, key [KeySize]byte, data [][]byte) (*Filte
// FromBytes deserializes a GCS filter from a known N, P, and serialized filter // FromBytes deserializes a GCS filter from a known N, P, and serialized filter
// as returned by Bytes(). // as returned by Bytes().
func FromBytes(N uint32, P uint8, M uint64, d []byte) (*Filter, error) { func FromBytes(N uint32, P uint8, M uint64, d []byte) (*Filter, error) { // nolint:gocritic
// Basic sanity check. // Basic sanity check.
if P > 32 { if P > 32 {
return nil, ErrPTooBig return nil, ErrPTooBig
@ -200,7 +200,7 @@ func FromBytes(N uint32, P uint8, M uint64, d []byte) (*Filter, error) {
// FromNBytes deserializes a GCS filter from a known P, and serialized N and // FromNBytes deserializes a GCS filter from a known P, and serialized N and
// filter as returned by NBytes(). // filter as returned by NBytes().
func FromNBytes(P uint8, M uint64, d []byte) (*Filter, error) { func FromNBytes(P uint8, M uint64, d []byte) (*Filter, error) { // nolint:gocritic
buffer := bytes.NewBuffer(d) buffer := bytes.NewBuffer(d)
N, err := wire.ReadVarInt(buffer, varIntProtoVer) N, err := wire.ReadVarInt(buffer, varIntProtoVer)
if err != nil { if err != nil {

View file

@ -11,7 +11,7 @@ import (
"math/rand" "math/rand"
"testing" "testing"
"github.com/btcsuite/btcutil/gcs" "github.com/lbryio/lbcutil/gcs"
) )
var ( var (
@ -27,7 +27,7 @@ var (
// Filters are conserved between tests but we must define with an // Filters are conserved between tests but we must define with an
// interface which functions we're testing because the gcsFilter type // interface which functions we're testing because the gcsFilter type
// isn't exported // isn't exported
filter, filter2, filter3, filter4, filter5 *gcs.Filter filter, filter2, filter3 *gcs.Filter
// We need to use the same key for building and querying the filters // We need to use the same key for building and querying the filters
key [gcs.KeySize]byte key [gcs.KeySize]byte
@ -328,6 +328,8 @@ func TestGCSFilterMatchAnySuite(t *testing.T) {
} }
for _, test := range funcs { for _, test := range funcs {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
contentsCopy := make([][]byte, len(contents2)) contentsCopy := make([][]byte, len(contents2))
copy(contentsCopy, contents2) copy(contentsCopy, contents2)

View file

@ -10,7 +10,7 @@ import (
"math/rand" "math/rand"
"testing" "testing"
"github.com/btcsuite/btcutil/gcs" "github.com/lbryio/lbcutil/gcs"
) )
func genRandFilterElements(numElements uint) ([][]byte, error) { func genRandFilterElements(numElements uint) ([][]byte, error) {
@ -28,7 +28,6 @@ func genRandFilterElements(numElements uint) ([][]byte, error) {
var ( var (
generatedFilter *gcs.Filter generatedFilter *gcs.Filter
filterErr error
) )
// BenchmarkGCSFilterBuild benchmarks building a filter. // BenchmarkGCSFilterBuild benchmarks building a filter.
@ -101,7 +100,7 @@ func BenchmarkGCSFilterMatch(b *testing.B) {
var localMatch bool var localMatch bool
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
localMatch, err = filter.Match(key, []byte("Nate")) _, err = filter.Match(key, []byte("Nate"))
if err != nil { if err != nil {
b.Fatalf("unable to match filter: %v", err) b.Fatalf("unable to match filter: %v", err)
} }
@ -115,8 +114,6 @@ func BenchmarkGCSFilterMatch(b *testing.B) {
} }
var ( var (
randElems1, _ = genRandFilterElements(1)
randElems10, _ = genRandFilterElements(10)
randElems100, _ = genRandFilterElements(100) randElems100, _ = genRandFilterElements(100)
randElems1000, _ = genRandFilterElements(1000) randElems1000, _ = genRandFilterElements(1000)
randElems10000, _ = genRandFilterElements(10000) randElems10000, _ = genRandFilterElements(10000)
@ -164,6 +161,8 @@ var matchAnyBenchmarks = []struct {
// BenchmarkGCSFilterMatchAny benchmarks the sort-and-zip MatchAny impl. // BenchmarkGCSFilterMatchAny benchmarks the sort-and-zip MatchAny impl.
func BenchmarkGCSFilterZipMatchAny(b *testing.B) { func BenchmarkGCSFilterZipMatchAny(b *testing.B) {
for _, test := range matchAnyBenchmarks { for _, test := range matchAnyBenchmarks {
test := test
b.Run(test.name, func(b *testing.B) { b.Run(test.name, func(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
@ -188,6 +187,8 @@ func BenchmarkGCSFilterZipMatchAny(b *testing.B) {
// BenchmarkGCSFilterMatchAny benchmarks the hash-join MatchAny impl. // BenchmarkGCSFilterMatchAny benchmarks the hash-join MatchAny impl.
func BenchmarkGCSFilterHashMatchAny(b *testing.B) { func BenchmarkGCSFilterHashMatchAny(b *testing.B) {
for _, test := range matchAnyBenchmarks { for _, test := range matchAnyBenchmarks {
test := test
b.Run(test.name, func(b *testing.B) { b.Run(test.name, func(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
@ -212,6 +213,8 @@ func BenchmarkGCSFilterHashMatchAny(b *testing.B) {
// BenchmarkGCSFilterMatchAny benchmarks the hybrid MatchAny impl. // BenchmarkGCSFilterMatchAny benchmarks the hybrid MatchAny impl.
func BenchmarkGCSFilterMatchAny(b *testing.B) { func BenchmarkGCSFilterMatchAny(b *testing.B) {
for _, test := range matchAnyBenchmarks { for _, test := range matchAnyBenchmarks {
test := test
b.Run(test.name, func(b *testing.B) { b.Run(test.name, func(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()

32
go.mod
View file

@ -1,11 +1,31 @@
module github.com/btcsuite/btcutil module github.com/lbryio/lbcutil
go 1.14 go 1.17
require ( require (
github.com/aead/siphash v1.0.1 github.com/aead/siphash v1.0.1
github.com/btcsuite/btcd v0.20.1-beta github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew v1.1.0 github.com/kkdai/bstream v1.0.0
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 github.com/lbryio/lbcd v0.22.101-beta
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b
)
require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/pebble v0.0.0-20210525181856-e45797baeb78 // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/snappy v0.0.2-0.20190904063534-ff6b7dc882cf // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/text v0.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/exp v0.0.0-20200513190911-00229845015e // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6 // indirect
) )

541
go.sum
View file

@ -1,55 +1,558 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw=
github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 h1:ZA/jbKoGcVAnER6pCHPEkGdZOV7U1oLUedErBHCUMs0= github.com/btcsuite/goleveldb v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4=
github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/snappy-go v1.0.0 h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE=
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4=
github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM=
github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y=
github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/cockroachdb/pebble v0.0.0-20210525181856-e45797baeb78 h1:bsZKpvDmUKiBm14kDi8sMqG3bRsfIJ64NwuaAr/8MZs=
github.com/cockroachdb/pebble v0.0.0-20210525181856-e45797baeb78/go.mod h1:1XpB4cLQcF189RAcWi4gUc110zJgtOfT7SVNGY8sOe0=
github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw=
github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/felixge/fgprof v0.9.1/go.mod h1:7/HK6JFtFaARhIljgP2IV8rJLIoHDoOYoUphsnGvqxE=
github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.2-0.20190904063534-ff6b7dc882cf h1:gFVkHXmVAhEbxZVDln5V9GKrLaluNoFHDbrZwAWZgws=
github.com/golang/snappy v0.0.2-0.20190904063534-ff6b7dc882cf/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20200615235658-03e1cf38a040/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI=
github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI=
github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q=
github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=
github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk=
github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U=
github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw=
github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8=
github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA=
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.11.7 h1:0hzRabrMN4tSTvMfnL3SCv1ZGeAP23ynzodBgaHeMeg=
github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/lbryio/lbcd v0.22.100-beta/go.mod h1:u8SaFX4xdGMMR5xasBGfgApC8pvD4rnK2OujZnrq5gs=
github.com/lbryio/lbcd v0.22.101-beta h1:umLIxhyRwPdi91vtsDfgW85viK0AV8RPtIF9zQYtXw0=
github.com/lbryio/lbcd v0.22.101-beta/go.mod h1:K8A7dGvV4n89Oahoc5IfDb6IMRmxyZYKb7ZE+50+Jwc=
github.com/lbryio/lbcutil v1.0.201/go.mod h1:gDHc/b+Rdz3J7+VB8e5/Bl9roVf8Q5/8FQCyuK9dXD0=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg=
github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM=
github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil/v3 v3.21.7/go.mod h1:RGl11Y7XMTQPmHh8F0ayC6haKNBgH4PXMJuTAcMOlz4=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tklauser/go-sysconf v0.3.7/go.mod h1:JZIdXh4RmBvZDBZ41ld2bGxRV3n4daiiqA3skYhAoQ4=
github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8dsCw5j+E=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/vmihailenco/msgpack/v5 v5.3.2/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d h1:2+ZP7EfsZV7Vvmx3TIqSlSzATMkTAKqM14YGFPoSKjI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b h1:QAqMVf3pSa6eeTsuklijukjXBlj7Es2QQplab+/RbQ4=
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
golang.org/x/exp v0.0.0-20200513190911-00229845015e h1:rMqLP+9XLy+LdbCXHjJHAmTfXCr93W7oruWA6Hq1Alc=
golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=

View file

@ -32,15 +32,4 @@ for i in $(find . -name go.mod -type f -print); do
go tool cover -func profile.cov go tool cover -func profile.cov
) )
# check linters
(cd $MODNAME && \
go mod download && \
golangci-lint run --deadline=10m --disable-all \
--enable=gofmt \
--enable=goimports \
--enable=golint \
--enable=govet \
--enable=gosimple \
--enable=unconvert
)
done done

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"crypto/sha256" "crypto/sha256"
@ -13,7 +13,7 @@ import (
// Calculate the hash of hasher over buf. // Calculate the hash of hasher over buf.
func calcHash(buf []byte, hasher hash.Hash) []byte { func calcHash(buf []byte, hasher hash.Hash) []byte {
hasher.Write(buf) _, _ = hasher.Write(buf)
return hasher.Sum(nil) return hasher.Sum(nil)
} }

View file

@ -1,9 +1,7 @@
hdkeychain hdkeychain
========== ==========
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcutil/hdkeychain)
Package hdkeychain provides an API for bitcoin hierarchical deterministic Package hdkeychain provides an API for bitcoin hierarchical deterministic
extended keys (BIP0032). extended keys (BIP0032).
@ -24,7 +22,7 @@ report.
keys keys
- Support for custom networks by registering them with chaincfg - Support for custom networks by registering them with chaincfg
- Obtaining the underlying EC pubkeys, EC privkeys, and associated bitcoin - Obtaining the underlying EC pubkeys, EC privkeys, and associated bitcoin
addresses ties in seamlessly with existing btcec and btcutil types which addresses ties in seamlessly with existing btcec and lbcutil types which
provide powerful tools for working with them to do things like sign provide powerful tools for working with them to do things like sign
transations and generate payment scripts transations and generate payment scripts
- Uses the btcec package which is highly optimized for secp256k1 - Uses the btcec package which is highly optimized for secp256k1
@ -36,24 +34,13 @@ report.
- Comprehensive test coverage including the BIP0032 test vectors - Comprehensive test coverage including the BIP0032 test vectors
- Benchmarks - Benchmarks
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/hdkeychain
```
## Examples ## Examples
* [NewMaster Example](http://godoc.org/github.com/btcsuite/btcutil/hdkeychain#example-NewMaster) * [NewMaster Example](http://godoc.org/github.com/lbryio/lbcutil/hdkeychain#example-NewMaster)
Demonstrates how to generate a cryptographically random seed then use it to Demonstrates how to generate a cryptographically random seed then use it to
create a new master node (extended key). create a new master node (extended key).
* [Default Wallet Layout Example](http://godoc.org/github.com/btcsuite/btcutil/hdkeychain#example-package--DefaultWalletLayout) * [Default Wallet Layout Example](http://godoc.org/github.com/lbryio/lbcutil/hdkeychain#example-package--DefaultWalletLayout)
Demonstrates the default hierarchical deterministic wallet layout as described Demonstrates the default hierarchical deterministic wallet layout as described
in BIP0032. in BIP0032.
* [Audits Use Case Example](http://godoc.org/github.com/btcsuite/btcutil/hdkeychain#example-package--Audits) * [Audits Use Case Example](http://godoc.org/github.com/lbryio/lbcutil/hdkeychain#example-package--Audits)
Demonstrates the audits use case in BIP0032. Demonstrates the audits use case in BIP0032.
## License
Package hdkeychain is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -7,7 +7,7 @@ package hdkeychain_test
import ( import (
"testing" "testing"
"github.com/btcsuite/btcutil/hdkeychain" "github.com/lbryio/lbcutil/hdkeychain"
) )
// bip0032MasterPriv1 is the master private extended key from the first set of // bip0032MasterPriv1 is the master private extended key from the first set of
@ -26,7 +26,7 @@ func BenchmarkDeriveHardened(b *testing.B) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
masterKey.Derive(hdkeychain.HardenedKeyStart) _, _ = masterKey.Derive(hdkeychain.HardenedKeyStart)
} }
} }
@ -41,7 +41,7 @@ func BenchmarkDeriveNormal(b *testing.B) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
masterKey.Derive(0) _, _ = masterKey.Derive(0)
} }
} }
@ -56,7 +56,7 @@ func BenchmarkPrivToPub(b *testing.B) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
masterKey.Neuter() _, _ = masterKey.Neuter()
} }
} }
@ -64,7 +64,7 @@ func BenchmarkPrivToPub(b *testing.B) {
// extended key. // extended key.
func BenchmarkDeserialize(b *testing.B) { func BenchmarkDeserialize(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
hdkeychain.NewKeyFromString(bip0032MasterPriv1) _, _ = hdkeychain.NewKeyFromString(bip0032MasterPriv1)
} }
} }

View file

@ -7,8 +7,8 @@ package hdkeychain_test
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
"github.com/btcsuite/btcutil/hdkeychain" "github.com/lbryio/lbcutil/hdkeychain"
) )
// This example demonstrates how to generate a cryptographically random seed // This example demonstrates how to generate a cryptographically random seed
@ -132,8 +132,8 @@ func Example_defaultWalletLayout() {
fmt.Println("Account 0 Internal Address 0:", acct0IntAddr) fmt.Println("Account 0 Internal Address 0:", acct0IntAddr)
// Output: // Output:
// Account 0 External Address 10: 1HVccubUT8iKTapMJ5AnNA4sLRN27xzQ4F // Account 0 External Address 10: bVDtK8vxoU6nyRfiNjUsapCjqJGCY2wwRq
// Account 0 Internal Address 0: 1J5rebbkQaunJTUoNVREDbeB49DqMNFFXk // Account 0 Internal Address 0: bVp8LpwEkvJFpJLAT9jKSFn3Z281nH4wcm
} }
// This example demonstrates the audits use case in BIP0032. // This example demonstrates the audits use case in BIP0032.

View file

@ -18,11 +18,11 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/btcsuite/btcd/btcec" "github.com/lbryio/lbcd/btcec"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
) )
const ( const (
@ -277,7 +277,7 @@ func (k *ExtendedKey) Derive(i uint32) (*ExtendedKey, error) {
// data: // data:
// I = HMAC-SHA512(Key = chainCode, Data = data) // I = HMAC-SHA512(Key = chainCode, Data = data)
hmac512 := hmac.New(sha512.New, k.chainCode) hmac512 := hmac.New(sha512.New, k.chainCode)
hmac512.Write(data) _, _ = hmac512.Write(data)
ilr := hmac512.Sum(nil) ilr := hmac512.Sum(nil)
// Split "I" into two 32-byte sequences Il and Ir where: // Split "I" into two 32-byte sequences Il and Ir where:
@ -346,7 +346,7 @@ func (k *ExtendedKey) Derive(i uint32) (*ExtendedKey, error) {
// The fingerprint of the parent for the derived child is the first 4 // The fingerprint of the parent for the derived child is the first 4
// bytes of the RIPEMD160(SHA256(parentPubKey)). // bytes of the RIPEMD160(SHA256(parentPubKey)).
parentFP := btcutil.Hash160(k.pubKeyBytes())[:4] parentFP := lbcutil.Hash160(k.pubKeyBytes())[:4]
return NewExtendedKey(k.version, childKey, childChainCode, parentFP, return NewExtendedKey(k.version, childKey, childChainCode, parentFP,
k.depth+1, i, isPrivate), nil k.depth+1, i, isPrivate), nil
} }
@ -380,7 +380,7 @@ func (k *ExtendedKey) DeriveNonStandard(i uint32) (*ExtendedKey, error) {
binary.BigEndian.PutUint32(data[keyLen:], i) binary.BigEndian.PutUint32(data[keyLen:], i)
hmac512 := hmac.New(sha512.New, k.chainCode) hmac512 := hmac.New(sha512.New, k.chainCode)
hmac512.Write(data) _, _ = hmac512.Write(data)
ilr := hmac512.Sum(nil) ilr := hmac512.Sum(nil)
il := ilr[:len(ilr)/2] il := ilr[:len(ilr)/2]
@ -415,7 +415,7 @@ func (k *ExtendedKey) DeriveNonStandard(i uint32) (*ExtendedKey, error) {
childKey = pk.SerializeCompressed() childKey = pk.SerializeCompressed()
} }
parentFP := btcutil.Hash160(k.pubKeyBytes())[:4] parentFP := lbcutil.Hash160(k.pubKeyBytes())[:4]
return NewExtendedKey(k.version, childKey, childChainCode, parentFP, return NewExtendedKey(k.version, childKey, childChainCode, parentFP,
k.depth+1, i, isPrivate), nil k.depth+1, i, isPrivate), nil
} }
@ -506,9 +506,9 @@ func (k *ExtendedKey) ECPrivKey() (*btcec.PrivateKey, error) {
// Address converts the extended key to a standard bitcoin pay-to-pubkey-hash // Address converts the extended key to a standard bitcoin pay-to-pubkey-hash
// address for the passed network. // address for the passed network.
func (k *ExtendedKey) Address(net *chaincfg.Params) (*btcutil.AddressPubKeyHash, error) { func (k *ExtendedKey) Address(net *chaincfg.Params) (*lbcutil.AddressPubKeyHash, error) {
pkHash := btcutil.Hash160(k.pubKeyBytes()) pkHash := lbcutil.Hash160(k.pubKeyBytes())
return btcutil.NewAddressPubKeyHash(pkHash, net) return lbcutil.NewAddressPubKeyHash(pkHash, net)
} }
// paddedAppend appends the src byte slice to dst, returning the new slice. // paddedAppend appends the src byte slice to dst, returning the new slice.
@ -610,7 +610,7 @@ func NewMaster(seed []byte, net *chaincfg.Params) (*ExtendedKey, error) {
// First take the HMAC-SHA512 of the master key and the seed data: // First take the HMAC-SHA512 of the master key and the seed data:
// I = HMAC-SHA512(Key = "Bitcoin seed", Data = S) // I = HMAC-SHA512(Key = "Bitcoin seed", Data = S)
hmac512 := hmac.New(sha512.New, masterKey) hmac512 := hmac.New(sha512.New, masterKey)
hmac512.Write(seed) _, _ = hmac512.Write(seed)
lr := hmac512.Sum(nil) lr := hmac512.Sum(nil)
// Split "I" into two 32-byte sequences Il and Ir where: // Split "I" into two 32-byte sequences Il and Ir where:

View file

@ -17,7 +17,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
) )
// TestBIP0032Vectors tests the vectors provided by [BIP32] to ensure the // TestBIP0032Vectors tests the vectors provided by [BIP32] to ensure the
@ -579,7 +579,7 @@ func TestExtendedKeyAPI(t *testing.T) {
childNum: 0, childNum: 0,
privKey: "e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35", privKey: "e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35",
pubKey: "0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2", pubKey: "0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2",
address: "15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma", address: "bHVb1pN9ACQB2QxFoXwVAbM4WSyUVVDfbW",
}, },
{ {
name: "test vector 1 chain m/0H/1/2H public", name: "test vector 1 chain m/0H/1/2H public",
@ -590,7 +590,7 @@ func TestExtendedKeyAPI(t *testing.T) {
childNum: 2147483650, childNum: 2147483650,
privKeyErr: ErrNotPrivExtKey, privKeyErr: ErrNotPrivExtKey,
pubKey: "0357bfe1e341d01c69fe5654309956cbea516822fba8a601743a012a7896ee8dc2", pubKey: "0357bfe1e341d01c69fe5654309956cbea516822fba8a601743a012a7896ee8dc2",
address: "1NjxqbA9aZWnh17q1UW3rB4EPu79wDXj7x", address: "baUEXpVdvtuGCqyC68p94qC6tn1LSJq1LA",
}, },
} }
@ -980,10 +980,10 @@ func TestZero(t *testing.T) {
return false return false
} }
wantAddr := "1HT7xU2Ngenf7D4yocz2SAcnNLW7rK8d4E" wantAddr := "bVBPehMs2zB8d3vLtHJ7epkesDQJJ9D7Ek"
addr, err := key.Address(&chaincfg.MainNetParams) addr, err := key.Address(&chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Addres s #%d (%s): unexpected error: %v", i, t.Errorf("Address #%d (%s): unexpected error: %v", i,
testName, err) testName, err)
return false return false
} }
@ -1196,7 +1196,7 @@ func TestLeadingZero(t *testing.T) {
} }
if hex.EncodeToString(child1nonstandard.key) != "ea46d8f58eb863a2d371a938396af8b0babe85c01920f59a8044412e70e837ee" { if hex.EncodeToString(child1nonstandard.key) != "ea46d8f58eb863a2d371a938396af8b0babe85c01920f59a8044412e70e837ee" {
t.Error("incorrect btcutil backwards compatible BIP32-like derivation") t.Error("incorrect lbcutil backwards compatible BIP32-like derivation")
} }
if !child0.IsAffectedByIssue172() { if !child0.IsAffectedByIssue172() {

View file

@ -1,20 +1,20 @@
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.String 100.00% (18/18) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.String 100.00% (18/18)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Zero 100.00% (9/9) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Zero 100.00% (9/9)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.pubKeyBytes 100.00% (7/7) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.pubKeyBytes 100.00% (7/7)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Neuter 100.00% (6/6) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Neuter 100.00% (6/6)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.ECPrivKey 100.00% (4/4) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.ECPrivKey 100.00% (4/4)
github.com/conformal/btcutil/hdkeychain/extendedkey.go zero 100.00% (3/3) github.com/conformal/lbcutil/hdkeychain/extendedkey.go zero 100.00% (3/3)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.SetNet 100.00% (3/3) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.SetNet 100.00% (3/3)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Address 100.00% (2/2) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Address 100.00% (2/2)
github.com/conformal/btcutil/hdkeychain/extendedkey.go newExtendedKey 100.00% (1/1) github.com/conformal/lbcutil/hdkeychain/extendedkey.go newExtendedKey 100.00% (1/1)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.IsPrivate 100.00% (1/1) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.IsPrivate 100.00% (1/1)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.ParentFingerprint 100.00% (1/1) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.ParentFingerprint 100.00% (1/1)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.ECPubKey 100.00% (1/1) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.ECPubKey 100.00% (1/1)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.IsForNet 100.00% (1/1) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.IsForNet 100.00% (1/1)
github.com/conformal/btcutil/hdkeychain/extendedkey.go NewKeyFromString 95.83% (23/24) github.com/conformal/lbcutil/hdkeychain/extendedkey.go NewKeyFromString 95.83% (23/24)
github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Child 91.67% (33/36) github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Child 91.67% (33/36)
github.com/conformal/btcutil/hdkeychain/extendedkey.go NewMaster 91.67% (11/12) github.com/conformal/lbcutil/hdkeychain/extendedkey.go NewMaster 91.67% (11/12)
github.com/conformal/btcutil/hdkeychain/extendedkey.go GenerateSeed 85.71% (6/7) github.com/conformal/lbcutil/hdkeychain/extendedkey.go GenerateSeed 85.71% (6/7)
github.com/conformal/btcutil/hdkeychain ----------------------------- 95.59% (130/136) github.com/conformal/lbcutil/hdkeychain ----------------------------- 95.59% (130/136)

View file

@ -3,18 +3,18 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
/* /*
This test file is part of the btcutil package rather than than the This test file is part of the lbcutil package rather than than the
btcutil_test package so it can bridge access to the internals to properly test lbcutil_test package so it can bridge access to the internals to properly test
cases which are either not possible or can't reliably be tested via the public cases which are either not possible or can't reliably be tested via the public
interface. The functions are only exported while the tests are being run. interface. The functions are only exported while the tests are being run.
*/ */
package btcutil package lbcutil
import ( import (
"github.com/btcsuite/btcd/btcec" "github.com/lbryio/lbcd/btcec"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
"github.com/btcsuite/btcutil/bech32" "github.com/lbryio/lbcutil/bech32"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
) )
@ -59,9 +59,11 @@ func TstAddressWitnessPubKeyHash(version byte, program [20]byte,
hrp string) *AddressWitnessPubKeyHash { hrp string) *AddressWitnessPubKeyHash {
return &AddressWitnessPubKeyHash{ return &AddressWitnessPubKeyHash{
hrp: hrp, AddressSegWit{
witnessVersion: version, hrp: hrp,
witnessProgram: program, witnessVersion: version,
witnessProgram: program[:],
},
} }
} }
@ -71,9 +73,24 @@ func TstAddressWitnessScriptHash(version byte, program [32]byte,
hrp string) *AddressWitnessScriptHash { hrp string) *AddressWitnessScriptHash {
return &AddressWitnessScriptHash{ return &AddressWitnessScriptHash{
hrp: hrp, AddressSegWit{
witnessVersion: version, hrp: hrp,
witnessProgram: program, witnessVersion: version,
witnessProgram: program[:],
},
}
}
// TstAddressTaproot creates an AddressTaproot, initiating the fields as given.
func TstAddressTaproot(version byte, program [32]byte,
hrp string) *AddressTaproot {
return &AddressTaproot{
AddressSegWit{
hrp: hrp,
witnessVersion: version,
witnessProgram: program[:],
},
} }
} }
@ -112,3 +129,19 @@ func TstAddressSegwitSAddr(addr string) []byte {
} }
return data return data
} }
// TstAddressTaprootSAddr returns the expected witness program bytes for a
// bech32m encoded P2TR bitcoin address.
func TstAddressTaprootSAddr(addr string) []byte {
_, data, err := bech32.Decode(addr)
if err != nil {
return []byte{}
}
// First byte is version, rest is base 32 encoded data.
data, err = bech32.ConvertBits(data[1:], 5, 8, false)
if err != nil {
return []byte{}
}
return data
}

3
net.go
View file

@ -2,9 +2,10 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !appengine
// +build !appengine // +build !appengine
package btcutil package lbcutil
import ( import (
"net" "net"

View file

@ -4,7 +4,7 @@
// +build appengine // +build appengine
package btcutil package lbcutil
import ( import (
"net" "net"

View file

@ -5,7 +5,7 @@
package psbt package psbt
import ( import (
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// MinTxVersion is the lowest transaction version that we'll permit. // MinTxVersion is the lowest transaction version that we'll permit.

View file

@ -12,8 +12,8 @@ package psbt
import ( import (
"bytes" "bytes"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// Extract takes a finalized psbt.Packet and outputs a finalized transaction // Extract takes a finalized psbt.Packet and outputs a finalized transaction

View file

@ -12,7 +12,7 @@ package psbt
// multisig and no other custom script. // multisig and no other custom script.
import ( import (
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
) )
// isFinalized considers this input finalized if it contains at least one of // isFinalized considers this input finalized if it contains at least one of

View file

@ -1,9 +0,0 @@
module github.com/btcsuite/btcutil/psbt
go 1.13
require (
github.com/btcsuite/btcd v0.20.1-beta
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/davecgh/go-spew v1.1.1
)

View file

@ -1,58 +0,0 @@
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v0.0.0-20191219182022-e17c9730c422 h1:EqnrgSSg0SFWRlEZLExgjtuUR/IPnuQ6qw6nwRda4Uk=
github.com/btcsuite/btcutil v0.0.0-20191219182022-e17c9730c422/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 h1:ZA/jbKoGcVAnER6pCHPEkGdZOV7U1oLUedErBHCUMs0=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QUXSfV0yi4Q0jkbq8NDtIKFtF61AoqV0=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 h1:9lP3x0pW80sDI6t1UMSLA4to18W7R7imwAI/sWS9S8Q=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View file

@ -6,8 +6,8 @@ import (
"io" "io"
"sort" "sort"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// PInput is a struct encapsulating all the data that can be attached to any // PInput is a struct encapsulating all the data that can be attached to any

View file

@ -5,7 +5,7 @@ import (
"io" "io"
"sort" "sort"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// POutput is a struct encapsulating all the data that can be attached // POutput is a struct encapsulating all the data that can be attached

View file

@ -3,7 +3,7 @@ package psbt
import ( import (
"bytes" "bytes"
"github.com/btcsuite/btcd/btcec" "github.com/lbryio/lbcd/btcec"
) )
// PartialSig encapsulate a (BTC public key, ECDSA signature) // PartialSig encapsulate a (BTC public key, ECDSA signature)

View file

@ -14,7 +14,7 @@ import (
"io" "io"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// psbtMagicLength is the length of the magic bytes used to signal the start of // psbtMagicLength is the length of the magic bytes used to signal the start of

View file

@ -11,11 +11,11 @@ import (
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/lbryio/lbcd/txscript"
"github.com/lbryio/lbcd/wire"
"github.com/lbryio/lbcutil"
) )
// Test vectors from: // Test vectors from:
@ -1369,7 +1369,7 @@ func TestWitnessForNonWitnessUtxo(t *testing.T) {
}}, }},
TxOut: []*wire.TxOut{{ TxOut: []*wire.TxOut{{
PkScript: outPkScript, PkScript: outPkScript,
Value: 1.9 * btcutil.SatoshiPerBitcoin, Value: 1.9 * lbcutil.SatoshiPerBitcoin,
}}, }},
}, },
Inputs: []PInput{{}}, Inputs: []PInput{{}},

View file

@ -10,7 +10,7 @@ package psbt
// is in the correct state. // is in the correct state.
import ( import (
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
) )
// SignOutcome is a enum-like value that expresses the outcome of a call to the // SignOutcome is a enum-like value that expresses the outcome of a call to the

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"sort" "sort"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
) )
// InPlaceSort modifies the passed packet's wire TX inputs and outputs to be // InPlaceSort modifies the passed packet's wire TX inputs and outputs to be
@ -16,7 +16,7 @@ import (
// (partial) witness data since it will mutate the transaction if it's not // (partial) witness data since it will mutate the transaction if it's not
// already sorted. This can cause issues if you mutate a tx in a block, for // already sorted. This can cause issues if you mutate a tx in a block, for
// example, which would invalidate the block. It could also cause cached hashes, // example, which would invalidate the block. It could also cause cached hashes,
// such as in a btcutil.Tx to become invalidated. // such as in a lbcutil.Tx to become invalidated.
// //
// The function should only be used if the caller is creating the transaction or // The function should only be used if the caller is creating the transaction or
// is otherwise 100% positive mutating will not cause adverse affects due to // is otherwise 100% positive mutating will not cause adverse affects due to

View file

@ -4,8 +4,8 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
func TestInPlaceSort(t *testing.T) { func TestInPlaceSort(t *testing.T) {

View file

@ -14,9 +14,9 @@ import (
"bytes" "bytes"
"crypto/sha256" "crypto/sha256"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil" "github.com/lbryio/lbcutil"
) )
// Updater encapsulates the role 'Updater' as specified in BIP174; it accepts // Updater encapsulates the role 'Updater' as specified in BIP174; it accepts
@ -125,7 +125,7 @@ func (p *Updater) addPartialSignature(inIndex int, sig []byte,
if pInput.RedeemScript != nil { if pInput.RedeemScript != nil {
outIndex := p.Upsbt.UnsignedTx.TxIn[inIndex].PreviousOutPoint.Index outIndex := p.Upsbt.UnsignedTx.TxIn[inIndex].PreviousOutPoint.Index
scriptPubKey := pInput.NonWitnessUtxo.TxOut[outIndex].PkScript scriptPubKey := pInput.NonWitnessUtxo.TxOut[outIndex].PkScript
scriptHash := btcutil.Hash160(pInput.RedeemScript) scriptHash := lbcutil.Hash160(pInput.RedeemScript)
scriptHashScript, err := txscript.NewScriptBuilder(). scriptHashScript, err := txscript.NewScriptBuilder().
AddOp(txscript.OP_HASH160). AddOp(txscript.OP_HASH160).
@ -155,7 +155,7 @@ func (p *Updater) addPartialSignature(inIndex int, sig []byte,
var script []byte var script []byte
if pInput.RedeemScript != nil { if pInput.RedeemScript != nil {
scriptHash := btcutil.Hash160(pInput.RedeemScript) scriptHash := lbcutil.Hash160(pInput.RedeemScript)
scriptHashScript, err := txscript.NewScriptBuilder(). scriptHashScript, err := txscript.NewScriptBuilder().
AddOp(txscript.OP_HASH160). AddOp(txscript.OP_HASH160).
AddData(scriptHash). AddData(scriptHash).
@ -195,7 +195,7 @@ func (p *Updater) addPartialSignature(inIndex int, sig []byte,
} }
} else { } else {
// Otherwise, this is a p2wkh input. // Otherwise, this is a p2wkh input.
pubkeyHash := btcutil.Hash160(pubkey) pubkeyHash := lbcutil.Hash160(pubkey)
pubkeyHashScript, err := txscript.NewScriptBuilder(). pubkeyHashScript, err := txscript.NewScriptBuilder().
AddOp(txscript.OP_0). AddOp(txscript.OP_0).
AddData(pubkeyHash). AddData(pubkeyHash).

View file

@ -12,8 +12,8 @@ import (
"io" "io"
"sort" "sort"
"github.com/btcsuite/btcd/txscript" "github.com/lbryio/lbcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// WriteTxWitness is a utility function due to non-exported witness // WriteTxWitness is a utility function due to non-exported witness

View file

@ -5,8 +5,8 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
func TestSumUtxoInputValues(t *testing.T) { func TestSumUtxoInputValues(t *testing.T) {

View file

@ -1,72 +0,0 @@
github.com/conformal/btcutil/base58.go Base58Decode 100.00% (20/20)
github.com/conformal/btcutil/base58.go Base58Encode 100.00% (15/15)
github.com/conformal/btcutil/block.go Block.Tx 100.00% (12/12)
github.com/conformal/btcutil/wif.go WIF.String 100.00% (11/11)
github.com/conformal/btcutil/block.go Block.Transactions 100.00% (11/11)
github.com/conformal/btcutil/amount.go AmountUnit.String 100.00% (8/8)
github.com/conformal/btcutil/tx.go NewTxFromReader 100.00% (6/6)
github.com/conformal/btcutil/block.go NewBlockFromBytes 100.00% (6/6)
github.com/conformal/btcutil/block.go NewBlockFromReader 100.00% (6/6)
github.com/conformal/btcutil/address.go encodeAddress 100.00% (6/6)
github.com/conformal/btcutil/address.go newAddressPubKeyHash 100.00% (5/5)
github.com/conformal/btcutil/address.go newAddressScriptHashFromHash 100.00% (5/5)
github.com/conformal/btcutil/tx.go Tx.Sha 100.00% (5/5)
github.com/conformal/btcutil/block.go Block.Sha 100.00% (5/5)
github.com/conformal/btcutil/amount.go NewAmount 100.00% (5/5)
github.com/conformal/btcutil/amount.go round 100.00% (3/3)
github.com/conformal/btcutil/address.go NewAddressScriptHash 100.00% (2/2)
github.com/conformal/btcutil/amount.go Amount.Format 100.00% (2/2)
github.com/conformal/btcutil/tx.go NewTxFromBytes 100.00% (2/2)
github.com/conformal/btcutil/hash160.go calcHash 100.00% (2/2)
github.com/conformal/btcutil/address.go AddressPubKeyHash.Hash160 100.00% (1/1)
github.com/conformal/btcutil/block.go OutOfRangeError.Error 100.00% (1/1)
github.com/conformal/btcutil/block.go Block.MsgBlock 100.00% (1/1)
github.com/conformal/btcutil/tx.go Tx.MsgTx 100.00% (1/1)
github.com/conformal/btcutil/hash160.go Hash160 100.00% (1/1)
github.com/conformal/btcutil/block.go NewBlockFromBlockAndBytes 100.00% (1/1)
github.com/conformal/btcutil/block.go Block.Height 100.00% (1/1)
github.com/conformal/btcutil/block.go Block.SetHeight 100.00% (1/1)
github.com/conformal/btcutil/block.go NewBlock 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKeyHash.IsForNet 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKey.EncodeAddress 100.00% (1/1)
github.com/conformal/btcutil/address.go NewAddressPubKeyHash 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKeyHash.EncodeAddress 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKeyHash.ScriptAddress 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKeyHash.String 100.00% (1/1)
github.com/conformal/btcutil/address.go NewAddressScriptHashFromHash 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressScriptHash.EncodeAddress 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressScriptHash.ScriptAddress 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressScriptHash.IsForNet 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressScriptHash.String 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressScriptHash.Hash160 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKey.ScriptAddress 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKey.IsForNet 100.00% (1/1)
github.com/conformal/btcutil/address.go AddressPubKey.String 100.00% (1/1)
github.com/conformal/btcutil/tx.go NewTx 100.00% (1/1)
github.com/conformal/btcutil/tx.go Tx.SetIndex 100.00% (1/1)
github.com/conformal/btcutil/amount.go Amount.ToUnit 100.00% (1/1)
github.com/conformal/btcutil/tx.go Tx.Index 100.00% (1/1)
github.com/conformal/btcutil/amount.go Amount.String 100.00% (1/1)
github.com/conformal/btcutil/amount.go Amount.MulF64 100.00% (1/1)
github.com/conformal/btcutil/appdata.go appDataDir 92.00% (23/25)
github.com/conformal/btcutil/block.go Block.TxLoc 88.89% (8/9)
github.com/conformal/btcutil/block.go Block.Bytes 88.89% (8/9)
github.com/conformal/btcutil/address.go NewAddressPubKey 87.50% (7/8)
github.com/conformal/btcutil/address.go DecodeAddress 85.00% (17/20)
github.com/conformal/btcutil/wif.go DecodeWIF 85.00% (17/20)
github.com/conformal/btcutil/address.go AddressPubKey.serialize 80.00% (4/5)
github.com/conformal/btcutil/block.go Block.TxSha 75.00% (3/4)
github.com/conformal/btcutil/wif.go paddedAppend 66.67% (2/3)
github.com/conformal/btcutil/wif.go NewWIF 66.67% (2/3)
github.com/conformal/btcutil/certgen.go NewTLSCertPair 0.00% (0/54)
github.com/conformal/btcutil/wif.go WIF.SerializePubKey 0.00% (0/4)
github.com/conformal/btcutil/address.go AddressPubKey.AddressPubKeyHash 0.00% (0/3)
github.com/conformal/btcutil/address.go AddressPubKey.Format 0.00% (0/1)
github.com/conformal/btcutil/address.go AddressPubKey.PubKey 0.00% (0/1)
github.com/conformal/btcutil/address.go AddressPubKey.SetFormat 0.00% (0/1)
github.com/conformal/btcutil/wif.go WIF.IsForNet 0.00% (0/1)
github.com/conformal/btcutil/appdata.go AppDataDir 0.00% (0/1)
github.com/conformal/btcutil/net.go interfaceAddrs 0.00% (0/1)
github.com/conformal/btcutil ------------------------------- 75.88% (258/340)

6
tx.go
View file

@ -2,14 +2,14 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"bytes" "bytes"
"io" "io"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// TxIndexUnknown is the value returned for a transaction index that is unknown. // TxIndexUnknown is the value returned for a transaction index that is unknown.

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"bytes" "bytes"
@ -10,15 +10,15 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/lbryio/lbcutil"
) )
// TestTx tests the API for Tx. // TestTx tests the API for Tx.
func TestTx(t *testing.T) { func TestTx(t *testing.T) {
testTx := Block100000.Transactions[0] testTx := Block100000.Transactions[0]
tx := btcutil.NewTx(testTx) tx := lbcutil.NewTx(testTx)
// Ensure we get the same data back out. // Ensure we get the same data back out.
if msgTx := tx.MsgTx(); !reflect.DeepEqual(msgTx, testTx) { if msgTx := tx.MsgTx(); !reflect.DeepEqual(msgTx, testTx) {
@ -63,7 +63,7 @@ func TestNewTxFromBytes(t *testing.T) {
testTxBytes := testTxBuf.Bytes() testTxBytes := testTxBuf.Bytes()
// Create a new transaction from the serialized bytes. // Create a new transaction from the serialized bytes.
tx, err := btcutil.NewTxFromBytes(testTxBytes) tx, err := lbcutil.NewTxFromBytes(testTxBytes)
if err != nil { if err != nil {
t.Errorf("NewTxFromBytes: %v", err) t.Errorf("NewTxFromBytes: %v", err)
return return
@ -89,7 +89,7 @@ func TestTxErrors(t *testing.T) {
// Truncate the transaction byte buffer to force errors. // Truncate the transaction byte buffer to force errors.
shortBytes := testTxBytes[:4] shortBytes := testTxBytes[:4]
_, err = btcutil.NewTxFromBytes(shortBytes) _, err = lbcutil.NewTxFromBytes(shortBytes)
if err != io.EOF { if err != io.EOF {
t.Errorf("NewTxFromBytes: did not get expected error - "+ t.Errorf("NewTxFromBytes: did not get expected error - "+
"got %v, want %v", err, io.EOF) "got %v, want %v", err, io.EOF)
@ -99,7 +99,7 @@ func TestTxErrors(t *testing.T) {
// TestTxHasWitness tests the HasWitness() method. // TestTxHasWitness tests the HasWitness() method.
func TestTxHasWitness(t *testing.T) { func TestTxHasWitness(t *testing.T) {
msgTx := Block100000.Transactions[0] // contains witness data msgTx := Block100000.Transactions[0] // contains witness data
tx := btcutil.NewTx(msgTx) tx := lbcutil.NewTx(msgTx)
tx.WitnessHash() // Populate the witness hash cache tx.WitnessHash() // Populate the witness hash cache
tx.HasWitness() // Should not fail (see btcsuite/btcd#1543) tx.HasWitness() // Should not fail (see btcsuite/btcd#1543)
@ -109,7 +109,7 @@ func TestTxHasWitness(t *testing.T) {
} }
for _, msgTxWithoutWitness := range Block100000.Transactions[1:] { for _, msgTxWithoutWitness := range Block100000.Transactions[1:] {
txWithoutWitness := btcutil.NewTx(msgTxWithoutWitness) txWithoutWitness := lbcutil.NewTx(msgTxWithoutWitness)
if txWithoutWitness.HasWitness() { if txWithoutWitness.HasWitness() {
t.Errorf("HasWitness: got false, want true") t.Errorf("HasWitness: got false, want true")
} }
@ -119,7 +119,7 @@ func TestTxHasWitness(t *testing.T) {
// TestTxWitnessHash tests the WitnessHash() method. // TestTxWitnessHash tests the WitnessHash() method.
func TestTxWitnessHash(t *testing.T) { func TestTxWitnessHash(t *testing.T) {
msgTx := Block100000.Transactions[0] // contains witness data msgTx := Block100000.Transactions[0] // contains witness data
tx := btcutil.NewTx(msgTx) tx := lbcutil.NewTx(msgTx)
if tx.WitnessHash().IsEqual(tx.Hash()) { if tx.WitnessHash().IsEqual(tx.Hash()) {
t.Errorf("WitnessHash: witness hash and tx id must NOT be same - "+ t.Errorf("WitnessHash: witness hash and tx id must NOT be same - "+
@ -127,7 +127,7 @@ func TestTxWitnessHash(t *testing.T) {
} }
for _, msgTxWithoutWitness := range Block100000.Transactions[1:] { for _, msgTxWithoutWitness := range Block100000.Transactions[1:] {
txWithoutWitness := btcutil.NewTx(msgTxWithoutWitness) txWithoutWitness := lbcutil.NewTx(msgTxWithoutWitness)
if !txWithoutWitness.WitnessHash().IsEqual(txWithoutWitness.Hash()) { if !txWithoutWitness.WitnessHash().IsEqual(txWithoutWitness.Hash()) {
t.Errorf("WitnessHash: witness hash and tx id must be same - "+ t.Errorf("WitnessHash: witness hash and tx id must be same - "+
"got %v, want %v", txWithoutWitness.WitnessHash(), txWithoutWitness.Hash()) "got %v, want %v", txWithoutWitness.WitnessHash(), txWithoutWitness.Hash())

View file

@ -1,9 +1,7 @@
txsort txsort
====== ======
[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcutil/txsort)
Package txsort provides the transaction sorting according to [BIP 69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki). Package txsort provides the transaction sorting according to [BIP 69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki).
@ -18,14 +16,3 @@ sorting on the amount and then on the raw public key script bytes as a tie
breaker. breaker.
A comprehensive suite of tests is provided to ensure proper functionality. A comprehensive suite of tests is provided to ensure proper functionality.
## Installation and Updating
```bash
$ go get -u github.com/btcsuite/btcutil/txsort
```
## License
Package txsort is licensed under the [copyfree](http://copyfree.org) ISC
License.

View file

@ -11,8 +11,8 @@ import (
"bytes" "bytes"
"sort" "sort"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
) )
// InPlaceSort modifies the passed transaction inputs and outputs to be sorted // InPlaceSort modifies the passed transaction inputs and outputs to be sorted
@ -21,7 +21,7 @@ import (
// WARNING: This function must NOT be called with published transactions since // WARNING: This function must NOT be called with published transactions since
// it will mutate the transaction if it's not already sorted. This can cause // it will mutate the transaction if it's not already sorted. This can cause
// issues if you mutate a tx in a block, for example, which would invalidate the // issues if you mutate a tx in a block, for example, which would invalidate the
// block. It could also cause cached hashes, such as in a btcutil.Tx to become // block. It could also cause cached hashes, such as in a lbcutil.Tx to become
// invalidated. // invalidated.
// //
// The function should only be used if the caller is creating the transaction or // The function should only be used if the caller is creating the transaction or

View file

@ -11,8 +11,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/btcsuite/btcd/wire" "github.com/lbryio/lbcd/wire"
"github.com/btcsuite/btcutil/txsort" "github.com/lbryio/lbcutil/txsort"
) )
// TestSort ensures the transaction sorting works according to the BIP. // TestSort ensures the transaction sorting works according to the BIP.

10
wif.go
View file

@ -2,16 +2,16 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil package lbcutil
import ( import (
"bytes" "bytes"
"errors" "errors"
"github.com/btcsuite/btcd/btcec" "github.com/lbryio/lbcd/btcec"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/lbryio/lbcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil/base58" "github.com/lbryio/lbcutil/base58"
) )
// ErrMalformedPrivateKey describes an error where a WIF-encoded private // ErrMalformedPrivateKey describes an error where a WIF-encoded private

View file

@ -2,16 +2,16 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcutil_test package lbcutil_test
import ( import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/lbryio/lbcd/btcec"
"github.com/btcsuite/btcd/chaincfg" "github.com/lbryio/lbcd/chaincfg"
. "github.com/btcsuite/btcutil" . "github.com/lbryio/lbcutil"
) )
func TestEncodeDecodeWIF(t *testing.T) { func TestEncodeDecodeWIF(t *testing.T) {
@ -64,6 +64,8 @@ func TestEncodeDecodeWIF(t *testing.T) {
} }
for _, validCase := range validEncodeCases { for _, validCase := range validEncodeCases {
validCase := validCase
t.Run(validCase.name, func(t *testing.T) { t.Run(validCase.name, func(t *testing.T) {
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), validCase.privateKey) priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), validCase.privateKey)
wif, err := NewWIF(priv, validCase.net, validCase.compress) wif, err := NewWIF(priv, validCase.net, validCase.compress)
@ -122,6 +124,8 @@ func TestEncodeDecodeWIF(t *testing.T) {
} }
for _, invalidCase := range invalidDecodeCases { for _, invalidCase := range invalidDecodeCases {
invalidCase := invalidCase
t.Run(invalidCase.name, func(t *testing.T) { t.Run(invalidCase.name, func(t *testing.T) {
decodedWif, err := DecodeWIF(invalidCase.wif) decodedWif, err := DecodeWIF(invalidCase.wif)
if decodedWif != nil { if decodedWif != nil {