internal/ethapi: implement fillTransaction#19915
Merged
karalabe merged 1 commit intoethereum:masterfrom Sep 3, 2019
Merged
Conversation
karalabe
reviewed
Aug 8, 2019
Contributor
Author
|
Fixed, ptal |
karalabe
reviewed
Aug 8, 2019
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &SignTransactionResult{data, tx}, nil |
Member
There was a problem hiding this comment.
Hmmm, shouldn't we perhaps declare a type FillTransactionResult that does not return R, S, V?
Contributor
Author
There was a problem hiding this comment.
Hm, maybe... I'm not sure it solves the usability question. So here are the steps you need to go through to actually fill and sign a tx:
> a = eth.fillTransaction({"to":"0x17Ff1b635D4A1E4Ba1377E06d1dD0e1C9015FB5f", value:"100", from:eth.accounts[0]})
{
raw: "0xdf80018252089417ff1b635d4a1e4ba1377e06d1dd0e1c9015fb5f6480808080",
tx: {
gas: "0x5208",
gasPrice: "0x1",
hash: "0xea7d97f5fe68d9fc638410cf134f3785ef690330660069252e5d7bb2f122f6c7",
input: "0x",
nonce: "0x0",
r: "0x0",
s: "0x0",
to: "0x17ff1b635d4a1e4ba1377e06d1dd0e1c9015fb5f",
v: "0x0",
value: "0x64"
}
}
> a.tx.from = eth.accounts[0]
"0x42e44603164ac2384c2c0894fe67b344a9f1f50b"
> eth.signTransaction(a.tx)
{
raw: "0xf86180018252089417ff1b635d4a1e4ba1377e06d1dd0e1c9015fb5f6480820a95a013c4a9a47cd447a6bef6a085b20e02ae393205bac903e74535c103c33bc54021a02d0ef0739ebd9267197625c0fb154619b0e385066e362dbac55fbdf57e68773a",
tx: {
gas: "0x5208",
gasPrice: "0x1",
hash: "0x656acc325802797f991d98ba48f8bd383332bcdbc4c390ac790740139c1adfe9",
input: "0x",
nonce: "0x0",
r: "0x13c4a9a47cd447a6bef6a085b20e02ae393205bac903e74535c103c33bc54021",
s: "0x2d0ef0739ebd9267197625c0fb154619b0e385066e362dbac55fbdf57e68773a",
to: "0x17ff1b635d4a1e4ba1377e06d1dd0e1c9015fb5f",
v: "0xa95",
value: "0x64"
}
}
You need to explicitly set the from. Would be neat if we could pass the output from fill as input to sign.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
eth.fillTransaction, which is useful if signing is done outside of the actual node.Below is a reference about what methods exist today (we might want to make it into a table and place in the docs)
Example
Example when using
geth --dev, which does not really have a sensible GPO.Transaction methods
ethsendTransactionhashethsendRawTransactionhashethsignTransactionRLP+JSON(signed tx)ethresendhashethfillTransactionRLP+JSON(unsigned tx)personalsendTransactionhashpersonalsignTransactionRLP+JSON(signed tx)eth.sendTransactioneth.sendRawTransactioneth.signTransactioneth.resendnonceif sending-account to an existing tx, applies modifications, signs and broadcastsnonce, fills other defaultseth.fillTransactionRLP+JSONpersonal.sendTransactionpersonal.signTransactionRLP+JSON