var result []*CtrlProgram
for _, cp := range cps {
- if cp.Address == "" || chainkd.CompareTwoXPubs(cp.XPubs, xpubs) != 0 {
+ if cp.Address == "" || chainkd.IsXpubsEqual(cp.XPubs, xpubs) {
continue
}
result = append(result, cp)
package chainkd
import (
+ "bytes"
"crypto/hmac"
"crypto/rand"
"crypto/sha512"
"github.com/bytom/crypto/ed25519"
"github.com/bytom/crypto/ed25519/ecmath"
- "bytes"
)
type (
XPub [64]byte
)
-// CompareTwoXPubs
-func CompareTwoXPubs(a, b []XPub) int {
+// IsXpubsEqual
+func IsXpubsEqual(a, b []XPub) bool {
for i, xpub := range a {
result := bytes.Compare(xpub[:], b[i][:])
if result != 0 {
- return result
+ return false
}
}
- return 0
+ return true
}
// NewXPrv takes a source of random bytes and produces a new XPrv.