Documentation
¶
Index ¶
- Constants
- Variables
- type ChainInformation
- type CollectionInformation
- type LastAnchorReply
- type LastDigests
- type LastDigestsReply
- type MerkleBranch
- type ResultT
- type Status
- type StatusReply
- type Timestamp
- type TimestampBatch
- type TimestampBatchReply
- type TimestampReply
- type Verify
- type VerifyBatch
- type VerifyBatchReply
- type VerifyDigest
- type VerifyReply
- type VerifyTimestamp
- type VersionReply
- type WalletBalanceReply
Constants ¶
const ( // APIVersion defines the version number for this code. APIVersion = 2 // ResultInvalid indicates the operation on the backend was invalid. ResultInvalid ResultT = 0 // ResultOK indicates the operation completed successfully. ResultOK ResultT = 1 // ResultExistsError indicates the digest already exists and was // rejected. ResultExistsError ResultT = 2 // ResultDoesntExistError indiciates the timestamp or digest does not // exist. ResultDoesntExistError ResultT = 3 // ResultDisabled indicates querying is disabled. ResultDisabled ResultT = 4 // DefaultMainnetTimeHost indicates the default mainnet time host // server. DefaultMainnetTimeHost = "time.decred.org" // DefaultMainnetTimePort indicates the default mainnet time host // port. DefaultMainnetTimePort = "49152" // DefaultTestnetTimeHost indicates the default testnet time host // server. DefaultTestnetTimeHost = "time-testnet.decred.org" // DefaultTestnetTimePort indicates the default testnet time host // port. DefaultTestnetTimePort = "59152" )
Variables ¶
var ( // RoutePrefix is the route url prefix for this version. RoutePrefix = fmt.Sprintf("/v%v", APIVersion) // VersionRoute defines a top-level API route for retrieving latest version VersionRoute = "/version" // StatusRoute defines the API route for retrieving // the server status. StatusRoute = RoutePrefix + "/status" // TimestampRoute defines the API route for submitting // a single string digest, used by no-js clients. TimestampRoute = RoutePrefix + "/timestamp" // Single digest timestamping // VerifyRoute defines the API route for verifying // a single digest and timestamp, used by no-js clients. VerifyRoute = RoutePrefix + "/verify" // Single verify digest // TimestampBatchRoute defines the API route for submitting // a batch of timestamps or digests. TimestampBatchRoute = RoutePrefix + "/timestamp/batch" // Multi digest timestamping // VerifyBatchRoute defines the API route for both timestamp // and digest batch verification. VerifyBatchRoute = RoutePrefix + "/verify/batch" // Multi verify digests // WalletBalanceRoute defines the API route for retrieving // the account balance from dcrtimed's wallet instance WalletBalanceRoute = RoutePrefix + "/balance" // LastAnchorRoute defines the API route for retrieving // info about last successful anchor, such as // timestamp, block height & tx id LastAnchorRoute = RoutePrefix + "/last" // LastDigestsRoute defines the API route for retriving // the last last n digests the client wants. Max n is defined // via the maxdigests config option LastDigestsRoute = RoutePrefix + "/last-digests" // Result defines legible string messages to a timestamping/query // result code. Result = map[ResultT]string{ ResultInvalid: "Invalid", ResultOK: "OK", ResultExistsError: "Exists", ResultDoesntExistError: "Doesn't exist", ResultDisabled: "Query disallowed", } // RegexpSHA256 is the valid text representation of a sha256 digest. RegexpSHA256 = regexp.MustCompile("^[A-Fa-f0-9]{64}$") // RegexpTimestamp is the valid text representation of a timestamp. RegexpTimestamp = regexp.MustCompile("^[0-9]{10}$") )
Functions ¶
This section is empty.
Types ¶
type ChainInformation ¶
type ChainInformation struct {
ChainTimestamp int64 `json:"chaintimestamp"`
Confirmations *int32 `json:"confirmations,omitempty"` // Using a pointer because we don't want to omit 0
MinConfirmations int32 `json:"minconfirmations,omitempty"`
Transaction string `json:"transaction"`
MerkleRoot string `json:"merkleroot"`
MerklePath MerkleBranch `json:"merklepath"`
}
ChainInformation is returned by the server on a verify digest request. It contains the merkle path of that digest.
type CollectionInformation ¶
type CollectionInformation struct {
ChainTimestamp int64 `json:"chaintimestamp"`
Confirmations *int32 `json:"confirmations,omitempty"` // Using a pointer because we don't want to omit 0
MinConfirmations int32 `json:"minconfirmations,omitempty"`
Transaction string `json:"transaction"`
MerkleRoot string `json:"merkleroot"`
Digests []string `json:"digests"`
}
CollectionInformation is returned by the server on a verify timestamp request. It contains all digests grouped on the collection of the requested block timestamp.
type LastAnchorReply ¶
type LastAnchorReply struct {
ChainTimestamp int64 `json:"chaintimestamp"`
Transaction string `json:"transaction"`
BlockHash string `json:"blockhash"`
BlockHeight int32 `json:"blockheight"`
}
LastAnchorReply is returned by server on a last succcessful anchor info request, it includes the id of the latest successfully broadcasted tx, block hash & block height if the transaction was included in a block and the chain timestamp if the tx block has more than the number of confirmations informed in the config file.
type LastDigests ¶
type LastDigests struct {
N int32 `json:"number"`
}
LastDigests is used to ask the server the info about the N last digests
type LastDigestsReply ¶
type LastDigestsReply struct {
Digests []VerifyDigest `json:"digests"`
}
LastDigestsReply is returned by server on a get last n digests request, it includes a list of timestamps status results
type MerkleBranch ¶
type MerkleBranch struct {
NumLeaves uint32 // Nuber of leaves
Hashes [][sha256.Size]byte // Merkle branch
Flags []byte // Bitmap of merkle tree
}
MerkleBranch shares the same struct definition as merkle.Branch. This has known horrible JSON marshaling in /v2.
type Status ¶
type Status struct {
ID string `json:"id"`
}
Status is used to ask the server if everything is running properly. ID is user settable and can be used as a unique identifier by the client.
type StatusReply ¶
type StatusReply struct {
ID string `json:"id"`
}
StatusReply is returned by the server if everything is running properly.
type Timestamp ¶
Timestamp is used to ask the timestamp server to store a single digest. ID is user settable and can be used as a unique identifier by the client.
type TimestampBatch ¶
TimestampBatch is used to ask the timestamp server to store a batch of digests. ID is user settable and can be used as a unique identifier by the client.
type TimestampBatchReply ¶
type TimestampBatchReply struct {
ID string `json:"id"`
ServerTimestamp int64 `json:"servertimestamp"`
Digests []string `json:"digests"`
Results []ResultT `json:"results"`
}
TimestampBatchReply is returned by the timestamp server after storing the batch of digests. ID is copied from the originating Timestamp call and can be used by the client as a unique identifier. The ServerTimestamp indicates what collection the Digests belong to. Results contains individual result codes for each digest.
type TimestampReply ¶
type TimestampReply struct {
ID string `json:"id"`
ServerTimestamp int64 `json:"servertimestamp"`
Digest string `json:"digest"`
Result ResultT `json:"result"`
}
TimestampReply is returned by the timestamp server after storing a single digest. ID is copied from the originating Timestamp call and can be used by the client as a unique identifier. ServerTimestamp indicates what collection the Digest belongs to. Result holds the result code for the digest.
type Verify ¶
type Verify struct {
ID string `form:"id"`
Digest string `form:"digest"`
Timestamp int64 `form:"timestamp"`
}
Verify is used to ask the server about the status of a single digest and/or timestamp.
type VerifyBatch ¶
type VerifyBatch struct {
ID string `json:"id"`
Digests []string `json:"digests"`
Timestamps []int64 `json:"timestamps"`
}
VerifyBatch is used to ask the server about the status of a batch of digests or timestamps
type VerifyBatchReply ¶
type VerifyBatchReply struct {
ID string `json:"id"`
Digests []VerifyDigest `json:"digests"`
Timestamps []VerifyTimestamp `json:"timestamps"`
}
VerifyBatchReply is returned by the server with the status results for the requested digests and timestamps.
type VerifyDigest ¶
type VerifyDigest struct {
Digest string `json:"digest"`
ServerTimestamp int64 `json:"servertimestamp"`
FlushTimestamp int64 `json:"flushtimestamp"`
Result ResultT `json:"result"`
ChainInformation ChainInformation `json:"chaininformation"`
}
VerifyDigest is returned by the server after verifying the status of a digest.
type VerifyReply ¶
type VerifyReply struct {
ID string `json:"id"`
Digest VerifyDigest `json:"digest"`
Timestamp VerifyTimestamp `json:"timestamp"`
}
VerifyReply is returned by the server with the status results for the requested digest and/or timestamp.
type VerifyTimestamp ¶
type VerifyTimestamp struct {
ServerTimestamp int64 `json:"servertimestamp"`
FlushTimestamp int64 `json:"flushtimestamp"`
Result ResultT `json:"result"`
CollectionInformation CollectionInformation `json:"collectioninformation"`
}
VerifyTimestamp is zero if this digest collection is not anchored in the blockchain; it is however set to the block timestamp it was anchored in.
type VersionReply ¶
type VersionReply struct {
Versions []uint `json:"versions"` // dcrtime API supported versions.
RoutePrefixes []string `json:"routeprefixes"`
}
VersionReply returns the version the server is currently running.
type WalletBalanceReply ¶
type WalletBalanceReply struct {
Total int64 `json:"total"`
Spendable int64 `json:"spendable"`
Unconfirmed int64 `json:"unconfirmed"`
}
WalletBalanceReply is returned by server on a balance information of the decred wallet.