mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-29 06:47:16 +00:00
Support for namereg
This commit is contained in:
parent
a2d01d6af8
commit
e7097641e3
@ -2,8 +2,10 @@ package ethpub
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -95,13 +97,29 @@ func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, script string)
|
|||||||
return lib.createTx(key, "", valueStr, gasStr, gasPriceStr, script)
|
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) {
|
func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, scriptStr string) (*PReceipt, error) {
|
||||||
var hash []byte
|
var hash []byte
|
||||||
var contractCreation bool
|
var contractCreation bool
|
||||||
if len(recipient) == 0 {
|
if len(recipient) == 0 {
|
||||||
contractCreation = true
|
contractCreation = true
|
||||||
} else {
|
} 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
|
var keyPair *ethutil.KeyPair
|
||||||
|
Loading…
Reference in New Issue
Block a user