Minor fixes that to reflect changes in library
This commit is contained in:
parent
0656f465b0
commit
fe9eb47288
@ -197,16 +197,16 @@ func (i *Console) ParseInput(input string) bool {
|
|||||||
}
|
}
|
||||||
case "contract":
|
case "contract":
|
||||||
fmt.Println("Contract editor (Ctrl-D = done)")
|
fmt.Println("Contract editor (Ctrl-D = done)")
|
||||||
code := i.Editor()
|
code := ethchain.Compile(i.Editor())
|
||||||
|
|
||||||
contract := ethchain.NewTransaction([]byte{}, ethutil.Big(tokens[1]), code)
|
contract := ethchain.NewTransaction(ethchain.ContractAddr, ethutil.Big(tokens[1]), code)
|
||||||
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
||||||
keyRing := ethutil.NewValueFromBytes(data)
|
keyRing := ethutil.NewValueFromBytes(data)
|
||||||
contract.Sign(keyRing.Get(0).Bytes())
|
contract.Sign(keyRing.Get(0).Bytes())
|
||||||
|
|
||||||
i.ethereum.TxPool.QueueTransaction(contract)
|
i.ethereum.TxPool.QueueTransaction(contract)
|
||||||
|
|
||||||
fmt.Printf("%x\n", contract.Hash())
|
fmt.Printf("%x\n", contract.Hash()[12:])
|
||||||
case "exit", "quit", "q":
|
case "exit", "quit", "q":
|
||||||
return false
|
return false
|
||||||
case "help":
|
case "help":
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/ethereum/eth-go"
|
"github.com/ethereum/eth-go"
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
|
"github.com/ethereum/eth-go/ethwire"
|
||||||
"github.com/ethereum/go-ethereum/ui"
|
"github.com/ethereum/go-ethereum/ui"
|
||||||
"github.com/niemeyer/qml"
|
"github.com/niemeyer/qml"
|
||||||
"github.com/obscuren/secp256k1-go"
|
"github.com/obscuren/secp256k1-go"
|
||||||
@ -195,6 +196,7 @@ func main() {
|
|||||||
|
|
||||||
// Search the nonce
|
// Search the nonce
|
||||||
block.Nonce = pow.Search(block)
|
block.Nonce = pow.Search(block)
|
||||||
|
ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.Value().Val})
|
||||||
err := ethereum.BlockManager.ProcessBlock(block)
|
err := ethereum.BlockManager.ProcessBlock(block)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"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"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EthLib struct {
|
type EthLib struct {
|
||||||
@ -13,22 +14,34 @@ type EthLib struct {
|
|||||||
txPool *ethchain.TxPool
|
txPool *ethchain.TxPool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lib *EthLib) CreateTx(receiver, a string) string {
|
func (lib *EthLib) CreateTx(receiver, a, data string) string {
|
||||||
hash, err := hex.DecodeString(receiver)
|
var hash []byte
|
||||||
if err != nil {
|
if len(receiver) == 0 {
|
||||||
return err.Error()
|
hash = ethchain.ContractAddr
|
||||||
|
} else {
|
||||||
|
var err error
|
||||||
|
hash, err = hex.DecodeString(receiver)
|
||||||
|
if err != nil {
|
||||||
|
return err.Error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
|
||||||
keyRing := ethutil.NewValueFromBytes(data)
|
k, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
||||||
|
keyRing := ethutil.NewValueFromBytes(k)
|
||||||
|
|
||||||
amount := ethutil.Big(a)
|
amount := ethutil.Big(a)
|
||||||
tx := ethchain.NewTransaction(hash, amount, []string{""})
|
code := ethchain.Compile(strings.Split(data, "\n"))
|
||||||
|
tx := ethchain.NewTransaction(hash, amount, code)
|
||||||
tx.Nonce = lib.blockManager.GetAddrState(keyRing.Get(1).Bytes()).Nonce
|
tx.Nonce = lib.blockManager.GetAddrState(keyRing.Get(1).Bytes()).Nonce
|
||||||
|
|
||||||
tx.Sign(keyRing.Get(0).Bytes())
|
tx.Sign(keyRing.Get(0).Bytes())
|
||||||
|
|
||||||
lib.txPool.QueueTransaction(tx)
|
lib.txPool.QueueTransaction(tx)
|
||||||
|
|
||||||
|
if len(receiver) == 0 {
|
||||||
|
ethutil.Config.Log.Infof("Contract addr %x", tx.Hash()[12:])
|
||||||
|
}
|
||||||
|
|
||||||
return ethutil.Hex(tx.Hash())
|
return ethutil.Hex(tx.Hash())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,5 +53,6 @@ func (lib *EthLib) GetBlock(hexHash string) *Block {
|
|||||||
|
|
||||||
block := lib.blockChain.GetBlock(hash)
|
block := lib.blockChain.GetBlock(hash)
|
||||||
fmt.Println(block)
|
fmt.Println(block)
|
||||||
|
|
||||||
return &Block{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
|
return &Block{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ ApplicationWindow {
|
|||||||
Button {
|
Button {
|
||||||
text: "Send"
|
text: "Send"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log(eth.createTx(txReceiver.text, txAmount.text))
|
console.log(eth.createTx(txReceiver.text, txAmount.text, codeView.text))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,8 +300,9 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addLog(str) {
|
function addLog(str) {
|
||||||
console.log(str)
|
if(str.len != 0) {
|
||||||
logModel.insert(0, {description: str})
|
logModel.append({description: str})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPeers(text) {
|
function setPeers(text) {
|
||||||
|
Loading…
Reference in New Issue
Block a user