aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-14 06:13:32 +0800
committerobscuren <geffobscura@gmail.com>2014-09-14 06:13:32 +0800
commit4b4830692a0e17b26338da75c6ab96f6bb4e14b1 (patch)
tree8607609f2c42a6469a12701b9e7c67cfb43a5469
parent2fb57b2ea7b7f697ddc4811c471d87116eae07cc (diff)
parent369e8c41509baef341e61e4c5243899d5ffba1fc (diff)
downloaddexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.tar
dexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.tar.gz
dexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.tar.bz2
dexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.tar.lz
dexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.tar.xz
dexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.tar.zst
dexon-4b4830692a0e17b26338da75c6ab96f6bb4e14b1.zip
Merge branch 'develop' of github.com-obscure:ethereum/eth-go into develop
-rw-r--r--ethpipe/js_pipe.go6
-rw-r--r--ethpipe/pipe.go9
-rw-r--r--ethrpc/packages.go21
3 files changed, 36 insertions, 0 deletions
diff --git a/ethpipe/js_pipe.go b/ethpipe/js_pipe.go
index 7ee183c84..32212b26a 100644
--- a/ethpipe/js_pipe.go
+++ b/ethpipe/js_pipe.go
@@ -223,6 +223,12 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
return NewJSReciept(contractCreation, tx.CreationAddress(), tx.Hash(), keyPair.Address()), nil
}
+func (self *JSPipe) PushTx(txStr string) (*JSReceipt, error) {
+ tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(txStr))
+ self.obj.TxPool().QueueTransaction(tx)
+ return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(), tx.Hash(), tx.Sender()), nil
+}
+
func (self *JSPipe) CompileMutan(code string) string {
data, err := self.Pipe.CompileMutan(code)
if err != nil {
diff --git a/ethpipe/pipe.go b/ethpipe/pipe.go
index 800a71139..b7d3be041 100644
--- a/ethpipe/pipe.go
+++ b/ethpipe/pipe.go
@@ -149,6 +149,15 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price
return tx.Hash(), nil
}
+func (self *Pipe) PushTx(tx *ethchain.Transaction) ([]byte, error) {
+ self.obj.TxPool().QueueTransaction(tx)
+ if tx.Recipient == nil {
+ logger.Infof("Contract addr %x", tx.CreationAddress())
+ return tx.CreationAddress(), nil
+ }
+ return tx.Hash(), nil
+}
+
func (self *Pipe) CompileMutan(code string) ([]byte, error) {
data, err := ethutil.Compile(code, false)
if err != nil {
diff --git a/ethrpc/packages.go b/ethrpc/packages.go
index f2e57fa49..087167a42 100644
--- a/ethrpc/packages.go
+++ b/ethrpc/packages.go
@@ -145,6 +145,27 @@ func (p *EthereumApi) Create(args *NewTxArgs, reply *string) error {
return nil
}
+type PushTxArgs struct {
+ Tx string
+}
+
+func (a *PushTxArgs) requirementsPushTx() error {
+ if a.Tx == "" {
+ return NewErrorResponse("PushTx requires a 'tx' as argument")
+ }
+ return nil
+}
+
+func (p *EthereumApi) PushTx(args *PushTxArgs, reply *string) error {
+ err := args.requirementsPushTx()
+ if err != nil {
+ return err
+ }
+ result, _ := p.pipe.PushTx(args.Tx)
+ *reply = NewSuccessRes(result)
+ return nil
+}
+
func (p *EthereumApi) GetKey(args interface{}, reply *string) error {
*reply = NewSuccessRes(p.pipe.Key())
return nil