Commit 7bf29261 authored by David Vorick's avatar David Vorick

json tags

parent 58dd8799
......@@ -11,9 +11,9 @@ import (
// The ConsensusGET struct contains general information about the consensus
// set, with tags to support idiomatic json encodings.
type ConsensusGET struct {
Height types.BlockHeight
CurrentBlock types.BlockID
Target types.Target
Height types.BlockHeight `json:"height"`
CurrentBlock types.BlockID `json:"currentblock"`
Target types.Target `json:target"`
}
// consensusHandlerGET handles a GET request to /consensus.
......
......@@ -16,59 +16,59 @@ import (
type (
// WalletGET contains general information about the wallet.
WalletGET struct {
Encrypted bool
Unlocked bool
Encrypted bool `json:"encrypted"`
Unlocked bool `json:"unlocked"`
ConfirmedSiacoinBalance types.Currency
UnconfirmedOutgoingSiacoins types.Currency
UnconfirmedIncomingSiacoins types.Currency
ConfirmedSiacoinBalance types.Currency `json:"confirmedsiacoinbalance"`
UnconfirmedOutgoingSiacoins types.Currency `json:"unconfirmedoutgoingsiacoins"`
UnconfirmedIncomingSiacoins types.Currency `json:"unconfirmedincomingsiacoins"`
SiafundBalance types.Currency
SiacoinClaimBalance types.Currency
SiafundBalance types.Currency `json:"siafundbalance"`
SiacoinClaimBalance types.Currency `json:"siacoinclaimbalance"`
}
// WalletAddressGET contains an address returned by a GET call to
// /wallet/address.
WalletAddressGET struct {
Address types.UnlockHash
Address types.UnlockHash `json:"address"`
}
// WalletEncryptPOST contains the primary seed that gets generated during a
// POST call to /wallet/encrypt.
WalletEncryptPOST struct {
PrimarySeed string
PrimarySeed string `json:"primaryseed"`
}
// WalletHistoryGET contains wallet transaction history.
WalletHistoryGET struct {
ConfirmedHistory []modules.WalletTransaction
UnconfirmedHistory []modules.WalletTransaction
ConfirmedHistory []modules.WalletTransaction `json:"confirmedhistory"`
UnconfirmedHistory []modules.WalletTransaction `json:"unconfirmedhistory"`
}
// WalletHistoryGETaddr contains the set of wallet transactions relevnat to
// the input address provided in the call to /wallet/history/$(addr)
WalletHistoryGETaddr struct {
Transactions []modules.WalletTransaction
Transactions []modules.WalletTransaction `json:"transactions"`
}
// WalletSeedGet contains the seeds used by the wallet.
WalletSeedsGET struct {
PrimarySeed string
AddressesRemaining int
AllSeeds []string
PrimarySeed string `json:"primaryseed"`
AddressesRemaining int `json:"addressesremaining"`
AllSeeds []string `json:"allseeds"`
}
// WalletTransactionGETid contains the transaction returned by a call to
// /wallet/transaction/$(id)
WalletTransactionGETid struct {
Transaction types.Transaction
Transaction types.Transaction `json:"transaction"`
}
// WalletTransactionsGET contains the specified set of confirmed and
// unconfirmed transactions.
WalletTransactionsGET struct {
ConfirmedTransactions []types.Transaction
UnconfirmedTransactions []types.Transaction
ConfirmedTransactions []types.Transaction `json:"confirmedtransactions"`
UnconfirmedTransactions []types.Transaction `json:"unconfirmedtransactions"`
}
)
......
This diff is collapsed.
......@@ -33,14 +33,14 @@ type (
WalletTransactionID crypto.Hash
WalletTransaction struct {
TransactionID types.TransactionID
ConfirmationHeight types.BlockHeight
ConfirmationTimestamp types.Timestamp
FundType types.Specifier
OutputID types.OutputID
RelatedAddress types.UnlockHash
Value types.Currency
TransactionID types.TransactionID `json:"transactionid"`
ConfirmationHeight types.BlockHeight `json:"confirmationheight"`
ConfirmationTimestamp types.Timestamp `json:"confirmationtimestamp"`
FundType types.Specifier `json:"fundtype"`
OutputID types.OutputID `json:"outputid"`
RelatedAddress types.UnlockHash `json:"relatedaddress"`
Value types.Currency `json:"value"`
}
// TransactionBuilder is used to construct custom transactions. A transaction
......
......@@ -21,21 +21,21 @@ type (
// then try to pick a Nonce that results in a block whose BlockID is below a
// given Target.
Block struct {
ParentID BlockID
Nonce BlockNonce
Timestamp Timestamp
MinerPayouts []SiacoinOutput
Transactions []Transaction
ParentID BlockID `json:"parentid"`
Nonce BlockNonce `json:"nonce"`
Timestamp Timestamp `json:"timestamp"`
MinerPayouts []SiacoinOutput `json:"minerpayouts"`
Transactions []Transaction `json:"transactions"`
}
// A BlockHeader, when encoded, is an 80-byte constant size field
// containing enough information to do headers-first block downloading.
// Hashing the header results in the block ID.
BlockHeader struct {
ParentID BlockID
Nonce BlockNonce
Timestamp Timestamp
MerkleRoot crypto.Hash
ParentID BlockID `json:"parentid"`
Nonce BlockNonce `json:"nonce"`
Timestamp Timestamp `json:"timestamp"`
MerkleRoot crypto.Hash `json:"merkleroot"`
}
BlockHeight uint64
......
......@@ -37,15 +37,15 @@ type (
// A contract can be terminated early by submitting a FileContractTermination
// whose UnlockConditions hash to 'TerminationHash'.
FileContract struct {
FileSize uint64
FileMerkleRoot crypto.Hash
WindowStart BlockHeight
WindowEnd BlockHeight
Payout Currency
ValidProofOutputs []SiacoinOutput
MissedProofOutputs []SiacoinOutput
UnlockHash UnlockHash
RevisionNumber uint64
FileSize uint64 `json:"filesize"`
FileMerkleRoot crypto.Hash `json:"filemerkleroot"`
WindowStart BlockHeight `json:"windowstart"`
WindowEnd BlockHeight `json:"windowend"`
Payout Currency `json:"payout"`
ValidProofOutputs []SiacoinOutput `json:"validproofoutputs"`
MissedProofOutputs []SiacoinOutput `json:"missedproofoutputs"`
UnlockHash UnlockHash `json:"unlockhash"`
RevisionNumber uint64 `json:"revisionnumber"`
}
// A FileContractRevision revises an existing file contract. The ParentID
......@@ -61,17 +61,17 @@ type (
// FileContractRevisions enable trust-free modifications to existing file
// contracts.
FileContractRevision struct {
ParentID FileContractID
UnlockConditions UnlockConditions
NewRevisionNumber uint64
ParentID FileContractID `json:"parentid"`
UnlockConditions UnlockConditions `json:"unlockconditions"`
NewRevisionNumber uint64 `json:"newrevisionnumber"`
NewFileSize uint64
NewFileMerkleRoot crypto.Hash
NewWindowStart BlockHeight
NewWindowEnd BlockHeight
NewValidProofOutputs []SiacoinOutput
NewMissedProofOutputs []SiacoinOutput
NewUnlockHash UnlockHash
NewFileSize uint64 `json:"newfilesize"`
NewFileMerkleRoot crypto.Hash `json:"newfilemerkleroot"`
NewWindowStart BlockHeight `json:"newwindowstart"`
NewWindowEnd BlockHeight `json:"newwindowend"`
NewValidProofOutputs []SiacoinOutput `json:"newvalidproofoutputs"`
NewMissedProofOutputs []SiacoinOutput `json:"newmissedproofoutputs"`
NewUnlockHash UnlockHash `json:"newunlockhash"`
}
// A StorageProof fulfills a FileContract. The proof contains a specific
......@@ -85,9 +85,9 @@ type (
// SiafundOutputs, or FileContracts. This is because a mundane reorg can
// invalidate the proof, and with it the rest of the transaction.
StorageProof struct {
ParentID FileContractID
Segment [crypto.SegmentSize]byte
HashSet []crypto.Hash
ParentID FileContractID `json:"parentid"`
Segment [crypto.SegmentSize]byte `json:"segment"`
HashSet []crypto.Hash `json:"hashset"`
}
ProofStatus bool
......
......@@ -61,17 +61,17 @@ type (
// fields must be empty (except for the Signatures field, since a signature
// cannot sign itself).
CoveredFields struct {
WholeTransaction bool
SiacoinInputs []uint64
SiacoinOutputs []uint64
FileContracts []uint64
FileContractRevisions []uint64
StorageProofs []uint64
SiafundInputs []uint64
SiafundOutputs []uint64
MinerFees []uint64
ArbitraryData []uint64
TransactionSignatures []uint64
WholeTransaction bool `json:"wholetransaction"`
SiacoinInputs []uint64 `json:"siacoininputs"`
SiacoinOutputs []uint64 `json:"siacoinoutputs"`
FileContracts []uint64 `json:"filecontracts"`
FileContractRevisions []uint64 `json:"filecontractrevisions"`
StorageProofs []uint64 `json:"storageproofs"`
SiafundInputs []uint64 `json:"siafundinputs"`
SiafundOutputs []uint64 `json:"siafundoutputs"`
MinerFees []uint64 `json:"minerfees"`
ArbitraryData []uint64 `json:"arbitrarydata"`
TransactionSignatures []uint64 `json:"transactionsignatures"`
}
// A SiaPublicKey is a public key prefixed by a Specifier. The Specifier
......@@ -79,8 +79,8 @@ type (
// algorithms will always verify, which allows new algorithms to be added to
// the protocol via a soft-fork.
SiaPublicKey struct {
Algorithm Specifier
Key []byte
Algorithm Specifier `json:"algorithm"`
Key []byte `json:"key"`
}
// A TransactionSignature is a signature that is included in the transaction.
......@@ -95,11 +95,11 @@ type (
// 'CoveredFields' indicates which parts of the transaction are being signed;
// see CoveredFields.
TransactionSignature struct {
ParentID crypto.Hash
PublicKeyIndex uint64
Timelock BlockHeight
CoveredFields CoveredFields
Signature []byte
ParentID crypto.Hash `json:"parentid"`
PublicKeyIndex uint64 `json:"publickeyindex"`
Timelock BlockHeight `json:"timelock"`
CoveredFields CoveredFields `json:"coveredfileds"`
Signature []byte `json:"signature"`
}
// UnlockConditions are a set of conditions which must be met to execute
......@@ -118,9 +118,9 @@ type (
// unlock." If 'SignaturesRequired' > len('PublicKeys'), then the UnlockConditions
// cannot be fulfilled under any circumstances.
UnlockConditions struct {
Timelock BlockHeight
PublicKeys []SiaPublicKey
SignaturesRequired uint64
Timelock BlockHeight `json:"timelock"`
PublicKeys []SiaPublicKey `json:"publickeys"`
SignaturesRequired uint64 `json:"signaturesrequired"`
}
// An UnlockHash is a specially constructed hash of the UnlockConditions
......
......@@ -65,16 +65,16 @@ type (
// but transactions cannot spend outputs that they create or otherwise be
// self-dependent.
Transaction struct {
SiacoinInputs []SiacoinInput
SiacoinOutputs []SiacoinOutput
FileContracts []FileContract
FileContractRevisions []FileContractRevision
StorageProofs []StorageProof
SiafundInputs []SiafundInput
SiafundOutputs []SiafundOutput
MinerFees []Currency
ArbitraryData [][]byte
TransactionSignatures []TransactionSignature
SiacoinInputs []SiacoinInput `json:"siacoininputs"`
SiacoinOutputs []SiacoinOutput `json:"siacoinoutputs"`
FileContracts []FileContract `json:"filecontracts"`
FileContractRevisions []FileContractRevision `json:"filecontractrevisions"`
StorageProofs []StorageProof `json:"storageproofs"`
SiafundInputs []SiafundInput `json:"siafundinputs"`
SiafundOutputs []SiafundOutput `json:"siafundoutputs"`
MinerFees []Currency `json:minerfees"`
ArbitraryData [][]byte `json:"arbitarydata"`
TransactionSignatures []TransactionSignature `json:"transactionsignatures"`
}
// A SiacoinInput consumes a SiacoinOutput and adds the siacoins to the set of
......@@ -83,8 +83,8 @@ type (
// for spending the output. The UnlockConditions must match the UnlockHash of
// the output.
SiacoinInput struct {
ParentID SiacoinOutputID
UnlockConditions UnlockConditions
ParentID SiacoinOutputID `json:"parentid"`
UnlockConditions UnlockConditions `json:"unlockconditions"`
}
// A SiacoinOutput holds a volume of siacoins. Outputs must be spent
......@@ -92,8 +92,8 @@ type (
// UnlockHash is the hash of the UnlockConditions that must be fulfilled
// in order to spend the output.
SiacoinOutput struct {
Value Currency
UnlockHash UnlockHash
Value Currency `json:"value"`
UnlockHash UnlockHash `json:"unlockhash"`
}
// A SiafundInput consumes a SiafundOutput and adds the siafunds to the set of
......@@ -102,9 +102,9 @@ type (
// for spending the output. The UnlockConditions must match the UnlockHash of
// the output.
SiafundInput struct {
ParentID SiafundOutputID
UnlockConditions UnlockConditions
ClaimUnlockHash UnlockHash
ParentID SiafundOutputID `json:"parentid"`
UnlockConditions UnlockConditions `json:"unlockconditions"`
ClaimUnlockHash UnlockHash `json:"claimunlockhash"`
}
// A SiafundOutput holds a volume of siafunds. Outputs must be spent
......@@ -121,9 +121,9 @@ type (
// equal zero. While the transaction is being processed, the ClaimStart is set
// to the value of the SiafundPool.
SiafundOutput struct {
Value Currency
UnlockHash UnlockHash
ClaimStart Currency
Value Currency `json:"value"`
UnlockHash UnlockHash `json:"unlockhash"`
ClaimStart Currency `json:"claimstart"`
}
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment