aboutsummaryrefslogtreecommitdiffstats
path: root/ethpub
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-30 22:58:31 +0800
committerobscuren <geffobscura@gmail.com>2014-05-30 22:58:31 +0800
commit6b7dfa1fb5279407177fb9fb6574ad9760a4e307 (patch)
tree7c8aca5aaf4355256bf245543842065073e56771 /ethpub
parent2ef3a989298aa8dca7872be07ad0abbc32728cc7 (diff)
parent17c825f53a2676ffe17fd7731f8f550aebcb56b0 (diff)
downloaddexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar
dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.gz
dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.bz2
dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.lz
dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.xz
dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.zst
dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.zip
Merge branch 'develop'
Diffstat (limited to 'ethpub')
-rw-r--r--ethpub/pub.go42
-rw-r--r--ethpub/types.go3
2 files changed, 20 insertions, 25 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go
index 5a9401d0d..a9a962f14 100644
--- a/ethpub/pub.go
+++ b/ethpub/pub.go
@@ -4,6 +4,7 @@ import (
"encoding/hex"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
+ "math/big"
"strings"
)
@@ -95,13 +96,29 @@ func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, script string)
return lib.createTx(key, "", valueStr, gasStr, gasPriceStr, script)
}
+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)
+
+ return reg.Bytes()
+}
+
func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, scriptStr string) (*PReceipt, error) {
var hash []byte
var contractCreation bool
if len(recipient) == 0 {
contractCreation = true
} else {
- hash = ethutil.FromHex(recipient)
+ // Check if an address is stored by this address
+ addr := GetAddressFromNameReg(lib.stateManager, recipient)
+ if len(addr) > 0 {
+ hash = addr
+ } else {
+ hash = ethutil.FromHex(recipient)
+ }
}
var keyPair *ethutil.KeyPair
@@ -122,29 +139,6 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, sc
var tx *ethchain.Transaction
// Compile and assemble the given data
if contractCreation {
- /*
- var initScript, mainScript []byte
- var err error
- if ethutil.IsHex(initStr) {
- initScript = ethutil.FromHex(initStr[2:])
- } else {
- initScript, err = ethutil.Compile(initStr)
- if err != nil {
- return nil, err
- }
- }
-
- if ethutil.IsHex(scriptStr) {
- mainScript = ethutil.FromHex(scriptStr[2:])
- } else {
- mainScript, err = ethutil.Compile(scriptStr)
- if err != nil {
- return nil, err
- }
- }
-
- script := ethchain.AppendScript(initScript, mainScript)
- */
var script []byte
var err error
if ethutil.IsHex(scriptStr) {
diff --git a/ethpub/types.go b/ethpub/types.go
index de1149a26..4e7c44ed4 100644
--- a/ethpub/types.go
+++ b/ethpub/types.go
@@ -16,6 +16,7 @@ type PBlock struct {
Hash string `json:"hash"`
Transactions string `json:"transactions"`
Time int64 `json:"time"`
+ Coinbase string `json:"coinbase"`
}
// Creates a new QML Block from a chain block
@@ -34,7 +35,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}
+ 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)}
}
func (self *PBlock) ToString() string {