tx

package
v0.0.0-...-3927449 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 23 Imported by: 8

README

GoDoc

transaction

Overview

This library is for cheking and packing transactions, and doing Proof of Work(PoW).

Requirements

  • git
  • go 1.9+

are required to compile this.

Installation

 $ go get github.com/AidosKuneen/aklib

Example

(This example omits error handlings for simplicity.)

	import "github.com/AidosKuneen/aklib/tx"
	import "github.com/AidosKuneen/aklib"
	import "github.com/AidosKuneen/aklib/address"

	var tx1,tx2,tx3,tx4 tx.Hash
	var adr1,adr2,adr3 string 
	var adr address.Address
	tr:=tx.New(aklib.MainConfig,tx1,tx2)
	tr.AddInput(tx3, 0)
	tr.AddMultisigIn(tx4, 1)
	if err := tr.AddOutput(aklib.DebugConfig, adr1, 111); err != nil {
	}
	if err := tr.AddMultisigOut(aklib.DebugConfig, 2, 331,adr1, adr2, adr3);err!=nil{
	}
	if err := tr.Sign(adr); err != nil {
		t.Error(err)
	}
	if err := tr.PoW(); err != nil {
	}
	if err := tr.Check(MainConfig,tx.TxNormal); err == nil {
	}
	if err := tr.CheckAll(aklib.MainConfig,GetTxFunction, TxNormal); err == nil {
	}
	h = tr.Hash()

Expected Time for PoW

The expecting time of suceeding to find a solution of cuckoo is around 20 seconds and 3-sigma is 60 seconds for general low-end PCs, and this lib is configured to do 2^2=4 times in average to meet hash-based PoW now. And generally high-end servers need half of this time.

So the estimation of expecting PoW time

  • for low-end PCs is 80 seconds in average and 3-sigma is 240 seconds.
  • for high-end servers is 40 seconds in average and 3-sigma is 120 seconds.

Documentation

Index

Constants

View Source
const (
	MessageMax          = 255
	TransactionMax      = 2000000
	ArrayMax            = 255
	DefaultPreviousSize = 2
)

max length of tx and fields in a transaction.

View Source
const (
	//HashTypeExcludeOutputs is for excluding some outputs.
	HashTypeNormal           = 0x0
	HashTypeExcludeOutputs   = 0x10
	HashTypeExcludeTicketOut = 0x20
)

Types when hashing a tx.

Variables

View Source
var (
	ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTx   = fmt.Errorf("proto: integer overflow")
)
View Source
var ErrCanceled = errors.New("PoW was canceled")

ErrCanceled means the PoW was canceled by context.

Functions

func Inout2key

func Inout2key(h Hash, typ InOutHashType, no byte) []byte

Inout2key returns a slice of serialized inout data.

func Inout2keyArray

func Inout2keyArray(h Hash, typ InOutHashType, no byte) [34]byte

Inout2keyArray returns a serialized inout data as an array.

func SetupFee

func SetupFee(conf *aklib.Config, w Wallet2, p *FeeParam, tr *Transaction) error

SetupFee setups a fee pram into the tr..

Types

type Body

