From 7d430448a9e74a3b41e1b914e02ac7473bcbbc65 Mon Sep 17 00:00:00 2001 From: Yongfeng LI Date: Tue, 17 Apr 2018 14:31:36 +0800 Subject: [PATCH] take place CompareTwoXpubs with chainkd.IsXpubsEqual --- account/accounts.go | 2 +- crypto/ed25519/chainkd/chainkd.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/account/accounts.go b/account/accounts.go index b85cfd07..0a3a197d 100644 --- a/account/accounts.go +++ b/account/accounts.go @@ -277,7 +277,7 @@ func (m *Manager) ListCtrlProgramsByXpubs(ctx context.Context, xpubs []chainkd.X 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) diff --git a/crypto/ed25519/chainkd/chainkd.go b/crypto/ed25519/chainkd/chainkd.go index 23f6fc24..eebeef49 100644 --- a/crypto/ed25519/chainkd/chainkd.go +++ b/crypto/ed25519/chainkd/chainkd.go @@ -1,6 +1,7 @@ package chainkd import ( + "bytes" "crypto/hmac" "crypto/rand" "crypto/sha512" @@ -8,7 +9,6 @@ import ( "github.com/bytom/crypto/ed25519" "github.com/bytom/crypto/ed25519/ecmath" - "bytes" ) type ( @@ -18,15 +18,15 @@ 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. -- 2.11.0