Skip to content

Commit 3c424d4

Browse files
committed
asset: remove TODO in script key check
Fixes a temporary TODO and makes the check nil-safe.
1 parent 97697ed commit 3c424d4

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

asset/asset.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,16 +1873,27 @@ func (a *Asset) deepEqual(allowSegWitIgnoreTxWitness bool, o *Asset) bool {
18731873
return false
18741874
}
18751875

1876-
// If both assets have a tweaked key
1877-
//
1878-
// TODO(roasbeef): fin
1879-
if !a.ScriptKey.PubKey.IsEqual(o.ScriptKey.PubKey) {
1876+
// If both assets have a script public key, comparing that is enough.
1877+
// We just want to know that we have the same key, not that the internal
1878+
// representation (e.g. the TweakedKey sub struct being set) is the same
1879+
// as well.
1880+
switch {
1881+
// If only one of the keys is nil, they are not equal.
1882+
case (a.ScriptKey.PubKey == nil && o.ScriptKey.PubKey != nil) ||
1883+
(a.ScriptKey.PubKey != nil && o.ScriptKey.PubKey == nil):
1884+
18801885
return false
1881-
}
18821886

1883-
/*if !reflect.DeepEqual(a.ScriptKey, o.ScriptKey) {
1887+
// If both are non-nil, we compare the public keys.
1888+
case a.ScriptKey.PubKey != nil && o.ScriptKey.PubKey != nil &&
1889+
!a.ScriptKey.PubKey.IsEqual(o.ScriptKey.PubKey):
1890+
18841891
return false
1885-
}*/
1892+
1893+
// If both are nil or both are non-nil and equal, we continue below.
1894+
default:
1895+
// Continue below
1896+
}
18861897

18871898
if !a.GroupKey.IsEqual(o.GroupKey) {
18881899
return false

0 commit comments

Comments
 (0)