Documentation
¶
Index ¶
- Constants
- func AddSingleSigToTxMsg(txm *TxMsg, ss *SingleSignature)
- func AddressFromPubKey(pk *[32]byte, netID byte) string
- func EncodeAddress(hashokey Address, netID byte) string
- func GetBalance(address string) (bal int64)
- func IsFaucet(in *Input) bool
- func NewDBEntryFromFBlock(b *FBlock) *notaryapi.DBEntry
- func NewOrphanPool() *orphanpool
- func NewTxPool() *txpool
- func TxMsgToWire(txm *TxMsg) (tx *factomwire.MsgTx)
- func VerifyAddressReveal(address Address, reveal AddressReveal) bool
- func VerifyInputSig(in *Input, sig *InputSig, tx *Tx) bool
- func VerifyTx(tx *Tx) bool
- type Address
- type AddressReveal
- type ByFBlockIDAccending
- type EntryCreditAddress
- type FBlock
- type FBlockHeader
- type FChain
- type FactoidPool
- func (fp *FactoidPool) AddGenesisBlock()
- func (fp *FactoidPool) AddToMemPool() (verified []*notaryapi.HashF)
- func (fp *FactoidPool) Confirm(fm *factomwire.MsgConfirmation) (ok bool, confirmed []*notaryapi.HashF)
- func (fp *FactoidPool) GetTxContext() *Tx
- func (fp *FactoidPool) SetContext(tx *factomwire.MsgTx)
- func (fp *FactoidPool) Utxo() *Utxo
- func (fp *FactoidPool) Verify() (ret bool)
- type Input
- type InputSig
- type MultisigReveal
- type Output
- type SingleSignature
- type Tx
- type TxData
- type TxMsg
- type TxOutSpent
- type TxProcessor
- type TxSpentList
- type Txid
- type Utxo
Constants ¶
const ( FACTOID_ADDR = byte(0) ENTRYCREDIT_PKEY = byte(1) )
Constants for Output.Type
const (
FaucetTxidStr = "FaucetTxidForSymulationTesting01"
)
const (
GenesisAddress = "FfZgRRHxuzsWkhXcb5Tb16EYuDEkbVCPAk1svfmYxyUXGPoS2X"
)
const ( //initail array allocation //each call to append will double capacity when len() = cap() TxPoolAllocSize = 1000 )
Variables ¶
This section is empty.
Functions ¶
func AddSingleSigToTxMsg ¶
func AddSingleSigToTxMsg(txm *TxMsg, ss *SingleSignature)
func AddressFromPubKey ¶
func EncodeAddress ¶
encodeAddress returns a human-readable payment address given a 32 bytes hash or publike-key and netID which encodes the factom network and address type. It is used in both entrycredit and factoid transactions.
func GetBalance ¶
GetBalance from GlobalUtxo helper function ToDo: should be depricated on GlobalUtxo redesign
func NewDBEntryFromFBlock ¶
func TxMsgToWire ¶
func TxMsgToWire(txm *TxMsg) (tx *factomwire.MsgTx)
convert from TxMsg to wire format
func VerifyAddressReveal ¶
func VerifyAddressReveal(address Address, reveal AddressReveal) bool
Types ¶
type Address ¶
raw address, either a hash of *Reveal (for factoid tx)
or a raw PublicKey (for entrycredit tx)
type AddressReveal ¶
type AddressReveal notaryapi.DetachedPublicKey
revealed address is the public key
type ByFBlockIDAccending ¶
type ByFBlockIDAccending []FBlock
------------------------------------------------ FBlock array sorting implementation - accending
func (ByFBlockIDAccending) Len ¶
func (f ByFBlockIDAccending) Len() int
func (ByFBlockIDAccending) Less ¶
func (f ByFBlockIDAccending) Less(i, j int) bool
func (ByFBlockIDAccending) Swap ¶
func (f ByFBlockIDAccending) Swap(i, j int)
type EntryCreditAddress ¶
type EntryCreditAddress AddressReveal
EntryCredit transactions sent directly to publickey
type FBlock ¶
type FBlock struct {
Header FBlockHeader
Transactions []Tx
//Not Marshalized
FBHash *notaryapi.Hash
Salt *notaryapi.Hash
Chain *FChain
IsSealed bool
}
Factoid Block - contains list of Tx, which has raw MsgTx plus the Txid
func FactoidGenesis ¶
func FactoidGenesis(net factomwire.FactomNet) (genesis *FBlock)
func (*FBlock) AddFBTransaction ¶
func (*FBlock) MarshalBinary ¶
func (*FBlock) MarshalledSize ¶
func (*FBlock) UnmarshalBinary ¶
type FBlockHeader ¶
type FBlockHeader struct {
Height uint64
PrevBlockHash *notaryapi.Hash
TimeStamp int64
TxCount uint32
}
Factoid Block header
func NewFBlockHeader ¶
func (*FBlockHeader) MarshalBinary ¶
func (b *FBlockHeader) MarshalBinary() (data []byte, err error)
func (*FBlockHeader) MarshalledSize ¶
func (b *FBlockHeader) MarshalledSize() uint64
func (*FBlockHeader) UnmarshalBinary ¶
func (b *FBlockHeader) UnmarshalBinary(data []byte) (err error)
type FChain ¶
type FChain struct {
ChainID *notaryapi.Hash
Name [][]byte
Blocks []*FBlock
CurrentBlock *FBlock
BlockMutex sync.Mutex
NextBlockID uint64
}
func (*FChain) MarshalBinary ¶
func (*FChain) MarshalledSize ¶
func (*FChain) UnmarshalBinary ¶
type FactoidPool ¶
type FactoidPool struct {
TxProcessor
sync.RWMutex
// contains filtered or unexported fields
}
txMemPool is used as a source of transactions that need to be mined into blocks and relayed to other peers. It is safe for concurrent access from multiple peers.
factoidpool impliments TxProcessor for generic mempool processing
func NewFactoidPool ¶
func NewFactoidPool() *FactoidPool
newTxMemPool returns a new memory pool for validating and storing standalone transactions until they are mined into a block.
func (*FactoidPool) AddGenesisBlock ¶
func (fp *FactoidPool) AddGenesisBlock()
func (*FactoidPool) AddToMemPool ¶
func (fp *FactoidPool) AddToMemPool() (verified []*notaryapi.HashF)
add transaction to memorypool after passing verification of signature and utxo assume the transaction is already set to factoidpool.context via call to SetContext
func (*FactoidPool) Confirm ¶
func (fp *FactoidPool) Confirm(fm *factomwire.MsgConfirmation) (ok bool, confirmed []*notaryapi.HashF)
Confirm is called when receivedd a confirmation msg from federatd server should only be called after already received the Tx ToDo: deal with confirms that come in diff order than in pool,
may need to store doubel spends, they may become valid
func (*FactoidPool) GetTxContext ¶
func (fp *FactoidPool) GetTxContext() *Tx
func (*FactoidPool) SetContext ¶
func (fp *FactoidPool) SetContext(tx *factomwire.MsgTx)
*** TxProcessor implimentaion ***// set context to tx, this context will be used by default when by Verify and AddToMemPool see factomd.TxMempool
func (*FactoidPool) Utxo ¶
func (fp *FactoidPool) Utxo() *Utxo
func (*FactoidPool) Verify ¶
func (fp *FactoidPool) Verify() (ret bool)
Verify is designed to be called by external packages without them needing to know the specific Tx foramt
type Input ¶
type Input struct {
Txid Txid
Index uint32
RevealAddr AddressReveal //notaryapi.ByteArray
}
Input is the UTXO being spent
Txid defines the transaction that contains Output being spent Index is Output number RevealAddr is the "reveal" for the Output.ToAddr "commit" it contains the public-key(s) corresponding to Signatures
func NewFaucetInput ¶
Create Input with faucet TXID. This input will not be checked against Utxo and will always be valid. Nonce is used to make resulting Transactions unique only need to update nonce when rest to Tx is same a previous one. /ToDo: remove before production
func NewInput ¶
func NewInput(id *Txid, index uint32, reveal AddressReveal) *Input
NewInput returns a new factoid transaction input with the provided Txid, index, and revealed address
func (*Input) MarshalBinary ¶
func (*Input) MarshalledSize ¶
func (*Input) UnmarshalBinary ¶
type InputSig ¶
type InputSig struct {
Hint rune
Sigs []SingleSignature
}
all sigs needed for input
Hint is used to help match sig to multi input tx signatures can then be reordered correctly, so can be vefified w/o hint. this allows signatures to sent and attached to tx in any order
func (*InputSig) AddSig ¶
func (ins *InputSig) AddSig(ss SingleSignature)
AddSig to append singlesignature to InputSig
func (*InputSig) MarshalBinary ¶
func (*InputSig) MarshalledSize ¶
func (*InputSig) UnmarshalBinary ¶
type MultisigReveal ¶
type MultisigReveal struct {
NumRequired uint8
Addresses []AddressReveal
}
multisig reveal structure that hashes into raw Address
type Output ¶
Output defines a receiver of the Input
Output.Type FACTOID_ADDR ENTRYCREDIT_PKEY Amount is amount of transfer in "Snow" ToAddr is a hash of struct, with public-keys(s) for Type = ENTRYCREDIT_PKEY , ToAddr is public-key
func NewOutput ¶
NewOutput returns a new bitcoin transaction output with the provided transaction value and public key script.
func (*Output) MarshalBinary ¶
func (*Output) MarshalledSize ¶
func (*Output) ToAddressString ¶
func (*Output) UnmarshalBinary ¶
type SingleSignature ¶
type SingleSignature struct {
Hint rune
Sig notaryapi.DetachedSignature
}
single signature of tx,
Hint is not signed! is used to help match sig to address in multisig input.
func NewSingleSignature ¶
func NewSingleSignature(insig *notaryapi.DetachedSignature) (ss *SingleSignature)
func SingleSigFromByte ¶
func SingleSigFromByte(sb []byte) (sig SingleSignature)
func (*SingleSignature) MarshalBinary ¶
func (s *SingleSignature) MarshalBinary() (data []byte, err error)
func (*SingleSignature) MarshalledSize ¶
func (s *SingleSignature) MarshalledSize() uint64
func (*SingleSignature) String ¶
func (s *SingleSignature) String() string
func (*SingleSignature) UnmarshalBinary ¶
func (s *SingleSignature) UnmarshalBinary(data []byte) (err error)
type Tx ¶
type Tx struct {
Txm *TxMsg
// contains filtered or unexported fields
}
Tx is the TxMsg and a chache of its Txid
type TxData ¶
TxData is the core of the transaction, it generates the TXID TxData is signed by each input
LockTime is intened as used in bitcoin
func (*TxData) MarshalBinary ¶
func (*TxData) MarshalledSize ¶
func (*TxData) UnmarshalBinary ¶
type TxMsg ¶
TxMsg is the signed and versioned Factoid transaction message
Sigs is at least 1 signature per Input
func NewTxFromInputToAddr ¶
func NewTxFromOutputToAddr ¶
func TxMsgFromWire ¶
func TxMsgFromWire(tx *factomwire.MsgTx) (txm *TxMsg)
convert from wire format to TxMsg
func (*TxMsg) AddInputSig ¶
AddInputSig adds a signature to transaction.
func (*TxMsg) MarshalBinary ¶
func (*TxMsg) MarshalledSize ¶
func (*TxMsg) UnmarshalBinary ¶
type TxOutSpent ¶
type TxOutSpent struct {
Outs []Output
Spent TxSpentList
}
type TxProcessor ¶
type TxProcessor interface {
SetContext(*factomwire.MsgTx)
Verify() bool
//Broadcast()
AddToMemPool() []*notaryapi.HashF
Confirm(*factomwire.MsgConfirmation) (bool, []*notaryapi.HashF)
}
ToDo: TxProcessor was copied from factomd.txmempool due to import cycle issues. fix this
TxProcessor is an interface that abstracts methods needed to process a TxMessage SetContext(*TxMessage) will store to concrete TxMessage in the concrete TxProcessor object
type TxSpentList ¶
type TxSpentList []bool
ToDo: use bits if faster , or if keeping full utxo in memory. should really do memory mapped files//
TxSpentList is a vector of bool indicators of:
if $Txids[tx.Input[i].Txid].Output[tx.Input[i].Index] have been spent
Output type ENTRYCREDIT_PKEY outputs are always flagged as spent
type Utxo ¶
type Utxo struct {
Txspent map[Txid]TxOutSpent
//BalanceByAddress is used to store current address balance
// used during testing of factoid, while full wallet in developent
//ToDo: refactor
BalanceByAddress map[string]int64
}
Unspent TransaXtion Outputs is implimented as a hashtable from Txid to bool array TxSpentList
var GlobalUtxo Utxo
GlobalUtxo will store utxo for all blocks temp use global var, to be called from "restapi" ToDo: redesign
func GetGlobUtxo ¶
func GetGlobUtxo() *Utxo
func (*Utxo) AddTx ¶
add transaction to Utxo used when tx passed all verifications ToDo: maybe support Udue (command pattern?)
func (*Utxo) AddVerifiedTxList ¶
Meant for adding verified blocks to Utxo
func (*Utxo) AddressBalance ¶
func (*Utxo) InputsKnown ¶
true if input parents are known