ethapi: implement filltransaction
This commit is contained in:
parent
aa6005b469
commit
c55e1b495c
|
@ -1441,6 +1441,22 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
|
||||||
return SubmitTransaction(ctx, s.b, signed)
|
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.
|
// SendRawTransaction will add the signed transaction to the transaction pool.
|
||||||
// The sender is responsible for signing the transaction and using the correct nonce.
|
// 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) {
|
func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
|
||||||
|
|
|
@ -483,6 +483,12 @@ web3._extend({
|
||||||
params: 1,
|
params: 1,
|
||||||
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
|
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({
|
new web3._extend.Method({
|
||||||
name: 'getHeaderByNumber',
|
name: 'getHeaderByNumber',
|
||||||
call: 'eth_getHeaderByNumber',
|
call: 'eth_getHeaderByNumber',
|
||||||
|
|
Loading…
Reference in New Issue