aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-08-08 16:22:10 +0800
committerMartin Holst Swende <martin@swende.se>2019-08-08 16:22:10 +0800
commitc55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd (patch)
tree2d3a90b7a0c466f59b8d334d6fb58428da5ee700
parentaa6005b469fdd1aa7a95f501ce87908011f43159 (diff)
downloadgo-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.tar
go-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.tar.gz
go-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.tar.bz2
go-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.tar.lz
go-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.tar.xz
go-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.tar.zst
go-tangerine-c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd.zip
ethapi: implement filltransaction
-rw-r--r--internal/ethapi/api.go16
-rw-r--r--internal/web3ext/web3ext.go6
2 files changed, 22 insertions, 0 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index a00598f82..d27c9ec9b 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -1441,6 +1441,22 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
return SubmitTransaction(ctx, s.b, signed)
}
+// FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction,
+// and returns it to the caller for further processing (signing + broadcast)
+func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) {
+ // Set some sanity defaults and terminate on failure
+ if err := args.setDefaults(ctx, s.b); err != nil {
+ return nil, err
+ }
+ // Assemble the transaction and obtain rlp
+ tx := args.toTransaction()
+ data, err := rlp.EncodeToBytes(tx)
+ if err != nil {
+ return nil, err
+ }
+ return &SignTransactionResult{data, tx}, nil
+}
+
// SendRawTransaction will add the signed transaction to the transaction pool.
// The sender is responsible for signing the transaction and using the correct nonce.
func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index 4a5d4b4dd..86e575439 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -484,6 +484,12 @@ web3._extend({
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
}),
new web3._extend.Method({
+ name: 'fillTransaction',
+ call: 'eth_fillTransaction',
+ params: 1,
+ inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
+ }),
+ new web3._extend.Method({
name: 'getHeaderByNumber',
call: 'eth_getHeaderByNumber',
params: 1