Skip to content

Commit b8a9457

Browse files
authored
Merge pull request #19915 from holiman/filltx
internal/ethapi: implement fillTransaction
2 parents af16ca1 + c55e1b4 commit b8a9457

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

internal/ethapi/api.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,22 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
14791479
return SubmitTransaction(ctx, s.b, signed)
14801480
}
14811481

1482+
// FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction,
1483+
// and returns it to the caller for further processing (signing + broadcast)
1484+
func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) {
1485+
// Set some sanity defaults and terminate on failure
1486+
if err := args.setDefaults(ctx, s.b); err != nil {
1487+
return nil, err
1488+
}
1489+
// Assemble the transaction and obtain rlp
1490+
tx := args.toTransaction()
1491+
data, err := rlp.EncodeToBytes(tx)
1492+
if err != nil {
1493+
return nil, err
1494+
}
1495+
return &SignTransactionResult{data, tx}, nil
1496+
}
1497+
14821498
// SendRawTransaction will add the signed transaction to the transaction pool.
14831499
// The sender is responsible for signing the transaction and using the correct nonce.
14841500
func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {

internal/web3ext/web3ext.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@ web3._extend({
483483
params: 1,
484484
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
485485
}),
486+
new web3._extend.Method({
487+
name: 'fillTransaction',
488+
call: 'eth_fillTransaction',
489+
params: 1,
490+
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
491+
}),
486492
new web3._extend.Method({
487493
name: 'getHeaderByNumber',
488494
call: 'eth_getHeaderByNumber',

0 commit comments

Comments
 (0)