Documentation
¶
Index ¶
- Constants
- Variables
- func BuildUtxoTemplate(inputs []InputAndSigInst, outputs []*TxOutput) (*Template, TxData, error)
- func TxSign(tpl *Template, xprv chainkd.XPrv, xpub chainkd.XPub) error
- type AssetAmount
- func (*AssetAmount) Descriptor() ([]byte, []int)
- func (m *AssetAmount) GetAmount() uint64
- func (m *AssetAmount) GetAssetId() *AssetID
- func (*AssetAmount) ProtoMessage()
- func (a *AssetAmount) ReadFrom(r *extend.Reader) (err error)
- func (m *AssetAmount) Reset()
- func (m *AssetAmount) String() string
- func (a AssetAmount) WriteTo(w io.Writer) (int64, error)
- type AssetID
- func (a AssetID) Bytes() []byte
- func (*AssetID) Descriptor() ([]byte, []int)
- func (m *AssetID) GetV0() uint64
- func (m *AssetID) GetV1() uint64
- func (m *AssetID) GetV2() uint64
- func (m *AssetID) GetV3() uint64
- func (*AssetID) ProtoMessage()
- func (a *AssetID) ReadFrom(r io.Reader) (int64, error)
- func (m *AssetID) Reset()
- func (m *AssetID) String() string
- func (a AssetID) WriteTo(w io.Writer) (int64, error)
- type CoinbaseInput
- type DataWitness
- type Entry
- type Hash
- func (h Hash) Byte32() (b32 [32]byte)
- func (h Hash) Bytes() []byte
- func (*Hash) Descriptor() ([]byte, []int)
- func (m *Hash) GetV0() uint64
- func (m *Hash) GetV1() uint64
- func (m *Hash) GetV2() uint64
- func (m *Hash) GetV3() uint64
- func (*Hash) ProtoMessage()
- func (h *Hash) ReadFrom(r io.Reader) (int64, error)
- func (m *Hash) Reset()
- func (m *Hash) String() string
- func (h Hash) WriteTo(w io.Writer) (int64, error)
- type HexBytes
- type InputAndSigInst
- type Map
- type Mux
- func (*Mux) Descriptor() ([]byte, []int)
- func (m *Mux) GetProgram() *Program
- func (m *Mux) GetSources() []*ValueSource
- func (m *Mux) GetWitnessArguments() [][]byte
- func (m *Mux) GetWitnessDestinations() []*ValueDestination
- func (*Mux) ProtoMessage()
- func (m *Mux) Reset()
- func (m *Mux) String() string
- type Output
- type OutputCommitment
- type Program
- type RawTxSigWitness
- type RawWitness
- type SigningInstruction
- type Spend
- func (*Spend) Descriptor() ([]byte, []int)
- func (m *Spend) GetOrdinal() uint64
- func (m *Spend) GetSpentOutputId() *Hash
- func (m *Spend) GetWitnessArguments() [][]byte
- func (m *Spend) GetWitnessDestination() *ValueDestination
- func (*Spend) ProtoMessage()
- func (m *Spend) Reset()
- func (s *Spend) SetDestination(id *Hash, val *AssetAmount, pos uint64)
- func (m *Spend) String() string
- type SpendCommitment
- type SpendInput
- type Template
- type Tx
- type TxData
- type TxFeed
- type TxFeedManager
- func (t *TxFeedManager) AddTxFeed(ctx context.Context, alias string, filter string) error
- func (t *TxFeedManager) DeleteTxFeed(ctx context.Context, alias string) error
- func (t *TxFeedManager) GetTxFeed(ctx context.Context, alias string) (*TxFeed, error)
- func (t *TxFeedManager) Prepare(ctx context.Context) error
- type TxHeader
- func (*TxHeader) Descriptor() ([]byte, []int)
- func (m *TxHeader) GetResultIds() []*Hash
- func (m *TxHeader) GetSerializedSize() uint64
- func (m *TxHeader) GetTimeRange() uint64
- func (m *TxHeader) GetVersion() uint64
- func (*TxHeader) ProtoMessage()
- func (m *TxHeader) Reset()
- func (m *TxHeader) String() string
- type TxInput
- type TxOutput
- type TxPool
- func (tp *TxPool) AddRemotes([]*types.Transaction) []error
- func (tp *TxPool) AddTransaction(tx Tx, fee uint64) error
- func (tp *TxPool) GetMsgCh() <-chan *TxPoolMsg
- func (tp *TxPool) GetTransaction(hash *Hash) (*TxPoolMsg, error)
- func (tp *TxPool) Pending() (map[common.Address]types.Transactions, error)
- func (tp *TxPool) SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
- func (tp *TxPool) TxSubmit(raw_transaction string) (TxSubmitResponse, error)
- type TxPoolMsg
- type TxSubmitResponse
- type TxWrap
- type TypedInput
- type UTXO
- type ValueDestination
- func (*ValueDestination) Descriptor() ([]byte, []int)
- func (m *ValueDestination) GetPosition() uint64
- func (m *ValueDestination) GetRef() *Hash
- func (m *ValueDestination) GetValue() *AssetAmount
- func (*ValueDestination) ProtoMessage()
- func (m *ValueDestination) Reset()
- func (m *ValueDestination) String() string
- type ValueSource
Constants ¶
const ( IssuanceInputType uint8 = iota SpendInputType CoinbaseInputType )
const ( SUCCESS = "success" FAIL = "fail" )
const (
MsgNewTx = iota
)
Variables ¶
var SRCAssetID = &AssetID{ V0: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), V1: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), V2: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}), }
Functions ¶
func BuildUtxoTemplate ¶
func BuildUtxoTemplate(inputs []InputAndSigInst, outputs []*TxOutput) (*Template, TxData, error)
Build build transactions with template
Types ¶
type AssetAmount ¶
type AssetAmount struct {
AssetId *AssetID `protobuf:"bytes,1,opt,name=asset_id,json=assetId" json:"asset_id,omitempty"`
Amount uint64 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"`
}
func (*AssetAmount) Descriptor ¶
func (*AssetAmount) Descriptor() ([]byte, []int)
func (*AssetAmount) GetAmount ¶
func (m *AssetAmount) GetAmount() uint64
func (*AssetAmount) GetAssetId ¶
func (m *AssetAmount) GetAssetId() *AssetID
func (*AssetAmount) ProtoMessage ¶
func (*AssetAmount) ProtoMessage()
func (*AssetAmount) ReadFrom ¶
func (a *AssetAmount) ReadFrom(r *extend.Reader) (err error)
ReadFrom read the AssetAmount from the bytes
func (*AssetAmount) Reset ¶
func (m *AssetAmount) Reset()
func (*AssetAmount) String ¶
func (m *AssetAmount) String() string
type AssetID ¶
type AssetID struct {
V0 uint64 `protobuf:"fixed64,1,opt,name=v0" json:"v0,omitempty"`
V1 uint64 `protobuf:"fixed64,2,opt,name=v1" json:"v1,omitempty"`
V2 uint64 `protobuf:"fixed64,3,opt,name=v2" json:"v2,omitempty"`
V3 uint64 `protobuf:"fixed64,4,opt,name=v3" json:"v3,omitempty"`
}
This message type duplicates Hash, above. One alternative is to embed a Hash inside an AssetID. But it's useful for AssetID to be plain old data (without pointers). Another alternative is use Hash in any protobuf types where an AssetID is called for, but it's preferable to have type safety.
func (*AssetID) Descriptor ¶
func (*AssetID) ProtoMessage ¶
func (*AssetID) ProtoMessage()
type CoinbaseInput ¶
type CoinbaseInput struct {
Arbitrary []byte
}
CoinbaseInput records the coinbase message
func (*CoinbaseInput) InputType ¶
func (cb *CoinbaseInput) InputType() uint8
InputType is the interface function for return the input type
type DataWitness ¶
type DataWitness HexBytes
DataWitness used sign transaction
func (DataWitness) MarshalJSON ¶
func (dw DataWitness) MarshalJSON() ([]byte, error)
MarshalJSON marshal DataWitness
type Entry ¶
Entry is the interface implemented by each addressable unit in a blockchain: transaction components such as spends, issuances, outputs, and retirements (among others), plus blockheaders.
type Hash ¶
type Hash struct {
V0 uint64 `protobuf:"fixed64,1,opt,name=v0" json:"v0,omitempty"`
V1 uint64 `protobuf:"fixed64,2,opt,name=v1" json:"v1,omitempty"`
V2 uint64 `protobuf:"fixed64,3,opt,name=v2" json:"v2,omitempty"`
V3 uint64 `protobuf:"fixed64,4,opt,name=v3" json:"v3,omitempty"`
}
func (*Hash) Descriptor ¶
func (*Hash) ProtoMessage ¶
func (*Hash) ProtoMessage()
type InputAndSigInst ¶
type InputAndSigInst struct {
// contains filtered or unexported fields
}
func NewInputAndSigInst ¶
func NewInputAndSigInst(input *TxInput, sigInst *SigningInstruction) InputAndSigInst
func UtxoInputs ¶
func UtxoInputs(xpubs []chainkd.XPub, u *UTXO) (InputAndSigInst, error)
UtxoToInputs convert an utxo to the txinput
type Mux ¶
type Mux struct {
Sources []*ValueSource `protobuf:"bytes,1,rep,name=sources" json:"sources,omitempty"`
Program *Program `protobuf:"bytes,2,opt,name=program" json:"program,omitempty"`
WitnessDestinations []*ValueDestination `protobuf:"bytes,3,rep,name=witness_destinations,json=witnessDestinations" json:"witness_destinations,omitempty"`
WitnessArguments [][]byte `protobuf:"bytes,4,rep,name=witness_arguments,json=witnessArguments,proto3" json:"witness_arguments,omitempty"`
}
func (*Mux) Descriptor ¶
func (*Mux) GetProgram ¶
func (*Mux) GetSources ¶
func (m *Mux) GetSources() []*ValueSource
func (*Mux) GetWitnessArguments ¶
func (*Mux) GetWitnessDestinations ¶
func (m *Mux) GetWitnessDestinations() []*ValueDestination
func (*Mux) ProtoMessage ¶
func (*Mux) ProtoMessage()
type Output ¶
type Output struct {
Source *ValueSource `protobuf:"bytes,1,opt,name=source" json:"source,omitempty"`
ControlProgram *Program `protobuf:"bytes,2,opt,name=control_program,json=controlProgram" json:"control_program,omitempty"`
Ordinal uint64 `protobuf:"varint,3,opt,name=ordinal" json:"ordinal,omitempty"`
}
func NewOutput ¶
func NewOutput(source *ValueSource, controlProgram *Program, ordinal uint64) *Output
NewOutput creates a new Output.
func (*Output) Descriptor ¶
func (*Output) GetControlProgram ¶
func (*Output) GetOrdinal ¶
func (*Output) GetSource ¶
func (m *Output) GetSource() *ValueSource
func (*Output) ProtoMessage ¶
func (*Output) ProtoMessage()
type OutputCommitment ¶
type OutputCommitment struct {
AssetAmount
VMVersion uint64
ControlProgram []byte
}
type Program ¶
type Program struct {
VmVersion uint64 `protobuf:"varint,1,opt,name=vm_version,json=vmVersion" json:"vm_version,omitempty"`
Code []byte `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
}
func (*Program) Descriptor ¶
func (*Program) GetVmVersion ¶
func (*Program) ProtoMessage ¶
func (*Program) ProtoMessage()
type RawTxSigWitness ¶
type RawTxSigWitness struct {
Quorum int `json:"quorum"`
Keys []keyID `json:"keys"`
Sigs []HexBytes `json:"signatures"`
}
RawTxSigWitness is like SignatureWitness but doesn't involve signature programs.
func (RawTxSigWitness) MarshalJSON ¶
func (sw RawTxSigWitness) MarshalJSON() ([]byte, error)
MarshalJSON convert struct to json
type RawWitness ¶
type SigningInstruction ¶
type SigningInstruction struct {
Position uint32 `json:"position"`
WitnessComponents []witnessComponent `json:"witness_components,omitempty"`
}
type Spend ¶
type Spend struct {
SpentOutputId *Hash `protobuf:"bytes,1,opt,name=spent_output_id,json=spentOutputId" json:"spent_output_id,omitempty"`
WitnessDestination *ValueDestination `protobuf:"bytes,2,opt,name=witness_destination,json=witnessDestination" json:"witness_destination,omitempty"`
WitnessArguments [][]byte `protobuf:"bytes,3,rep,name=witness_arguments,json=witnessArguments,proto3" json:"witness_arguments,omitempty"`
Ordinal uint64 `protobuf:"varint,4,opt,name=ordinal" json:"ordinal,omitempty"`
}
func (*Spend) Descriptor ¶
func (*Spend) GetOrdinal ¶
func (*Spend) GetSpentOutputId ¶
func (*Spend) GetWitnessArguments ¶
func (*Spend) GetWitnessDestination ¶
func (m *Spend) GetWitnessDestination() *ValueDestination
func (*Spend) ProtoMessage ¶
func (*Spend) ProtoMessage()
func (*Spend) SetDestination ¶
func (s *Spend) SetDestination(id *Hash, val *AssetAmount, pos uint64)
SetDestination will link the spend to the output
type SpendCommitment ¶
type SpendCommitment struct {
AssetAmount
SourceID Hash
SourcePosition uint64
VMVersion uint64
ControlProgram []byte
}
SpendCommitment contains the commitment data for a transaction output.
type SpendInput ¶
type SpendInput struct {
SpendCommitmentSuffix []byte // The unconsumed suffix of the output commitment
Arguments [][]byte // Witness
SpendCommitment
}
SpendInput satisfies the TypedInput interface and represents a spend transaction.
func (*SpendInput) InputType ¶
func (si *SpendInput) InputType() uint8
InputType is the interface function for return the input type.
type Template ¶
type Template struct {
Transaction Tx `json:"raw_transaction"`
SigningInstructions []*SigningInstruction `json:"signing_instructions"`
// AllowAdditional affects whether Sign commits to the tx sighash or
// to individual details of the tx so far. When true, signatures
// commit to tx details, and new details may be added but existing
// ones cannot be changed. When false, signatures commit to the tx
// as a whole, and any change to the tx invalidates the signature.
AllowAdditional bool `json:"allow_additional_actions"`
}
Template represents a partially- or fully-signed transaction.
type Tx ¶
Tx holds a transaction along with its hash.
func (*Tx) SetInputArguments ¶
SetInputArguments sets the Arguments field in input n.
func (*Tx) UnmarshalText ¶
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type TxData ¶
type TxData struct {
Version uint64
SerializedSize uint64
TimeRange uint64
Inputs []*TxInput
Outputs []*TxOutput
}
TxData encodes a transaction in the blockchain.
func (*TxData) MarshalText ¶
MarshalText fulfills the json.Marshaler interface.
func (*TxData) UnmarshalText ¶
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type TxFeed ¶
type TxFeed struct {
ID string `json:"id,omitempty"`
Alias string `json:"alias"`
Filter string `json:"filter,omitempty"`
Param filter `json:"param,omitempty"`
}
TxFeed describe a filter
type TxFeedManager ¶
type TxFeedManager struct {
DB database.LDBDatabase
TxFeeds []*TxFeed
// contains filtered or unexported fields
}
Tracker filter tracker object.
func NewTxFeedManager ¶
func NewTxFeedManager(db database.LDBDatabase) *TxFeedManager
func (*TxFeedManager) DeleteTxFeed ¶
func (t *TxFeedManager) DeleteTxFeed(ctx context.Context, alias string) error
type TxHeader ¶
type TxHeader struct {
Version uint64 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
SerializedSize uint64 `protobuf:"varint,2,opt,name=serialized_size,json=serializedSize" json:"serialized_size,omitempty"`
TimeRange uint64 `protobuf:"varint,3,opt,name=time_range,json=timeRange" json:"time_range,omitempty"`
ResultIds []*Hash `protobuf:"bytes,4,rep,name=result_ids,json=resultIds" json:"result_ids,omitempty"`
}
func NewTxHeader ¶
NewTxHeader creates an new TxHeader.
func (*TxHeader) Descriptor ¶
func (*TxHeader) GetResultIds ¶
func (*TxHeader) GetSerializedSize ¶
func (*TxHeader) GetTimeRange ¶
func (*TxHeader) GetVersion ¶
func (*TxHeader) ProtoMessage ¶
func (*TxHeader) ProtoMessage()
type TxInput ¶
type TxInput struct {
AssetVersion uint64
CommitmentSuffix []byte
WitnessSuffix []byte
TypedInput
}
TxInput is the top level struct of tx input.
func NewCoinbaseInput ¶
NewCoinbaseInput creates a new coinbase input struct
func NewSpendInput ¶
func NewSpendInput(arguments [][]byte, sourceID Hash, assetID AssetID, amount, sourcePos uint64, controlProgram []byte) *TxInput
NewSpendInput create a new SpendInput struct.
func (*TxInput) SetArguments ¶
SetArguments set the args for the input
type TxOutput ¶
type TxOutput struct {
AssetVersion uint64
OutputCommitment
// Unconsumed suffixes of the commitment and witness extensible strings.
CommitmentSuffix []byte
}
type TxPool ¶
type TxPool struct {
Utxo map[Hash]Tx
Tx Tx
Weight uint64
Height uint64
Fee uint64
Mtx sync.RWMutex
MsgCh chan *TxPoolMsg
Pool map[Hash]*TxPoolMsg
}
func (*TxPool) AddRemotes ¶
func (tp *TxPool) AddRemotes([]*types.Transaction) []error
TODO: 有请张先生现身说法
func (*TxPool) SubscribeNewTxsEvent ¶
func (tp *TxPool) SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
type TxSubmitResponse ¶
type TxWrap ¶
type TxWrap struct {
*TxHeader
ID Hash
Entries map[Hash]Entry
InputIDs []Hash // 1:1 correspondence with TxData.Inputs
SpentOutputIDs []Hash
GasInputIDs []Hash
}
Tx is a wrapper for the entries-based representation of a transaction.
type TypedInput ¶
type TypedInput interface {
InputType() uint8
}
TypedInput return the txinput type.
type ValueDestination ¶
type ValueDestination struct {
Ref *Hash `protobuf:"bytes,1,opt,name=ref" json:"ref,omitempty"`
Value *AssetAmount `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
Position uint64 `protobuf:"varint,3,opt,name=position" json:"position,omitempty"`
}
func (*ValueDestination) Descriptor ¶
func (*ValueDestination) Descriptor() ([]byte, []int)
func (*ValueDestination) GetPosition ¶
func (m *ValueDestination) GetPosition() uint64
func (*ValueDestination) GetRef ¶
func (m *ValueDestination) GetRef() *Hash
func (*ValueDestination) GetValue ¶
func (m *ValueDestination) GetValue() *AssetAmount
func (*ValueDestination) ProtoMessage ¶
func (*ValueDestination) ProtoMessage()
func (*ValueDestination) Reset ¶
func (m *ValueDestination) Reset()
func (*ValueDestination) String ¶
func (m *ValueDestination) String() string
type ValueSource ¶
type ValueSource struct {
Ref *Hash `protobuf:"bytes,1,opt,name=ref" json:"ref,omitempty"`
Value *AssetAmount `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
Position uint64 `protobuf:"varint,3,opt,name=position" json:"position,omitempty"`
}
func (*ValueSource) Descriptor ¶
func (*ValueSource) Descriptor() ([]byte, []int)
func (*ValueSource) GetPosition ¶
func (m *ValueSource) GetPosition() uint64
func (*ValueSource) GetRef ¶
func (m *ValueSource) GetRef() *Hash
func (*ValueSource) GetValue ¶
func (m *ValueSource) GetValue() *AssetAmount
func (*ValueSource) ProtoMessage ¶
func (*ValueSource) ProtoMessage()
func (*ValueSource) Reset ¶
func (m *ValueSource) Reset()
func (*ValueSource) String ¶
func (m *ValueSource) String() string