-
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.
Merge pull request #54 from SiaFoundation/nate/single-wallet-v2
Add support for v2 transactions to Single Address Wallet
- Loading branch information
Showing
6 changed files
with
987 additions
and
245 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
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
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,81 @@ | ||
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"` | ||
} | ||
|
||
// EventV1Transaction is a transaction event that includes the transaction | ||
EventV1Transaction types.Transaction | ||
|
||
// EventV2Transaction is a transaction event that includes the transaction | ||
EventV2Transaction types.V2Transaction | ||
|
||
// EventData contains the data associated with an event. | ||
EventData interface { | ||
isEvent() bool | ||
} | ||
|
||
// 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 EventData `json:"data"` | ||
MaturityHeight uint64 `json:"maturityHeight"` | ||
Timestamp time.Time `json:"timestamp"` | ||
} | ||
) | ||
|
||
func (EventMinerPayout) isEvent() bool { return true } | ||
func (EventFoundationSubsidy) isEvent() bool { return true } | ||
func (EventV1ContractPayout) isEvent() bool { return true } | ||
func (EventV2ContractPayout) isEvent() bool { return true } | ||
func (EventV1Transaction) isEvent() bool { return true } | ||
func (EventV2Transaction) isEvent() bool { return true } |
Oops, something went wrong.