forked from kaspanet/kaspad
-
Notifications
You must be signed in to change notification settings - Fork 27
/
coinbase.go
38 lines (29 loc) · 1008 Bytes
/
coinbase.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package externalapi
import "bytes"
// DomainCoinbaseData contains data by which a coinbase transaction
// is built
type DomainCoinbaseData struct {
ScriptPublicKey *ScriptPublicKey
ExtraData []byte
}
// Clone returns a clone of DomainCoinbaseData
func (dcd *DomainCoinbaseData) Clone() *DomainCoinbaseData {
scriptPubKeyClone := make([]byte, len(dcd.ScriptPublicKey.Script))
copy(scriptPubKeyClone, dcd.ScriptPublicKey.Script)
extraDataClone := make([]byte, len(dcd.ExtraData))
copy(extraDataClone, dcd.ExtraData)
return &DomainCoinbaseData{
ScriptPublicKey: &ScriptPublicKey{Script: scriptPubKeyClone, Version: dcd.ScriptPublicKey.Version},
ExtraData: extraDataClone,
}
}
// Equal returns whether dcd equals to other
func (dcd *DomainCoinbaseData) Equal(other *DomainCoinbaseData) bool {
if dcd == nil || other == nil {
return dcd == other
}
if !bytes.Equal(dcd.ExtraData, other.ExtraData) {
return false
}
return dcd.ScriptPublicKey.Equal(other.ScriptPublicKey)
}