type Body struct {
	Type         ByteSlice                                  `protobuf:"bytes,1,opt,name=type,proto3,casttype=ByteSlice" json:"type,omitempty"`
	Nonce        []uint32                                   `protobuf:"varint,2,rep,packed,name=nonce,proto3" json:"nonce,omitempty"`
	Gnonce       uint32                                     `protobuf:"varint,3,opt,name=gnonce,proto3" json:"gnonce,omitempty"`
	Time         time.Time                                  `protobuf:"bytes,4,opt,name=time,proto3,stdtime" json:"time"`
	Message      ByteSlice                                  `protobuf:"bytes,5,opt,name=message,proto3,casttype=ByteSlice" json:"message,omitempty"`
	ExchangeKey  []byte                                     `protobuf:"bytes,6,opt,name=exchange_key,json=exchangeKey,proto3" json:"exchange_key,omitempty"`
	Inputs       []*Input                                   `protobuf:"bytes,7,rep,name=inputs,proto3" json:"inputs,omitempty"`
	MultiSigIns  []*MultiSigIn                              `protobuf:"bytes,8,rep,name=multi_sig_ins,json=multiSigIns,proto3" json:"multi_sig_ins,omitempty"`
	Outputs      []*Output                                  `protobuf:"bytes,9,rep,name=outputs,proto3" json:"outputs,omitempty"`
	MultiSigOuts []*MultiSigOut                             `protobuf:"bytes,10,rep,name=multi_sig_outs,json=multiSigOuts,proto3" json:"multi_sig_outs,omitempty"`
	Parent       []Hash                                     `protobuf:"bytes,11,rep,name=parent,proto3,casttype=Hash" json:"parent,omitempty"`
	Easiness     uint32                                     `protobuf:"varint,12,opt,name=easiness,proto3" json:"easiness,omitempty"`
	LockTime     time.Time                                  `protobuf:"bytes,13,opt,name=lock_time,json=lockTime,proto3,stdtime" json:"lock_time"`
	HashType     uint16                                     `protobuf:"varint,14,opt,name=hash_type,json=hashType,proto3,casttype=uint16" json:"hash_type,omitempty"`
	TicketInput  Hash                                       `protobuf:"bytes,15,opt,name=ticket_input,json=ticketInput,proto3,casttype=Hash" json:"ticket_input,omitempty"`
	TicketOutput github_com_AidosKuneen_aklib_address.Bytes `` /* 150-byte string literal not displayed */
}

Body is a Transactoin except signature.

func NewPopulatedBody

func NewPopulatedBody(r randyTx, easy bool) *Body

func (*Body) AddInput

func (body *Body) AddInput(h Hash, idx byte)

AddInput add an input into tx.

func (*Body) AddMultisigIn

func (body *Body) AddMultisigIn(h Hash, idx byte)

AddMultisigIn add a multisig input into tx.

func (*Body) AddMultisigOut

func (body *Body) AddMultisigOut(cfg *aklib.Config, m byte, v uint64, adrs ...string) error

AddMultisigOut add a mulsig output into tx.

func (*Body) AddOutput

func (body *Body) AddOutput(cfg *aklib.Config, adr string, v uint64) error

AddOutput add an output into tx.

func (*Body) Descriptor

func (*Body) Descriptor() ([]byte, []int)

func (*Body) Equal

func (this *Body) Equal(that interface{}) bool

func (*Body) Marshal

func (m *Body) Marshal() (dAtA []byte, err error)

func (*Body) MarshalTo

func (m *Body) MarshalTo(dAtA []byte) (int, error)

func (*Body) Prevs

func (body *Body) Prevs() []Hash

Prevs returns hashes of inputs/mulsiginputs and ticketinput hash.

func (*Body) ProtoMessage

func (*Body) ProtoMessage()

func (*Body) Reset

func (m *Body) Reset()

func (*Body) Size

func (m *Body) Size() (n int)

func (*Body) String

func (m *Body) String() string

func (*Body) Unmarshal

func (m *Body) Unmarshal(dAtA []byte) error

func (*Body) XXX_DiscardUnknown

func (m *Body) XXX_DiscardUnknown()

func (*Body) XXX_Marshal

func (m *Body) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Body) XXX_Merge

func (dst *Body) XXX_Merge(src proto.Message)

func (*Body) XXX_Size

func (m *Body) XXX_Size() int

func (*Body) XXX_Unmarshal

func (m *Body) XXX_Unmarshal(b []byte) error

type BuildParam

type BuildParam struct {
	Comment string
	Dest    []*RawOutput
	FeeParam
}

BuildParam is a param for building a tx..

type ByteSlice

type ByteSlice []byte

ByteSlice is a byte slice marsharing to hex string.

func (ByteSlice) MarshalJSON

func (bs ByteSlice) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (*ByteSlice) UnmarshalJSON

func (bs *ByteSlice) UnmarshalJSON(b []byte) error

UnmarshalJSON sets *bs to a copy of data.

type FeeParam

type FeeParam struct {
	PoWType Type
	Fee     uint64
}

FeeParam is a param for fee.

type GetTXFunc

type GetTXFunc func(hash []byte) (*Body, error)

GetTXFunc gets tx.

type Hash

type Hash []byte

Hash is a tx hash.

func (Hash) Array

func (h Hash) Array() [32]byte

Array converts slice to array If opssible the func get the underlaying array of slice h. So don't modify the returned array.

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(b []byte) error

UnmarshalJSON sets *bs to a copy of data.

type HashWithType

type HashWithType struct {
	Hash Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=Hash" json:"hash,omitempty"`
	Type Type `protobuf:"varint,2,opt,name=type,proto3,casttype=Type" json:"type,omitempty"`
}

func NewPopulatedHashWithType

func NewPopulatedHashWithType(r randyTx, easy bool) *HashWithType

func (*HashWithType) Descriptor

func (*HashWithType) Descriptor() ([]byte, []int)

func (*HashWithType) Equal

func (this *HashWithType) Equal(that interface{}) bool

func (*HashWithType) Marshal

func (m *HashWithType) Marshal() (dAtA []byte, err error)

func (*HashWithType) MarshalTo

func (m *HashWithType) MarshalTo(dAtA []byte) (int, error)

func (*HashWithType) ProtoMessage

func (*HashWithType) ProtoMessage()

func (*HashWithType) Reset

func (m *HashWithType) Reset()

func (*HashWithType) Size

func (m *HashWithType) Size() (n int)

func (*HashWithType) String

func (m *HashWithType) String() string

func (*HashWithType) Unmarshal

func (m *HashWithType) Unmarshal(dAtA []byte) error

func (*HashWithType) XXX_DiscardUnknown

func (m *HashWithType) XXX_DiscardUnknown()

func (*HashWithType) XXX_Marshal

func (m *HashWithType) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HashWithType) XXX_Merge

func (dst *HashWithType) XXX_Merge(src proto.Message)

func (*HashWithType) XXX_Size

func (m *HashWithType) XXX_Size() int

func (*HashWithType) XXX_Unmarshal

func (m *HashWithType) XXX_Unmarshal(b []byte) error

type InOutHashType

type InOutHashType byte

InOutHashType is a type in InOutHash struct.

const (
	TypeIn InOutHashType = iota
	TypeMulin
	TypeTicketin
	TypeOut
	TypeMulout
	TypeTicketout
	TypeOTAOut
)

Types for in/out txs.

func (InOutHashType) String

func (t InOutHashType) String() string

type InoutHash

type InoutHash struct {
	Hash  Hash          `protobuf:"bytes,1,opt,name=hash,proto3,casttype=Hash" json:"hash,omitempty"`
	Type  InOutHashType `protobuf:"varint,2,opt,name=type,proto3,casttype=InOutHashType" json:"type,omitempty"`
	Index byte          `protobuf:"varint,3,opt,name=index,proto3,casttype=byte" json:"index,omitempty"`
}

InOutHashType is a type in InOutHash struct.

func InputHashes

func InputHashes(tr *Body) []*InoutHash

InputHashes returns output info referred by inputs of tr..

func NewInoutHash

func NewInoutHash(dat []byte) (*InoutHash, error)

NewInoutHash returns a InoutHash object from serialized inout data.

func NewPopulatedInoutHash

func NewPopulatedInoutHash(r randyTx, easy bool) *InoutHash

func (*InoutHash) Bytes

func (ih *InoutHash) Bytes() []byte

Bytes returns a serialized inout data as a slice.

func (*InoutHash) Descriptor

func (*InoutHash) Descriptor() ([]byte, []int)

func (*InoutHash) Equal

func (this *InoutHash) Equal(that interface{}) bool

func (*InoutHash) Marshal

func (m *InoutHash) Marshal() (dAtA []byte, err error)

func (*InoutHash) MarshalTo

func (m *InoutHash) MarshalTo(dAtA []byte) (int, error)

func (*InoutHash) ProtoMessage

func (*InoutHash) ProtoMessage()

func (*InoutHash) Reset

func (m *InoutHash) Reset()

func (*InoutHash) Serialize

func (ih *InoutHash) Serialize() [34]byte

Serialize returns serialized a 34 bytes array.

func (*InoutHash) Size

func (m *InoutHash) Size() (n int)

func (*InoutHash) String

func (m *InoutHash) String() string

func (*InoutHash) Unmarshal

func (m *InoutHash) Unmarshal(dAtA []byte) error

func (*InoutHash) XXX_DiscardUnknown

func (m *InoutHash) XXX_DiscardUnknown()

func (*InoutHash) XXX_Marshal

func (m *InoutHash) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InoutHash) XXX_Merge

func (dst *InoutHash) XXX_Merge(src proto.Message)

func (*InoutHash) XXX_Size

func (m *InoutHash) XXX_Size() int

func (*InoutHash) XXX_Unmarshal

func (m *InoutHash) XXX_Unmarshal(b []byte) error

type Input

type Input struct {
	PreviousTX Hash `protobuf:"bytes,1,opt,name=previous_tx,json=previousTx,proto3,casttype=Hash" json:"previous_tx,omitempty"`
	Index      byte `protobuf:"varint,2,opt,name=index,proto3,casttype=byte" json:"index,omitempty"`
}

Input is an input in transactions.

func NewPopulatedInput

func NewPopulatedInput(r randyTx, easy bool) *Input

func (*Input) Descriptor

func (*Input) Descriptor() ([]byte, []int)

func (*Input) Equal

func (this *Input) Equal(that interface{}) bool

func (*Input) Marshal

func (m *Input) Marshal() (dAtA []byte, err error)

func (*Input) MarshalTo

func (m *Input) MarshalTo(dAtA []byte) (int, error)

func (*Input) ProtoMessage

func (*Input) ProtoMessage()

func (*Input) Reset

func (m *Input) Reset()

func (*Input) Size

func (m *Input) Size() (n int)

func (*Input) String

func (m *Input) String() string

func (*Input) Unmarshal

func (m *Input) Unmarshal(dAtA []byte) error

func (*Input) XXX_DiscardUnknown

func (m *Input) XXX_DiscardUnknown()

func (*Input) XXX_Marshal

func (m *Input) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Input) XXX_Merge

func (dst *Input) XXX_Merge(src proto.Message)

func (*Input) XXX_Size

func (m *Input) XXX_Size() int

func (*Input) XXX_Unmarshal

func (m *Input) XXX_Unmarshal(b []byte) error

type MultiSigIn

type MultiSigIn struct {
	PreviousTX Hash `protobuf:"bytes,1,opt,name=previous_tx,json=previousTx,proto3,casttype=Hash" json:"previous_tx,omitempty"`
	Index      byte `protobuf:"varint,2,opt,name=index,proto3,casttype=byte" json:"index,omitempty"`
}

MultiSigIn is an multisig input in transactions.

func NewPopulatedMultiSigIn

func NewPopulatedMultiSigIn(r randyTx, easy bool) *MultiSigIn

func (*MultiSigIn) Descriptor

func (*MultiSigIn) Descriptor() ([]byte, []int)

func (*MultiSigIn) Equal

func (this *MultiSigIn) Equal(that interface{}) bool

func (*MultiSigIn) Marshal

func (m *MultiSigIn) Marshal() (dAtA []byte, err error)

func (*MultiSigIn) MarshalTo

func (m *MultiSigIn) MarshalTo(dAtA []byte) (int, error)

func (*MultiSigIn) ProtoMessage

func (*MultiSigIn) ProtoMessage()

func (*MultiSigIn) Reset

func (m *MultiSigIn) Reset()

func (*MultiSigIn) Size

func (m *MultiSigIn) Size() (n int)

func (*MultiSigIn) String

func (m *MultiSigIn) String() string

func (*MultiSigIn) Unmarshal

func (m *MultiSigIn) Unmarshal(dAtA []byte) error

func (*MultiSigIn) XXX_DiscardUnknown

func (m *MultiSigIn) XXX_DiscardUnknown()

func (*MultiSigIn) XXX_Marshal

func (m *MultiSigIn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MultiSigIn) XXX_Merge

func (dst *MultiSigIn) XXX_Merge(src proto.Message)

func (*MultiSigIn) XXX_Size

func (m *MultiSigIn) XXX_Size() int

func (*MultiSigIn) XXX_Unmarshal

func (m *MultiSigIn) XXX_Unmarshal(b []byte) error

type MultiSigOut

type MultiSigOut struct {
	MultisigStruct `protobuf:"bytes,1,opt,name=MultisigStruct,proto3,embedded=MultisigStruct" json:"MultisigStruct"`
	Value          uint64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
}

MultiSigOut is an multisig output in transactions.

func NewPopulatedMultiSigOut

func NewPopulatedMultiSigOut(r randyTx, easy bool) *MultiSigOut

func (*MultiSigOut) Descriptor

func (*MultiSigOut) Descriptor() ([]byte, []int)

func (*MultiSigOut) Equal

func (this *MultiSigOut) Equal(that interface{}) bool

func (*MultiSigOut) Marshal

func (m *MultiSigOut) Marshal() (dAtA []byte, err error)

func (*MultiSigOut) MarshalTo

func (m *MultiSigOut) MarshalTo(dAtA []byte) (int, error)

func (*MultiSigOut) ProtoMessage

func (*MultiSigOut) ProtoMessage()

func (*MultiSigOut) Reset

func (m *MultiSigOut) Reset()

func (*MultiSigOut) Size

func (m *MultiSigOut) Size() (n int)

func (*MultiSigOut) String

func (m *MultiSigOut) String() string

func (*MultiSigOut) Unmarshal

func (m *MultiSigOut) Unmarshal(dAtA []byte) error

func (*MultiSigOut) XXX_DiscardUnknown

func (m *MultiSigOut) XXX_DiscardUnknown()

func (*MultiSigOut) XXX_Marshal

func (m *MultiSigOut) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MultiSigOut) XXX_Merge

func (dst *MultiSigOut) XXX_Merge(src proto.Message)

func (*MultiSigOut) XXX_Size

func (m *MultiSigOut) XXX_Size() int

func (*MultiSigOut) XXX_Unmarshal

func (m *MultiSigOut) XXX_Unmarshal(b []byte) error

type MultisigStruct

type MultisigStruct struct {
	M         byte                                         `protobuf:"varint,1,opt,name=m,proto3,casttype=byte" json:"m,omitempty"`
	Addresses []github_com_AidosKuneen_aklib_address.Bytes `protobuf:"bytes,2,rep,name=addresses,proto3,casttype=github.com/AidosKuneen/aklib/address.Bytes" json:"addresses,omitempty"`
}

MultisigStruct is a structure of multisig.

func NewPopulatedMultisigStruct

func NewPopulatedMultisigStruct(r randyTx, easy bool) *MultisigStruct

func (*MultisigStruct) Address

func (mout *MultisigStruct) Address(cfg *aklib.Config) string

Address returns a multisig address.

func (*MultisigStruct) AddressByte

func (mout *MultisigStruct) AddressByte(cfg *aklib.Config) address.Bytes

AddressByte returns a multisig address in binary form.

func (*MultisigStruct) Descriptor

func (*MultisigStruct) Descriptor() ([]byte, []int)

func (*MultisigStruct) Equal

func (this *MultisigStruct) Equal(that interface{}) bool

func (*MultisigStruct) Marshal

func (m *MultisigStruct) Marshal() (dAtA []byte, err error)

func (*MultisigStruct) MarshalTo

func (m *MultisigStruct) MarshalTo(dAtA []byte) (int, error)

func (*MultisigStruct) ProtoMessage

func (*MultisigStruct) ProtoMessage()

func (*MultisigStruct) Reset

func (m *MultisigStruct) Reset()

func (*MultisigStruct) Size

func (m *MultisigStruct) Size() (n int)

func (*MultisigStruct) String

func (m *MultisigStruct) String() string

func (*MultisigStruct) Unmarshal

func (m *MultisigStruct) Unmarshal(dAtA []byte) error

func (*MultisigStruct) XXX_DiscardUnknown

func (m *MultisigStruct) XXX_DiscardUnknown()

func (*MultisigStruct) XXX_Marshal

func (m *MultisigStruct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MultisigStruct) XXX_Merge

func (dst *MultisigStruct) XXX_Merge(src proto.Message)

func (*MultisigStruct) XXX_Size

func (m *MultisigStruct) XXX_Size() int

func (*MultisigStruct) XXX_Unmarshal

func (m *MultisigStruct) XXX_Unmarshal(b []byte) error

type Output

