diff --git a/README.md b/README.md index 46a1d3e1b..81344f00e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -btcutil +rddutil ======= [![Build Status](https://travis-ci.org/reddcoin-project/rddutil.png?branch=master)] @@ -6,35 +6,35 @@ btcutil (https://coveralls.io/repos/reddcoin-project/rddutil/badge.png?branch=master)] (https://coveralls.io/r/reddcoin-project/rddutil?branch=master) -Package btcutil provides bitcoin-specific convenience functions and types. +Package rddutil provides Reddcoin-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 btcutil is licensed under the liberal ISC license. +report. Package rddutil is licensed under the liberal ISC license. -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 +This package was developed for rddd, an alternative full-node implementation of +Reddcoin which is under active development by Conformal. Although it was +primarily written for rddd, this package has intentionally been designed so it can be used as a standalone package for any projects needing the functionality provided. ## Documentation -[![GoDoc](https://godoc.org/github.com/conformal/btcutil?status.png)] -(http://godoc.org/github.com/conformal/btcutil) +[![GoDoc](https://godoc.org/github.com/reddcoin-project/rddutil?status.png)] +(http://godoc.org/github.com/reddcoin-project/rddutil) Full `go doc` style documentation for the project can be viewed online without installing this package by using the GoDoc site here: -http://godoc.org/github.com/conformal/btcutil +http://godoc.org/github.com/reddcoin-project/rddutil You can also view the documentation locally once the package is installed with the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to -http://localhost:6060/pkg/github.com/conformal/btcutil +http://localhost:6060/pkg/github.com/reddcoin-project/rddutil ## Installation ```bash -$ go get github.com/conformal/btcutil +$ go get github.com/reddcoin-project/rddutil ``` ## GPG Verification Key @@ -59,5 +59,5 @@ signature perform the following: ## License -Package btcutil is licensed under the [copyfree](http://copyfree.org) ISC +Package rddutil is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/address.go b/address.go index 80f594948..1fbd2a856 100644 --- a/address.go +++ b/address.go @@ -36,7 +36,7 @@ var ( ) // encodeAddress returns a human-readable payment address given a ripemd160 hash -// and netID which encodes the bitcoin network and address type. It is used +// and netID which encodes the Reddcoin network and address type. It is used // in both pay-to-pubkey-hash (P2PKH) and pay-to-script-hash (P2SH) address // encoding. func encodeAddress(hash160 []byte, netID byte) string { @@ -76,14 +76,14 @@ type Address interface { ScriptAddress() []byte // IsForNet returns whether or not the address is associated with the - // passed bitcoin network. + // passed Reddcoin network. IsForNet(*rddnet.Params) bool } // DecodeAddress decodes the string encoding of an address and returns // the Address if addr is a valid encoding for a known address type. // -// The bitcoin network the address is associated with is extracted if possible. +// The Reddcoin network the address is associated with is extracted if possible. // When the address does not encode the network, such as in the case of a raw // public key, the address will be associated with the passed defaultNet. func DecodeAddress(addr string, defaultNet *rddnet.Params) (Address, error) { @@ -170,7 +170,7 @@ func (a *AddressPubKeyHash) ScriptAddress() []byte { } // IsForNet returns whether or not the pay-to-pubkey-hash address is associated -// with the passed bitcoin network. +// with the passed Reddcoin network. func (a *AddressPubKeyHash) IsForNet(net *rddnet.Params) bool { return a.netID == net.PubKeyHashAddrID } @@ -237,7 +237,7 @@ func (a *AddressScriptHash) ScriptAddress() []byte { } // IsForNet returns whether or not the pay-to-script-hash address is associated -// with the passed bitcoin network. +// with the passed Reddcoin network. func (a *AddressScriptHash) IsForNet(net *rddnet.Params) bool { return a.netID == net.ScriptHashAddrID } @@ -329,7 +329,7 @@ func (a *AddressPubKey) serialize() []byte { // pay-to-pubkey-hash. Note that the public key format (uncompressed, // compressed, etc) will change the resulting address. This is expected since // pay-to-pubkey-hash is a hash of the serialized public key which obviously -// differs with the format. At the time of this writing, most Bitcoin addresses +// differs with the format. At the time of this writing, most Reddcoin addresses // are pay-to-pubkey-hash constructed from the uncompressed public key. // // Part of the Address interface. @@ -345,7 +345,7 @@ func (a *AddressPubKey) ScriptAddress() []byte { } // IsForNet returns whether or not the pay-to-pubkey address is associated -// with the passed bitcoin network. +// with the passed Reddcoin network. func (a *AddressPubKey) IsForNet(net *rddnet.Params) bool { return a.pubKeyHashID == net.PubKeyHashAddrID } @@ -372,7 +372,7 @@ func (a *AddressPubKey) SetFormat(pkFormat PubKeyFormat) { // pay-to-pubkey-hash address. Note that the public key format (uncompressed, // compressed, etc) will change the resulting address. This is expected since // pay-to-pubkey-hash is a hash of the serialized public key which obviously -// differs with the format. At the time of this writing, most Bitcoin addresses +// differs with the format. At the time of this writing, most Reddcoin addresses // are pay-to-pubkey-hash constructed from the uncompressed public key. func (a *AddressPubKey) AddressPubKeyHash() *AddressPubKeyHash { addr := &AddressPubKeyHash{netID: a.pubKeyHashID} diff --git a/address_test.go b/address_test.go index 3721428b1..6897819f4 100644 --- a/address_test.go +++ b/address_test.go @@ -19,7 +19,7 @@ import ( ) // invalidNet is an invalid bitcoin network. -const invalidNet = rddwire.BitcoinNet(0xffffffff) +const invalidNet = rddwire.ReddcoinNet(0xffffffff) func TestAddresses(t *testing.T) { tests := []struct { diff --git a/bloom/README.md b/bloom/README.md index e9b5b0804..1ef2c5020 100644 --- a/bloom/README.md +++ b/bloom/README.md @@ -13,27 +13,27 @@ report. Package coinset is licensed under the liberal ISC license. ## Documentation -[![GoDoc](https://godoc.org/github.com/conformal/btcutil/bloom?status.png)] -(http://godoc.org/github.com/conformal/btcutil/bloom) +[![GoDoc](https://godoc.org/github.com/reddcoin-project/rddutil/bloom?status.png)] +(http://godoc.org/github.com/reddcoin-project/rddutil/bloom) Full `go doc` style documentation for the project can be viewed online without installing this package by using the GoDoc site here: -http://godoc.org/github.com/conformal/btcutil/bloom +http://godoc.org/github.com/reddcoin-project/rddutil/bloom You can also view the documentation locally once the package is installed with the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to -http://localhost:6060/pkg/github.com/conformal/btcutil/bloom +http://localhost:6060/pkg/github.com/reddcoin-project/rddutil/bloom ## Installation ```bash -$ go get github.com/conformal/btcutil/bloom +$ go get github.com/reddcoin-project/rddutil/bloom ``` ## Examples * [NewFilter Example] - (http://godoc.org/github.com/conformal/btcutil/bloom#example-NewFilter) + (http://godoc.org/github.com/reddcoin-project/rddutil/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. diff --git a/bloom/example_test.go b/bloom/example_test.go index f01c1425e..bb26d743b 100644 --- a/bloom/example_test.go +++ b/bloom/example_test.go @@ -9,8 +9,8 @@ import ( "math/rand" "time" - "github.com/conformal/btcutil/bloom" - "github.com/conformal/btcwire" + "github.com/reddcoin-project/rddutil/bloom" + "github.com/reddcoin-project/rddwire" ) // This example demonstrates how to create a new bloom filter, add a transaction @@ -22,13 +22,13 @@ func ExampleNewFilter() { // Create a new bloom filter intended to hold 10 elements with a 0.01% // false positive rate and does not include any automatic update // functionality when transactions are matched. - filter := bloom.NewFilter(10, tweak, 0.0001, btcwire.BloomUpdateNone) + filter := bloom.NewFilter(10, tweak, 0.0001, rddwire.BloomUpdateNone) // Create a transaction hash and add it to the filter. This particular // trasaction is the first transaction in block 310,000 of the main - // bitcoin block chain. + // Reddcoin block chain. txHashStr := "fd611c56ca0d378cdcd16244b45c2ba9588da3adac367c4ef43e808b280b8a45" - txHash, err := btcwire.NewShaHashFromStr(txHashStr) + txHash, err := rddwire.NewShaHashFromStr(txHashStr) if err != nil { fmt.Println(err) return diff --git a/bloom/filter.go b/bloom/filter.go index 10a08eae6..83a0c6cab 100644 --- a/bloom/filter.go +++ b/bloom/filter.go @@ -9,9 +9,9 @@ import ( "math" "sync" - "github.com/conformal/btcscript" - "github.com/conformal/btcutil" - "github.com/conformal/btcwire" + "github.com/reddcoin-project/rddscript" + "github.com/reddcoin-project/rddutil" + "github.com/reddcoin-project/rddwire" ) // ln2Squared is simply the square of the natural log of 2. @@ -26,11 +26,11 @@ func minUint32(a, b uint32) uint32 { return b } -// Filter defines a bitcoin bloom filter that provides easy manipulation of raw +// Filter defines a Reddcoin bloom filter that provides easy manipulation of raw // filter data. type Filter struct { mtx sync.Mutex - msgFilterLoad *btcwire.MsgFilterLoad + msgFilterLoad *rddwire.MsgFilterLoad } // NewFilter creates a new bloom filter instance, mainly to be used by SPV @@ -42,7 +42,7 @@ type Filter struct { // // For more information on what values to use for both elements and fprate, // see https://en.wikipedia.org/wiki/Bloom_filter. -func NewFilter(elements, tweak uint32, fprate float64, flags btcwire.BloomUpdateType) *Filter { +func NewFilter(elements, tweak uint32, fprate float64, flags rddwire.BloomUpdateType) *Filter { // Massage the false positive rate to sane values. if fprate > 1.0 { fprate = 1.0 @@ -57,7 +57,7 @@ func NewFilter(elements, tweak uint32, fprate float64, flags btcwire.BloomUpdate // Equivalent to m = -(n*ln(p) / ln(2)^2), where m is in bits. // Then clamp it to the maximum filter size and convert to bytes. dataLen := uint32(-1 * float64(elements) * math.Log(fprate) / ln2Squared) - dataLen = minUint32(dataLen, btcwire.MaxFilterLoadFilterSize*8) / 8 + dataLen = minUint32(dataLen, rddwire.MaxFilterLoadFilterSize*8) / 8 // Calculate the number of hash functions based on the size of the // filter calculated above and the number of elements. @@ -65,10 +65,10 @@ func NewFilter(elements, tweak uint32, fprate float64, flags btcwire.BloomUpdate // Equivalent to k = (m/n) * ln(2) // Then clamp it to the maximum allowed hash funcs. hashFuncs := uint32(float64(dataLen*8) / float64(elements) * math.Ln2) - hashFuncs = minUint32(hashFuncs, btcwire.MaxFilterLoadHashFuncs) + hashFuncs = minUint32(hashFuncs, rddwire.MaxFilterLoadHashFuncs) data := make([]byte, dataLen) - msg := btcwire.NewMsgFilterLoad(data, hashFuncs, tweak, flags) + msg := rddwire.NewMsgFilterLoad(data, hashFuncs, tweak, flags) return &Filter{ msgFilterLoad: msg, @@ -76,8 +76,8 @@ func NewFilter(elements, tweak uint32, fprate float64, flags btcwire.BloomUpdate } // LoadFilter creates a new Filter instance with the given underlying -// btcwire.MsgFilterLoad. -func LoadFilter(filter *btcwire.MsgFilterLoad) *Filter { +// rddwire.MsgFilterLoad. +func LoadFilter(filter *rddwire.MsgFilterLoad) *Filter { return &Filter{ msgFilterLoad: filter, } @@ -96,7 +96,7 @@ func (bf *Filter) IsLoaded() bool { // Reload loads a new filter replacing any existing filter. // // This function is safe for concurrent access. -func (bf *Filter) Reload(filter *btcwire.MsgFilterLoad) { +func (bf *Filter) Reload(filter *rddwire.MsgFilterLoad) { bf.mtx.Lock() bf.msgFilterLoad = filter bf.mtx.Unlock() @@ -114,7 +114,7 @@ func (bf *Filter) Unload() { // hash returns the bit offset in the bloom filter which corresponds to the // passed data for the given indepedent hash function number. func (bf *Filter) hash(hashNum uint32, data []byte) uint32 { - // bitcoind: 0xfba4c795 chosen as it guarantees a reasonable bit + // reddcoind: 0xfba4c795 chosen as it guarantees a reasonable bit // difference between hashNum values. // // Note that << 3 is equivalent to multiplying by 8, but is faster. @@ -164,11 +164,11 @@ func (bf *Filter) Matches(data []byte) bool { // outpoint and false if it definitely does not. // // This function MUST be called with the filter lock held. -func (bf *Filter) matchesOutPoint(outpoint *btcwire.OutPoint) bool { +func (bf *Filter) matchesOutPoint(outpoint *rddwire.OutPoint) bool { // Serialize - var buf [btcwire.HashSize + 4]byte + var buf [rddwire.HashSize + 4]byte copy(buf[:], outpoint.Hash.Bytes()) - binary.LittleEndian.PutUint32(buf[btcwire.HashSize:], outpoint.Index) + binary.LittleEndian.PutUint32(buf[rddwire.HashSize:], outpoint.Index) return bf.matches(buf[:]) } @@ -177,7 +177,7 @@ func (bf *Filter) matchesOutPoint(outpoint *btcwire.OutPoint) bool { // outpoint and false if it definitely does not. // // This function is safe for concurrent access. -func (bf *Filter) MatchesOutPoint(outpoint *btcwire.OutPoint) bool { +func (bf *Filter) MatchesOutPoint(outpoint *rddwire.OutPoint) bool { bf.mtx.Lock() match := bf.matchesOutPoint(outpoint) bf.mtx.Unlock() @@ -214,10 +214,10 @@ func (bf *Filter) Add(data []byte) { bf.mtx.Unlock() } -// AddShaHash adds the passed btcwire.ShaHash to the Filter. +// AddShaHash adds the passed rddwire.ShaHash to the Filter. // // This function is safe for concurrent access. -func (bf *Filter) AddShaHash(sha *btcwire.ShaHash) { +func (bf *Filter) AddShaHash(sha *rddwire.ShaHash) { bf.mtx.Lock() bf.add(sha.Bytes()) bf.mtx.Unlock() @@ -226,11 +226,11 @@ func (bf *Filter) AddShaHash(sha *btcwire.ShaHash) { // addOutPoint adds the passed transaction outpoint to the bloom filter. // // This function MUST be called with the filter lock held. -func (bf *Filter) addOutPoint(outpoint *btcwire.OutPoint) { +func (bf *Filter) addOutPoint(outpoint *rddwire.OutPoint) { // Serialize - var buf [btcwire.HashSize + 4]byte + var buf [rddwire.HashSize + 4]byte copy(buf[:], outpoint.Hash.Bytes()) - binary.LittleEndian.PutUint32(buf[btcwire.HashSize:], outpoint.Index) + binary.LittleEndian.PutUint32(buf[rddwire.HashSize:], outpoint.Index) bf.add(buf[:]) } @@ -238,7 +238,7 @@ func (bf *Filter) addOutPoint(outpoint *btcwire.OutPoint) { // AddOutPoint adds the passed transaction outpoint to the bloom filter. // // This function is safe for concurrent access. -func (bf *Filter) AddOutPoint(outpoint *btcwire.OutPoint) { +func (bf *Filter) AddOutPoint(outpoint *rddwire.OutPoint) { bf.mtx.Lock() bf.addOutPoint(outpoint) bf.mtx.Unlock() @@ -249,15 +249,15 @@ func (bf *Filter) AddOutPoint(outpoint *btcwire.OutPoint) { // script. // // This function MUST be called with the filter lock held. -func (bf *Filter) maybeAddOutpoint(pkScript []byte, outHash *btcwire.ShaHash, outIdx uint32) { +func (bf *Filter) maybeAddOutpoint(pkScript []byte, outHash *rddwire.ShaHash, outIdx uint32) { switch bf.msgFilterLoad.Flags { - case btcwire.BloomUpdateAll: - outpoint := btcwire.NewOutPoint(outHash, outIdx) + case rddwire.BloomUpdateAll: + outpoint := rddwire.NewOutPoint(outHash, outIdx) bf.addOutPoint(outpoint) - case btcwire.BloomUpdateP2PubkeyOnly: - class := btcscript.GetScriptClass(pkScript) - if class == btcscript.PubKeyTy || class == btcscript.MultiSigTy { - outpoint := btcwire.NewOutPoint(outHash, outIdx) + case rddwire.BloomUpdateP2PubkeyOnly: + class := rddscript.GetScriptClass(pkScript) + if class == rddscript.PubKeyTy || class == rddscript.MultiSigTy { + outpoint := rddwire.NewOutPoint(outHash, outIdx) bf.addOutPoint(outpoint) } } @@ -269,7 +269,7 @@ func (bf *Filter) maybeAddOutpoint(pkScript []byte, outHash *btcwire.ShaHash, ou // 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 *rddutil.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.Sha().Bytes()) @@ -283,7 +283,7 @@ func (bf *Filter) matchTxAndUpdate(tx *btcutil.Tx) bool { // from the client and avoids some potential races that could otherwise // occur. for i, txOut := range tx.MsgTx().TxOut { - pushedData, err := btcscript.PushedData(txOut.PkScript) + pushedData, err := rddscript.PushedData(txOut.PkScript) if err != nil { continue } @@ -314,7 +314,7 @@ func (bf *Filter) matchTxAndUpdate(tx *btcutil.Tx) bool { return true } - pushedData, err := btcscript.PushedData(txin.SignatureScript) + pushedData, err := rddscript.PushedData(txin.SignatureScript) if err != nil { continue } @@ -334,18 +334,18 @@ 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 *rddutil.Tx) bool { bf.mtx.Lock() match := bf.matchTxAndUpdate(tx) bf.mtx.Unlock() return match } -// MsgFilterLoad returns the underlying btcwire.MsgFilterLoad for the bloom +// MsgFilterLoad returns the underlying rddwire.MsgFilterLoad for the bloom // filter. // // This function is safe for concurrent access. -func (bf *Filter) MsgFilterLoad() *btcwire.MsgFilterLoad { +func (bf *Filter) MsgFilterLoad() *rddwire.MsgFilterLoad { bf.mtx.Lock() msg := bf.msgFilterLoad bf.mtx.Unlock() diff --git a/bloom/filter_test.go b/bloom/filter_test.go index 59e2a58d2..fae6da421 100644 --- a/bloom/filter_test.go +++ b/bloom/filter_test.go @@ -9,23 +9,23 @@ import ( "encoding/hex" "testing" - "github.com/conformal/btcutil" - "github.com/conformal/btcutil/bloom" - "github.com/conformal/btcwire" + "github.com/reddcoin-project/rddutil" + "github.com/reddcoin-project/rddutil/bloom" + "github.com/reddcoin-project/rddwire" ) // TestFilterLarge ensures a maximum sized filter can be created. func TestFilterLarge(t *testing.T) { - f := bloom.NewFilter(100000000, 0, 0.01, btcwire.BloomUpdateNone) - if len(f.MsgFilterLoad().Filter) > btcwire.MaxFilterLoadFilterSize { + f := bloom.NewFilter(100000000, 0, 0.01, rddwire.BloomUpdateNone) + if len(f.MsgFilterLoad().Filter) > rddwire.MaxFilterLoadFilterSize { t.Errorf("TestFilterLarge test failed: %d > %d", - len(f.MsgFilterLoad().Filter), btcwire.MaxFilterLoadFilterSize) + len(f.MsgFilterLoad().Filter), rddwire.MaxFilterLoadFilterSize) } } // TestFilterLoad ensures loading and unloading of a filter pass. func TestFilterLoad(t *testing.T) { - merkle := btcwire.MsgFilterLoad{} + merkle := rddwire.MsgFilterLoad{} f := bloom.LoadFilter(&merkle) if !f.IsLoaded() { @@ -55,7 +55,7 @@ func TestFilterInsert(t *testing.T) { {"b9300670b4c5366e95b2699e8b18bc75e5f729c5", true}, } - f := bloom.NewFilter(3, 0, 0.01, btcwire.BloomUpdateAll) + f := bloom.NewFilter(3, 0, 0.01, rddwire.BloomUpdateAll) for i, test := range tests { data, err := hex.DecodeString(test.hex) @@ -82,7 +82,7 @@ func TestFilterInsert(t *testing.T) { } got := bytes.NewBuffer(nil) - err = f.MsgFilterLoad().BtcEncode(got, btcwire.ProtocolVersion) + err = f.MsgFilterLoad().BtcEncode(got, rddwire.ProtocolVersion) if err != nil { t.Errorf("TestFilterInsert BtcDecode failed: %v\n", err) return @@ -109,7 +109,7 @@ func TestFilterInsertWithTweak(t *testing.T) { {"b9300670b4c5366e95b2699e8b18bc75e5f729c5", true}, } - f := bloom.NewFilter(3, 2147483649, 0.01, btcwire.BloomUpdateAll) + f := bloom.NewFilter(3, 2147483649, 0.01, rddwire.BloomUpdateAll) for i, test := range tests { data, err := hex.DecodeString(test.hex) @@ -135,7 +135,7 @@ func TestFilterInsertWithTweak(t *testing.T) { return } got := bytes.NewBuffer(nil) - err = f.MsgFilterLoad().BtcEncode(got, btcwire.ProtocolVersion) + err = f.MsgFilterLoad().BtcEncode(got, rddwire.ProtocolVersion) if err != nil { t.Errorf("TestFilterInsertWithTweak BtcDecode failed: %v\n", err) return @@ -153,15 +153,15 @@ func TestFilterInsertWithTweak(t *testing.T) { func TestFilterInsertKey(t *testing.T) { secret := "5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C" - wif, err := btcutil.DecodeWIF(secret) + wif, err := rddutil.DecodeWIF(secret) if err != nil { t.Errorf("TestFilterInsertKey DecodeWIF failed: %v", err) return } - f := bloom.NewFilter(2, 0, 0.001, btcwire.BloomUpdateAll) + f := bloom.NewFilter(2, 0, 0.001, rddwire.BloomUpdateAll) f.Add(wif.SerializePubKey()) - f.Add(btcutil.Hash160(wif.SerializePubKey())) + f.Add(rddutil.Hash160(wif.SerializePubKey())) want, err := hex.DecodeString("038fc16b080000000000000001") if err != nil { @@ -169,7 +169,7 @@ func TestFilterInsertKey(t *testing.T) { return } got := bytes.NewBuffer(nil) - err = f.MsgFilterLoad().BtcEncode(got, btcwire.ProtocolVersion) + err = f.MsgFilterLoad().BtcEncode(got, rddwire.ProtocolVersion) if err != nil { t.Errorf("TestFilterInsertWithTweak BtcDecode failed: %v\n", err) return @@ -197,7 +197,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch DecodeString failure: %v", err) return } - tx, err := btcutil.NewTxFromBytes(strBytes) + tx, err := rddutil.NewTxFromBytes(strBytes) if err != nil { t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err) return @@ -232,15 +232,15 @@ 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 := rddutil.NewTxFromBytes(spendingTxBytes) if err != nil { t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err) return } - f := bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f := bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr := "b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b" - sha, err := btcwire.NewShaHashFromStr(inputStr) + sha, err := rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterBloomMatch NewShaHashFromStr failed: %v\n", err) return @@ -250,7 +250,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch didn't match sha %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "6bff7fcd4f8565ef406dd5d63d4ff94f318fe82027fd4dc451b04474019f74b4" shaBytes, err := hex.DecodeString(inputStr) if err != nil { @@ -262,7 +262,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch didn't match sha %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "30450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065" + "f37b8a4af6141022100a8e160b856c2d43d27d8fba71e5aef6405b8643" + "ac4cb7cb3c462aced7f14711a01" @@ -276,7 +276,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch didn't match input signature %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95" + "c9a40ac5eeef87e10a5cd336c19a84565f80fa6c547957b7700ff4dfbdefe" + "76036c339" @@ -290,7 +290,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch didn't match input pubkey %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "04943fdd508053c75000106d3bc6e2754dbcff19" shaBytes, err = hex.DecodeString(inputStr) if err != nil { @@ -305,7 +305,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch spendingTx didn't match output address %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "a266436d2965547608b9e15d9032a7b9d64fa431" shaBytes, err = hex.DecodeString(inputStr) if err != nil { @@ -317,22 +317,22 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch didn't match output address %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b" - sha, err = btcwire.NewShaHashFromStr(inputStr) + sha, err = rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterBloomMatch NewShaHashFromStr failed: %v\n", err) return } - outpoint := btcwire.NewOutPoint(sha, 0) + outpoint := rddwire.NewOutPoint(sha, 0) f.AddOutPoint(outpoint) if !f.MatchTxAndUpdate(tx) { t.Errorf("TestFilterBloomMatch didn't match outpoint %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "00000009e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436" - sha, err = btcwire.NewShaHashFromStr(inputStr) + sha, err = rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterBloomMatch NewShaHashFromStr failed: %v\n", err) return @@ -342,7 +342,7 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch matched sha %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "0000006d2965547608b9e15d9032a7b9d64fa431" shaBytes, err = hex.DecodeString(inputStr) if err != nil { @@ -354,27 +354,27 @@ func TestFilterBloomMatch(t *testing.T) { t.Errorf("TestFilterBloomMatch matched address %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b" - sha, err = btcwire.NewShaHashFromStr(inputStr) + sha, err = rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterBloomMatch NewShaHashFromStr failed: %v\n", err) return } - outpoint = btcwire.NewOutPoint(sha, 1) + outpoint = rddwire.NewOutPoint(sha, 1) f.AddOutPoint(outpoint) if f.MatchTxAndUpdate(tx) { t.Errorf("TestFilterBloomMatch matched outpoint %s", inputStr) } - f = bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f = bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr = "000000d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b" - sha, err = btcwire.NewShaHashFromStr(inputStr) + sha, err = rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterBloomMatch NewShaHashFromStr failed: %v\n", err) return } - outpoint = btcwire.NewOutPoint(sha, 0) + outpoint = rddwire.NewOutPoint(sha, 0) f.AddOutPoint(outpoint) if f.MatchTxAndUpdate(tx) { t.Errorf("TestFilterBloomMatch matched outpoint %s", inputStr) @@ -382,7 +382,7 @@ func TestFilterBloomMatch(t *testing.T) { } func TestFilterInsertUpdateNone(t *testing.T) { - f := bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateNone) + f := bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateNone) // Add the generation pubkey inputStr := "04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c" + @@ -405,12 +405,12 @@ func TestFilterInsertUpdateNone(t *testing.T) { f.Add(inputBytes) inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b" - sha, err := btcwire.NewShaHashFromStr(inputStr) + sha, err := rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterInsertUpdateNone NewShaHashFromStr failed: %v", err) return } - outpoint := btcwire.NewOutPoint(sha, 0) + outpoint := rddwire.NewOutPoint(sha, 0) if f.MatchesOutPoint(outpoint) { t.Errorf("TestFilterInsertUpdateNone matched outpoint %s", inputStr) @@ -418,12 +418,12 @@ func TestFilterInsertUpdateNone(t *testing.T) { } inputStr = "02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041" - sha, err = btcwire.NewShaHashFromStr(inputStr) + sha, err = rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestFilterInsertUpdateNone NewShaHashFromStr failed: %v", err) return } - outpoint = btcwire.NewOutPoint(sha, 0) + outpoint = rddwire.NewOutPoint(sha, 0) if f.MatchesOutPoint(outpoint) { t.Errorf("TestFilterInsertUpdateNone matched outpoint %s", inputStr) @@ -524,13 +524,13 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) { t.Errorf("TestFilterInsertP2PubKeyOnly DecodeString failed: %v", err) return } - block, err := btcutil.NewBlockFromBytes(blockBytes) + block, err := rddutil.NewBlockFromBytes(blockBytes) if err != nil { t.Errorf("TestFilterInsertP2PubKeyOnly NewBlockFromBytes failed: %v", err) return } - f := bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateP2PubkeyOnly) + f := bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateP2PubkeyOnly) // Generation pubkey inputStr := "04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c" + @@ -557,12 +557,12 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) { // We should match the generation pubkey inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b" - sha, err := btcwire.NewShaHashFromStr(inputStr) + sha, err := rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestMerkleBlockP2PubKeyOnly NewShaHashFromStr failed: %v", err) return } - outpoint := btcwire.NewOutPoint(sha, 0) + outpoint := rddwire.NewOutPoint(sha, 0) if !f.MatchesOutPoint(outpoint) { t.Errorf("TestMerkleBlockP2PubKeyOnly didn't match the generation "+ "outpoint %s", inputStr) @@ -571,12 +571,12 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) { // We should not match the 4th transaction, which is not p2pk inputStr = "02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041" - sha, err = btcwire.NewShaHashFromStr(inputStr) + sha, err = rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestMerkleBlockP2PubKeyOnly NewShaHashFromStr failed: %v", err) return } - outpoint = btcwire.NewOutPoint(sha, 0) + outpoint = rddwire.NewOutPoint(sha, 0) if f.MatchesOutPoint(outpoint) { t.Errorf("TestMerkleBlockP2PubKeyOnly matched outpoint %s", inputStr) return @@ -584,7 +584,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) { } func TestFilterReload(t *testing.T) { - f := bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f := bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) bFilter := bloom.LoadFilter(f.MsgFilterLoad()) if bFilter.MsgFilterLoad() == nil { diff --git a/bloom/merkleblock.go b/bloom/merkleblock.go index 7432248e7..b44f724f6 100644 --- a/bloom/merkleblock.go +++ b/bloom/merkleblock.go @@ -5,17 +5,17 @@ package bloom import ( - "github.com/conformal/btcchain" - "github.com/conformal/btcutil" - "github.com/conformal/btcwire" + "github.com/reddcoin-project/rddchain" + "github.com/reddcoin-project/rddutil" + "github.com/reddcoin-project/rddwire" ) // merkleBlock is used to house intermediate information needed to generate a -// btcwire.MsgMerkleBlock according to a filter. +// rddwire.MsgMerkleBlock according to a filter. type merkleBlock struct { numTx uint32 - allHashes []*btcwire.ShaHash - finalHashes []*btcwire.ShaHash + allHashes []*rddwire.ShaHash + finalHashes []*rddwire.ShaHash matchedBits []byte bits []byte } @@ -28,19 +28,19 @@ func (m *merkleBlock) calcTreeWidth(height uint32) uint32 { // calcHash returns the hash for a sub-tree given a depth-first height and // node position. -func (m *merkleBlock) calcHash(height, pos uint32) *btcwire.ShaHash { +func (m *merkleBlock) calcHash(height, pos uint32) *rddwire.ShaHash { if height == 0 { return m.allHashes[pos] } - var right *btcwire.ShaHash + var right *rddwire.ShaHash left := m.calcHash(height-1, pos*2) if pos*2+1 < m.calcTreeWidth(height-1) { right = m.calcHash(height-1, pos*2+1) } else { right = left } - return btcchain.HashMerkleBranches(left, right) + return rddchain.HashMerkleBranches(left, right) } // traverseAndBuild builds a partial merkle tree using a recursive depth-first @@ -76,18 +76,18 @@ func (m *merkleBlock) traverseAndBuild(height, pos uint32) { } } -// NewMerkleBlock returns a new *btcwire.MsgMerkleBlock and an array of the matched +// NewMerkleBlock returns a new *rddwire.MsgMerkleBlock and an array of the matched // transaction hashes based on the passed block and filter. -func NewMerkleBlock(block *btcutil.Block, filter *Filter) (*btcwire.MsgMerkleBlock, []*btcwire.ShaHash) { +func NewMerkleBlock(block *rddutil.Block, filter *Filter) (*rddwire.MsgMerkleBlock, []*rddwire.ShaHash) { numTx := uint32(len(block.Transactions())) mBlock := merkleBlock{ numTx: numTx, - allHashes: make([]*btcwire.ShaHash, 0, numTx), + allHashes: make([]*rddwire.ShaHash, 0, numTx), matchedBits: make([]byte, 0, numTx), } // Find and keep track of any transactions that match the filter. - var matchedHashes []*btcwire.ShaHash + var matchedHashes []*rddwire.ShaHash for _, tx := range block.Transactions() { if filter.MatchTxAndUpdate(tx) { mBlock.matchedBits = append(mBlock.matchedBits, 0x01) @@ -108,10 +108,10 @@ func NewMerkleBlock(block *btcutil.Block, filter *Filter) (*btcwire.MsgMerkleBlo mBlock.traverseAndBuild(height, 0) // Create and return the merkle block. - msgMerkleBlock := btcwire.MsgMerkleBlock{ + msgMerkleBlock := rddwire.MsgMerkleBlock{ Header: block.MsgBlock().Header, Transactions: uint32(mBlock.numTx), - Hashes: make([]*btcwire.ShaHash, 0, len(mBlock.finalHashes)), + Hashes: make([]*rddwire.ShaHash, 0, len(mBlock.finalHashes)), Flags: make([]byte, (len(mBlock.bits)+7)/8), } for _, sha := range mBlock.finalHashes { diff --git a/bloom/merkleblock_test.go b/bloom/merkleblock_test.go index fbb529e5c..3b5855a5d 100644 --- a/bloom/merkleblock_test.go +++ b/bloom/merkleblock_test.go @@ -9,9 +9,9 @@ import ( "encoding/hex" "testing" - "github.com/conformal/btcutil" - "github.com/conformal/btcutil/bloom" - "github.com/conformal/btcwire" + "github.com/reddcoin-project/rddutil" + "github.com/reddcoin-project/rddutil/bloom" + "github.com/reddcoin-project/rddwire" ) func TestMerkleBlock3(t *testing.T) { @@ -28,16 +28,16 @@ func TestMerkleBlock3(t *testing.T) { t.Errorf("TestMerkleBlock3 DecodeString failed: %v", err) return } - blk, err := btcutil.NewBlockFromBytes(blockBytes) + blk, err := rddutil.NewBlockFromBytes(blockBytes) if err != nil { t.Errorf("TestMerkleBlock3 NewBlockFromBytes failed: %v", err) return } - f := bloom.NewFilter(10, 0, 0.000001, btcwire.BloomUpdateAll) + f := bloom.NewFilter(10, 0, 0.000001, rddwire.BloomUpdateAll) inputStr := "63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669c00cb5" - sha, err := btcwire.NewShaHashFromStr(inputStr) + sha, err := rddwire.NewShaHashFromStr(inputStr) if err != nil { t.Errorf("TestMerkleBlock3 NewShaHashFromStr failed: %v", err) return @@ -59,7 +59,7 @@ func TestMerkleBlock3(t *testing.T) { } got := bytes.NewBuffer(nil) - err = mBlock.BtcEncode(got, btcwire.ProtocolVersion) + err = mBlock.BtcEncode(got, rddwire.ProtocolVersion) if err != nil { t.Errorf("TestMerkleBlock3 BtcEncode failed: %v", err) return diff --git a/bloom/murmurhash3_test.go b/bloom/murmurhash3_test.go index fd0eaf062..20f198451 100644 --- a/bloom/murmurhash3_test.go +++ b/bloom/murmurhash3_test.go @@ -7,7 +7,7 @@ package bloom_test import ( "testing" - "github.com/conformal/btcutil/bloom" + "github.com/reddcoin-project/rddutil/bloom" ) // TestMurmurHash3 ensure the MurmurHash3 function produces the correct hash diff --git a/bloom/test_coverage.txt b/bloom/test_coverage.txt index e503f26fe..6eea951a0 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/reddcoin-project/rddutil/bloom/murmurhash3.go MurmurHash3 100.00% (31/31) +github.com/reddcoin-project/rddutil/bloom/merkleblock.go NewMerkleBlock 100.00% (19/19) +github.com/reddcoin-project/rddutil/bloom/merkleblock.go merkleBlock.traverseAndBuild 100.00% (10/10) +github.com/reddcoin-project/rddutil/bloom/merkleblock.go merkleBlock.calcHash 100.00% (8/8) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.maybeAddOutpoint 100.00% (7/7) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.addOutPoint 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.IsLoaded 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.MsgFilterLoad 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.matchesOutPoint 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.MatchesOutPoint 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.MatchTxAndUpdate 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.Matches 100.00% (4/4) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.Add 100.00% (3/3) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.Reload 100.00% (3/3) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.Unload 100.00% (3/3) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.AddShaHash 100.00% (3/3) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.AddOutPoint 100.00% (3/3) +github.com/reddcoin-project/rddutil/bloom/filter.go minUint32 100.00% (3/3) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.hash 100.00% (2/2) +github.com/reddcoin-project/rddutil/bloom/merkleblock.go merkleBlock.calcTreeWidth 100.00% (1/1) +github.com/reddcoin-project/rddutil/bloom/filter.go LoadFilter 100.00% (1/1) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.matchTxAndUpdate 91.30% (21/23) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.matches 85.71% (6/7) +github.com/reddcoin-project/rddutil/bloom/filter.go NewFilter 81.82% (9/11) +github.com/reddcoin-project/rddutil/bloom/filter.go Filter.add 80.00% (4/5) +github.com/reddcoin-project/rddutil/bloom ---------------------------- 96.49% (165/171) diff --git a/coinset/README.md b/coinset/README.md index d31d3619e..a83576001 100644 --- a/coinset/README.md +++ b/coinset/README.md @@ -14,21 +14,21 @@ report. Package coinset is licensed under the liberal ISC license. ## Documentation -[![GoDoc](https://godoc.org/github.com/conformal/btcutil/coinset?status.png)] -(http://godoc.org/github.com/conformal/btcutil/coinset) +[![GoDoc](https://godoc.org/github.com/reddcoin-project/rddutil/coinset?status.png)] +(http://godoc.org/github.com/reddcoin-project/rddutil/coinset) Full `go doc` style documentation for the project can be viewed online without installing this package by using the GoDoc site here: -http://godoc.org/github.com/conformal/btcutil/coinset +http://godoc.org/github.com/reddcoin-project/rddutil/coinset You can also view the documentation locally once the package is installed with the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to -http://localhost:6060/pkg/github.com/conformal/btcutil/coinset +http://localhost:6060/pkg/github.com/reddcoin-project/rddutil/coinset ## Installation ```bash -$ go get github.com/conformal/btcutil/coinset +$ go get github.com/reddcoin-project/rddutil/coinset ``` ## Usage diff --git a/coinset/coins.go b/coinset/coins.go index 0012bda62..59c05e7d4 100644 --- a/coinset/coins.go +++ b/coinset/coins.go @@ -377,7 +377,7 @@ func (c *SimpleCoin) Value() rddutil.Amount { // // This can be used to determine what type of script the Coin uses // and extract standard addresses if possible using -// btcscript.ExtractPkScriptAddrs for example. +// rddscript.ExtractPkScriptAddrs for example. func (c *SimpleCoin) PkScript() []byte { return c.txOut().PkScript } diff --git a/doc.go b/doc.go index 7b49269cb..c628bd2b0 100644 --- a/doc.go +++ b/doc.go @@ -3,18 +3,18 @@ // license that can be found in the LICENSE file. /* -Package rddutil provides bitcoin-specific convenience functions and types. +Package rddutil provides Reddcoin-specific convenience functions and types. Block Overview -A Block defines a bitcoin block that provides easier and more efficient +A Block defines a Reddcoin block that provides easier and more efficient manipulation of raw wire protocol blocks. It also memoizes hashes for the block and its transactions on their first access so subsequent accesses don't have to repeat the relatively expensive hashing operations. Tx Overview -A Tx defines a bitcoin transaction that provides more efficient manipulation of +A Tx defines a Reddcoin transaction that provides more efficient manipulation of raw wire protocol transactions. It memoizes the hash for the transaction on its first access so subsequent accesses don't have to repeat the relatively expensive hashing operations. diff --git a/hdkeychain/README.md b/hdkeychain/README.md index 2c22b242b..e5d71cd1f 100644 --- a/hdkeychain/README.md +++ b/hdkeychain/README.md @@ -4,7 +4,7 @@ hdkeychain [![Build Status](https://travis-ci.org/conformal/btcutil.png?branch=master)] (https://travis-ci.org/conformal/btcutil) -Package hdkeychain provides an API for bitcoin hierarchical deterministic +Package hdkeychain provides an API for Reddcoin hierarchical deterministic extended keys (BIP0032). A comprehensive suite of tests is provided to ensure proper functionality. See @@ -21,9 +21,9 @@ report. Package hdkeychain is licensed under the liberal ISC license. - Support for multi-layer derivation - Easy serialization and deserialization for both private and public extended keys -- Support for custom networks by registering them with btcnet -- Obtaining the underlying EC pubkeys, EC privkeys, and associated bitcoin - addresses ties in seamlessly with existing btcec and btcutil types which +- Support for custom networks by registering them with rddnet +- Obtaining the underlying EC pubkeys, EC privkeys, and associated Reddcoin + addresses ties in seamlessly with existing btcec and rddutil 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 @@ -37,35 +37,35 @@ report. Package hdkeychain is licensed under the liberal ISC license. ## Documentation -[![GoDoc](https://godoc.org/github.com/conformal/btcutil/hdkeychain?status.png)] -(http://godoc.org/github.com/conformal/btcutil/hdkeychain) +[![GoDoc](https://godoc.org/github.com/reddcoin-project/rddutil/hdkeychain?status.png)] +(http://godoc.org/github.com/reddcoin-project/rddutil/hdkeychain) Full `go doc` style documentation for the project can be viewed online without installing this package by using the GoDoc site here: -http://godoc.org/github.com/conformal/btcutil/hdkeychain +http://godoc.org/github.com/reddcoin-project/rddutil/hdkeychain You can also view the documentation locally once the package is installed with the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to -http://localhost:6060/pkg/github.com/conformal/btcutil/hdkeychain +http://localhost:6060/pkg/github.com/reddcoin-project/rddutil/hdkeychain ## Installation ```bash -$ go get github.com/conformal/btcutil/hdkeychain +$ go get github.com/reddcoin-project/rddutil/hdkeychain ``` ## Examples * [NewMaster Example] - (http://godoc.org/github.com/conformal/btcutil/hdkeychain#example-NewMaster) + (http://godoc.org/github.com/reddcoin-project/rddutil/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/conformal/btcutil/hdkeychain#example-package--DefaultWalletLayout) + (http://godoc.org/github.com/reddcoin-project/rddutil/hdkeychain#example-package--DefaultWalletLayout) Demonstrates the default hierarchical deterministic wallet layout as described in BIP0032. * [Audits Use Case Example] - (http://godoc.org/github.com/conformal/btcutil/hdkeychain#example-package--Audits) + (http://godoc.org/github.com/reddcoin-project/rddutil/hdkeychain#example-package--Audits) Demonstrates the audits use case in BIP0032. ## License diff --git a/hdkeychain/bench_test.go b/hdkeychain/bench_test.go index 521818a58..79812d594 100644 --- a/hdkeychain/bench_test.go +++ b/hdkeychain/bench_test.go @@ -7,7 +7,7 @@ package hdkeychain_test import ( "testing" - "github.com/conformal/btcutil/hdkeychain" + "github.com/reddcoin-project/rddutil/hdkeychain" ) // bip0032MasterPriv1 is the master private extended key from the first set of diff --git a/hdkeychain/doc.go b/hdkeychain/doc.go index d9c83c268..42243c634 100644 --- a/hdkeychain/doc.go +++ b/hdkeychain/doc.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. /* -Package hdkeychain provides an API for bitcoin hierarchical deterministic +Package hdkeychain provides an API for Reddcoin hierarchical deterministic extended keys (BIP0032). Overview @@ -76,7 +76,7 @@ looks like the following: Network -Extended keys are much like normal Bitcoin addresses in that they have version +Extended keys are much like normal Reddcoin addresses in that they have version bytes which tie them to a specific network. The SetNet and IsForNet functions are provided to set and determinine which network an extended key is associated with. diff --git a/hdkeychain/example_test.go b/hdkeychain/example_test.go index 44c27afc7..6864345a7 100644 --- a/hdkeychain/example_test.go +++ b/hdkeychain/example_test.go @@ -7,8 +7,8 @@ package hdkeychain_test import ( "fmt" - "github.com/conformal/btcnet" - "github.com/conformal/btcutil/hdkeychain" + "github.com/reddcoin-project/rddnet" + "github.com/reddcoin-project/rddutil/hdkeychain" ) // This example demonstrates how to generate a cryptographically random seed @@ -117,13 +117,13 @@ func Example_defaultWalletLayout() { } // Get and show the address associated with the extended keys for the - // main bitcoin network. - acct0ExtAddr, err := acct0Ext10.Address(&btcnet.MainNetParams) + // main Reddcoin network. + acct0ExtAddr, err := acct0Ext10.Address(&rddnet.MainNetParams) if err != nil { fmt.Println(err) return } - acct0IntAddr, err := acct0Int0.Address(&btcnet.MainNetParams) + acct0IntAddr, err := acct0Int0.Address(&rddnet.MainNetParams) if err != nil { fmt.Println(err) return diff --git a/hdkeychain/extendedkey.go b/hdkeychain/extendedkey.go index 01d3d49b8..dfc2e45d6 100644 --- a/hdkeychain/extendedkey.go +++ b/hdkeychain/extendedkey.go @@ -19,9 +19,9 @@ import ( "math/big" "github.com/conformal/btcec" - "github.com/conformal/btcnet" - "github.com/conformal/btcutil" - "github.com/conformal/btcwire" + "github.com/reddcoin-project/rddnet" + "github.com/reddcoin-project/rddutil" + "github.com/reddcoin-project/rddwire" ) const ( @@ -91,7 +91,7 @@ var ( // masterKey is the master key used along with a random seed used to generate // the master node in the hierarchical tree. -var masterKey = []byte("Bitcoin seed") +var masterKey = []byte("Reddcoin seed") // ExtendedKey houses all the information needed to support a hierarchical // deterministic extended key. See the package overview documentation for @@ -300,7 +300,7 @@ func (k *ExtendedKey) Child(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 := rddutil.Hash160(k.pubKeyBytes())[:4] return newExtendedKey(k.version, childKey, childChainCode, parentFP, k.depth+1, i, isPrivate), nil } @@ -320,7 +320,7 @@ func (k *ExtendedKey) Neuter() (*ExtendedKey, error) { } // Get the associated public extended key version bytes. - version, err := btcnet.HDPrivateKeyToPublicKeyID(k.version) + version, err := rddnet.HDPrivateKeyToPublicKeyID(k.version) if err != nil { return nil, err } @@ -351,11 +351,11 @@ func (k *ExtendedKey) ECPrivKey() (*btcec.PrivateKey, error) { return privKey, nil } -// Address converts the extended key to a standard bitcoin pay-to-pubkey-hash +// Address converts the extended key to a standard Reddcoin pay-to-pubkey-hash // address for the passed network. -func (k *ExtendedKey) Address(net *btcnet.Params) (*btcutil.AddressPubKeyHash, error) { - pkHash := btcutil.Hash160(k.pubKeyBytes()) - return btcutil.NewAddressPubKeyHash(pkHash, net) +func (k *ExtendedKey) Address(net *rddnet.Params) (*rddutil.AddressPubKeyHash, error) { + pkHash := rddutil.Hash160(k.pubKeyBytes()) + return rddutil.NewAddressPubKeyHash(pkHash, net) } // String returns the extended key as a human-readable base58-encoded string. @@ -384,21 +384,21 @@ func (k *ExtendedKey) String() string { serializedBytes = append(serializedBytes, k.pubKeyBytes()...) } - checkSum := btcwire.DoubleSha256(serializedBytes)[:4] + checkSum := rddwire.DoubleSha256(serializedBytes)[:4] serializedBytes = append(serializedBytes, checkSum...) - return btcutil.Base58Encode(serializedBytes) + return rddutil.Base58Encode(serializedBytes) } // IsForNet returns whether or not the extended key is associated with the -// passed bitcoin network. -func (k *ExtendedKey) IsForNet(net *btcnet.Params) bool { +// passed Reddcoin network. +func (k *ExtendedKey) IsForNet(net *rddnet.Params) bool { return bytes.Equal(k.version, net.HDPrivateKeyID[:]) || bytes.Equal(k.version, net.HDPublicKeyID[:]) } // SetNet associates the extended key, and any child keys yet to be derived from // it, with the passed network. -func (k *ExtendedKey) SetNet(net *btcnet.Params) { +func (k *ExtendedKey) SetNet(net *rddnet.Params) { if k.isPrivate { k.version = net.HDPrivateKeyID[:] } else { @@ -446,7 +446,7 @@ func NewMaster(seed []byte) (*ExtendedKey, error) { } // First take the HMAC-SHA512 of the master key and the seed data: - // I = HMAC-SHA512(Key = "Bitcoin seed", Data = S) + // I = HMAC-SHA512(Key = "Reddcoin seed", Data = S) hmac512 := hmac.New(sha512.New, masterKey) hmac512.Write(seed) lr := hmac512.Sum(nil) @@ -464,7 +464,7 @@ func NewMaster(seed []byte) (*ExtendedKey, error) { } parentFP := []byte{0x00, 0x00, 0x00, 0x00} - return newExtendedKey(btcnet.MainNetParams.HDPrivateKeyID[:], secretKey, + return newExtendedKey(rddnet.MainNetParams.HDPrivateKeyID[:], secretKey, chainCode, parentFP, 0, 0, true), nil } @@ -473,7 +473,7 @@ func NewMaster(seed []byte) (*ExtendedKey, error) { func NewKeyFromString(key string) (*ExtendedKey, error) { // The base58-decoded extended key must consist of a serialized payload // plus an additional 4 bytes for the checksum. - decoded := btcutil.Base58Decode(key) + decoded := rddutil.Base58Decode(key) if len(decoded) != serializedKeyLen+4 { return nil, ErrInvalidKeyLen } @@ -485,7 +485,7 @@ func NewKeyFromString(key string) (*ExtendedKey, error) { // Split the payload and checksum up and ensure the checksum matches. payload := decoded[:len(decoded)-4] checkSum := decoded[len(decoded)-4:] - expectedCheckSum := btcwire.DoubleSha256(payload)[:4] + expectedCheckSum := rddwire.DoubleSha256(payload)[:4] if !bytes.Equal(checkSum, expectedCheckSum) { return nil, ErrBadChecksum } diff --git a/hdkeychain/extendedkey_test.go b/hdkeychain/extendedkey_test.go index d106bb50a..2ed9aa5a4 100644 --- a/hdkeychain/extendedkey_test.go +++ b/hdkeychain/extendedkey_test.go @@ -15,8 +15,8 @@ import ( "reflect" "testing" - "github.com/conformal/btcnet" - "github.com/conformal/btcutil/hdkeychain" + "github.com/reddcoin-project/rddnet" + "github.com/reddcoin-project/rddutil/hdkeychain" ) // TestBIP0032Vectors tests the vectors provided by [BIP32] to ensure the @@ -432,7 +432,7 @@ func TestExtendedKeyAPI(t *testing.T) { continue } - addr, err := key.Address(&btcnet.MainNetParams) + addr, err := key.Address(&rddnet.MainNetParams) if err != nil { t.Errorf("Address #%d (%s): unexpected error: %v", i, test.name, err) @@ -452,8 +452,8 @@ func TestNet(t *testing.T) { tests := []struct { name string key string - origNet *btcnet.Params - newNet *btcnet.Params + origNet *rddnet.Params + newNet *rddnet.Params newPriv string newPub string isPrivate bool @@ -462,8 +462,8 @@ func TestNet(t *testing.T) { { name: "mainnet -> simnet", key: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", - origNet: &btcnet.MainNetParams, - newNet: &btcnet.SimNetParams, + origNet: &rddnet.MainNetParams, + newNet: &rddnet.SimNetParams, newPriv: "sprv8Erh3X3hFeKunvVdAGQQtambRPapECWiTDtvsTGdyrhzhbYgnSZajRRWbihzvq4AM4ivm6uso31VfKaukwJJUs3GYihXP8ebhMb3F2AHu3P", newPub: "spub4Tr3T2ab61tD1Qa6GHwRFiiKyRRJdfEZpSpXfqgFYCEyaPsqKysqHDjzSzMJSiUEGbcsG3w2SLMoTqn44B8x6u3MLRRkYfACTUBnHK79THk", isPrivate: true, @@ -471,8 +471,8 @@ func TestNet(t *testing.T) { { name: "simnet -> mainnet", key: "sprv8Erh3X3hFeKunvVdAGQQtambRPapECWiTDtvsTGdyrhzhbYgnSZajRRWbihzvq4AM4ivm6uso31VfKaukwJJUs3GYihXP8ebhMb3F2AHu3P", - origNet: &btcnet.SimNetParams, - newNet: &btcnet.MainNetParams, + origNet: &rddnet.SimNetParams, + newNet: &rddnet.MainNetParams, newPriv: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", isPrivate: true, @@ -480,8 +480,8 @@ func TestNet(t *testing.T) { { name: "mainnet -> regtest", key: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", - origNet: &btcnet.MainNetParams, - newNet: &btcnet.RegressionNetParams, + origNet: &rddnet.MainNetParams, + newNet: &rddnet.RegressionNetParams, newPriv: "tprv8ZgxMBicQKsPeDgjzdC36fs6bMjGApWDNLR9erAXMs5skhMv36j9MV5ecvfavji5khqjWaWSFhN3YcCUUdiKH6isR4Pwy3U5y5egddBr16m", newPub: "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp", isPrivate: true, @@ -489,8 +489,8 @@ func TestNet(t *testing.T) { { name: "regtest -> mainnet", key: "tprv8ZgxMBicQKsPeDgjzdC36fs6bMjGApWDNLR9erAXMs5skhMv36j9MV5ecvfavji5khqjWaWSFhN3YcCUUdiKH6isR4Pwy3U5y5egddBr16m", - origNet: &btcnet.RegressionNetParams, - newNet: &btcnet.MainNetParams, + origNet: &rddnet.RegressionNetParams, + newNet: &rddnet.MainNetParams, newPriv: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", isPrivate: true, @@ -500,32 +500,32 @@ func TestNet(t *testing.T) { { name: "mainnet -> simnet", key: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", - origNet: &btcnet.MainNetParams, - newNet: &btcnet.SimNetParams, + origNet: &rddnet.MainNetParams, + newNet: &rddnet.SimNetParams, newPub: "spub4Tr3T2ab61tD1Qa6GHwRFiiKyRRJdfEZpSpXfqgFYCEyaPsqKysqHDjzSzMJSiUEGbcsG3w2SLMoTqn44B8x6u3MLRRkYfACTUBnHK79THk", isPrivate: false, }, { name: "simnet -> mainnet", key: "spub4Tr3T2ab61tD1Qa6GHwRFiiKyRRJdfEZpSpXfqgFYCEyaPsqKysqHDjzSzMJSiUEGbcsG3w2SLMoTqn44B8x6u3MLRRkYfACTUBnHK79THk", - origNet: &btcnet.SimNetParams, - newNet: &btcnet.MainNetParams, + origNet: &rddnet.SimNetParams, + newNet: &rddnet.MainNetParams, newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", isPrivate: false, }, { name: "mainnet -> regtest", key: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", - origNet: &btcnet.MainNetParams, - newNet: &btcnet.RegressionNetParams, + origNet: &rddnet.MainNetParams, + newNet: &rddnet.RegressionNetParams, newPub: "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp", isPrivate: false, }, { name: "regtest -> mainnet", key: "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp", - origNet: &btcnet.RegressionNetParams, - newNet: &btcnet.MainNetParams, + origNet: &rddnet.RegressionNetParams, + newNet: &rddnet.MainNetParams, newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", isPrivate: false, }, @@ -650,7 +650,7 @@ func TestErrors(t *testing.T) { key: "xbad4LfUL9eKmA66w2GJdVMqhvDmYGJpTGjWRAtjHqoUY17sGaymoMV9Cm3ocn9Ud6Hh2vLFVC7KSKCRVVrqc6dsEdsTjRV1WUmkK85YEUujAPX", err: nil, neuter: true, - neuterErr: btcnet.ErrUnknownHDKeyID, + neuterErr: rddnet.ErrUnknownHDKeyID, }, } @@ -743,7 +743,7 @@ func TestZero(t *testing.T) { } wantAddr := "1HT7xU2Ngenf7D4yocz2SAcnNLW7rK8d4E" - addr, err := key.Address(&btcnet.MainNetParams) + addr, err := key.Address(&rddnet.MainNetParams) if err != nil { t.Errorf("Addres s #%d (%s): unexpected error: %v", i, testName, err) diff --git a/internal_test.go b/internal_test.go index 820c79892..0e7f65347 100644 --- a/internal_test.go +++ b/internal_test.go @@ -65,7 +65,7 @@ func TstAddressPubKey(serializedPubKey []byte, pubKeyFormat PubKeyFormat, } // TstAddressSAddr returns the expected script address bytes for -// P2PKH and P2SH bitcoin addresses. +// P2PKH and P2SH Reddcoin addresses. func TstAddressSAddr(addr string) []byte { decoded := Base58Decode(addr) return decoded[1 : 1+ripemd160.Size] diff --git a/tx.go b/tx.go index 5e5349b10..ec64df527 100644 --- a/tx.go +++ b/tx.go @@ -16,7 +16,7 @@ import ( // yet. const TxIndexUnknown = -1 -// Tx defines a bitcoin transaction that provides easier and more efficient +// Tx defines a Reddcoin transaction that provides easier and more efficient // manipulation of raw transactions. It also memoizes the hash for the // transaction on its first access so subsequent accesses don't have to repeat // the relatively expensive hashing operations. @@ -61,7 +61,7 @@ func (t *Tx) SetIndex(index int) { t.txIndex = index } -// NewTx returns a new instance of a bitcoin transaction given an underlying +// NewTx returns a new instance of a Reddcoin transaction given an underlying // rddwire.MsgTx. See Tx. func NewTx(msgTx *rddwire.MsgTx) *Tx { return &Tx{ @@ -70,14 +70,14 @@ func NewTx(msgTx *rddwire.MsgTx) *Tx { } } -// NewTxFromBytes returns a new instance of a bitcoin transaction given the +// NewTxFromBytes returns a new instance of a Reddcoin transaction given the // serialized bytes. See Tx. func NewTxFromBytes(serializedTx []byte) (*Tx, error) { br := bytes.NewReader(serializedTx) return NewTxFromReader(br) } -// NewTxFromReader returns a new instance of a bitcoin transaction given a +// NewTxFromReader returns a new instance of a Reddcoin transaction given a // Reader to deserialize the transaction. See Tx. func NewTxFromReader(r io.Reader) (*Tx, error) { // Deserialize the bytes into a MsgTx. diff --git a/wif.go b/wif.go index 08e6eeed1..e28f93afb 100644 --- a/wif.go +++ b/wif.go @@ -39,7 +39,7 @@ type WIF struct { // uncompressed (65-byte) one. CompressPubKey bool - // netID is the bitcoin network identifier byte used when + // netID is the Reddcoin network identifier byte used when // WIF encoding the private key. netID byte } @@ -56,7 +56,7 @@ func NewWIF(privKey *btcec.PrivateKey, net *rddnet.Params, compress bool) (*WIF, } // IsForNet returns whether or not the decoded WIF structure is associated -// with the passed bitcoin network. +// with the passed Reddcoin network. func (w *WIF) IsForNet(net *rddnet.Params) bool { return w.netID == net.PrivateKeyID }