diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-09-03 16:38:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 16:38:11 +0800 |
commit | b8a94571397c1afd5579f1e319aff05a676c917d (patch) | |
tree | 30747e7599073a4aa3b77bc0da7d2d00baeca84f | |
parent | af16ca177f0fbe3434b6f4ee0f536722e1983507 (diff) | |
parent | c55e1b495cb1082b5bb11b3c2e6e3d0943dae3cd (diff) | |
download | go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.tar go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.tar.gz go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.tar.bz2 go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.tar.lz go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.tar.xz go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.tar.zst go-tangerine-b8a94571397c1afd5579f1e319aff05a676c917d.zip |
Merge pull request #19915 from holiman/filltx
internal/ethapi: implement fillTransaction
-rw-r--r-- | internal/ethapi/api.go | 16 | ||||
-rw-r--r-- | internal/web3ext/web3ext.go | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d18700e25..354614d0a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1479,6 +1479,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 |