mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-29 10:16:45 +00:00

* [NOD-1567] Add clone methods to data stores types * [NOD-1567] Fix comments * [NOD-1567] Fix test
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package externalapi
|
|
|
|
// UTXOEntry houses details about an individual transaction output in a utxo
|
|
// set such as whether or not it was contained in a coinbase tx, the blue
|
|
// score of the block that accepts the tx, its public key script, and how
|
|
// much it pays.
|
|
type UTXOEntry struct {
|
|
Amount uint64
|
|
ScriptPublicKey []byte // The public key script for the output.
|
|
BlockBlueScore uint64 // Blue score of the block accepting the tx.
|
|
IsCoinbase bool
|
|
}
|
|
|
|
// Clone returns a clone of UTXOEntry
|
|
func (entry *UTXOEntry) Clone() *UTXOEntry {
|
|
if entry == nil {
|
|
return nil
|
|
}
|
|
|
|
scriptPublicKeyClone := make([]byte, len(entry.ScriptPublicKey))
|
|
copy(scriptPublicKeyClone, entry.ScriptPublicKey)
|
|
|
|
return &UTXOEntry{
|
|
Amount: entry.Amount,
|
|
ScriptPublicKey: scriptPublicKeyClone,
|
|
BlockBlueScore: entry.BlockBlueScore,
|
|
IsCoinbase: entry.IsCoinbase,
|
|
}
|
|
}
|
|
|
|
// NewUTXOEntry creates a new utxoEntry representing the given txOut
|
|
func NewUTXOEntry(amount uint64, scriptPubKey []byte, isCoinbase bool, blockBlueScore uint64) *UTXOEntry {
|
|
return &UTXOEntry{
|
|
Amount: amount,
|
|
ScriptPublicKey: scriptPubKey,
|
|
BlockBlueScore: blockBlueScore,
|
|
IsCoinbase: isCoinbase,
|
|
}
|
|
}
|