aboutsummaryrefslogtreecommitdiffstats
path: root/ethpub
diff options
context:
space:
mode:
Diffstat (limited to 'ethpub')
-rw-r--r--ethpub/pub.go10
-rw-r--r--ethpub/types.go13
2 files changed, 14 insertions, 9 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go
index e00bd0dbe..20ba79d0b 100644
--- a/ethpub/pub.go
+++ b/ethpub/pub.go
@@ -115,9 +115,13 @@ var namereg = ethutil.FromHex("bb5f186604d057c1c5240ca2ae0f6430138ac010")
func GetAddressFromNameReg(stateManager *ethchain.StateManager, name string) []byte {
recp := new(big.Int).SetBytes([]byte(name))
object := stateManager.CurrentState().GetStateObject(namereg)
- reg := object.GetStorage(recp)
+ if object != nil {
+ reg := object.GetStorage(recp)
- return reg.Bytes()
+ return reg.Bytes()
+ }
+
+ return nil
}
func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, scriptStr string) (*PReceipt, error) {
@@ -193,8 +197,6 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, sc
if contractCreation {
ethutil.Config.Log.Infof("Contract addr %x", tx.CreationAddress())
- } else {
- ethutil.Config.Log.Infof("Tx hash %x", tx.Hash())
}
return NewPReciept(contractCreation, tx.CreationAddress(), tx.Hash(), keyPair.Address()), nil
diff --git a/ethpub/types.go b/ethpub/types.go
index 6893c7e09..a76421007 100644
--- a/ethpub/types.go
+++ b/ethpub/types.go
@@ -46,6 +46,8 @@ type PBlock struct {
Transactions string `json:"transactions"`
Time int64 `json:"time"`
Coinbase string `json:"coinbase"`
+ GasLimit string `json:"gasLimit"`
+ GasUsed string `json:"gasUsed"`
}
// Creates a new QML Block from a chain block
@@ -64,7 +66,7 @@ func NewPBlock(block *ethchain.Block) *PBlock {
return nil
}
- return &PBlock{ref: block, Number: int(block.Number.Uint64()), Hash: ethutil.Hex(block.Hash()), Transactions: string(txJson), Time: block.Time, Coinbase: ethutil.Hex(block.Coinbase)}
+ return &PBlock{ref: block, Number: int(block.Number.Uint64()), GasUsed: block.GasUsed.String(), GasLimit: block.GasLimit.String(), Hash: ethutil.Hex(block.Hash()), Transactions: string(txJson), Time: block.Time, Coinbase: ethutil.Hex(block.Coinbase)}
}
func (self *PBlock) ToString() string {
@@ -109,11 +111,12 @@ func NewPTx(tx *ethchain.Transaction) *PTx {
sender := hex.EncodeToString(tx.Sender())
createsContract := tx.CreatesContract()
- data := strings.Join(ethchain.Disassemble(tx.Data), "\n")
-
- isContract := len(tx.Data) > 0
+ data := string(tx.Data)
+ if tx.CreatesContract() {
+ data = strings.Join(ethchain.Disassemble(tx.Data), "\n")
+ }
- return &PTx{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: receiver, Contract: isContract, Gas: tx.Gas.String(), GasPrice: tx.GasPrice.String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: hex.EncodeToString(tx.Data)}
+ return &PTx{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: receiver, Contract: tx.CreatesContract(), Gas: tx.Gas.String(), GasPrice: tx.GasPrice.String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: hex.EncodeToString(tx.Data)}
}
func (self *PTx) ToString() string {