-
Notifications
You must be signed in to change notification settings - Fork 21.6k
internal/ethapi: implement fillTransaction #19915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Fixed, ptal |
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &SignTransactionResult{data, tx}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, shouldn't we perhaps declare a type FillTransactionResult that does not return R, S, V?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
karalabe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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