Skip to content

Commit e7f46d0

Browse files
authored
Update cliui.go
1 parent 18a9027 commit e7f46d0

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

signer/core/cliui.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core
1818

1919
import (
2020
"bufio"
21+
"bytes"
2122
"context"
2223
"encoding/json"
2324
"fmt"
@@ -142,10 +143,32 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
142143
fmt.Printf(" %v\n", bh)
143144
}
144145
}
145-
if request.Transaction.Data != nil {
146-
d := *request.Transaction.Data
147-
if len(d) > 0 {
148-
fmt.Printf("data: %v\n", hexutil.Encode(d))
146+
{
147+
var (
148+
data []byte
149+
inputSet bool
150+
dataSet bool
151+
)
152+
if request.Transaction.Input != nil {
153+
data = *request.Transaction.Input
154+
inputSet = true
155+
}
156+
if request.Transaction.Data != nil {
157+
dataSet = true
158+
if !inputSet {
159+
data = *request.Transaction.Data
160+
}
161+
}
162+
if inputSet && dataSet && !bytes.Equal(*request.Transaction.Input, *request.Transaction.Data) {
163+
fmt.Printf("input: %v\n", hexutil.Encode(*request.Transaction.Input))
164+
fmt.Printf("data: %v\n", hexutil.Encode(*request.Transaction.Data))
165+
fmt.Printf("WARNING: both input and data provided and differ; input will be used\n")
166+
} else if len(data) > 0 {
167+
label := "data"
168+
if inputSet {
169+
label = "input"
170+
}
171+
fmt.Printf("%s: %v\n", label, hexutil.Encode(data))
149172
}
150173
}
151174
if request.Callinfo != nil {

0 commit comments

Comments
 (0)