Documentation ¶
Index ¶
- Constants
- Variables
- func AddressFromPassphrase(passphrase string) (string, error)
- func Base58CheckDecodeFatal(data string) []byte
- func Byte2Hex(data byte) string
- func ECDSASignatureLen(signature []byte) int
- func GetEpoch() uint32
- func GetFile(path string) string
- func GetFixture(file string) string
- func GetTime() int32
- func Hex2Byte(data []byte) string
- func HexDecode(data string) []byte
- func HexEncode(data []byte) string
- func SetFee(transactionType uint16, value FlexToshi)
- func SetNetwork(network *Network)
- func ValidateAddress(address string) (bool, error)
- type DelegateAsset
- type FlexToshi
- type HtlcClaimAsset
- type HtlcLockAsset
- type HtlcLockExpirationAsset
- type HtlcRefundAsset
- type Message
- type MultiPaymentAsset
- type MultiSignatureRegistrationAsset
- type Network
- type PrivateKey
- func (privateKey *PrivateKey) Sign(hash []byte) ([]byte, error)
- func (privateKey *PrivateKey) SignECDSA(hash []byte) ([]byte, error)
- func (privateKey *PrivateKey) SignSchnorr(hash []byte) ([]byte, error)
- func (privateKey *PrivateKey) ToAddress() string
- func (privateKey *PrivateKey) ToHex() string
- func (privateKey *PrivateKey) ToWif() string
- type PublicKey
- func (publicKey *PublicKey) AddressBytes() []byte
- func (publicKey *PublicKey) Serialize() []byte
- func (publicKey *PublicKey) ToAddress() string
- func (publicKey *PublicKey) ToHex() string
- func (publicKey *PublicKey) Verify(signature []byte, data []byte) (bool, error)
- func (publicKey *PublicKey) VerifyECDSA(signature []byte, data []byte) (bool, error)
- func (publicKey *PublicKey) VerifySchnorr(signature []byte, hash []byte) (bool, error)
- type SecondSignatureRegistrationAsset
- type TestingFixture
- type TestingIdentityFixture
- type TestingMessageFixture
- type Transaction
- func BuildDelegateRegistration(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildDelegateResignation(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildHtlcClaim(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildHtlcLock(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildHtlcRefund(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildIpfs(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildMultiPayment(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildMultiSignatureRegistration(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildSecondSignatureRegistration(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildTransfer(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func BuildTransferMultiSignature(transaction *Transaction, signerIndex int, passphrase string) *Transaction
- func BuildVote(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
- func DeserializeTransaction(serialized string) *Transaction
- func (transaction *Transaction) GetId() string
- func (transaction *Transaction) ParseSignatures(sigOffset int) *Transaction
- func (transaction *Transaction) ParseSignaturesECDSA(signatures []byte) *Transaction
- func (transaction *Transaction) ParseSignaturesSchnorr(signatures []byte) *Transaction
- func (transaction *Transaction) SecondSign(passphrase string)
- func (transaction *Transaction) SecondVerify(secondPublicKey *PublicKey) (bool, error)
- func (transaction *Transaction) Sign(passphrase string)
- func (transaction *Transaction) SignMulti(signerIndex int, passphrase string)
- func (transaction *Transaction) ToJson() (string, error)
- func (transaction *Transaction) ToMap() map[string]interface{}
- func (transaction *Transaction) Verify(multiSignatureAsset ...*MultiSignatureRegistrationAsset) (bool, error)
- func (transaction *Transaction) VerifyMultiSignature(multiSignatureAsset *MultiSignatureRegistrationAsset) (bool, error)
- type TransactionAsset
- type TransactionFees
- type TransactionTypeGroups
- type TransactionTypes
Constants ¶
const ( SIGNATURE_TYPE_ECDSA = 0 SIGNATURE_TYPE_SCHNORR = 1 )
Variables ¶
var ( CONFIG_NETWORK = &Network{} CONFIG_FEES = []FlexToshi{ TRANSACTION_FEES.Transfer, TRANSACTION_FEES.SecondSignatureRegistration, TRANSACTION_FEES.DelegateRegistration, TRANSACTION_FEES.Vote, TRANSACTION_FEES.MultiSignatureRegistration, TRANSACTION_FEES.Ipfs, TRANSACTION_FEES.MultiPayment, TRANSACTION_FEES.DelegateResignation, TRANSACTION_FEES.HtlcLock, TRANSACTION_FEES.HtlcClaim, TRANSACTION_FEES.HtlcRefund, } CONFIG_SIGNATURE_TYPE = SIGNATURE_TYPE_SCHNORR )
var ( TRANSACTION_TYPES = &TransactionTypes{ Transfer: 0, SecondSignatureRegistration: 1, DelegateRegistration: 2, Vote: 3, MultiSignatureRegistration: 4, Ipfs: 5, MultiPayment: 6, DelegateResignation: 7, HtlcLock: 8, HtlcClaim: 9, HtlcRefund: 10, } TRANSACTION_TYPE_GROUPS = &TransactionTypeGroups{ Test: 0, Core: 1, } TRANSACTION_FEES = &TransactionFees{ Transfer: 10000000, SecondSignatureRegistration: 500000000, DelegateRegistration: 2500000000, Vote: 100000000, MultiSignatureRegistration: 500000000, Ipfs: 500000000, MultiPayment: 10000000, DelegateResignation: 2500000000, HtlcLock: 10000000, HtlcClaim: 0, HtlcRefund: 0, } )
var ( NETWORKS_MAINNET = &Network{ Epoch: time.Date(2017, 3, 21, 13, 00, 0, 0, time.UTC), Version: 23, Wif: 170, } NETWORKS_DEVNET = &Network{ Epoch: time.Date(2017, 3, 21, 13, 00, 0, 0, time.UTC), Version: 30, Wif: 170, } NETWORKS_TESTNET = &Network{ Epoch: time.Date(2017, 3, 21, 13, 00, 0, 0, time.UTC), Version: 23, Wif: 186, } )
Functions ¶
func AddressFromPassphrase ¶
func Base58CheckDecodeFatal ¶
func ECDSASignatureLen ¶
func GetFixture ¶
func SetNetwork ¶
func SetNetwork(network *Network)
func ValidateAddress ¶
Types ¶
type DelegateAsset ¶
type DelegateAsset struct {
Username string `json:"username,omitempty"`
}
type HtlcClaimAsset ¶
type HtlcLockAsset ¶
type HtlcLockAsset struct { SecretHash string `json:"secretHash,omitempty"` Expiration *HtlcLockExpirationAsset `json:"expiration,omitempty"` }
type HtlcLockExpirationAsset ¶
type HtlcRefundAsset ¶
type HtlcRefundAsset struct {
LockTransactionId string `json:"lockTransactionId,omitempty"`
}
type Message ¶
type MultiPaymentAsset ¶
type Network ¶
func GetNetwork ¶
func GetNetwork() *Network
type PrivateKey ¶
type PrivateKey struct { *btcec.PrivateKey PublicKey *PublicKey }
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(bytes []byte) *PrivateKey
func PrivateKeyFromHex ¶
func PrivateKeyFromHex(privateKeyHex string) (*PrivateKey, error)
func PrivateKeyFromPassphrase ¶
func PrivateKeyFromPassphrase(passphrase string) (*PrivateKey, error)
func (*PrivateKey) SignSchnorr ¶
func (privateKey *PrivateKey) SignSchnorr(hash []byte) ([]byte, error)
func (*PrivateKey) ToAddress ¶
func (privateKey *PrivateKey) ToAddress() string
func (*PrivateKey) ToHex ¶
func (privateKey *PrivateKey) ToHex() string
func (*PrivateKey) ToWif ¶
func (privateKey *PrivateKey) ToWif() string
type PublicKey ¶
type PublicKey struct { *btcec.PublicKey Network *Network // contains filtered or unexported fields }
func PublicKeyFromBytes ¶
func PublicKeyFromHex ¶
func PublicKeyFromPassphrase ¶
func (*PublicKey) AddressBytes ¶
func (*PublicKey) VerifyECDSA ¶
type SecondSignatureRegistrationAsset ¶
type SecondSignatureRegistrationAsset struct {
PublicKey string `json:"publicKey,omitempty"`
}
type TestingFixture ¶
type TestingFixture struct { MultiSignatureAsset MultiSignatureRegistrationAsset `json:"multiSignatureAsset"` Transaction Transaction `json:"transaction"` SerializedHex string `json:"serializedHex"` }
type TestingIdentityFixture ¶
type TestingIdentityFixture struct { Data struct { PrivateKey string `json:"privateKey,omitempty"` PublicKey string `json:"publicKey,omitempty"` Address string `json:"address,omitempty"` WIF string `json:"wif,omitempty"` } `json:"data,omitempty"` Passphrase string `json:"passphrase,omitempty"` }
func GetIdentityFixture ¶
func GetIdentityFixture() TestingIdentityFixture
type TestingMessageFixture ¶
type TestingMessageFixture struct { Data struct { PublicKey string `json:"publickey,omitempty"` Signature string `json:"signature,omitempty"` Message string `json:"message,omitempty"` } `json:"data,omitempty"` Passphrase string `json:"passphrase,omitempty"` }
func GetMessageFixture ¶
func GetMessageFixture() TestingMessageFixture
type Transaction ¶
type Transaction struct { // XXX check that all relevant fields are set in all Build*() methods Amount FlexToshi `json:"amount,omitempty"` Asset *TransactionAsset `json:"asset,omitempty"` Expiration uint32 `json:"expiration,omitempty"` Fee FlexToshi `json:"fee,omitempty"` Id string `json:"id,omitempty"` Network byte `json:"network,omitempty"` Nonce uint64 `json:"nonce,omitempty,string"` RecipientId string `json:"recipientId,omitempty"` SecondSenderPublicKey string `json:"secondSenderPublicKey,omitempty"` SecondSignature string `json:"secondSignature,omitempty"` SenderPublicKey string `json:"senderPublicKey,omitempty"` Serialized []byte `json:"serialized,omitempty"` Signature string `json:"signature,omitempty"` Signatures []string `json:"signatures,omitempty"` Timestamp int32 `json:"timestamp,omitempty"` Type uint16 `json:"type"` TypeGroup uint32 `json:"typeGroup"` VendorField string `json:"vendorField,omitempty"` Version byte `json:"version,omitempty"` }
func BuildDelegateRegistration ¶
func BuildDelegateRegistration(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.DelegateRegistration transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Delegate.Username
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildDelegateResignation ¶
func BuildDelegateResignation(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.DelegateResignation transaction.
- Members of the supplied transaction that must be set when calling this function:
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildHtlcClaim ¶
func BuildHtlcClaim(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.HtlcClaim transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Claim
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildHtlcLock ¶
func BuildHtlcLock(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.HtlcLock transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Lock
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildHtlcRefund ¶
func BuildHtlcRefund(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.HtlcRefund transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Refund
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildIpfs ¶
func BuildIpfs(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.Ipfs transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Ipfs
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildMultiPayment ¶
func BuildMultiPayment(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.MultiPayment transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Payments
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildMultiSignatureRegistration ¶
func BuildMultiSignatureRegistration(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.MultiSignatureRegistration transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.MultiSignature
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildSecondSignatureRegistration ¶
func BuildSecondSignatureRegistration(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.SecondSignatureRegistration transaction.
- Members of the supplied transaction that must be set when calling this function:
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildTransfer ¶
func BuildTransfer(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.Transfer transaction.
- Members of the supplied transaction that must be set when calling this function:
- Amount
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- RecipientId
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildTransferMultiSignature ¶
func BuildTransferMultiSignature(transaction *Transaction, signerIndex int, passphrase string) *Transaction
* Set all fields and sign a multi signature TransactionTypes.Transfer transaction.
- Members of the supplied transaction that must be set when calling this function:
- Amount
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- RecipientId
- Signatures - must be an array (could be empty); a new signature will be appended to it
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func BuildVote ¶
func BuildVote(transaction *Transaction, passphrase string, secondPassphrase string) *Transaction
* Set all fields and sign a TransactionTypes.Vote transaction.
- Members of the supplied transaction that must be set when calling this function:
- Asset.Votes
- Expiration - optional, could be 0 to designate no expiration
- Fee - optional, if 0, then it will be set to a default fee
- Network - optional, if 0, then it will be set to the configured network
- Nonce
- Timestamp - optional, if 0, then it will be set to the present time
- VendorField - optional
func DeserializeTransaction ¶
func DeserializeTransaction(serialized string) *Transaction
func (*Transaction) GetId ¶
func (transaction *Transaction) GetId() string
func (*Transaction) ParseSignatures ¶
func (transaction *Transaction) ParseSignatures(sigOffset int) *Transaction
func (*Transaction) ParseSignaturesECDSA ¶
func (transaction *Transaction) ParseSignaturesECDSA(signatures []byte) *Transaction
func (*Transaction) ParseSignaturesSchnorr ¶
func (transaction *Transaction) ParseSignaturesSchnorr(signatures []byte) *Transaction
func (*Transaction) SecondSign ¶
func (transaction *Transaction) SecondSign(passphrase string)
func (*Transaction) SecondVerify ¶
func (transaction *Transaction) SecondVerify(secondPublicKey *PublicKey) (bool, error)
func (*Transaction) Sign ¶
func (transaction *Transaction) Sign(passphrase string)
func (*Transaction) SignMulti ¶
func (transaction *Transaction) SignMulti(signerIndex int, passphrase string)
func (*Transaction) ToJson ¶
func (transaction *Transaction) ToJson() (string, error)
func (*Transaction) ToMap ¶
func (transaction *Transaction) ToMap() map[string]interface{}
func (*Transaction) Verify ¶
func (transaction *Transaction) Verify(multiSignatureAsset ...*MultiSignatureRegistrationAsset) (bool, error)
func (*Transaction) VerifyMultiSignature ¶
func (transaction *Transaction) VerifyMultiSignature(multiSignatureAsset *MultiSignatureRegistrationAsset) (bool, error)
type TransactionAsset ¶
type TransactionAsset struct { Votes []string `json:"votes,omitempty"` Signature *SecondSignatureRegistrationAsset `json:"signature,omitempty"` Delegate *DelegateAsset `json:"delegate,omitempty"` MultiSignature *MultiSignatureRegistrationAsset `json:"multiSignature,omitempty"` Ipfs string `json:"ipfs,omitempty"` Payments []*MultiPaymentAsset `json:"payments,omitempty"` Lock *HtlcLockAsset `json:"lock,omitempty"` Claim *HtlcClaimAsset `json:"claim,omitempty"` Refund *HtlcRefundAsset `json:"refund,omitempty"` }