From a2d01d6af8cace4ea0ef87662727659eaa1ff791 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 29 May 2014 02:05:57 +0200 Subject: Removed comments --- ethpub/pub.go | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'ethpub') diff --git a/ethpub/pub.go b/ethpub/pub.go index 5a9401d0d..6dd7798ae 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -122,29 +122,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) { -- cgit v1.2.3 From e7097641e3987420429fe47efdb678c9e4cd9ba9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 29 May 2014 11:49:41 +0200 Subject: Support for namereg --- ethpub/pub.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ethpub') diff --git a/ethpub/pub.go b/ethpub/pub.go index 6dd7798ae..6beab5cf9 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -2,8 +2,10 @@ package ethpub import ( "encoding/hex" + "fmt" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" + "math/big" "strings" ) @@ -95,13 +97,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 -- cgit v1.2.3 From 9bb7633254f5ded891f1162783bc06c1b4d131a0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 29 May 2014 11:50:36 +0200 Subject: Removed fmt --- ethpub/pub.go | 1 - 1 file changed, 1 deletion(-) (limited to 'ethpub') diff --git a/ethpub/pub.go b/ethpub/pub.go index 6beab5cf9..a9a962f14 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -2,7 +2,6 @@ package ethpub import ( "encoding/hex" - "fmt" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" "math/big" -- cgit v1.2.3 From 99797858a692520b47c2ca767b433ca425637d2a Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 30 May 2014 11:47:23 +0200 Subject: Added coin base to pub block --- ethpub/types.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ethpub') 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 { -- cgit v1.2.3