ownSdk

package module
v0.0.0-...-c7be78d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 19 Imported by: 0

README

own-blockchain-sdk-go

Own Blockchain SDK for Go

Quick Start

$ git clone https://github.com/OwnMarket/own-blockchain-sdk-go.git
$ cd own-blockchain-sdk-go

Run tests:

$ go test -v

Usage

Fetch Own Blockchain SDK for Go package

$ go get github.com/OwnMarket/own-blockchain-sdk-go

Use the package in Go code

package main

import (
	"fmt"

	ownSdk "github.com/OwnMarket/own-blockchain-sdk-go"
)

func main() {
	// Create a new wallet
	wallet := ownSdk.GenerateWallet()

	// Compose a transaction with nonce = 1 and actionFee = 0.1
	tx := ownSdk.CreateTx(wallet.Address, 1, 0.1, 0)
	tx.AddTransferChxAction("CHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 100) // Transfer 100 CHX to CHxxx... address.

	// Look at the raw transaction in JSON format
	fmt.Println(tx.ToJson(true))

	// Sign the transaction for submission to node API on TestNet
	networkCode := "OWN_PUBLIC_BLOCKCHAIN_TESTNET"
	signedTx := tx.Sign(networkCode, wallet.PrivateKey)
	fmt.Println(signedTx.ToJson(false))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressFromPrivateKey

func AddressFromPrivateKey(privateKey string) string

func Decode58

func Decode58(src string) []byte

func Decode64

func Decode64(src string) []byte

func Decrypt

func Decrypt(encryptedText []byte, passwordHash [32]byte) []byte

func DeriveHash

func DeriveHash(address string, nonce int64, txActionNumber int16) string

func Encode58

func Encode58(src []byte) string

func Encode64

func Encode64(src []byte) string

func Encrypt

func Encrypt(text []byte, passwordHash [32]byte) []byte

func GenerateKeystore

func GenerateKeystore(mnemonic string, passwordHash [32]byte) []byte

func GenerateMnemonic

func GenerateMnemonic() string

func GenerateSeedFromKeystore

func GenerateSeedFromKeystore(keyStoreEncrypted []byte, passwordHash [32]byte) []byte

func GenerateSeedFromMnemonic

func GenerateSeedFromMnemonic(mnemonic string, passphrase string) []byte

func Hash

func Hash(data []byte) string

func IsValidBlockchainAddress

func IsValidBlockchainAddress(address string) bool

func SignMessage

func SignMessage(networkCode string, privateKey string, message string) string

func SignPlainText

func SignPlainText(privateKey string, text string) string

func VerifyPlainTextSignature

func VerifyPlainTextSignature(signature string, text string) string

Types

type AddKycProviderTxActionDto

type AddKycProviderTxActionDto struct {
	AssetHash       string `json:"assetHash"`
	ProviderAddress string `json:"providerAddress"`
}

type ChangeKycControllerAddressTxActionDto

type ChangeKycControllerAddressTxActionDto struct {
	AccountHash          string `json:"accountHash"`
	AssetHash            string `json:"assetHash"`
	KycControllerAddress string `json:"kycControllerAddress"`
}

type ConfigureValidatorTxActionDto

type ConfigureValidatorTxActionDto struct {
	NetworkAddress      string  `json:"networkAddress"`
	SharedRewardPercent float64 `json:"sharedRewardPercent"`
	IsEnabled           bool    `json:"isEnabled"`
}

type CreateAccountTxActionDto

type CreateAccountTxActionDto struct{}

type CreateAssetEmissionTxActionDto

type CreateAssetEmissionTxActionDto struct {
	EmissionAccountHash string  `json:"emissionAccountHash"`
	AssetHash           string  `json:"assetHash"`
	Amount              float64 `json:"amount"`
}

type CreateAssetTxActionDto

type CreateAssetTxActionDto struct{}

type DelegateStakeTxActionDto

type DelegateStakeTxActionDto struct {
	ValidatorAddress string  `json:"validatorAddress"`
	Amount           float64 `json:"amount"`
}

type RemoveKycProviderTxActionDto

type RemoveKycProviderTxActionDto struct {
	AssetHash       string `json:"assetHash"`
	ProviderAddress string `json:"providerAddress"`
}

type RemoveValidatorTxActionDto

type RemoveValidatorTxActionDto struct{}

type SetAccountControllerTxActionDto

type SetAccountControllerTxActionDto struct {
	AccountHash       string `json:"accountHash"`
	ControllerAddress string `json:"controllerAddress"`
}

type SetAccountEligibilityTxActionDto

type SetAccountEligibilityTxActionDto struct {
	AccountHash         string `json:"accountHash"`
	AssetHash           string `json:"assetHash"`
	IsPrimaryEligible   bool   `json:"isPrimaryEligible"`
	IsSecondaryEligible bool   `json:"isSecondaryEligible"`
}

type SetAssetCodeTxActionDto

type SetAssetCodeTxActionDto struct {
	AssetHash string `json:"assetHash"`
	AssetCode string `json:"assetCode"`
}

type SetAssetControllerTxActionDto

type SetAssetControllerTxActionDto struct {
	AssetHash         string `json:"assetHash"`
	ControllerAddress string `json:"controllerAddress"`
}

type SetAssetEligibilityTxActionDto

type SetAssetEligibilityTxActionDto struct {
	AssetHash             string `json:"assetHash"`
	IsEligibilityRequired bool   `json:"isEligibilityRequired"`
}

type SignedTx

type SignedTx struct {
	Tx        string `json:"tx"`
	Signature string `json:"signature"`
}

func (*SignedTx) ToJson

func (signedTx *SignedTx) ToJson(indentation bool) string

type SubmitVoteTxActionDto

type SubmitVoteTxActionDto struct {
	AccountHash    string `json:"accountHash"`
	AssetHash      string `json:"assetHash"`
	ResolutionHash string `json:"resolutionHash"`
	VoteHash       string `json:"voteHash"`
}

type SubmitVoteWeightTxActionDto

type SubmitVoteWeightTxActionDto struct {
	AccountHash    string  `json:"accountHash"`
	AssetHash      string  `json:"assetHash"`
	ResolutionHash string  `json:"resolutionHash"`
	VoteWeight     float64 `json:"voteWeight"`
}

type TransferAssetTxActionDto

type TransferAssetTxActionDto struct {
	FromAccountHash string  `json:"fromAccountHash"`
	ToAccountHash   string  `json:"toAccountHash"`
	AssetHash       string  `json:"assetHash"`
	Amount          float64 `json:"amount"`
}

type TransferChxTxActionDto

type TransferChxTxActionDto struct {
	RecipientAddress string  `json:"recipientAddress"`
	Amount           float64 `json:"amount"`
}

type Tx

type Tx struct {
	SenderAddress  string     `json:"senderAddress"`
	Nonce          int64      `json:"nonce"`
	ExpirationTime int64      `json:"expirationTime"`
	ActionFee      float64    `json:"actionFee"`
	Actions        []TxAction `json:"actions"`
}

func CreateTx

func CreateTx(senderAddress string, nonce int64, actionFee float64, expirationTime int64) *Tx

func (*Tx) AddAddKycProviderAction

func (tx *Tx) AddAddKycProviderAction(assetHash string, providerAddress string)

func (*Tx) AddChangeKycControllerAddressAction

func (tx *Tx) AddChangeKycControllerAddressAction(accountHash string, assetHash string, kycControllerAddress string)

func (*Tx) AddConfigureValidatorAction

func (tx *Tx) AddConfigureValidatorAction(networkAddress string, sharedRewardPercent float64, isEnabled bool)

func (*Tx) AddCreateAccountAction

func (tx *Tx) AddCreateAccountAction() string

func (*Tx) AddCreateAssetAction

func (tx *Tx) AddCreateAssetAction() string

func (*Tx) AddCreateAssetEmissionAction

func (tx *Tx) AddCreateAssetEmissionAction(emissionAccountHash string, assetHash string, amount float64)

func (*Tx) AddDelegateStakeAction

func (tx *Tx) AddDelegateStakeAction(validatorAddress string, amount float64)

func (*Tx) AddRemoveKycProviderAction

func (tx *Tx) AddRemoveKycProviderAction(assetHash string, providerAddress string)

func (*Tx) AddRemoveValidatorAction

func (tx *Tx) AddRemoveValidatorAction()

func (*Tx) AddSetAccountControllerAction

func (tx *Tx) AddSetAccountControllerAction(accountHash string, controllerAddress string)

func (*Tx) AddSetAccountEligibilityAction

func (tx *Tx) AddSetAccountEligibilityAction(accountHash string, assetHash string, isPrimaryEligible bool, isSecondaryEligible bool)

func (*Tx) AddSetAssetCodeAction

func (tx *Tx) AddSetAssetCodeAction(assetHash string, assetCode string)

func (*Tx) AddSetAssetControllerAction

func (tx *Tx) AddSetAssetControllerAction(assetHash string, controllerAddress string)

func (*Tx) AddSetAssetEligibilityAction

func (tx *Tx) AddSetAssetEligibilityAction(assetHash string, isEligibilityRequired bool)

func (*Tx) AddSubmitVoteAction

func (tx *Tx) AddSubmitVoteAction(accountHash string, assetHash string, resolutionHash string, voteHash string)

func (*Tx) AddSubmitVoteWeightAction

func (tx *Tx) AddSubmitVoteWeightAction(accountHash string, assetHash string, resolutionHash string, voteWeight float64)

func (*Tx) AddTransferAssetAction

func (tx *Tx) AddTransferAssetAction(fromAccountHash string, toAccountHash string, assetHash string, amount float64)

func (*Tx) AddTransferChxAction

func (tx *Tx) AddTransferChxAction(recipientAddress string, amount float64)

func (*Tx) Sign

func (tx *Tx) Sign(networkCode string, privateKey string) *SignedTx

func (*Tx) ToJson

func (tx *Tx) ToJson(indentation bool) string

type TxAction

type TxAction struct {
	ActionType string      `json:"actionType"`
	ActionData interface{} `json:"actionData"`
}

type WalletInfo

type WalletInfo struct {
	PrivateKey string
	Address    string
}

func GenerateWallet

func GenerateWallet() *WalletInfo

func GenerateWalletFromKeystore

func GenerateWalletFromKeystore(keyStoreEncrypted []byte, passwordHash [32]byte, keyIndex uint32) *WalletInfo

func GenerateWalletFromSeed

func GenerateWalletFromSeed(seed []byte, keyIndex uint32) *WalletInfo

func RestoreWalletsFromKeystore

func RestoreWalletsFromKeystore(keyStoreEncrypted []byte, passwordHash [32]byte, walletCount uint32) [](*WalletInfo)

func RestoreWalletsFromSeed

func RestoreWalletsFromSeed(seed []byte, walletCount uint32) [](*WalletInfo)

func WalletFromPrivateKey

func WalletFromPrivateKey(privateKey string) *WalletInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL