@@ -33,13 +33,15 @@ pub fn encode_for_sign(mut transaction: Transaction) -> Result<Transaction, Chai
3333 Ok ( transaction)
3434}
3535
36- pub fn encode_for_broadcast ( transaction : Transaction ) -> Result < Transaction , ChainError > {
36+ pub fn encode_for_broadcast ( mut transaction : Transaction ) -> Result < Transaction , ChainError > {
3737 let mut eth_tx = EthereumTransaction :: decode ( & transaction. raw_data ) ?;
3838
3939 let mut signature_bytes: [ u8 ; 65 ] = [ 0 ; 65 ] ;
4040 signature_bytes. copy_from_slice ( & transaction. signature [ ..] ) ;
4141 eth_tx. signature = Some ( signature_bytes) ;
4242
43+ transaction. raw_data = eth_tx. encode ( ) ?;
44+
4345 Ok ( transaction)
4446}
4547
@@ -87,6 +89,7 @@ mod test {
8789 hex:: encode( result. tx_hash) ,
8890 "5ed21ed1618c98b5b1814565d8d7a63ebc6425997c75b2b857d8692f0b73a64f"
8991 ) ;
92+ assert_eq ! ( hex:: encode( result. raw_data) , "b302f101819e84ae7937b285035f6cccc58252089498de4c83810b87f0e2cd92d80c9fac28c4ded4818568c696991f80c0808080" ) ;
9093
9194 tx. signature = vec ! [
9295 0x30 , 0x45 , 0x02 , 0x21 , 0x00 , 0xd3 , 0x8f , 0x71 , 0x94 , 0x7b , 0x2c , 0xf5 , 0x43 , 0x58 ,
@@ -98,7 +101,7 @@ mod test {
98101
99102 let signed_tx = encode_for_broadcast ( tx. clone ( ) ) . unwrap ( ) ;
100103
101- assert_eq ! ( hex:: encode( signed_tx. raw_data) , "b302f101819e84ae7937b285035f6cccc58252089498de4c83810b87f0e2cd92d80c9fac28c4ded4818568c696991f80c0808080 " ) ;
104+ assert_eq ! ( hex:: encode( signed_tx. raw_data) , "02f87101819e84ae7937b285035f6cccc58252089498de4c83810b87f0e2cd92d80c9fac28c4ded4818568c696991f80c054a054ad49a590596b77452a01141de380dd50945843f52c7b94718fd30021024530a0ad49a590596b77452a01141de380dd50945843f52c7b94718fd3002102453007 " ) ;
102105 assert_eq ! (
103106 hex:: encode( signed_tx. signature) ,
104107 "3045022100d38f71947b2cf543589450dd80e31d14012a45776b5990a549ad54073045022100d38f71947b2cf543589450dd80e31d14012a45776b5990a549ad54"
@@ -121,6 +124,7 @@ mod test {
121124 hex:: encode( result. tx_hash) ,
122125 "8823151a6987f2625239f058e453f5850e3d800b31f1dd60951a7e36e0769c2e"
123126 ) ;
127+ assert_eq ! ( hex:: encode( result. raw_data) , "b87602f8730182014f84147b7eeb85084ec9f83f8301450994dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000004cbeee256240c92a9ad920ea6f4d7df6466d2cdc000000000000000000000000000000000000000000000000000000000000000ac0808080" ) ;
124128
125129 tx. signature = vec ! [
126130 0x30 , 0x45 , 0x02 , 0x21 , 0x00 , 0xd3 , 0x8f , 0x71 , 0x94 , 0x7b , 0x2c , 0xf5 , 0x43 , 0x58 ,
@@ -132,7 +136,7 @@ mod test {
132136
133137 let signed_tx = encode_for_broadcast ( tx. clone ( ) ) . unwrap ( ) ;
134138
135- assert_eq ! ( hex:: encode( signed_tx. raw_data) , "b87602f8730182014f84147b7eeb85084ec9f83f8301450994dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000004cbeee256240c92a9ad920ea6f4d7df6466d2cdc000000000000000000000000000000000000000000000000000000000000000ac0808080 " ) ;
139+ assert_eq ! ( hex:: encode( signed_tx. raw_data) , "02f8b30182014f84147b7eeb85084ec9f83f8301450994dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000004cbeee256240c92a9ad920ea6f4d7df6466d2cdc000000000000000000000000000000000000000000000000000000000000000ac054a054ad49a590596b77452a01141de380dd50945843f52c7b94718fd30021024530a0ad49a590596b77452a01141de380dd50945843f52c7b94718fd3002102453007 " ) ;
136140 assert_eq ! (
137141 hex:: encode( signed_tx. signature) ,
138142 "3045022100d38f71947b2cf543589450dd80e31d14012a45776b5990a549ad54073045022100d38f71947b2cf543589450dd80e31d14012a45776b5990a549ad54"
0 commit comments