[lbry] renamed package to lbcutil, updated refs to it
This commit is contained in:
parent
0ef993d30c
commit
bea5c62644
73 changed files with 456 additions and 586 deletions
44
README.md
44
README.md
|
@ -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.
|
|
10
address.go
10
address.go
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
226
address_test.go
226
address_test.go
|
@ -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,18 +640,18 @@ 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,
|
||||||
},
|
},
|
||||||
|
@ -662,7 +662,7 @@ func TestAddresses(t *testing.T) {
|
||||||
addr: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c",
|
addr: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c",
|
||||||
encoded: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c",
|
encoded: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c",
|
||||||
valid: true,
|
valid: true,
|
||||||
result: btcutil.TstAddressTaproot(
|
result: lbcutil.TstAddressTaproot(
|
||||||
1, [32]byte{
|
1, [32]byte{
|
||||||
0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33,
|
0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33,
|
||||||
0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9,
|
0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9,
|
||||||
|
@ -670,14 +670,14 @@ func TestAddresses(t *testing.T) {
|
||||||
0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6,
|
0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6,
|
||||||
}, chaincfg.MainNetParams.Bech32HRPSegwit,
|
}, chaincfg.MainNetParams.Bech32HRPSegwit,
|
||||||
),
|
),
|
||||||
f: func() (btcutil.Address, error) {
|
f: func() (lbcutil.Address, error) {
|
||||||
scriptHash := []byte{
|
scriptHash := []byte{
|
||||||
0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33,
|
0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33,
|
||||||
0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9,
|
0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9,
|
||||||
0x7c, 0x26, 0x70, 0xda, 0xa9, 0x1e, 0x9f, 0x3a,
|
0x7c, 0x26, 0x70, 0xda, 0xa9, 0x1e, 0x9f, 0x3a,
|
||||||
0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6,
|
0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6,
|
||||||
}
|
}
|
||||||
return btcutil.NewAddressTaproot(
|
return lbcutil.NewAddressTaproot(
|
||||||
scriptHash, &chaincfg.MainNetParams,
|
scriptHash, &chaincfg.MainNetParams,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -847,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
|
||||||
|
@ -884,22 +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 *btcutil.AddressTaproot:
|
case *lbcutil.AddressTaproot:
|
||||||
saddr = btcutil.TstAddressTaprootSAddr(encoded)
|
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
|
||||||
|
@ -910,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)
|
||||||
|
@ -944,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)
|
||||||
|
|
18
amount.go
18
amount.go
|
@ -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.
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -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: 21,
|
||||||
s: "21 MBTC",
|
s: "21 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",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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.
|
|
|
@ -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 {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil/base58"
|
"github.com/lbryio/lbcutil/base58"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
12
block.go
12
block.go
|
@ -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
|
||||||
|
|
|
@ -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/lbryio/lbcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/lbryio/lbcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/lbryio/lbcutil"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
@ -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.
|
|
|
@ -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
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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
|
||||||
|
@ -585,7 +585,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||||
t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err)
|
t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
block, err := btcutil.NewBlockFromBytes(blockBytes)
|
block, err := lbcutil.NewBlockFromBytes(blockBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("TestFilterInsertP2PubKeyOnly NewBlockFromBytes failed: %v", err)
|
t.Errorf("TestFilterInsertP2PubKeyOnly NewBlockFromBytes failed: %v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -63,9 +55,4 @@ 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.
|
|
|
@ -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.
|
||||||
|
|
|
@ -11,27 +11,27 @@ 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))
|
||||||
|
@ -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,
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
2
const.go
2
const.go
|
@ -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.
|
||||||
|
|
6
doc.go
6
doc.go
|
@ -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
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
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 BTC
|
||||||
|
@ -24,28 +24,28 @@ func ExampleAmount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
@ -59,13 +59,13 @@ func ExampleNewAmount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 kBTC:", amount.Format(lbcutil.AmountKiloBTC))
|
||||||
fmt.Println("Satoshi to BTC:", amount)
|
fmt.Println("Satoshi to BTC:", amount)
|
||||||
fmt.Println("Satoshi to MilliBTC:", amount.Format(btcutil.AmountMilliBTC))
|
fmt.Println("Satoshi to MilliBTC:", amount.Format(lbcutil.AmountMilliBTC))
|
||||||
fmt.Println("Satoshi to MicroBTC:", amount.Format(btcutil.AmountMicroBTC))
|
fmt.Println("Satoshi to MicroBTC:", 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 kBTC: 444.333222111 kBTC
|
||||||
|
|
|
@ -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.
|
|
|
@ -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 (
|
||||||
|
|
|
@ -9,13 +9,13 @@ 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 (
|
||||||
|
@ -76,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())
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/aead/siphash"
|
"github.com/aead/siphash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/lbryio/lbcd/wire"
|
||||||
"github.com/kkdai/bstream"
|
"github.com/kkdai/bstream"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil/gcs"
|
"github.com/lbryio/lbcutil/gcs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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.
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 (
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
@ -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() {
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
2
net.go
2
net.go
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// +build !appengine
|
// +build !appengine
|
||||||
|
|
||||||
package btcutil
|
package lbcutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// +build appengine
|
// +build appengine
|
||||||
|
|
||||||
package btcutil
|
package lbcutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module github.com/btcsuite/btcutil/psbt
|
module github.com/lbryio/lbcutil/psbt
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btcd v0.20.1-beta
|
github.com/lbryio/lbcd v0.20.1-beta
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
|
github.com/lbryio/lbcutil v0.0.0-20190425235716-9e5f4b9a998d
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
)
|
)
|
||||||
|
|
12
psbt/go.sum
12
psbt/go.sum
|
@ -1,13 +1,13 @@
|
||||||
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/lbryio/lbcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
|
||||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
github.com/lbryio/lbcd 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 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 h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
|
github.com/lbryio/lbcutil 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/lbryio/lbcutil 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/lbryio/lbcutil 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/lbryio/lbcutil 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 h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
|
||||||
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 h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE=
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
1
psbt/profile.cov
Normal file
1
psbt/profile.cov
Normal file
|
@ -0,0 +1 @@
|
||||||
|
mode: atomic
|
|
@ -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
|
||||||
|
|
|
@ -11,10 +11,10 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -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{{}},
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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).
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
6
tx.go
6
tx.go
|
@ -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.
|
||||||
|
|
20
tx_test.go
20
tx_test.go
|
@ -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/lbryio/lbcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/lbryio/lbcutil"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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())
|
||||||
|
|
|
@ -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).
|
||||||
|
|
||||||
|
@ -17,15 +15,4 @@ then on the index as a tie breaker. The order for outputs is defined as first
|
||||||
sorting on the amount and then on the raw public key script bytes as a tie
|
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.
|
|
|
@ -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
|
||||||
|
|
|
@ -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
10
wif.go
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue