-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet: refactor event struct, add v2 event types
- Loading branch information
1 parent
cbe0215
commit 67582e2
Showing
4 changed files
with
303 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package wallet | ||
|
||
import ( | ||
"time" | ||
|
||
"go.sia.tech/core/types" | ||
) | ||
|
||
// event types indicate the source of an event. Events can | ||
// either be created by sending Siacoins between addresses or they can be | ||
// created by consensus (e.g. a miner payout, a siafund claim, or a contract). | ||
const ( | ||
EventTypeMinerPayout = "miner" | ||
EventTypeFoundationSubsidy = "foundation" | ||
|
||
EventTypeV1Transaction = "v1Transaction" | ||
EventTypeV1Contract = "v1Contract" | ||
|
||
EventTypeV2Transaction = "v2Transaction" | ||
EventTypeV2Contract = "v2Contract" | ||
) | ||
|
||
type ( | ||
// An EventMinerPayout represents a miner payout from a block. | ||
EventMinerPayout struct { | ||
SiacoinElement types.SiacoinElement `json:"siacoinElement"` | ||
} | ||
|
||
// EventFoundationSubsidy represents a foundation subsidy from a block. | ||
EventFoundationSubsidy struct { | ||
SiacoinElement types.SiacoinElement `json:"siacoinElement"` | ||
} | ||
|
||
// An EventV1ContractPayout represents a file contract payout from a v1 | ||
// contract. | ||
EventV1ContractPayout struct { | ||
FileContract types.FileContractElement `json:"fileContract"` | ||
SiacoinElement types.SiacoinElement `json:"siacoinElement"` | ||
Missed bool `json:"missed"` | ||
} | ||
|
||
// An EventV2ContractPayout represents a file contract payout from a v2 | ||
// contract. | ||
EventV2ContractPayout struct { | ||
FileContract types.V2FileContractElement `json:"fileContract"` | ||
Resolution types.V2FileContractResolutionType `json:"resolution"` | ||
SiacoinElement types.SiacoinElement `json:"siacoinElement"` | ||
Missed bool `json:"missed"` | ||
} | ||
|
||
// An Event is a transaction or other event that affects the wallet including | ||
// miner payouts, siafund claims, and file contract payouts. | ||
Event struct { | ||
ID types.Hash256 `json:"id"` | ||
Index types.ChainIndex `json:"index"` | ||
Inflow types.Currency `json:"inflow"` | ||
Outflow types.Currency `json:"outflow"` | ||
Type string `json:"type"` | ||
Data any `json:"data"` | ||
MaturityHeight uint64 `json:"maturityHeight"` | ||
Timestamp time.Time `json:"timestamp"` | ||
} | ||
) |
Oops, something went wrong.