@@ -69,9 +69,9 @@ export default class Transaction {
69
69
to : to && to . length > 0 ? new Address ( to ) : undefined ,
70
70
value : new BN ( value ) ,
71
71
data : data ?? emptyBuffer ,
72
- v : ! v ? .equals ( emptyBuffer ) ? new BN ( v ) : undefined ,
73
- r : ! r ? .equals ( emptyBuffer ) ? new BN ( r ) : undefined ,
74
- s : ! s ? .equals ( emptyBuffer ) ? new BN ( s ) : undefined ,
72
+ v : v && ! v . equals ( emptyBuffer ) ? new BN ( v ) : undefined ,
73
+ r : r && ! r . equals ( emptyBuffer ) ? new BN ( r ) : undefined ,
74
+ s : s && ! s . equals ( emptyBuffer ) ? new BN ( s ) : undefined ,
75
75
} ,
76
76
opts
77
77
)
@@ -135,19 +135,7 @@ export default class Transaction {
135
135
* Computes a sha3-256 hash of the serialized tx
136
136
*/
137
137
hash ( ) : Buffer {
138
- const values = [
139
- bnToRlp ( this . nonce ) ,
140
- bnToRlp ( this . gasPrice ) ,
141
- bnToRlp ( this . gasLimit ) ,
142
- this . to !== undefined ? this . to . buf : Buffer . from ( [ ] ) ,
143
- bnToRlp ( this . value ) ,
144
- this . data ,
145
- this . v ? bnToRlp ( this . v ) : Buffer . from ( [ ] ) ,
146
- this . r ? bnToRlp ( this . r ) : Buffer . from ( [ ] ) ,
147
- this . s ? bnToRlp ( this . s ) : Buffer . from ( [ ] ) ,
148
- ]
149
-
150
- return rlphash ( values )
138
+ return rlphash ( this . raw ( ) )
151
139
}
152
140
153
141
getMessageToSign ( ) {
@@ -383,14 +371,7 @@ export default class Transaction {
383
371
}
384
372
385
373
private _getMessageToSign ( withEIP155 : boolean ) {
386
- const values = [
387
- bnToRlp ( this . nonce ) ,
388
- bnToRlp ( this . gasPrice ) ,
389
- bnToRlp ( this . gasLimit ) ,
390
- this . to !== undefined ? this . to . buf : Buffer . from ( [ ] ) ,
391
- bnToRlp ( this . value ) ,
392
- this . data ,
393
- ]
374
+ const values = this . raw ( ) . slice ( 0 , 6 )
394
375
395
376
if ( withEIP155 ) {
396
377
values . push ( toBuffer ( this . getChainId ( ) ) )
@@ -405,7 +386,7 @@ export default class Transaction {
405
386
* Validates tx's `v` value
406
387
*/
407
388
private _validateTxV ( v : BN | undefined ) : void {
408
- if ( v === undefined || v . toNumber ( ) === 0 ) {
389
+ if ( v === undefined ) {
409
390
return
410
391
}
411
392
0 commit comments