Transaction querying

This commit is contained in:
obscuren
2014-05-22 17:56:33 +02:00
parent 230aafbf66
commit cc8464ce80
3 changed files with 30 additions and 4 deletions

View File

@ -31,7 +31,18 @@ func (self *PBlock) ToString() string {
return ""
}
func (self *PBlock) GetTransaction(hash string) *PTx {
tx := self.ref.GetTransaction(ethutil.FromHex(hash))
if tx == nil {
return nil
}
return NewPTx(tx)
}
type PTx struct {
ref *ethchain.Transaction
Value, Hash, Address string
Contract bool
}
@ -41,7 +52,11 @@ func NewPTx(tx *ethchain.Transaction) *PTx {
sender := hex.EncodeToString(tx.Recipient)
isContract := len(tx.Data) > 0
return &PTx{Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: sender, Contract: isContract}
return &PTx{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: sender, Contract: isContract}
}
func (self *PTx) ToString() string {
return self.ref.String()
}
type PKey struct {