type Output struct {
	Address github_com_AidosKuneen_aklib_address.Bytes `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/AidosKuneen/aklib/address.Bytes" json:"address,omitempty"`
	Value   uint64                                     `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
}

Output is an output in transactions.

func NewPopulatedOutput

func NewPopulatedOutput(r randyTx, easy bool) *Output

func (*Output) Descriptor

func (*Output) Descriptor() ([]byte, []int)

func (*Output) Equal

func (this *Output) Equal(that interface{}) bool

func (*Output) Marshal

func (m *Output) Marshal() (dAtA []byte, err error)

func (*Output) MarshalTo

func (m *Output) MarshalTo(dAtA []byte) (int, error)

func (*Output) ProtoMessage

func (*Output) ProtoMessage()

func (*Output) Reset

func (m *Output) Reset()

func (*Output) Size

func (m *Output) Size() (n int)

func (*Output) String

func (m *Output) String() string

func (*Output) Unmarshal

func (m *Output) Unmarshal(dAtA []byte) error

func (*Output) XXX_DiscardUnknown

func (m *Output) XXX_DiscardUnknown()

func (*Output) XXX_Marshal

func (m *Output) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Output) XXX_Merge

func (dst *Output) XXX_Merge(src proto.Message)

func (*Output) XXX_Size

func (m *Output) XXX_Size() int

func (*Output) XXX_Unmarshal

func (m *Output) XXX_Unmarshal(b []byte) error

type RawOutput

type RawOutput struct {
	Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	Value   uint64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
}

RawOutput is an output in a tx.

func NewPopulatedRawOutput

func NewPopulatedRawOutput(r randyTx, easy bool) *RawOutput

func (*RawOutput) Descriptor

func (*RawOutput) Descriptor() ([]byte, []int)

func (*RawOutput) Equal

func (this *RawOutput) Equal(that interface{}) bool

func (*RawOutput) Marshal

func (m *RawOutput) Marshal() (dAtA []byte, err error)

func (*RawOutput) MarshalTo

func (m *RawOutput) MarshalTo(dAtA []byte) (int, error)

func (*RawOutput) ProtoMessage

func (*RawOutput) ProtoMessage()

func (*RawOutput) Reset

func (m *RawOutput) Reset()

func (*RawOutput) Size

func (m *RawOutput) Size() (n int)

func (*RawOutput) String

func (m *RawOutput) String() string

func (*RawOutput) Unmarshal

func (m *RawOutput) Unmarshal(dAtA []byte) error

func (*RawOutput) XXX_DiscardUnknown

func (m *RawOutput) XXX_DiscardUnknown()

func (*RawOutput) XXX_Marshal

func (m *RawOutput) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RawOutput) XXX_Merge

func (dst *RawOutput) XXX_Merge(src proto.Message)

func (*RawOutput) XXX_Size

func (m *RawOutput) XXX_Size() int

func (*RawOutput) XXX_Unmarshal

func (m *RawOutput) XXX_Unmarshal(b []byte) error

type Signatures

type Signatures struct {
	Sigs []*address.Signature `protobuf:"bytes,1,rep,name=sigs,proto3" json:"sigs,omitempty"`
}

Signatures is a slice of Signature for protobuf

func NewPopulatedSignatures

func NewPopulatedSignatures(r randyTx, easy bool) *Signatures

func (*Signatures) Descriptor

func (*Signatures) Descriptor() ([]byte, []int)

func (*Signatures) Equal

func (this *Signatures) Equal(that interface{}) bool

func (*Signatures) Marshal

func (m *Signatures) Marshal() (dAtA []byte, err error)

func (*Signatures) MarshalTo

func (m *Signatures) MarshalTo(dAtA []byte) (int, error)

func (*Signatures) ProtoMessage

func (*Signatures) ProtoMessage()

func (*Signatures) Reset

func (m *Signatures) Reset()

func (*Signatures) Size

func (m *Signatures) Size() (n int)

func (*Signatures) String

func (m *Signatures) String() string

func (*Signatures) Unmarshal

func (m *Signatures) Unmarshal(dAtA []byte) error

func (*Signatures) XXX_DiscardUnknown

func (m *Signatures) XXX_DiscardUnknown()

func (*Signatures) XXX_Marshal

func (m *Signatures) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Signatures) XXX_Merge

func (dst *Signatures) XXX_Merge(src proto.Message)

func (*Signatures) XXX_Size

func (m *Signatures) XXX_Size() int

func (*Signatures) XXX_Unmarshal

func (m *Signatures) XXX_Unmarshal(b []byte) error

type Transaction

type Transaction struct {
	*Body      `protobuf:"bytes,1,opt,name=body,proto3,embedded=body" json:"body,omitempty"`
	Signatures `protobuf:"bytes,2,opt,name=signatures,proto3,embedded=signatures" json:"signatures"`
}

Transaction is a transactio in Aidos Kuneen.

func Build

func Build(conf *aklib.Config, w Wallet2, p *BuildParam) (*Transaction, error)

Build builds a tx for sending coins with fee or ticket..

func BuildMain

func BuildMain(conf *aklib.Config, w Wallet, tag []byte, outputs []*RawOutput,
	beforeSignFunc func(*Transaction) error) (*Transaction, error)

BuildMain builds a tx for sending coins.

func IssueTicket

func IssueTicket(ctx context.Context, s *aklib.Config, ticketOut []byte, previous ...Hash) (*Transaction, error)

IssueTicket make and does PoW for a transaction for issuing tx.

func New

func New(s *aklib.Config, previous ...Hash) *Transaction

New returns a transaction object.

func NewMinableFee

func NewMinableFee(s *aklib.Config, previous ...Hash) *Transaction

NewMinableFee returns a minable transaction by fee..

func NewMinableTicket

func NewMinableTicket(s *aklib.Config, ticketIn Hash, previous ...Hash) *Transaction

NewMinableTicket returns a minable transaction by ticket..

func NewPopulatedTransaction

func NewPopulatedTransaction(r randyTx, easy bool) *Transaction

func (*Transaction) AddOTAOutput

func (tr *Transaction) AddOTAOutput(s *aklib.Config, otAddress string, v uint64) (*address.Address, error)

AddOTAOutput returns a tx with outout of one time address.

func (*Transaction) AddSig

func (tr *Transaction) AddSig(sig *address.Signature)

AddSig adds a signature to tx.

func (*Transaction) Check

func (tr *Transaction) Check(cfg *aklib.Config, typ Type) error

Check checks the tx.

func (*Transaction) CheckAll

func (tr *Transaction) CheckAll(cfg *aklib.Config, getTX GetTXFunc, typ Type) error

CheckAll checks the tx, including other txs referred by the tx.. Genesis block must be saved in the store

func (*Transaction) Clone

func (tr *Transaction) Clone() *Transaction

Clone clones tx.

func (*Transaction) Descriptor

func (*Transaction) Descriptor() ([]byte, []int)

func (*Transaction) Equal

func (this *Transaction) Equal(that interface{}) bool

func (*Transaction) Hash

func (tr *Transaction) Hash() Hash

Hash reteurns hash of tx.

func (*Transaction) Marshal

func (m *Transaction) Marshal() (dAtA []byte, err error)

func (*Transaction) MarshalJSON

func (tr *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON marshals Transaction into valid JSON.

func (*Transaction) MarshalTo

func (m *Transaction) MarshalTo(dAtA []byte) (int, error)

func (*Transaction) OTAAddress

func (tr *Transaction) OTAAddress(s *aklib.Config, priv *sidh.PrivateKey) (*address.Address, byte, error)

OTAAddress returns an shared address and its output index in OTA transaction. return err if the OTA is not mine.

func (*Transaction) PoW

func (tx *Transaction) PoW() error

PoW does PoW.

func (*Transaction) PoWContext

func (tx *Transaction) PoWContext(ctx context.Context) error

PoWContext does PoW with context..

func (*Transaction) ProtoMessage

func (*Transaction) ProtoMessage()

func (*Transaction) Reset

func (m *Transaction) Reset()

func (*Transaction) Sign

func (tr *Transaction) Sign(a *address.Address) error

Sign sings the tx.

func (*Transaction) Signature

func (tr *Transaction) Signature(a *address.Address) (*address.Signature, error)

Signature returns singture of the tx.

func (*Transaction) Size

func (m *Transaction) Size() (n int)

func (*Transaction) String

func (m *Transaction) String() string

func (*Transaction) Unmarshal

func (m *Transaction) Unmarshal(dAtA []byte) error

func (*Transaction) XXX_DiscardUnknown

func (m *Transaction) XXX_DiscardUnknown()

func (*Transaction) XXX_Marshal

func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Transaction) XXX_Merge

func (dst *Transaction) XXX_Merge(src proto.Message)

func (*Transaction) XXX_Size

func (m *Transaction) XXX_Size() int

func (*Transaction) XXX_Unmarshal

func (m *Transaction) XXX_Unmarshal(b []byte) error

type TransactionSigHash

type TransactionSigHash struct {
	*Body   `protobuf:"bytes,1,opt,name=body,proto3,embedded=body" json:"body,omitempty"`
	SigHash []byte `protobuf:"bytes,2,opt,name=sig_hash,json=sigHash,proto3" json:"sig_hash,omitempty"`
}

TransactionSigHash is a transactio whose sig is hash.

func NewPopulatedTransactionSigHash

func NewPopulatedTransactionSigHash(r randyTx, easy bool) *TransactionSigHash

func (*TransactionSigHash) Descriptor

func (*TransactionSigHash) Descriptor() ([]byte, []int)

func (*TransactionSigHash) Equal

func (this *TransactionSigHash) Equal(that interface{}) bool

func (*TransactionSigHash) Marshal

func (m *TransactionSigHash) Marshal() (dAtA []byte, err error)

func (*TransactionSigHash) MarshalTo

func (m *TransactionSigHash) MarshalTo(dAtA []byte) (int, error)

func (*TransactionSigHash) ProtoMessage

func (*TransactionSigHash) ProtoMessage()

func (*TransactionSigHash) Reset

func (m *TransactionSigHash) Reset()

func (*TransactionSigHash) Size

func (m *TransactionSigHash) Size() (n int)

func (*TransactionSigHash) String

func (m *TransactionSigHash) String() string

func (*TransactionSigHash) Unmarshal

func (m *TransactionSigHash) Unmarshal(dAtA []byte) error

func (*TransactionSigHash) XXX_DiscardUnknown

func (m *TransactionSigHash) XXX_DiscardUnknown()

func (*TransactionSigHash) XXX_Marshal

func (m *TransactionSigHash) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TransactionSigHash) XXX_Merge

func (dst *TransactionSigHash) XXX_Merge(src proto.Message)

func (*TransactionSigHash) XXX_Size

func (m *TransactionSigHash) XXX_Size() int

func (*TransactionSigHash) XXX_Unmarshal

func (m *TransactionSigHash) XXX_Unmarshal(b []byte) error

type Type

type Type byte

Type is a tx type.

const (
	TypeNormal Type = iota
	TypeRewardTicket
	TypeRewardFee
	TypeNotPoWed
)

type for minable tx.

type UTXO

type UTXO struct {
	Name       string           `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Address    *address.Address `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
	*InoutHash `protobuf:"bytes,3,opt,name=inout_hash,json=inoutHash,proto3,embedded=inout_hash" json:"inout_hash,omitempty"`
	Value      uint64 `protobuf:"varint,4,opt,name=value,proto3" json:"value,omitempty"`
}

UTXO is an candidate of inputs in a tx.

func NewPopulatedUTXO

func NewPopulatedUTXO(r randyTx, easy bool) *UTXO

func (*UTXO) Descriptor

func (*UTXO) Descriptor() ([]byte, []int)

func (*UTXO) Equal

func (this *UTXO) Equal(that interface{}) bool

func (*UTXO) Marshal

func (m *UTXO) Marshal() (dAtA []byte, err error)

func (*UTXO) MarshalTo

func (m *UTXO) MarshalTo(dAtA []byte) (int, error)

func (*UTXO) ProtoMessage

func (*UTXO) ProtoMessage()

func (*UTXO) Reset

func (m *UTXO) Reset()

func (*UTXO) Size

func (m *UTXO) Size() (n int)

func (*UTXO) String

func (m *UTXO) String() string

func (*UTXO) Unmarshal

func (m *UTXO) Unmarshal(dAtA []byte) error

func (*UTXO) XXX_DiscardUnknown

func (m *UTXO) XXX_DiscardUnknown()

func (*UTXO) XXX_Marshal

func (m *UTXO) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UTXO) XXX_Merge

func (dst *UTXO) XXX_Merge(src proto.Message)

func (*UTXO) XXX_Size

func (m *UTXO) XXX_Size() int

func (*UTXO) XXX_Unmarshal

func (m *UTXO) XXX_Unmarshal(b []byte) error

type Wallet

type Wallet interface {
	GetUTXO(uint64) ([]*UTXO, error)
	NewChangeAddress() (*address.Address, error)
	GetLeaves() ([]Hash, error)
	UTXOUsed(*UTXO)
}

Wallet is a wallet interface for getting UTXOs and a new address.

type Wallet2

type Wallet2 interface {
	Wallet
	GetTicketout() (Hash, *address.Address, error)
}

Wallet2 is a wallet interface for getting a ticket out tx.

Jump to

Keyboard shortcuts

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