-
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 9a881ac
Showing
4 changed files
with
303 additions
and
179 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 EventContractPayout represents a file contract payout | ||
Check warning on line 34 in wallet/events.go GitHub Actions / test (ubuntu-latest, 1.22)
|
||
EventV1ContractPayout struct { | ||
FileContract types.FileContractElement `json:"fileContract"` | ||
SiacoinElement types.SiacoinElement `json:"siacoinElement"` | ||
Missed bool `json:"missed"` | ||
} | ||
|
||
EventV2ContractPayout struct { | ||
Check warning on line 41 in wallet/events.go GitHub Actions / test (ubuntu-latest, 1.22)
|
||
FileContract types.V2FileContractElement `json:"fileContract"` | ||
Resolution types.V2FileContractResolutionType `json:"resolution"` | ||
SiacoinElement types.SiacoinElement `json:"siacoinElement"` | ||
Missed bool `json:"missed"` | ||
} | ||
|
||
// An EventSource is a string indicating the source of a transaction. | ||
EventSource string | ||
|
||
// 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.