Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
1cd7d445
Commit
1cd7d445
authored
Apr 16, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to use new state object
parent
6b644c17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
39 deletions
+24
-39
gui.go
ethereal/ui/gui.go
+1
-1
library.go
ethereal/ui/library.go
+3
-22
ui_lib.go
ethereal/ui/ui_lib.go
+8
-10
dev_console.go
ethereum/dev_console.go
+12
-6
No files found.
ethereal/ui/gui.go
View file @
1cd7d445
...
...
@@ -170,7 +170,7 @@ func (ui *Gui) update() {
txChan
:=
make
(
chan
ethchain
.
TxMsg
,
1
)
ui
.
eth
.
TxPool
()
.
Subscribe
(
txChan
)
account
:=
ui
.
eth
.
StateManager
()
.
GetAddrState
(
ui
.
addr
)
.
Accoun
t
account
:=
ui
.
eth
.
StateManager
()
.
GetAddrState
(
ui
.
addr
)
.
Objec
t
unconfirmedFunds
:=
new
(
big
.
Int
)
ui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
fmt
.
Sprintf
(
"%v"
,
ethutil
.
CurrencyToString
(
account
.
Amount
)))
for
{
...
...
ethereal/ui/library.go
View file @
1cd7d445
...
...
@@ -6,7 +6,6 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/obscuren/mutan"
"github.com/obscuren/secp256k1-go"
"strings"
)
...
...
@@ -44,22 +43,6 @@ func (lib *EthLib) CreateAndSetPrivKey() (string, string, string, string) {
return
mnemonicString
,
fmt
.
Sprintf
(
"%x"
,
pair
.
Address
()),
fmt
.
Sprintf
(
"%x"
,
prv
),
fmt
.
Sprintf
(
"%x"
,
pub
)
}
// General compiler and preprocessor function
func
compile
(
script
string
)
([]
byte
,
error
)
{
asm
,
errors
:=
mutan
.
Compile
(
strings
.
NewReader
(
script
),
false
)
if
len
(
errors
)
>
0
{
var
errs
string
for
_
,
er
:=
range
errors
{
if
er
!=
nil
{
errs
+=
er
.
Error
()
}
}
return
nil
,
fmt
.
Errorf
(
"%v"
,
errs
)
}
return
ethutil
.
Assemble
(
asm
...
),
nil
}
func
(
lib
*
EthLib
)
CreateTx
(
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
data
string
)
(
string
,
error
)
{
var
hash
[]
byte
var
contractCreation
bool
...
...
@@ -81,18 +64,16 @@ func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data strin
// Compile and assemble the given data
if
contractCreation
{
mainInput
,
initInput
:=
ethutil
.
PreProcess
(
data
)
mainScript
,
err
:=
c
ompile
(
mainInput
)
mainScript
,
err
:=
utils
.
C
ompile
(
mainInput
)
if
err
!=
nil
{
return
""
,
err
}
initScript
,
err
:=
c
ompile
(
initInput
)
initScript
,
err
:=
utils
.
C
ompile
(
initInput
)
if
err
!=
nil
{
return
""
,
err
}
// TODO
fmt
.
Println
(
initScript
)
tx
=
ethchain
.
NewContractCreationTx
(
value
,
gasPrice
,
mainScript
)
tx
=
ethchain
.
NewContractCreationTx
(
value
,
gasPrice
,
mainScript
,
initScript
)
}
else
{
tx
=
ethchain
.
NewTransactionMessage
(
hash
,
value
,
gasPrice
,
gas
,
nil
)
}
...
...
ethereal/ui/ui_lib.go
View file @
1cd7d445
...
...
@@ -6,14 +6,13 @@ import (
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/niemeyer/qml"
"github.com/obscuren/mutan"
"math/big"
"os"
"path"
"path/filepath"
"runtime"
"strings"
)
type
memAddr
struct
{
...
...
@@ -99,25 +98,24 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string)
state
:=
ui
.
eth
.
BlockChain
()
.
CurrentBlock
.
State
()
mainInput
,
_
:=
ethutil
.
PreProcess
(
data
)
asm
,
err
:=
mutan
.
Compile
(
strings
.
NewReader
(
mainInput
),
false
)
callerScript
,
err
:=
utils
.
Compile
(
mainInput
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
for
_
,
e
:=
range
err
{
ui
.
win
.
Root
()
.
Call
(
"addDebugMessage"
,
e
.
Error
())
}
ethutil
.
Config
.
Log
.
Debugln
(
err
)
return
}
callerScript
:=
ethutil
.
Assemble
(
asm
...
)
dis
:=
ethchain
.
Disassemble
(
callerScript
)
ui
.
win
.
Root
()
.
Call
(
"clearAsm"
)
for
_
,
str
:=
range
dis
{
ui
.
win
.
Root
()
.
Call
(
"setAsm"
,
str
)
}
callerTx
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
valueStr
),
ethutil
.
Big
(
gasPriceStr
),
callerScript
)
callerTx
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
valueStr
),
ethutil
.
Big
(
gasPriceStr
),
callerScript
,
nil
)
// Contract addr as test address
keyPair
:=
ethutil
.
Config
.
Db
.
GetKeys
()[
0
]
account
:=
ui
.
eth
.
StateManager
()
.
GetAddrState
(
keyPair
.
Address
())
.
Accoun
t
account
:=
ui
.
eth
.
StateManager
()
.
GetAddrState
(
keyPair
.
Address
())
.
Objec
t
c
:=
ethchain
.
MakeContract
(
callerTx
,
state
)
callerClosure
:=
ethchain
.
NewClosure
(
account
,
c
,
c
.
Script
(),
state
,
ethutil
.
Big
(
gasStr
),
new
(
big
.
Int
))
...
...
ethereum/dev_console.go
View file @
1cd7d445
...
...
@@ -11,8 +11,7 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"github.com/obscuren/mutan"
_
"math/big"
"github.com/ethereum/go-ethereum/utils"
"os"
"strings"
)
...
...
@@ -171,7 +170,7 @@ func (i *Console) ParseInput(input string) bool {
if
err
!=
nil
{
fmt
.
Println
(
"recipient err:"
,
err
)
}
else
{
tx
:=
ethchain
.
NewTransactionMessage
(
recipient
,
ethutil
.
Big
(
tokens
[
2
]),
ethutil
.
Big
(
tokens
[
3
]),
ethutil
.
Big
(
tokens
[
4
]),
[]
string
{
""
}
)
tx
:=
ethchain
.
NewTransactionMessage
(
recipient
,
ethutil
.
Big
(
tokens
[
2
]),
ethutil
.
Big
(
tokens
[
3
]),
ethutil
.
Big
(
tokens
[
4
]),
nil
)
key
:=
ethutil
.
Config
.
Db
.
GetKeys
()[
0
]
tx
.
Sign
(
key
.
PrivateKey
)
...
...
@@ -190,15 +189,22 @@ func (i *Console) ParseInput(input string) bool {
}
case
"contract"
:
fmt
.
Println
(
"Contract editor (Ctrl-D = done)"
)
asm
,
err
:=
mutan
.
Compile
(
strings
.
NewReader
(
i
.
Editor
()),
false
)
mainInput
,
initInput
:=
ethutil
.
PreProcess
(
i
.
Editor
())
mainScript
,
err
:=
utils
.
Compile
(
mainInput
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
break
}
initScript
,
err
:=
utils
.
Compile
(
initInput
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
code
:=
ethutil
.
Assemble
(
asm
)
break
}
contract
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
tokens
[
0
]),
ethutil
.
Big
(
tokens
[
1
]),
code
)
contract
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
tokens
[
0
]),
ethutil
.
Big
(
tokens
[
1
]),
mainScript
,
initScript
)
key
:=
ethutil
.
Config
.
Db
.
GetKeys
()[
0
]
contract
.
Sign
(
key
.
PrivateKey
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment