Skip to content

Commit

Permalink
types,consensus: Add V2ClaimOutputID
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechampine committed Oct 13, 2023
1 parent 9cbf7aa commit c985cf2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion consensus/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (ms *MidState) ApplyV2Transaction(txn types.V2Transaction) {
ms.spendSiafundElement(sfi.Parent, txid)
claimPortion := ms.siafundPool.Sub(sfi.Parent.ClaimStart).Div64(ms.base.SiafundCount()).Mul64(sfi.Parent.SiafundOutput.Value)
ms.addSiacoinElement(types.SiacoinElement{
StateElement: types.StateElement{ID: types.Hash256(types.SiafundOutputID(sfi.Parent.ID).ClaimOutputID())},
StateElement: types.StateElement{ID: types.Hash256(types.SiafundOutputID(sfi.Parent.ID).V2ClaimOutputID())},
SiacoinOutput: types.SiacoinOutput{Value: claimPortion, Address: sfi.ClaimAddress},
MaturityHeight: ms.base.MaturityHeight(),
})
Expand Down
11 changes: 11 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ func (sfoid SiafundOutputID) ClaimOutputID() SiacoinOutputID {
return SiacoinOutputID(HashBytes(sfoid[:]))
}

// V2ClaimOutputID returns the ID of the SiacoinOutput that is created when the
// siafund output is spent.
func (sfoid SiafundOutputID) V2ClaimOutputID() SiacoinOutputID {
h := hasherPool.Get().(*Hasher)
defer hasherPool.Put(h)
h.Reset()
h.WriteDistinguisher("id/siacoinclaimoutput")
sfoid.EncodeTo(h.E)
return SiacoinOutputID(h.Sum())
}

// A SiafundInput spends an unspent SiafundOutput in the UTXO set by revealing
// and satisfying its unlock conditions. SiafundInputs also include a
// ClaimAddress, specifying the recipient of the siacoins that were earned by
Expand Down

0 comments on commit c985cf2

Please sign in to comment.