Documentation ¶
Index ¶
- Constants
- Variables
- func AddrToDid(addr string) string
- func BlockToHash(block chaintree.Block) ([]byte, error)
- func ConflictSetID(objectID []byte, height uint64) string
- func DecodePath(path string) ([]string, error)
- func DidToAddr(did string) string
- func EcdsaPubkeyToDid(key ecdsa.PublicKey) string
- func EstablishTokenTransaction(chainTreeDID string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
- func GetSenderDagFromReceive(payload *transactions.ReceiveTokenPayload) (*dag.Dag, chaintree.CodedError)
- func GetSignable(sig *signatures.TreeState) []byte
- func IsBlockSignedBy(ctx context.Context, blockWithHeaders *chaintree.BlockWithHeaders, addr string) (bool, error)
- func MintTokenTransaction(chainTreeDID string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
- func MustObjToHash(payload interface{}) []byte
- func NewEmptyTree(ctx context.Context, did string, nodeStore nodestore.DagStore) *dag.Dag
- func NodeToObj(node format.Node) (obj interface{}, err error)
- func ObjToHash(payload interface{}) ([]byte, error)
- func PassPhraseKey(passPhrase, salt []byte) (*ecdsa.PrivateKey, error)
- func ReceiveTokenTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedError chaintree.CodedError)
- func RequestID(req *services.AddBlockRequest) []byte
- func SendTokenTransaction(chainTreeDID string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
- func SetDataTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
- func SetOwnershipTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
- func SignBlock(ctx context.Context, blockWithHeaders *chaintree.BlockWithHeaders, ...) (*chaintree.BlockWithHeaders, error)
- func StakeTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
- func TokenPath(tokenName *TokenName) ([]string, error)
- func TokenPayloadForTransaction(chain *chaintree.ChainTree, tokenName *TokenName, sendTokenTxId string, ...) (*transactions.TokenPayload, error)
- func TokenTransactionCidsForType(tree *dag.Dag, tokenName *TokenName, txType string) ([]cid.Cid, error)
- type ErrorCode
- type GetDiffNodesRequest
- type GetDiffNodesResponse
- type SignatureMap
- type SignedChainTree
- type StandardHeaders
- type TipRequest
- type TipResponse
- type TipSignature
- type Token
- type TokenLedger
- type TokenMint
- type TokenName
- type TokenReceive
- type TokenSend
- type TreeLedger
- func (l *TreeLedger) Balance() (uint64, error)
- func (l *TreeLedger) EstablishToken(monetaryPolicy transactions.TokenMonetaryPolicy) (*dag.Dag, error)
- func (l *TreeLedger) MintToken(amount uint64) (*dag.Dag, error)
- func (l *TreeLedger) ReceiveToken(sendTokenTxId string, amount uint64) (*dag.Dag, error)
- func (l *TreeLedger) SendToken(txId, destination string, amount uint64) (*dag.Dag, error)
- func (l *TreeLedger) TokenExists() (bool, error)
Constants ¶
const ( ErrUnknown = iota ErrInvalidTip = iota ErrInvalidSig = iota )
const ( TreePathForAuthentications = "_tupelo/authentications" TreePathForTokens = "_tupelo/tokens" TreePathForStake = "_tupelo/stake" TreePathForData = "data" TokenMintLabel = "mints" TokenSendLabel = "sends" TokenReceiveLabel = "receives" )
const ( MonetaryPolicyLabel = "monetaryPolicy" TokenBalanceLabel = "balance" )
const MessageType_AddBlock = "ADD_BLOCK"
const MessageType_GetDiffNodes = "GET_DIFF_NODES"
const MessageType_TipRequest = "TIP_REQUEST"
Variables ¶
var DefaultTransactors = map[transactions.Transaction_Type]chaintree.TransactorFunc{ transactions.Transaction_ESTABLISHTOKEN: EstablishTokenTransaction, transactions.Transaction_MINTTOKEN: MintTokenTransaction, transactions.Transaction_SENDTOKEN: SendTokenTransaction, transactions.Transaction_RECEIVETOKEN: ReceiveTokenTransaction, transactions.Transaction_SETDATA: SetDataTransaction, transactions.Transaction_SETOWNERSHIP: SetOwnershipTransaction, transactions.Transaction_STAKE: StakeTransaction, }
Functions ¶
func ConflictSetID ¶
func DecodePath ¶
func EcdsaPubkeyToDid ¶
func EstablishTokenTransaction ¶
func EstablishTokenTransaction(chainTreeDID string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
func GetSenderDagFromReceive ¶
func GetSenderDagFromReceive(payload *transactions.ReceiveTokenPayload) (*dag.Dag, chaintree.CodedError)
GetSenderDagFromReceive takes the receive token payload and returns the SendToken dag that was included in the ReceiveTokenPayload
func GetSignable ¶
func GetSignable(sig *signatures.TreeState) []byte
func IsBlockSignedBy ¶
func MintTokenTransaction ¶
func MintTokenTransaction(chainTreeDID string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
func MustObjToHash ¶
func MustObjToHash(payload interface{}) []byte
func NewEmptyTree ¶
func PassPhraseKey ¶
func PassPhraseKey(passPhrase, salt []byte) (*ecdsa.PrivateKey, error)
PassPhraseKey implements a known passphrase -> private Key generator following very closely the params from Warp Wallet. The only difference here is that the N on scrypt is 256 instead of 218 because go requires N to be a power of 2. from the Warp Wallet ( https://keybase.io/warp/warp_1.0.9_SHA256_a2067491ab582bde779f4505055807c2479354633a2216b22cf1e92d1a6e4a87.html ): s1 = scrypt(key=(passphrase||0x1), salt=(salt||0x1), N=218, r=8, p=1, dkLen=32) s2 = pbkdf2(key=(passphrase||0x2), salt=(salt||0x2), c=216, dkLen=32, prf=HMAC_SHA256) keypair = generate_bitcoin_keypair(s1 ⊕ s2)
func ReceiveTokenTransaction ¶
func ReceiveTokenTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedError chaintree.CodedError)
func RequestID ¶
func RequestID(req *services.AddBlockRequest) []byte
func SendTokenTransaction ¶
func SendTokenTransaction(chainTreeDID string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
func SetDataTransaction ¶
func SetDataTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
SetDataTransaction just sets a path in tree/data to arbitrary data.
func SetOwnershipTransaction ¶
func SetOwnershipTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
SetOwnershipTransaction changes the ownership of a tree by adding a public key array to /_tupelo/authentications
func SignBlock ¶
func SignBlock(ctx context.Context, blockWithHeaders *chaintree.BlockWithHeaders, key *ecdsa.PrivateKey) (*chaintree.BlockWithHeaders, error)
func StakeTransaction ¶
func StakeTransaction(_ string, tree *dag.Dag, txn *transactions.Transaction) (newTree *dag.Dag, valid bool, codedErr chaintree.CodedError)
THIS IS A pre-ALPHA TRANSACTION AND NO RULES ARE ENFORCED! Anyone can stake and join a group with no consequences. additionally, it only allows staking a single group at the moment
func TokenPayloadForTransaction ¶
func TokenPayloadForTransaction(chain *chaintree.ChainTree, tokenName *TokenName, sendTokenTxId string, sendTxProof *gossip.Proof) (*transactions.TokenPayload, error)
Types ¶
type GetDiffNodesResponse ¶
type GetDiffNodesResponse struct {
Nodes [][]byte
}
type SignatureMap ¶
type SignatureMap map[string]*signatures.Signature
func (SignatureMap) Merge ¶
func (sm SignatureMap) Merge(other SignatureMap) SignatureMap
Merge returns a new SignatatureMap composed of the original with the other merged in other wins when both SignatureMaps have signatures
func (SignatureMap) Only ¶
func (sm SignatureMap) Only(keys []string) SignatureMap
Only returns a new SignatureMap with only keys in the keys slice argument
func (SignatureMap) Subtract ¶
func (sm SignatureMap) Subtract(other SignatureMap) SignatureMap
Subtract returns a new SignatureMap with only the new signatures in other.
type SignedChainTree ¶
func NewSignedChainTree ¶
func NewSignedChainTreeFromChainTree ¶
func NewSignedChainTreeFromChainTree(tree *chaintree.ChainTree) *SignedChainTree
func (*SignedChainTree) Authentications ¶
func (sct *SignedChainTree) Authentications() ([]string, error)
func (*SignedChainTree) Id ¶
func (sct *SignedChainTree) Id() (string, error)
func (*SignedChainTree) IsGenesis ¶
func (sct *SignedChainTree) IsGenesis() bool
func (*SignedChainTree) MustId ¶
func (sct *SignedChainTree) MustId() string
func (*SignedChainTree) Tip ¶
func (sct *SignedChainTree) Tip() cid.Cid
type StandardHeaders ¶
type StandardHeaders struct {
Signatures SignatureMap `refmt:"signatures,omitempty" json:"signatures,omitempty" cbor:"signatures,omitempty"`
}
type TipRequest ¶
type TipRequest struct {
ChainId string
}
type TipResponse ¶
type TipResponse struct { ChainId string Tip *cid.Cid Signature signatures.Signature }
type TipSignature ¶
type TipSignature struct { Tip *cid.Cid Signature signatures.Signature }
type Token ¶
type Token struct { MonetaryPolicy *cid.Cid Mints *cid.Cid Sends *cid.Cid Receives *cid.Cid Balance uint64 }
TODO: Consider removing from the CBOR atlas to allow us to resolve the child nodes into their native objects directly by navigating through Token nodes. This would require changing the balance field to a composite object so we can resolve the balance without integer overflow
type TokenLedger ¶
type TokenLedger interface { TokenExists() (bool, error) Balance() (uint64, error) EstablishToken(monetaryPolicy transactions.TokenMonetaryPolicy) (*dag.Dag, error) MintToken(amount uint64) (*dag.Dag, error) SendToken(txId, destination string, amount uint64) (*dag.Dag, error) ReceiveToken(sendTokenTxId string, amount uint64) (*dag.Dag, error) }
type TokenMint ¶
type TokenMint struct {
Amount uint64
}
TODO: These token struct types should probably be protobufs in the messages repo.
type TokenName ¶
func CanonicalTokenName ¶
func GetTokenNameFromReceive ¶
func GetTokenNameFromReceive(senderDag *dag.Dag) (*TokenName, chaintree.CodedError)
GetTokenNameFromReceive takes the SendToken that was included in a ReceiveTokenPayload and returns the name of the sent token.
func TokenNameFromString ¶
func (*TokenName) IsCanonical ¶
type TokenReceive ¶
type TokenSend ¶
func GetSendTokenFromReceive ¶
func GetSendTokenFromReceive(senderDag *dag.Dag, tokenName *TokenName) (*TokenSend, chaintree.CodedError)
GetSendTokenFromReceive takes DAG that is part of the ReceiveTokenPayload and returns The TokenSend for the specified tokenName
type TreeLedger ¶
type TreeLedger struct {
// contains filtered or unexported fields
}
func NewTreeLedger ¶
func NewTreeLedger(tree *dag.Dag, tokenName *TokenName) *TreeLedger
func (*TreeLedger) Balance ¶
func (l *TreeLedger) Balance() (uint64, error)
func (*TreeLedger) EstablishToken ¶
func (l *TreeLedger) EstablishToken(monetaryPolicy transactions.TokenMonetaryPolicy) (*dag.Dag, error)
func (*TreeLedger) ReceiveToken ¶
func (*TreeLedger) TokenExists ¶
func (l *TreeLedger) TokenExists() (bool, error)