diff --git a/README.md b/README.md index fffb0f7..b1956b9 100644 --- a/README.md +++ b/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) -[![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 bitcoin which is under active development by Conformal. Although it was 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 -provided. - -## 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. +provided. It has been modified to support lbcd. \ No newline at end of file diff --git a/address.go b/address.go index 8eaf2db..996d84a 100644 --- a/address.go +++ b/address.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "bytes" @@ -11,10 +11,10 @@ import ( "fmt" "strings" - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcutil/base58" - "github.com/btcsuite/btcutil/bech32" + "github.com/lbryio/lbcd/btcec" + "github.com/lbryio/lbcd/chaincfg" + "github.com/lbryio/lbcutil/base58" + "github.com/lbryio/lbcutil/bech32" "golang.org/x/crypto/ripemd160" ) diff --git a/address_test.go b/address_test.go index 754fec8..e496454 100644 --- a/address_test.go +++ b/address_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "bytes" @@ -12,9 +12,9 @@ import ( "strings" "testing" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/chaincfg" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" "golang.org/x/crypto/ripemd160" ) @@ -50,8 +50,8 @@ func TestAddresses(t *testing.T) { addr string encoded string valid bool - result btcutil.Address - f func() (btcutil.Address, error) + result lbcutil.Address + f func() (lbcutil.Address, error) net *chaincfg.Params }{ // Positive P2PKH tests. @@ -60,16 +60,16 @@ func TestAddresses(t *testing.T) { addr: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", encoded: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: lbcutil.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84}, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 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, }, @@ -78,16 +78,16 @@ func TestAddresses(t *testing.T) { addr: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG", encoded: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: lbcutil.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa}, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 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, }, @@ -96,16 +96,16 @@ func TestAddresses(t *testing.T) { addr: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1", encoded: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: lbcutil.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c, 0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1}, CustomParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c, 0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1} - return btcutil.NewAddressPubKeyHash(pkHash, &customParams) + return lbcutil.NewAddressPubKeyHash(pkHash, &customParams) }, net: &customParams, }, @@ -114,16 +114,16 @@ func TestAddresses(t *testing.T) { addr: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz", encoded: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: lbcutil.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83, 0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f}, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83, 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, }, @@ -133,12 +133,12 @@ func TestAddresses(t *testing.T) { name: "p2pkh wrong hash length", addr: "", valid: false, - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x00, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 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, }, @@ -158,12 +158,12 @@ func TestAddresses(t *testing.T) { addr: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC", encoded: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC", valid: true, - result: btcutil.TstAddressScriptHash( + result: lbcutil.TstAddressScriptHash( [ripemd160.Size]byte{ 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10}, chaincfg.MainNetParams.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { script := []byte{ 0x52, 0x41, 0x04, 0x91, 0xbb, 0xa2, 0x51, 0x09, 0x12, 0xa5, 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, 0xc4, 0x1f, 0x32, 0x2a, 0x18, 0x63, 0xd4, 0x62, 0x13, 0x53, 0xae} - return btcutil.NewAddressScriptHash(script, &chaincfg.MainNetParams) + return lbcutil.NewAddressScriptHash(script, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -195,16 +195,16 @@ func TestAddresses(t *testing.T) { addr: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9", encoded: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9", valid: true, - result: btcutil.TstAddressScriptHash( + result: lbcutil.TstAddressScriptHash( [ripemd160.Size]byte{ 0xee, 0x34, 0xac, 0x67, 0x6b, 0xda, 0xf6, 0xe3, 0x70, 0xc8, 0xc8, 0x20, 0xb9, 0x48, 0xed, 0xfa, 0xd3, 0xa8, 0x73, 0xd8}, CustomParams.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0xEE, 0x34, 0xAC, 0x67, 0x6B, 0xDA, 0xF6, 0xE3, 0x70, 0xC8, 0xC8, 0x20, 0xB9, 0x48, 0xED, 0xFA, 0xD3, 0xA8, 0x73, 0xD8} - return btcutil.NewAddressScriptHashFromHash(pkHash, &customParams) + return lbcutil.NewAddressScriptHashFromHash(pkHash, &customParams) }, net: &customParams, }, @@ -216,16 +216,16 @@ func TestAddresses(t *testing.T) { addr: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8", encoded: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8", valid: true, - result: btcutil.TstAddressScriptHash( + result: lbcutil.TstAddressScriptHash( [ripemd160.Size]byte{ 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4}, chaincfg.MainNetParams.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { hash := []byte{ 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 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, }, @@ -235,16 +235,16 @@ func TestAddresses(t *testing.T) { addr: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", encoded: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", valid: true, - result: btcutil.TstAddressScriptHash( + result: lbcutil.TstAddressScriptHash( [ripemd160.Size]byte{ 0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e, 0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a}, chaincfg.TestNet3Params.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { hash := []byte{ 0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e, 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, }, @@ -254,12 +254,12 @@ func TestAddresses(t *testing.T) { name: "p2sh wrong hash length", addr: "", valid: false, - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { hash := []byte{ 0x00, 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10} - return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) + return lbcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -270,20 +270,20 @@ func TestAddresses(t *testing.T) { addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4", encoded: "13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4}, - btcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -292,20 +292,20 @@ func TestAddresses(t *testing.T) { addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65", encoded: "15sHANNUBSh6nDp8XkDPmQcW6n3EFwmvE6", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65}, - btcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -315,7 +315,7 @@ func TestAddresses(t *testing.T) { "e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", encoded: "12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 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, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3}, - btcutil.PKFUncompressed, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFUncompressed, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 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, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -344,7 +344,7 @@ func TestAddresses(t *testing.T) { "0d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e", encoded: "1Ja5rs7XBZnK88EuLVcFqYGMEbBitzchmX", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 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, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x44, 0xd3, 0x3f, 0x45, 0x3e}, - btcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 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, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x44, 0xd3, 0x3f, 0x45, 0x3e} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -373,7 +373,7 @@ func TestAddresses(t *testing.T) { "37a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b", encoded: "1ExqMmf6yMxcBMzHjbj41wbqYuqoX6uBLG", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 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, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x1e, 0x09, 0x08, 0xef, 0x7b}, - btcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 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, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x1e, 0x09, 0x08, 0xef, 0x7b} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -401,20 +401,20 @@ func TestAddresses(t *testing.T) { addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4", encoded: "mhiDPVP2nJunaAgTjzWSHCYfAqxxrxzjmo", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4}, - btcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -423,20 +423,20 @@ func TestAddresses(t *testing.T) { addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65", encoded: "mkPETRTSzU8MZLHkFKBmbKppxmdw9qT42t", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65}, - btcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -446,7 +446,7 @@ func TestAddresses(t *testing.T) { "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", encoded: "mh8YhPYEAYs3E7EVyKtB5xrcfMExkkdEMF", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 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, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3}, - btcutil.PKFUncompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFUncompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 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, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -475,7 +475,7 @@ func TestAddresses(t *testing.T) { "40d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e", encoded: "my639vCVzbDZuEiX44adfTUg6anRomZLEP", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 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, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x44, 0xd3, 0x3f, 0x45, 0x3e}, - btcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 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, 0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c, 0x44, 0xd3, 0x3f, 0x45, 0x3e} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -504,7 +504,7 @@ func TestAddresses(t *testing.T) { "537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b", encoded: "muUnepk5nPPrxUTuTAhRqrpAQuSWS5fVii", valid: true, - result: btcutil.TstAddressPubKey( + result: lbcutil.TstAddressPubKey( []byte{ 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 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, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x1e, 0x09, 0x08, 0xef, 0x7b}, - btcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + lbcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (lbcutil.Address, error) { serializedPubKey := []byte{ 0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 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, 0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c, 0x1e, 0x09, 0x08, 0xef, 0x7b} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return lbcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -533,17 +533,17 @@ func TestAddresses(t *testing.T) { addr: "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4", encoded: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", valid: true, - result: btcutil.TstAddressWitnessPubKeyHash( + result: lbcutil.TstAddressWitnessPubKeyHash( 0, [20]byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, chaincfg.MainNetParams.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 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, }, @@ -552,7 +552,7 @@ func TestAddresses(t *testing.T) { addr: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", encoded: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", valid: true, - result: btcutil.TstAddressWitnessScriptHash( + result: lbcutil.TstAddressWitnessScriptHash( 0, [32]byte{ 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, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}, chaincfg.MainNetParams.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { scriptHash := []byte{ 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62} - return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.MainNetParams) + return lbcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -575,17 +575,17 @@ func TestAddresses(t *testing.T) { addr: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", encoded: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", valid: true, - result: btcutil.TstAddressWitnessPubKeyHash( + result: lbcutil.TstAddressWitnessPubKeyHash( 0, [20]byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, chaincfg.TestNet3Params.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 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, }, @@ -594,7 +594,7 @@ func TestAddresses(t *testing.T) { addr: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", encoded: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", valid: true, - result: btcutil.TstAddressWitnessScriptHash( + result: lbcutil.TstAddressWitnessScriptHash( 0, [32]byte{ 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, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}, chaincfg.TestNet3Params.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { scriptHash := []byte{ 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62} - return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) + return lbcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -617,7 +617,7 @@ func TestAddresses(t *testing.T) { addr: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", encoded: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", valid: true, - result: btcutil.TstAddressWitnessScriptHash( + result: lbcutil.TstAddressWitnessScriptHash( 0, [32]byte{ 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, 0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33}, chaincfg.TestNet3Params.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { scriptHash := []byte{ 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x21, 0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66, 0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2, 0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33} - return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) + return lbcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -640,18 +640,18 @@ func TestAddresses(t *testing.T) { addr: "LTC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KGMN4N9", encoded: "ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9", valid: true, - result: btcutil.TstAddressWitnessPubKeyHash( + result: lbcutil.TstAddressWitnessPubKeyHash( 0, [20]byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, CustomParams.Bech32HRPSegwit, ), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { pkHash := []byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} - return btcutil.NewAddressWitnessPubKeyHash(pkHash, &customParams) + return lbcutil.NewAddressWitnessPubKeyHash(pkHash, &customParams) }, net: &customParams, }, @@ -662,7 +662,7 @@ func TestAddresses(t *testing.T) { addr: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c", encoded: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c", valid: true, - result: btcutil.TstAddressTaproot( + result: lbcutil.TstAddressTaproot( 1, [32]byte{ 0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33, 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, }, chaincfg.MainNetParams.Bech32HRPSegwit, ), - f: func() (btcutil.Address, error) { + f: func() (lbcutil.Address, error) { scriptHash := []byte{ 0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33, 0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9, 0x7c, 0x26, 0x70, 0xda, 0xa9, 0x1e, 0x9f, 0x3a, 0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6, } - return btcutil.NewAddressTaproot( + return lbcutil.NewAddressTaproot( scriptHash, &chaincfg.MainNetParams, ) }, @@ -847,7 +847,7 @@ func TestAddresses(t *testing.T) { for _, test := range tests { // 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 { t.Errorf("%v: decoding test failed: %v", test.name, err) return @@ -884,22 +884,22 @@ func TestAddresses(t *testing.T) { // Perform type-specific calculations. var saddr []byte switch d := decoded.(type) { - case *btcutil.AddressPubKeyHash: - saddr = btcutil.TstAddressSAddr(encoded) + case *lbcutil.AddressPubKeyHash: + saddr = lbcutil.TstAddressSAddr(encoded) - case *btcutil.AddressScriptHash: - saddr = btcutil.TstAddressSAddr(encoded) + case *lbcutil.AddressScriptHash: + saddr = lbcutil.TstAddressSAddr(encoded) - case *btcutil.AddressPubKey: + case *lbcutil.AddressPubKey: // Ignore the error here since the script // address is checked below. saddr, _ = hex.DecodeString(d.String()) - case *btcutil.AddressWitnessPubKeyHash: - saddr = btcutil.TstAddressSegwitSAddr(encoded) - case *btcutil.AddressWitnessScriptHash: - saddr = btcutil.TstAddressSegwitSAddr(encoded) - case *btcutil.AddressTaproot: - saddr = btcutil.TstAddressTaprootSAddr(encoded) + case *lbcutil.AddressWitnessPubKeyHash: + saddr = lbcutil.TstAddressSegwitSAddr(encoded) + case *lbcutil.AddressWitnessScriptHash: + saddr = lbcutil.TstAddressSegwitSAddr(encoded) + case *lbcutil.AddressTaproot: + saddr = lbcutil.TstAddressTaprootSAddr(encoded) } // Check script address, as well as the Hash160 method for P2PKH and @@ -910,28 +910,28 @@ func TestAddresses(t *testing.T) { return } switch a := decoded.(type) { - case *btcutil.AddressPubKeyHash: + case *lbcutil.AddressPubKeyHash: if h := a.Hash160()[:]; !bytes.Equal(saddr, h) { t.Errorf("%v: hashes do not match:\n%x != \n%x", test.name, saddr, h) return } - case *btcutil.AddressScriptHash: + case *lbcutil.AddressScriptHash: if h := a.Hash160()[:]; !bytes.Equal(saddr, h) { t.Errorf("%v: hashes do not match:\n%x != \n%x", test.name, saddr, h) return } - case *btcutil.AddressWitnessPubKeyHash: + case *lbcutil.AddressWitnessPubKeyHash: if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp { t.Errorf("%v: hrps do not match:\n%x != \n%x", test.name, test.net.Bech32HRPSegwit, hrp) return } - expVer := test.result.(*btcutil.AddressWitnessPubKeyHash).WitnessVersion() + expVer := test.result.(*lbcutil.AddressWitnessPubKeyHash).WitnessVersion() if v := a.WitnessVersion(); v != expVer { t.Errorf("%v: witness versions do not match:\n%x != \n%x", test.name, expVer, v) @@ -944,14 +944,14 @@ func TestAddresses(t *testing.T) { return } - case *btcutil.AddressWitnessScriptHash: + case *lbcutil.AddressWitnessScriptHash: if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp { t.Errorf("%v: hrps do not match:\n%x != \n%x", test.name, test.net.Bech32HRPSegwit, hrp) return } - expVer := test.result.(*btcutil.AddressWitnessScriptHash).WitnessVersion() + expVer := test.result.(*lbcutil.AddressWitnessScriptHash).WitnessVersion() if v := a.WitnessVersion(); v != expVer { t.Errorf("%v: witness versions do not match:\n%x != \n%x", test.name, expVer, v) diff --git a/amount.go b/amount.go index e2f057e..bd6c92e 100644 --- a/amount.go +++ b/amount.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "errors" @@ -29,23 +29,23 @@ const ( // String returns the unit as a string. For recognized units, the SI // 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 { switch u { case AmountMegaBTC: - return "MBTC" + return "MLBC" case AmountKiloBTC: - return "kBTC" + return "kLBC" case AmountBTC: - return "BTC" + return "LBC" case AmountMilliBTC: - return "mBTC" + return "mLBC" case AmountMicroBTC: - return "μBTC" + return "μLBC" case AmountSatoshi: return "Satoshi" 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. // 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. -// 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) { // The amount is only considered invalid if it cannot be represented // as an integer type. This may happen if f is NaN or +-Infinity. diff --git a/amount_test.go b/amount_test.go index 808ea24..86054b5 100644 --- a/amount_test.go +++ b/amount_test.go @@ -2,13 +2,13 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "math" "testing" - . "github.com/btcsuite/btcutil" + . "github.com/lbryio/lbcutil" ) func TestAmountCreation(t *testing.T) { @@ -119,40 +119,40 @@ func TestAmountUnitConversions(t *testing.T) { s string }{ { - name: "MBTC", + name: "MLBC", amount: MaxSatoshi, unit: AmountMegaBTC, converted: 21, - s: "21 MBTC", + s: "21 MLBC", }, { - name: "kBTC", + name: "kLBC", amount: 44433322211100, unit: AmountKiloBTC, converted: 444.33322211100, - s: "444.333222111 kBTC", + s: "444.333222111 kLBC", }, { - name: "BTC", + name: "LBC", amount: 44433322211100, unit: AmountBTC, converted: 444333.22211100, - s: "444333.222111 BTC", + s: "444333.222111 LBC", }, { - name: "mBTC", + name: "mLBC", amount: 44433322211100, unit: AmountMilliBTC, converted: 444333222.11100, - s: "444333222.111 mBTC", + s: "444333222.111 mLBC", }, { - name: "μBTC", + name: "μLBC", amount: 44433322211100, unit: AmountMicroBTC, converted: 444333222111.00, - s: "444333222111 μBTC", + s: "444333222111 μLBC", }, { @@ -168,7 +168,7 @@ func TestAmountUnitConversions(t *testing.T) { amount: 44433322211100, unit: AmountUnit(-1), converted: 4443332.2211100, - s: "4443332.22111 1e-1 BTC", + s: "4443332.22111 1e-1 LBC", }, } diff --git a/appdata.go b/appdata.go index e36cf7c..6120482 100644 --- a/appdata.go +++ b/appdata.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "os" diff --git a/appdata_test.go b/appdata_test.go index dff62d4..474f560 100644 --- a/appdata_test.go +++ b/appdata_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "os" @@ -12,7 +12,7 @@ import ( "testing" "unicode" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcutil" ) // 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)) 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 { t.Errorf("appDataDir #%d (%s) does not match - "+ "expected got %s, want %s", i, test.goos, ret, diff --git a/base58/README.md b/base58/README.md index 98dfb1d..63813c5 100644 --- a/base58/README.md +++ b/base58/README.md @@ -1,9 +1,7 @@ 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) -[![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 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. -## Installation and Updating - -```bash -$ go get -u github.com/btcsuite/btcutil/base58 -``` - ## 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. -* [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. -* [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. -* [CheckEncode Example](http://godoc.org/github.com/btcsuite/btcutil/base58#example-CheckEncode) - Demonstrates how to encode data using the Base58Check encoding scheme. - -## License - -Package base58 is licensed under the [copyfree](http://copyfree.org) ISC -License. +* [CheckEncode Example](http://godoc.org/github.com/lbryio/lbcutil/base58#example-CheckEncode) + Demonstrates how to encode data using the Base58Check encoding scheme. \ No newline at end of file diff --git a/base58/base58_test.go b/base58/base58_test.go index c4bba4f..2b1fbff 100644 --- a/base58/base58_test.go +++ b/base58/base58_test.go @@ -9,7 +9,7 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcutil/base58" + "github.com/lbryio/lbcutil/base58" ) var stringTests = []struct { diff --git a/base58/base58bench_test.go b/base58/base58bench_test.go index 04c4a00..838a82d 100644 --- a/base58/base58bench_test.go +++ b/base58/base58bench_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "github.com/btcsuite/btcutil/base58" + "github.com/lbryio/lbcutil/base58" ) var ( diff --git a/base58/base58check_test.go b/base58/base58check_test.go index 20a4177..de764e0 100644 --- a/base58/base58check_test.go +++ b/base58/base58check_test.go @@ -7,7 +7,7 @@ package base58_test import ( "testing" - "github.com/btcsuite/btcutil/base58" + "github.com/lbryio/lbcutil/base58" ) var checkEncodingStringTests = []struct { diff --git a/base58/example_test.go b/base58/example_test.go index 230a784..671597d 100644 --- a/base58/example_test.go +++ b/base58/example_test.go @@ -7,7 +7,7 @@ package base58_test import ( "fmt" - "github.com/btcsuite/btcutil/base58" + "github.com/lbryio/lbcutil/base58" ) // This example demonstrates how to decode modified base58 encoded data. diff --git a/bech32/README.md b/bech32/README.md index e6fa43f..fc909f6 100644 --- a/bech32/README.md +++ b/bech32/README.md @@ -1,29 +1,16 @@ 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) -[![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 [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. -## Installation and Updating - -```bash -$ go get -u github.com/btcsuite/btcutil/bech32 -``` - ## 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. -* [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. - -## License - -Package bech32 is licensed under the [copyfree](http://copyfree.org) ISC -License. diff --git a/bech32/example_test.go b/bech32/example_test.go index 6a1f696..1af4f6a 100644 --- a/bech32/example_test.go +++ b/bech32/example_test.go @@ -8,7 +8,7 @@ import ( "encoding/hex" "fmt" - "github.com/btcsuite/btcutil/bech32" + "github.com/lbryio/lbcutil/bech32" ) // This example demonstrates how to decode a bech32 encoded string. diff --git a/block.go b/block.go index 7d38abc..844d7a4 100644 --- a/block.go +++ b/block.go @@ -2,15 +2,15 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "bytes" "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" ) // OutOfRangeError describes an error due to accessing an element that is out @@ -105,7 +105,7 @@ func (b *Block) Hash() *chainhash.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 // say, the first transaction in the block is txNum 0. This is nearly // 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 } -// 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 (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 { // Return transactions if they have ALL already been generated. This // flag is necessary because the wrapped transactions are lazily diff --git a/block_test.go b/block_test.go index 4ad8f89..5fb615a 100644 --- a/block_test.go +++ b/block_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "bytes" @@ -11,15 +11,15 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" "github.com/davecgh/go-spew/spew" ) // TestBlock tests the API for Block. func TestBlock(t *testing.T) { - b := btcutil.NewBlock(&Block100000) + b := lbcutil.NewBlock(&Block100000) // Ensure we get the same data back out. 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. - b = btcutil.NewBlock(&Block100000) + b = lbcutil.NewBlock(&Block100000) // Request hash for all transactions one at a time via Tx. for i, txHash := range wantTxHashes { @@ -88,7 +88,7 @@ func TestBlock(t *testing.T) { } // 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 // and caching. @@ -175,7 +175,7 @@ func TestNewBlockFromBytes(t *testing.T) { block100000Bytes := block100000Buf.Bytes() // Create a new block from the serialized bytes. - b, err := btcutil.NewBlockFromBytes(block100000Bytes) + b, err := lbcutil.NewBlockFromBytes(block100000Bytes) if err != nil { t.Errorf("NewBlockFromBytes: %v", err) return @@ -212,7 +212,7 @@ func TestNewBlockFromBlockAndBytes(t *testing.T) { block100000Bytes := block100000Buf.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. serializedBytes, err := b.Bytes() @@ -235,7 +235,7 @@ func TestNewBlockFromBlockAndBytes(t *testing.T) { func TestBlockErrors(t *testing.T) { // Ensure out of range errors are as expected. wantErr := "transaction index -1 is out of range - max 3" - testErr := btcutil.OutOfRangeError(wantErr) + testErr := lbcutil.OutOfRangeError(wantErr) if testErr.Error() != wantErr { t.Errorf("OutOfRangeError: wrong error - got %v, want %v", testErr.Error(), wantErr) @@ -250,7 +250,7 @@ func TestBlockErrors(t *testing.T) { block100000Bytes := block100000Buf.Bytes() // Create a new block from the serialized bytes. - b, err := btcutil.NewBlockFromBytes(block100000Bytes) + b, err := lbcutil.NewBlockFromBytes(block100000Bytes) if err != nil { t.Errorf("NewBlockFromBytes: %v", err) return @@ -258,7 +258,7 @@ func TestBlockErrors(t *testing.T) { // Truncate the block byte buffer to force errors. shortBytes := block100000Bytes[:80] - _, err = btcutil.NewBlockFromBytes(shortBytes) + _, err = lbcutil.NewBlockFromBytes(shortBytes) if err != io.EOF { t.Errorf("NewBlockFromBytes: did not get expected error - "+ "got %v, want %v", err, io.EOF) @@ -266,26 +266,26 @@ func TestBlockErrors(t *testing.T) { // Ensure TxHash returns expected error on invalid indices. _, err = b.TxHash(-1) - if _, ok := err.(btcutil.OutOfRangeError); !ok { + if _, ok := err.(lbcutil.OutOfRangeError); !ok { 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)) - if _, ok := err.(btcutil.OutOfRangeError); !ok { + if _, ok := err.(lbcutil.OutOfRangeError); !ok { 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. _, err = b.Tx(-1) - if _, ok := err.(btcutil.OutOfRangeError); !ok { + if _, ok := err.(lbcutil.OutOfRangeError); !ok { 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)) - if _, ok := err.(btcutil.OutOfRangeError); !ok { + if _, ok := err.(lbcutil.OutOfRangeError); !ok { 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. diff --git a/bloom/README.md b/bloom/README.md index a317734..1b10b89 100644 --- a/bloom/README.md +++ b/bloom/README.md @@ -1,9 +1,7 @@ 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) -[![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. @@ -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 report. -## Installation and Updating - -```bash -$ go get -u github.com/btcsuite/btcutil/bloom -``` - ## 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, - and check if the filter matches the transaction. - -## License - -Package bloom is licensed under the [copyfree](http://copyfree.org) ISC -License. + and check if the filter matches the transaction. \ No newline at end of file diff --git a/bloom/example_test.go b/bloom/example_test.go index f45ec2f..9c748ea 100644 --- a/bloom/example_test.go +++ b/bloom/example_test.go @@ -9,9 +9,9 @@ import ( "math/rand" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil/bloom" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil/bloom" ) // This example demonstrates how to create a new bloom filter, add a transaction diff --git a/bloom/filter.go b/bloom/filter.go index b3379ec..1141f10 100644 --- a/bloom/filter.go +++ b/bloom/filter.go @@ -9,10 +9,10 @@ import ( "math" "sync" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" ) // 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. // // 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. // This is useful for finding transactions when they appear in a block. 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. // // 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() match := bf.matchTxAndUpdate(tx) bf.mtx.Unlock() diff --git a/bloom/filter_test.go b/bloom/filter_test.go index 6589d04..f972486 100644 --- a/bloom/filter_test.go +++ b/bloom/filter_test.go @@ -9,10 +9,10 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcutil/bloom" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" + "github.com/lbryio/lbcutil/bloom" ) // TestFilterLarge ensures a maximum sized filter can be created. @@ -214,7 +214,7 @@ func TestFilterInsertWithTweak(t *testing.T) { func TestFilterInsertKey(t *testing.T) { secret := "5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C" - wif, err := btcutil.DecodeWIF(secret) + wif, err := lbcutil.DecodeWIF(secret) if err != nil { t.Errorf("TestFilterInsertKey DecodeWIF failed: %v", err) return @@ -222,7 +222,7 @@ func TestFilterInsertKey(t *testing.T) { f := bloom.NewFilter(2, 0, 0.001, wire.BloomUpdateAll) f.Add(wif.SerializePubKey()) - f.Add(btcutil.Hash160(wif.SerializePubKey())) + f.Add(lbcutil.Hash160(wif.SerializePubKey())) want, err := hex.DecodeString("038fc16b080000000000000001") if err != nil { @@ -258,7 +258,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch DecodeString failure: %v", err) return } - tx, err := btcutil.NewTxFromBytes(strBytes) + tx, err := lbcutil.NewTxFromBytes(strBytes) if err != nil { t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err) return @@ -293,7 +293,7 @@ func TestFilterBloomMatch(t *testing.T) { 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00} - spendingTx, err := btcutil.NewTxFromBytes(spendingTxBytes) + spendingTx, err := lbcutil.NewTxFromBytes(spendingTxBytes) if err != nil { t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err) return @@ -585,7 +585,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) { t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err) return } - block, err := btcutil.NewBlockFromBytes(blockBytes) + block, err := lbcutil.NewBlockFromBytes(blockBytes) if err != nil { t.Errorf("TestFilterInsertP2PubKeyOnly NewBlockFromBytes failed: %v", err) return diff --git a/bloom/merkleblock.go b/bloom/merkleblock.go index b1da716..08e9632 100644 --- a/bloom/merkleblock.go +++ b/bloom/merkleblock.go @@ -5,10 +5,10 @@ package bloom import ( - "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/blockchain" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" ) // 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 // 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())) mBlock := merkleBlock{ numTx: numTx, diff --git a/bloom/merkleblock_test.go b/bloom/merkleblock_test.go index bd4a3dc..c1c6e25 100644 --- a/bloom/merkleblock_test.go +++ b/bloom/merkleblock_test.go @@ -9,10 +9,10 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcutil/bloom" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" + "github.com/lbryio/lbcutil/bloom" ) func TestMerkleBlock3(t *testing.T) { @@ -29,7 +29,7 @@ func TestMerkleBlock3(t *testing.T) { t.Errorf("TestMerkleBlock3 DecodeString failed: %v", err) return } - blk, err := btcutil.NewBlockFromBytes(blockBytes) + blk, err := lbcutil.NewBlockFromBytes(blockBytes) if err != nil { t.Errorf("TestMerkleBlock3 NewBlockFromBytes failed: %v", err) return diff --git a/bloom/murmurhash3_test.go b/bloom/murmurhash3_test.go index a637b24..412f965 100644 --- a/bloom/murmurhash3_test.go +++ b/bloom/murmurhash3_test.go @@ -7,7 +7,7 @@ package bloom_test import ( "testing" - "github.com/btcsuite/btcutil/bloom" + "github.com/lbryio/lbcutil/bloom" ) // TestMurmurHash3 ensure the MurmurHash3 function produces the correct hash diff --git a/bloom/test_coverage.txt b/bloom/test_coverage.txt index e503f26..6e8725c 100644 --- a/bloom/test_coverage.txt +++ b/bloom/test_coverage.txt @@ -1,28 +1,28 @@ -github.com/conformal/btcutil/bloom/murmurhash3.go MurmurHash3 100.00% (31/31) -github.com/conformal/btcutil/bloom/merkleblock.go NewMerkleBlock 100.00% (19/19) -github.com/conformal/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/bloom/filter.go Filter.AddOutPoint 100.00% (3/3) -github.com/conformal/btcutil/bloom/filter.go minUint32 100.00% (3/3) -github.com/conformal/btcutil/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/btcutil/bloom/filter.go LoadFilter 100.00% (1/1) -github.com/conformal/btcutil/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/btcutil/bloom/filter.go NewFilter 81.82% (9/11) -github.com/conformal/btcutil/bloom/filter.go Filter.add 80.00% (4/5) -github.com/conformal/btcutil/bloom ---------------------------- 96.49% (165/171) +github.com/conformal/lbcutil/bloom/murmurhash3.go MurmurHash3 100.00% (31/31) +github.com/conformal/lbcutil/bloom/merkleblock.go NewMerkleBlock 100.00% (19/19) +github.com/conformal/lbcutil/bloom/merkleblock.go merkleBlock.traverseAndBuild 100.00% (10/10) +github.com/conformal/lbcutil/bloom/merkleblock.go merkleBlock.calcHash 100.00% (8/8) +github.com/conformal/lbcutil/bloom/filter.go Filter.maybeAddOutpoint 100.00% (7/7) +github.com/conformal/lbcutil/bloom/filter.go Filter.addOutPoint 100.00% (4/4) +github.com/conformal/lbcutil/bloom/filter.go Filter.IsLoaded 100.00% (4/4) +github.com/conformal/lbcutil/bloom/filter.go Filter.MsgFilterLoad 100.00% (4/4) +github.com/conformal/lbcutil/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/lbcutil/bloom/filter.go Filter.MatchTxAndUpdate 100.00% (4/4) +github.com/conformal/lbcutil/bloom/filter.go Filter.Matches 100.00% (4/4) +github.com/conformal/lbcutil/bloom/filter.go Filter.Add 100.00% (3/3) +github.com/conformal/lbcutil/bloom/filter.go Filter.Reload 100.00% (3/3) +github.com/conformal/lbcutil/bloom/filter.go Filter.Unload 100.00% (3/3) +github.com/conformal/lbcutil/bloom/filter.go Filter.AddShaHash 100.00% (3/3) +github.com/conformal/lbcutil/bloom/filter.go Filter.AddOutPoint 100.00% (3/3) +github.com/conformal/lbcutil/bloom/filter.go minUint32 100.00% (3/3) +github.com/conformal/lbcutil/bloom/filter.go Filter.hash 100.00% (2/2) +github.com/conformal/lbcutil/bloom/merkleblock.go merkleBlock.calcTreeWidth 100.00% (1/1) +github.com/conformal/lbcutil/bloom/filter.go LoadFilter 100.00% (1/1) +github.com/conformal/lbcutil/bloom/filter.go Filter.matchTxAndUpdate 91.30% (21/23) +github.com/conformal/lbcutil/bloom/filter.go Filter.matches 85.71% (6/7) +github.com/conformal/lbcutil/bloom/filter.go NewFilter 81.82% (9/11) +github.com/conformal/lbcutil/bloom/filter.go Filter.add 80.00% (4/5) +github.com/conformal/lbcutil/bloom ---------------------------- 96.49% (165/171) diff --git a/certgen.go b/certgen.go index 52e2d9c..edba66c 100644 --- a/certgen.go +++ b/certgen.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "bytes" diff --git a/certgen_test.go b/certgen_test.go index f9e2c95..4551dab 100644 --- a/certgen_test.go +++ b/certgen_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "crypto/x509" @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcutil" //"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) org := "test autogenerated cert" 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 { t.Fatalf("failed with unexpected error: %v", err) } diff --git a/coinset/README.md b/coinset/README.md index fd05f8c..5ee00ca 100644 --- a/coinset/README.md +++ b/coinset/README.md @@ -1,9 +1,7 @@ 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) -[![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 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 report. -## Installation and Updating - -```bash -$ go get -u github.com/btcsuite/btcutil/coinset -``` - ## Usage 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 -transaction and transmit it to the network. - -## License - -Package coinset is licensed under the [copyfree](http://copyfree.org) ISC -License. +transaction and transmit it to the network. \ No newline at end of file diff --git a/coinset/coins.go b/coinset/coins.go index 1777918..2c51f86 100644 --- a/coinset/coins.go +++ b/coinset/coins.go @@ -9,16 +9,16 @@ import ( "errors" "sort" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" ) // Coin represents a spendable transaction outpoint type Coin interface { Hash() *chainhash.Hash Index() uint32 - Value() btcutil.Amount + Value() lbcutil.Amount PkScript() []byte NumConfs() int64 ValueAge() int64 @@ -39,7 +39,7 @@ type Coins interface { // the CoinSet, otherwise the cached values will be incorrect. type CoinSet struct { coinList *list.List - totalValue btcutil.Amount + totalValue lbcutil.Amount totalValueAge int64 } @@ -70,7 +70,7 @@ func (cs *CoinSet) Coins() []Coin { } // 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 } @@ -149,7 +149,7 @@ var ( // satisfiesTargetValue checks that the totalValue is either exactly the targetValue // 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) } @@ -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 // a constant ValueAge() during the execution of CoinSelect. 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 @@ -173,12 +173,12 @@ type CoinSelector interface { // any number of lower indexes (as in the ordered array) over higher ones. type MinIndexCoinSelector struct { MaxInputs int - MinChangeAmount btcutil.Amount + MinChangeAmount lbcutil.Amount } // CoinSelect will attempt to select coins using the algorithm described // 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) for n := 0; n < len(coins) && n < s.MaxInputs; 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. type MinNumberCoinSelector struct { MaxInputs int - MinChangeAmount btcutil.Amount + MinChangeAmount lbcutil.Amount } // CoinSelect will attempt to select coins using the algorithm described // 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 = append(sortedCoins, coins...) sort.Sort(sort.Reverse(byAmount(sortedCoins))) @@ -216,12 +216,12 @@ func (s MinNumberCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Co // block. type MaxValueAgeCoinSelector struct { MaxInputs int - MinChangeAmount btcutil.Amount + MinChangeAmount lbcutil.Amount } // CoinSelect will attempt to select coins using the algorithm described // 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 = append(sortedCoins, coins...) sort.Sort(sort.Reverse(byValueAge(sortedCoins))) @@ -241,13 +241,13 @@ func (s MaxValueAgeCoinSelector) CoinSelect(targetValue btcutil.Amount, coins [] // type MinPriorityCoinSelector struct { MaxInputs int - MinChangeAmount btcutil.Amount + MinChangeAmount lbcutil.Amount MinAvgValueAgePerInput int64 } // CoinSelect will attempt to select coins using the algorithm described // 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 = 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() } // 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. type SimpleCoin struct { - Tx *btcutil.Tx + Tx *lbcutil.Tx TxIndex uint32 TxNumConfs int64 } @@ -370,8 +370,8 @@ func (c *SimpleCoin) txOut() *wire.TxOut { } // Value returns the value of the Coin -func (c *SimpleCoin) Value() btcutil.Amount { - return btcutil.Amount(c.txOut().Value) +func (c *SimpleCoin) Value() lbcutil.Amount { + return lbcutil.Amount(c.txOut().Value) } // PkScript returns the outpoint script of the Coin. diff --git a/coinset/coins_test.go b/coinset/coins_test.go index dc02d9f..bddc65a 100644 --- a/coinset/coins_test.go +++ b/coinset/coins_test.go @@ -11,27 +11,27 @@ import ( "fmt" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcutil/coinset" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" + "github.com/lbryio/lbcutil/coinset" ) type TestCoin struct { TxHash *chainhash.Hash TxIndex uint32 - TxValue btcutil.Amount + TxValue lbcutil.Amount TxNumConfs int64 } func (c *TestCoin) Hash() *chainhash.Hash { return c.TxHash } 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) NumConfs() int64 { return 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.Write([]byte(fmt.Sprintf("%d", index))) hash, _ := chainhash.NewHash(h.Sum(nil)) @@ -47,7 +47,7 @@ func NewCoin(index int64, value btcutil.Amount, numConfs int64) coinset.Coin { type coinSelectTest struct { selector coinset.CoinSelector inputCoins []coinset.Coin - targetValue btcutil.Amount + targetValue lbcutil.Amount expectedCoins []coinset.Coin expectedError error } @@ -225,12 +225,12 @@ var ( testSimpleCoinNumConfs = int64(1) testSimpleCoinTxHash = "9b5965c86de51d5dc824e179a05cf232db78c80ae86ca9d7cb2a655b5e19c1e2" testSimpleCoinTxHex = "0100000001a214a110f79e4abe073865ea5b3745c6e82c913bad44be70652804a5e4003b0a010000008c493046022100edd18a69664efa57264be207100c203e6cade1888cbb88a0ad748548256bb2f0022100f1027dc2e6c7f248d78af1dd90027b5b7d8ec563bb62aa85d4e74d6376f3868c0141048f3757b65ed301abd1b0e8942d1ab5b50594d3314cff0299f300c696376a0a9bf72e74710a8af7a5372d4af4bb519e2701a094ef48c8e48e3b65b28502452dceffffffff02e0673500000000001976a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ace86ef102000000001976a914ac3f995655e81b875b38b64351d6f896ddbfc68588ac00000000" - testSimpleCoinTxValue0 = btcutil.Amount(3500000) + testSimpleCoinTxValue0 = lbcutil.Amount(3500000) testSimpleCoinTxValueAge0 = int64(testSimpleCoinTxValue0) * testSimpleCoinNumConfs testSimpleCoinTxPkScript0Hex = "76a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ac" testSimpleCoinTxPkScript0Bytes, _ = hex.DecodeString(testSimpleCoinTxPkScript0Hex) testSimpleCoinTxBytes, _ = hex.DecodeString(testSimpleCoinTxHex) - testSimpleCoinTx, _ = btcutil.NewTxFromBytes(testSimpleCoinTxBytes) + testSimpleCoinTx, _ = lbcutil.NewTxFromBytes(testSimpleCoinTxBytes) testSimpleCoin = &coinset.SimpleCoin{ Tx: testSimpleCoinTx, TxIndex: 0, diff --git a/coinset/test_coverage.txt b/coinset/test_coverage.txt index 0e3e15d..99c265d 100644 --- a/coinset/test_coverage.txt +++ b/coinset/test_coverage.txt @@ -1,31 +1,31 @@ -github.com/conformal/btcutil/coinset/coins.go MinPriorityCoinSelector.CoinSelect 100.00% (39/39) -github.com/conformal/btcutil/coinset/coins.go NewMsgTxWithInputCoins 100.00% (6/6) -github.com/conformal/btcutil/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/btcutil/coinset/coins.go NewCoinSet 100.00% (4/4) -github.com/conformal/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/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/btcutil/coinset/coins.go satisfiesTargetValue 100.00% (1/1) -github.com/conformal/btcutil/coinset ---------------------------------- 100.00% (100/100) +github.com/conformal/lbcutil/coinset/coins.go MinPriorityCoinSelector.CoinSelect 100.00% (39/39) +github.com/conformal/lbcutil/coinset/coins.go NewMsgTxWithInputCoins 100.00% (6/6) +github.com/conformal/lbcutil/coinset/coins.go MinIndexCoinSelector.CoinSelect 100.00% (6/6) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.removeElement 100.00% (5/5) +github.com/conformal/lbcutil/coinset/coins.go NewCoinSet 100.00% (4/4) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.Coins 100.00% (4/4) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.PopCoin 100.00% (4/4) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.ShiftCoin 100.00% (4/4) +github.com/conformal/lbcutil/coinset/coins.go MinNumberCoinSelector.CoinSelect 100.00% (4/4) +github.com/conformal/lbcutil/coinset/coins.go MaxValueAgeCoinSelector.CoinSelect 100.00% (4/4) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.PushCoin 100.00% (3/3) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.TotalValueAge 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.NumConfs 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.ValueAge 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.TotalValue 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go byValueAge.Len 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go byValueAge.Swap 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go byValueAge.Less 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go byAmount.Len 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go byAmount.Swap 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go byAmount.Less 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.Hash 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.Index 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.txOut 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.Value 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go SimpleCoin.PkScript 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go CoinSet.Num 100.00% (1/1) +github.com/conformal/lbcutil/coinset/coins.go satisfiesTargetValue 100.00% (1/1) +github.com/conformal/lbcutil/coinset ---------------------------------- 100.00% (100/100) diff --git a/const.go b/const.go index 41d48b3..bcd7314 100644 --- a/const.go +++ b/const.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil const ( // SatoshiPerBitcent is the number of satoshi in one bitcoin cent. diff --git a/doc.go b/doc.go index 36cda1c..5d29fd9 100644 --- a/doc.go +++ b/doc.go @@ -3,7 +3,7 @@ // 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 @@ -36,11 +36,11 @@ To decode/encode an address: "e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d57" + "8a4c702b6bf11d5f" defaultNet := &chaincfg.MainNetParams - addr, err := btcutil.DecodeAddress(addrString, defaultNet) + addr, err := lbcutil.DecodeAddress(addrString, defaultNet) if err != nil { fmt.Println(err) return } fmt.Println(addr.EncodeAddress()) */ -package btcutil +package lbcutil diff --git a/example_test.go b/example_test.go index 73ec9f8..dec585f 100644 --- a/example_test.go +++ b/example_test.go @@ -1,21 +1,21 @@ -package btcutil_test +package lbcutil_test import ( "fmt" "math" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcutil" ) func ExampleAmount() { - a := btcutil.Amount(0) + a := lbcutil.Amount(0) fmt.Println("Zero Satoshi:", a) - a = btcutil.Amount(1e8) + a = lbcutil.Amount(1e8) fmt.Println("100,000,000 Satoshis:", a) - a = btcutil.Amount(1e5) + a = lbcutil.Amount(1e5) fmt.Println("100,000 Satoshis:", a) // Output: // Zero Satoshi: 0 BTC @@ -24,28 +24,28 @@ func ExampleAmount() { } func ExampleNewAmount() { - amountOne, err := btcutil.NewAmount(1) + amountOne, err := lbcutil.NewAmount(1) if err != nil { fmt.Println(err) return } fmt.Println(amountOne) //Output 1 - amountFraction, err := btcutil.NewAmount(0.01234567) + amountFraction, err := lbcutil.NewAmount(0.01234567) if err != nil { fmt.Println(err) return } fmt.Println(amountFraction) //Output 2 - amountZero, err := btcutil.NewAmount(0) + amountZero, err := lbcutil.NewAmount(0) if err != nil { fmt.Println(err) return } fmt.Println(amountZero) //Output 3 - amountNaN, err := btcutil.NewAmount(math.NaN()) + amountNaN, err := lbcutil.NewAmount(math.NaN()) if err != nil { fmt.Println(err) return @@ -59,13 +59,13 @@ func ExampleNewAmount() { } 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 MilliBTC:", amount.Format(btcutil.AmountMilliBTC)) - fmt.Println("Satoshi to MicroBTC:", amount.Format(btcutil.AmountMicroBTC)) - fmt.Println("Satoshi to Satoshi:", amount.Format(btcutil.AmountSatoshi)) + fmt.Println("Satoshi to MilliBTC:", amount.Format(lbcutil.AmountMilliBTC)) + fmt.Println("Satoshi to MicroBTC:", amount.Format(lbcutil.AmountMicroBTC)) + fmt.Println("Satoshi to Satoshi:", amount.Format(lbcutil.AmountSatoshi)) // Output: // Satoshi to kBTC: 444.333222111 kBTC diff --git a/gcs/README.md b/gcs/README.md index e663a0e..2e21b27 100644 --- a/gcs/README.md +++ b/gcs/README.md @@ -1,24 +1,9 @@ gcs ========== -[![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) -[![GoDoc](https://godoc.org/github.com/btcsuite/btcutil/gcs?status.png)] -(http://godoc.org/github.com/btcsuite/btcutil/gcs) +[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) 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). -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. +A comprehensive suite of tests is provided to ensure proper functionality. \ No newline at end of file diff --git a/gcs/builder/builder.go b/gcs/builder/builder.go index 8b45d78..430dbd5 100644 --- a/gcs/builder/builder.go +++ b/gcs/builder/builder.go @@ -10,10 +10,10 @@ import ( "fmt" "math" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil/gcs" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil/gcs" ) const ( diff --git a/gcs/builder/builder_test.go b/gcs/builder/builder_test.go index de04421..90ce26a 100644 --- a/gcs/builder/builder_test.go +++ b/gcs/builder/builder_test.go @@ -9,13 +9,13 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcutil/gcs" - "github.com/btcsuite/btcutil/gcs/builder" + "github.com/lbryio/lbcd/chaincfg" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" + "github.com/lbryio/lbcutil/gcs" + "github.com/lbryio/lbcutil/gcs/builder" ) var ( @@ -76,8 +76,8 @@ func TestUseBlockHash(t *testing.T) { Index: 4321, } - // btcutil.Address - addr, err := btcutil.DecodeAddress(testAddr, &chaincfg.MainNetParams) + // lbcutil.Address + addr, err := lbcutil.DecodeAddress(testAddr, &chaincfg.MainNetParams) if err != nil { t.Fatalf("Address decode failed: %s", err.Error()) } diff --git a/gcs/gcs.go b/gcs/gcs.go index fbffb06..a148f0f 100644 --- a/gcs/gcs.go +++ b/gcs/gcs.go @@ -12,7 +12,7 @@ import ( "sort" "github.com/aead/siphash" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/wire" "github.com/kkdai/bstream" ) diff --git a/gcs/gcs_test.go b/gcs/gcs_test.go index bb4d550..ab3574d 100644 --- a/gcs/gcs_test.go +++ b/gcs/gcs_test.go @@ -11,7 +11,7 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcutil/gcs" + "github.com/lbryio/lbcutil/gcs" ) var ( diff --git a/gcs/gcsbench_test.go b/gcs/gcsbench_test.go index ffb2599..4d855d6 100644 --- a/gcs/gcsbench_test.go +++ b/gcs/gcsbench_test.go @@ -10,7 +10,7 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcutil/gcs" + "github.com/lbryio/lbcutil/gcs" ) func genRandFilterElements(numElements uint) ([][]byte, error) { diff --git a/hash160.go b/hash160.go index fa26e09..51b5dc6 100644 --- a/hash160.go +++ b/hash160.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "crypto/sha256" diff --git a/hdkeychain/README.md b/hdkeychain/README.md index f9c15d8..f863576 100644 --- a/hdkeychain/README.md +++ b/hdkeychain/README.md @@ -1,9 +1,7 @@ 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) -[![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 extended keys (BIP0032). @@ -24,7 +22,7 @@ report. keys - Support for custom networks by registering them with chaincfg - 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 transations and generate payment scripts - Uses the btcec package which is highly optimized for secp256k1 @@ -36,24 +34,13 @@ report. - Comprehensive test coverage including the BIP0032 test vectors - Benchmarks -## Installation and Updating - -```bash -$ go get -u github.com/btcsuite/btcutil/hdkeychain -``` - ## 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 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 in BIP0032. -* [Audits Use Case Example](http://godoc.org/github.com/btcsuite/btcutil/hdkeychain#example-package--Audits) - Demonstrates the audits use case in BIP0032. - -## License - -Package hdkeychain is licensed under the [copyfree](http://copyfree.org) ISC -License. +* [Audits Use Case Example](http://godoc.org/github.com/lbryio/lbcutil/hdkeychain#example-package--Audits) + Demonstrates the audits use case in BIP0032. \ No newline at end of file diff --git a/hdkeychain/bench_test.go b/hdkeychain/bench_test.go index 7c86ca9..502e177 100644 --- a/hdkeychain/bench_test.go +++ b/hdkeychain/bench_test.go @@ -7,7 +7,7 @@ package hdkeychain_test import ( "testing" - "github.com/btcsuite/btcutil/hdkeychain" + "github.com/lbryio/lbcutil/hdkeychain" ) // bip0032MasterPriv1 is the master private extended key from the first set of diff --git a/hdkeychain/example_test.go b/hdkeychain/example_test.go index e7f462d..1205c46 100644 --- a/hdkeychain/example_test.go +++ b/hdkeychain/example_test.go @@ -7,8 +7,8 @@ package hdkeychain_test import ( "fmt" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcutil/hdkeychain" + "github.com/lbryio/lbcd/chaincfg" + "github.com/lbryio/lbcutil/hdkeychain" ) // This example demonstrates how to generate a cryptographically random seed diff --git a/hdkeychain/extendedkey.go b/hdkeychain/extendedkey.go index 929fe99..c5b8185 100644 --- a/hdkeychain/extendedkey.go +++ b/hdkeychain/extendedkey.go @@ -18,11 +18,11 @@ import ( "fmt" "math/big" - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcutil/base58" + "github.com/lbryio/lbcd/btcec" + "github.com/lbryio/lbcd/chaincfg" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcutil" + "github.com/lbryio/lbcutil/base58" ) 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 // 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, k.depth+1, i, isPrivate), nil } @@ -415,7 +415,7 @@ func (k *ExtendedKey) DeriveNonStandard(i uint32) (*ExtendedKey, error) { childKey = pk.SerializeCompressed() } - parentFP := btcutil.Hash160(k.pubKeyBytes())[:4] + parentFP := lbcutil.Hash160(k.pubKeyBytes())[:4] return NewExtendedKey(k.version, childKey, childChainCode, parentFP, 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 for the passed network. -func (k *ExtendedKey) Address(net *chaincfg.Params) (*btcutil.AddressPubKeyHash, error) { - pkHash := btcutil.Hash160(k.pubKeyBytes()) - return btcutil.NewAddressPubKeyHash(pkHash, net) +func (k *ExtendedKey) Address(net *chaincfg.Params) (*lbcutil.AddressPubKeyHash, error) { + pkHash := lbcutil.Hash160(k.pubKeyBytes()) + return lbcutil.NewAddressPubKeyHash(pkHash, net) } // paddedAppend appends the src byte slice to dst, returning the new slice. diff --git a/hdkeychain/extendedkey_test.go b/hdkeychain/extendedkey_test.go index dd6deb5..22110f9 100644 --- a/hdkeychain/extendedkey_test.go +++ b/hdkeychain/extendedkey_test.go @@ -17,7 +17,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/lbryio/lbcd/chaincfg" ) // 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" { - t.Error("incorrect btcutil backwards compatible BIP32-like derivation") + t.Error("incorrect lbcutil backwards compatible BIP32-like derivation") } if !child0.IsAffectedByIssue172() { diff --git a/hdkeychain/test_coverage.txt b/hdkeychain/test_coverage.txt index c0bc7ef..990001d 100644 --- a/hdkeychain/test_coverage.txt +++ b/hdkeychain/test_coverage.txt @@ -1,20 +1,20 @@ -github.com/conformal/btcutil/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/btcutil/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/btcutil/hdkeychain/extendedkey.go ExtendedKey.ECPrivKey 100.00% (4/4) -github.com/conformal/btcutil/hdkeychain/extendedkey.go zero 100.00% (3/3) -github.com/conformal/btcutil/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/btcutil/hdkeychain/extendedkey.go newExtendedKey 100.00% (1/1) -github.com/conformal/btcutil/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/btcutil/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/btcutil/hdkeychain/extendedkey.go NewKeyFromString 95.83% (23/24) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Child 91.67% (33/36) -github.com/conformal/btcutil/hdkeychain/extendedkey.go NewMaster 91.67% (11/12) -github.com/conformal/btcutil/hdkeychain/extendedkey.go GenerateSeed 85.71% (6/7) -github.com/conformal/btcutil/hdkeychain ----------------------------- 95.59% (130/136) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.String 100.00% (18/18) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Zero 100.00% (9/9) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.pubKeyBytes 100.00% (7/7) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Neuter 100.00% (6/6) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.ECPrivKey 100.00% (4/4) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go zero 100.00% (3/3) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.SetNet 100.00% (3/3) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Address 100.00% (2/2) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go newExtendedKey 100.00% (1/1) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.IsPrivate 100.00% (1/1) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.ParentFingerprint 100.00% (1/1) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.ECPubKey 100.00% (1/1) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.IsForNet 100.00% (1/1) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go NewKeyFromString 95.83% (23/24) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go ExtendedKey.Child 91.67% (33/36) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go NewMaster 91.67% (11/12) +github.com/conformal/lbcutil/hdkeychain/extendedkey.go GenerateSeed 85.71% (6/7) +github.com/conformal/lbcutil/hdkeychain ----------------------------- 95.59% (130/136) diff --git a/internal_test.go b/internal_test.go index ec2daa0..216f210 100644 --- a/internal_test.go +++ b/internal_test.go @@ -3,18 +3,18 @@ // license that can be found in the LICENSE file. /* -This test file is part of the btcutil package rather than than the -btcutil_test package so it can bridge access to the internals to properly test +This test file is part of the lbcutil package rather than than the +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 interface. The functions are only exported while the tests are being run. */ -package btcutil +package lbcutil import ( - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcutil/base58" - "github.com/btcsuite/btcutil/bech32" + "github.com/lbryio/lbcd/btcec" + "github.com/lbryio/lbcutil/base58" + "github.com/lbryio/lbcutil/bech32" "golang.org/x/crypto/ripemd160" ) diff --git a/net.go b/net.go index bf11733..a80097c 100644 --- a/net.go +++ b/net.go @@ -4,7 +4,7 @@ // +build !appengine -package btcutil +package lbcutil import ( "net" diff --git a/net_noop.go b/net_noop.go index b0b7c2e..bdfc408 100644 --- a/net_noop.go +++ b/net_noop.go @@ -4,7 +4,7 @@ // +build appengine -package btcutil +package lbcutil import ( "net" diff --git a/psbt/creator.go b/psbt/creator.go index a5f832e..90d6432 100644 --- a/psbt/creator.go +++ b/psbt/creator.go @@ -5,7 +5,7 @@ package psbt import ( - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/wire" ) // MinTxVersion is the lowest transaction version that we'll permit. diff --git a/psbt/extractor.go b/psbt/extractor.go index dc7f10f..1b10607 100644 --- a/psbt/extractor.go +++ b/psbt/extractor.go @@ -12,8 +12,8 @@ package psbt import ( "bytes" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" ) // Extract takes a finalized psbt.Packet and outputs a finalized transaction diff --git a/psbt/finalizer.go b/psbt/finalizer.go index 0bf9dbb..44763e2 100644 --- a/psbt/finalizer.go +++ b/psbt/finalizer.go @@ -12,7 +12,7 @@ package psbt // multisig and no other custom script. import ( - "github.com/btcsuite/btcd/txscript" + "github.com/lbryio/lbcd/txscript" ) // isFinalized considers this input finalized if it contains at least one of diff --git a/psbt/go.mod b/psbt/go.mod index d47c286..7e58da4 100644 --- a/psbt/go.mod +++ b/psbt/go.mod @@ -1,9 +1,9 @@ -module github.com/btcsuite/btcutil/psbt +module github.com/lbryio/lbcutil/psbt go 1.13 require ( - github.com/btcsuite/btcd v0.20.1-beta - github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d + github.com/lbryio/lbcd v0.20.1-beta + github.com/lbryio/lbcutil v0.0.0-20190425235716-9e5f4b9a998d github.com/davecgh/go-spew v1.1.1 ) diff --git a/psbt/go.sum b/psbt/go.sum index 96107a5..e154325 100644 --- a/psbt/go.sum +++ b/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/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/lbryio/lbcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= +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/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v0.0.0-20191219182022-e17c9730c422 h1:EqnrgSSg0SFWRlEZLExgjtuUR/IPnuQ6qw6nwRda4Uk= -github.com/btcsuite/btcutil v0.0.0-20191219182022-e17c9730c422/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/lbryio/lbcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng= +github.com/lbryio/lbcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/lbryio/lbcutil v0.0.0-20191219182022-e17c9730c422 h1:EqnrgSSg0SFWRlEZLExgjtuUR/IPnuQ6qw6nwRda4Uk= +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/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE= diff --git a/psbt/partial_input.go b/psbt/partial_input.go index 4783c74..6915058 100644 --- a/psbt/partial_input.go +++ b/psbt/partial_input.go @@ -6,8 +6,8 @@ import ( "io" "sort" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" ) // PInput is a struct encapsulating all the data that can be attached to any diff --git a/psbt/partial_output.go b/psbt/partial_output.go index 64d1bd4..2f389ff 100644 --- a/psbt/partial_output.go +++ b/psbt/partial_output.go @@ -5,7 +5,7 @@ import ( "io" "sort" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/wire" ) // POutput is a struct encapsulating all the data that can be attached diff --git a/psbt/partialsig.go b/psbt/partialsig.go index e11bb80..b301836 100644 --- a/psbt/partialsig.go +++ b/psbt/partialsig.go @@ -3,7 +3,7 @@ package psbt import ( "bytes" - "github.com/btcsuite/btcd/btcec" + "github.com/lbryio/lbcd/btcec" ) // PartialSig encapsulate a (BTC public key, ECDSA signature) diff --git a/psbt/profile.cov b/psbt/profile.cov new file mode 100644 index 0000000..79b28a0 --- /dev/null +++ b/psbt/profile.cov @@ -0,0 +1 @@ +mode: atomic diff --git a/psbt/psbt.go b/psbt/psbt.go index 73126c3..bd05636 100644 --- a/psbt/psbt.go +++ b/psbt/psbt.go @@ -14,7 +14,7 @@ import ( "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 diff --git a/psbt/psbt_test.go b/psbt/psbt_test.go index c366766..be7ea3f 100644 --- a/psbt/psbt_test.go +++ b/psbt/psbt_test.go @@ -11,10 +11,10 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" "github.com/davecgh/go-spew/spew" ) @@ -1369,7 +1369,7 @@ func TestWitnessForNonWitnessUtxo(t *testing.T) { }}, TxOut: []*wire.TxOut{{ PkScript: outPkScript, - Value: 1.9 * btcutil.SatoshiPerBitcoin, + Value: 1.9 * lbcutil.SatoshiPerBitcoin, }}, }, Inputs: []PInput{{}}, diff --git a/psbt/signer.go b/psbt/signer.go index 5882653..dfb36ad 100644 --- a/psbt/signer.go +++ b/psbt/signer.go @@ -10,7 +10,7 @@ package psbt // is in the correct state. 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 diff --git a/psbt/sort.go b/psbt/sort.go index 2232d68..afa41ab 100644 --- a/psbt/sort.go +++ b/psbt/sort.go @@ -4,7 +4,7 @@ import ( "bytes" "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 @@ -16,7 +16,7 @@ import ( // (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 // 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 // is otherwise 100% positive mutating will not cause adverse affects due to diff --git a/psbt/sort_test.go b/psbt/sort_test.go index 3dee0f4..0d668c0 100644 --- a/psbt/sort_test.go +++ b/psbt/sort_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" ) func TestInPlaceSort(t *testing.T) { diff --git a/psbt/updater.go b/psbt/updater.go index 01fb2f3..fb70673 100644 --- a/psbt/updater.go +++ b/psbt/updater.go @@ -14,9 +14,9 @@ import ( "bytes" "crypto/sha256" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil" ) // 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 { outIndex := p.Upsbt.UnsignedTx.TxIn[inIndex].PreviousOutPoint.Index scriptPubKey := pInput.NonWitnessUtxo.TxOut[outIndex].PkScript - scriptHash := btcutil.Hash160(pInput.RedeemScript) + scriptHash := lbcutil.Hash160(pInput.RedeemScript) scriptHashScript, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_HASH160). @@ -155,7 +155,7 @@ func (p *Updater) addPartialSignature(inIndex int, sig []byte, var script []byte if pInput.RedeemScript != nil { - scriptHash := btcutil.Hash160(pInput.RedeemScript) + scriptHash := lbcutil.Hash160(pInput.RedeemScript) scriptHashScript, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_HASH160). AddData(scriptHash). @@ -195,7 +195,7 @@ func (p *Updater) addPartialSignature(inIndex int, sig []byte, } } else { // Otherwise, this is a p2wkh input. - pubkeyHash := btcutil.Hash160(pubkey) + pubkeyHash := lbcutil.Hash160(pubkey) pubkeyHashScript, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_0). AddData(pubkeyHash). diff --git a/psbt/utils.go b/psbt/utils.go index 494d040..c82ec69 100644 --- a/psbt/utils.go +++ b/psbt/utils.go @@ -12,8 +12,8 @@ import ( "io" "sort" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/txscript" + "github.com/lbryio/lbcd/wire" ) // WriteTxWitness is a utility function due to non-exported witness diff --git a/psbt/utils_test.go b/psbt/utils_test.go index 90593ff..2a190c5 100644 --- a/psbt/utils_test.go +++ b/psbt/utils_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" ) func TestSumUtxoInputValues(t *testing.T) { diff --git a/tx.go b/tx.go index 5633fef..b3fef07 100644 --- a/tx.go +++ b/tx.go @@ -2,14 +2,14 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "bytes" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" ) // TxIndexUnknown is the value returned for a transaction index that is unknown. diff --git a/tx_test.go b/tx_test.go index 6105b30..ca21521 100644 --- a/tx_test.go +++ b/tx_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "bytes" @@ -10,15 +10,15 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcutil" "github.com/davecgh/go-spew/spew" ) // TestTx tests the API for Tx. func TestTx(t *testing.T) { testTx := Block100000.Transactions[0] - tx := btcutil.NewTx(testTx) + tx := lbcutil.NewTx(testTx) // Ensure we get the same data back out. if msgTx := tx.MsgTx(); !reflect.DeepEqual(msgTx, testTx) { @@ -63,7 +63,7 @@ func TestNewTxFromBytes(t *testing.T) { testTxBytes := testTxBuf.Bytes() // Create a new transaction from the serialized bytes. - tx, err := btcutil.NewTxFromBytes(testTxBytes) + tx, err := lbcutil.NewTxFromBytes(testTxBytes) if err != nil { t.Errorf("NewTxFromBytes: %v", err) return @@ -89,7 +89,7 @@ func TestTxErrors(t *testing.T) { // Truncate the transaction byte buffer to force errors. shortBytes := testTxBytes[:4] - _, err = btcutil.NewTxFromBytes(shortBytes) + _, err = lbcutil.NewTxFromBytes(shortBytes) if err != io.EOF { t.Errorf("NewTxFromBytes: did not get expected error - "+ "got %v, want %v", err, io.EOF) @@ -99,7 +99,7 @@ func TestTxErrors(t *testing.T) { // TestTxHasWitness tests the HasWitness() method. func TestTxHasWitness(t *testing.T) { msgTx := Block100000.Transactions[0] // contains witness data - tx := btcutil.NewTx(msgTx) + tx := lbcutil.NewTx(msgTx) tx.WitnessHash() // Populate the witness hash cache tx.HasWitness() // Should not fail (see btcsuite/btcd#1543) @@ -109,7 +109,7 @@ func TestTxHasWitness(t *testing.T) { } for _, msgTxWithoutWitness := range Block100000.Transactions[1:] { - txWithoutWitness := btcutil.NewTx(msgTxWithoutWitness) + txWithoutWitness := lbcutil.NewTx(msgTxWithoutWitness) if txWithoutWitness.HasWitness() { t.Errorf("HasWitness: got false, want true") } @@ -119,7 +119,7 @@ func TestTxHasWitness(t *testing.T) { // TestTxWitnessHash tests the WitnessHash() method. func TestTxWitnessHash(t *testing.T) { msgTx := Block100000.Transactions[0] // contains witness data - tx := btcutil.NewTx(msgTx) + tx := lbcutil.NewTx(msgTx) if tx.WitnessHash().IsEqual(tx.Hash()) { 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:] { - txWithoutWitness := btcutil.NewTx(msgTxWithoutWitness) + txWithoutWitness := lbcutil.NewTx(msgTxWithoutWitness) if !txWithoutWitness.WitnessHash().IsEqual(txWithoutWitness.Hash()) { t.Errorf("WitnessHash: witness hash and tx id must be same - "+ "got %v, want %v", txWithoutWitness.WitnessHash(), txWithoutWitness.Hash()) diff --git a/txsort/README.md b/txsort/README.md index bd410ec..b7615b2 100644 --- a/txsort/README.md +++ b/txsort/README.md @@ -1,9 +1,7 @@ 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) -[![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). @@ -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 breaker. -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. +A comprehensive suite of tests is provided to ensure proper functionality. \ No newline at end of file diff --git a/txsort/txsort.go b/txsort/txsort.go index f72a7db..1dc7d2a 100644 --- a/txsort/txsort.go +++ b/txsort/txsort.go @@ -11,8 +11,8 @@ import ( "bytes" "sort" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcd/wire" ) // 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 // 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 -// 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. // // The function should only be used if the caller is creating the transaction or diff --git a/txsort/txsort_test.go b/txsort/txsort_test.go index 59f4d6c..7030521 100644 --- a/txsort/txsort_test.go +++ b/txsort/txsort_test.go @@ -11,8 +11,8 @@ import ( "path/filepath" "testing" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil/txsort" + "github.com/lbryio/lbcd/wire" + "github.com/lbryio/lbcutil/txsort" ) // TestSort ensures the transaction sorting works according to the BIP. diff --git a/wif.go b/wif.go index 8b17dc9..f36a8c2 100644 --- a/wif.go +++ b/wif.go @@ -2,16 +2,16 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package lbcutil import ( "bytes" "errors" - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcutil/base58" + "github.com/lbryio/lbcd/btcec" + "github.com/lbryio/lbcd/chaincfg" + "github.com/lbryio/lbcd/chaincfg/chainhash" + "github.com/lbryio/lbcutil/base58" ) // ErrMalformedPrivateKey describes an error where a WIF-encoded private diff --git a/wif_test.go b/wif_test.go index 589f2ac..3183307 100644 --- a/wif_test.go +++ b/wif_test.go @@ -2,16 +2,16 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package lbcutil_test import ( "bytes" "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/chaincfg" - . "github.com/btcsuite/btcutil" + "github.com/lbryio/lbcd/btcec" + "github.com/lbryio/lbcd/chaincfg" + . "github.com/lbryio/lbcutil" ) func TestEncodeDecodeWIF(t *testing.T) {