core/types: make Transaction zero value printable (#3595)
This commit is contained in:
parent
96778a1c21
commit
fc52f2c007
@ -134,7 +134,7 @@ func (tx *Transaction) ChainId() *big.Int {
|
|||||||
return deriveChainId(tx.data.V)
|
return deriveChainId(tx.data.V)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protected returns whether the transaction is pretected from replay protection
|
// Protected returns whether the transaction is protected from replay protection.
|
||||||
func (tx *Transaction) Protected() bool {
|
func (tx *Transaction) Protected() bool {
|
||||||
return isProtectedV(tx.data.V)
|
return isProtectedV(tx.data.V)
|
||||||
}
|
}
|
||||||
@ -311,16 +311,20 @@ func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tx *Transaction) String() string {
|
func (tx *Transaction) String() string {
|
||||||
// make a best guess about the signer and use that to derive
|
|
||||||
// the sender.
|
|
||||||
signer := deriveSigner(tx.data.V)
|
|
||||||
|
|
||||||
var from, to string
|
var from, to string
|
||||||
if f, err := Sender(signer, tx); err != nil { // derive but don't cache
|
if tx.data.V != nil {
|
||||||
from = "[invalid sender: invalid sig]"
|
// make a best guess about the signer and use that to derive
|
||||||
|
// the sender.
|
||||||
|
signer := deriveSigner(tx.data.V)
|
||||||
|
if f, err := Sender(signer, tx); err != nil { // derive but don't cache
|
||||||
|
from = "[invalid sender: invalid sig]"
|
||||||
|
} else {
|
||||||
|
from = fmt.Sprintf("%x", f[:])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
from = fmt.Sprintf("%x", f[:])
|
from = "[invalid sender: nil V field]"
|
||||||
}
|
}
|
||||||
|
|
||||||
if tx.data.Recipient == nil {
|
if tx.data.Recipient == nil {
|
||||||
to = "[contract creation]"
|
to = "[contract creation]"
|
||||||
} else {
|
} else {
|
||||||
@ -333,13 +337,13 @@ func (tx *Transaction) String() string {
|
|||||||
From: %s
|
From: %s
|
||||||
To: %s
|
To: %s
|
||||||
Nonce: %v
|
Nonce: %v
|
||||||
GasPrice: %v
|
GasPrice: %#x
|
||||||
GasLimit %v
|
GasLimit %#x
|
||||||
Value: %v
|
Value: %#x
|
||||||
Data: 0x%x
|
Data: 0x%x
|
||||||
V: 0x%x
|
V: %#x
|
||||||
R: 0x%x
|
R: %#x
|
||||||
S: 0x%x
|
S: %#x
|
||||||
Hex: %x
|
Hex: %x
|
||||||
`,
|
`,
|
||||||
tx.Hash(),
|
tx.Hash(),
|
||||||
|
Loading…
Reference in New Issue
Block a user