-
Notifications
You must be signed in to change notification settings - Fork 328
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
[api] correct signature's V value in returned web3 transaction #3952
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,13 +154,15 @@ func TestBlockObjectMarshal(t *testing.T) { | |
}) | ||
|
||
t.Run("BlockWithDetail", func(t *testing.T) { | ||
raw := types.NewContractCreation(2, unit.ConvertIotxToRau(1000), 21000, unit.ConvertIotxToRau(1), []byte{}) | ||
ethTx, err := action.RawTxToSignedTx(raw, 0, sevlp.Signature()) | ||
require.NoError(err) | ||
tx := &getTransactionResult{ | ||
blockHash: _testBlkHash, | ||
to: nil, | ||
ethTx: types.NewContractCreation(2, unit.ConvertIotxToRau(1000), 21000, unit.ConvertIotxToRau(1), []byte{}), | ||
ethTx: ethTx, | ||
receipt: blk.Receipts[0], | ||
pubkey: sevlp.SrcPubkey(), | ||
signature: sevlp.Signature(), | ||
} | ||
res, err := json.Marshal(&getBlockResult{ | ||
blk: &blk, | ||
|
@@ -226,14 +228,15 @@ func TestTransactionObjectMarshal(t *testing.T) { | |
} | ||
|
||
t.Run("ContractCreation", func(t *testing.T) { | ||
raw := types.NewContractCreation(1, big.NewInt(10), 21000, big.NewInt(0), []byte{}) | ||
sig, _ := hex.DecodeString("363964383961306166323764636161363766316236326133383335393464393735393961616464326237623136346362343131326161386464666434326638391b") | ||
tx, err := action.RawTxToSignedTx(raw, 4690, sig) | ||
res, err := json.Marshal(&getTransactionResult{ | ||
blockHash: _testBlkHash, | ||
to: nil, | ||
ethTx: types.NewContractCreation(1, big.NewInt(10), 21000, big.NewInt(0), []byte{}), | ||
ethTx: tx, | ||
receipt: receipt, | ||
pubkey: _testPubKey, | ||
// TODO: should decode signature from hex string | ||
signature: []byte("69d89a0af27dcaa67f1b62a383594d97599aadd2b7b164cb4112aa8ddfd42f895649075cae1b7216c43a491c5e9be68d1d9a27b863d71155ecdd7c95dab5394f01"), | ||
}) | ||
require.NoError(err) | ||
require.JSONEq(` | ||
|
@@ -251,7 +254,7 @@ func TestTransactionObjectMarshal(t *testing.T) { | |
"input":"0x", | ||
"r":"0x3639643839613061663237646361613637663162363261333833353934643937", | ||
"s":"0x3539396161646432623762313634636234313132616138646466643432663839", | ||
"v":"0x35" | ||
"v":"0x24c7" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the correct value corresponding to chainID = 4690 |
||
} | ||
`, string(res)) | ||
}) | ||
|
@@ -262,10 +265,13 @@ func TestTransactionObjectMarshal(t *testing.T) { | |
data, _ := hex.DecodeString("1fad948c0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ec4daee51c4bf81bd00af165f8ca66823ee3b12a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000003e24491a4f2a946e30baf624fda6b4484d106c12000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000009fd90000000000000000000000000000000000000000000000000000000000011da4000000000000000000000000000000000000000000000000000000000000db26000000000000000000000000000000000000000000000000000000e8d4a51000000000000000000000000000000000000000000000000000000000e8d4a510000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084b61d27f6000000000000000000000000065e1164818487818e6ba714e8d80b91718ad75800000000000000000000000000000000000000000000000000038d7ea4c6800000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000095ccc7012efb2e65aa31752f3ac01e23817c08a47500000000000000000000000000000000000000000000000000000000650af9f8000000000000000000000000000000000000000000000000000000006509a878b5acba7277159ae6fa661ed1988cc10ac2c96c58dc332bde2a6dc0d8531ea3924d9d04cda681c271411250ae7d9e9aea47661dba67a66f08d19804a255e45c561b0000000000000000000000000000000000000000000000000000000000000000000000000000000000004160daa88165299ca7e585d5d286cee98b54397b57ac704b74331a48d67651195322ef3884c7d60023333f2542a07936f34edc9efa3cbd19e8cd0f8972c54171a21b00000000000000000000000000000000000000000000000000000000000000") | ||
pubkey, _ := crypto.HexStringToPublicKey("04806b217cb0b6a675974689fd99549e525d967287eee9a62dc4e598eea981b8158acfe026da7bf58397108abd0607672832c28ef3bc7b5855077f6e67ab5fc096") | ||
actHash, _ := hash.HexStringToHash256("cbc2560d986d79a46bfd96a08d18c6045b29f97352c1360289e371d9cffd6b6a") | ||
raw := types.NewContractCreation(305, big.NewInt(0), 297131, big.NewInt(1000000000000), data) | ||
tx, err := action.RawTxToSignedTx(raw, 0, sig) | ||
require.NoError(err) | ||
res, err := json.Marshal(&getTransactionResult{ | ||
blockHash: blkHash, | ||
to: &contract, | ||
ethTx: types.NewContractCreation(305, big.NewInt(0), 297131, big.NewInt(1000000000000), data), | ||
ethTx: tx, | ||
receipt: &action.Receipt{ | ||
Status: 1, | ||
BlockHeight: 22354907, | ||
|
@@ -274,8 +280,7 @@ func TestTransactionObjectMarshal(t *testing.T) { | |
ContractAddress: "", | ||
TxIndex: 0, | ||
}, | ||
pubkey: pubkey, | ||
signature: sig, | ||
pubkey: pubkey, | ||
}) | ||
require.NoError(err) | ||
require.JSONEq(` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,13 +117,16 @@ func (svr *web3Handler) getTransactionFromActionInfo(blkHash hash.Hash256, selp | |
if err != nil { | ||
return nil, err | ||
} | ||
tx, err := action.RawTxToSignedTx(ethTx, svr.coreService.ChainID(), selp.Signature()) | ||
Liuhaai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return nil, err | ||
} | ||
return &getTransactionResult{ | ||
blockHash: blkHash, | ||
to: to, | ||
ethTx: ethTx, | ||
ethTx: tx, | ||
receipt: receipt, | ||
pubkey: selp.SrcPubkey(), | ||
signature: selp.Signature(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why could signature be deleted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed anymore, now the signed tx is generated, which contains correct signature value |
||
}, 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.
duplicate code, same as
DecodeRawTx