add pushtx to api

Previously the software assumed use of an internal private key for use in all broadcasted transactions. This addition lets nodes relay pre-signed transactions originating from sources other than the node itself.
This commit is contained in:
Cayman Nava
2014-09-09 21:27:34 -07:00
parent 6afc16399f
commit 7dacd7eb78
3 changed files with 36 additions and 0 deletions
+21
View File
@@ -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