Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions cmd/livepeer_cli/wizard_bond.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ func (w *wizard) bond() {
"toAddr": {fmt.Sprintf("%v", tAddr.Hex())},
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/bond", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/bond", w.host, w.httpPort), val)
}
}

func (w *wizard) rebond() {
Expand Down Expand Up @@ -243,7 +247,11 @@ func (w *wizard) rebond() {
val["toAddr"] = []string{fmt.Sprintf("%v", toAddr.Hex())}
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/rebond", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/rebond", w.host, w.httpPort), val)
}
}

func (w *wizard) unbond() {
Expand Down Expand Up @@ -290,7 +298,11 @@ func (w *wizard) unbond() {
"amount": {fmt.Sprintf("%v", amount.String())},
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/unbond", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/unbond", w.host, w.httpPort), val)
}
}

func (w *wizard) withdrawStake() {
Expand Down Expand Up @@ -327,7 +339,11 @@ func (w *wizard) withdrawStake() {
"unbondingLockId": {fmt.Sprintf("%v", strconv.FormatInt(unbondingLockID, 10))},
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/withdrawStake", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/withdrawStake", w.host, w.httpPort), val)
}
}

func (w *wizard) withdrawFees() {
Expand All @@ -341,5 +357,9 @@ func (w *wizard) withdrawFees() {
"amount": {fmt.Sprintf("%v", dInfo.PendingFees.String())},
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/withdrawFees", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/withdrawFees", w.host, w.httpPort), val)
}
}
32 changes: 20 additions & 12 deletions cmd/livepeer_cli/wizard_broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,16 @@ func (w *wizard) setBroadcastConfig() {
"transcodingOptions": {fmt.Sprintf("%v", transOpts)},
}

result, ok := httpPostWithParams(fmt.Sprintf("http://%v:%v/setBroadcastConfig", w.host, w.httpPort), val)
if !ok {
fmt.Printf("Error applying configuration: %s\n", result)
} else {
fmt.Printf("Configuration applied successfully\n")
}
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
result, ok := httpPostWithParams(fmt.Sprintf("http://%v:%v/setBroadcastConfig", w.host, w.httpPort), val)
if !ok {
fmt.Printf("Error applying configuration: %s\n", result)
} else {
fmt.Printf("Configuration applied successfully\n")
}
}
}

func (w *wizard) setBroadcastMaxPricePerCapability() {
Expand All @@ -119,12 +123,16 @@ func (w *wizard) setBroadcastMaxPricePerCapability() {
"modelID": {fmt.Sprintf("%v", modelID)},
}

resp, ok := httpPostWithParams(fmt.Sprintf("http://%v:%v/setMaxPriceForCapability", w.host, w.httpPort), val)
if !ok {
fmt.Printf("Error setting max price for capability: %v\n", resp)
} else {
fmt.Printf("Max price per capability set successfully\n")
}
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
resp, ok := httpPostWithParams(fmt.Sprintf("http://%v:%v/setMaxPriceForCapability", w.host, w.httpPort), val)
if !ok {
fmt.Printf("Error setting max price for capability: %v\n", resp)
} else {
fmt.Printf("Max price per capability set successfully\n")
}
}
}

func (w *wizard) idListToVideoProfileList(idList string, opts map[int]string) (string, error) {
Expand Down
42 changes: 28 additions & 14 deletions cmd/livepeer_cli/wizard_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ func (w *wizard) setMaxGasPrice() {
"amount": {fmt.Sprintf("%v", amount.String())},
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/setMaxGasPrice", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/setMaxGasPrice", w.host, w.httpPort), val)
}
}

func (w *wizard) setMinGasPrice() {
Expand All @@ -24,7 +28,11 @@ func (w *wizard) setMinGasPrice() {
"minGasPrice": {fmt.Sprintf("%v", minGasPrice.String())},
}

httpPostWithParams(fmt.Sprintf("http://%v:%v/setMinGasPrice", w.host, w.httpPort), val)
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPostWithParams(fmt.Sprintf("http://%v:%v/setMinGasPrice", w.host, w.httpPort), val)
}
}

func (w *wizard) signMessage() {
Expand All @@ -33,12 +41,15 @@ func (w *wizard) signMessage() {
val := url.Values{
"message": {msg},
}
result, ok := httpPostWithParams(fmt.Sprintf("http://%v:%v/signMessage", w.host, w.httpPort), val)
if !ok {
fmt.Printf("Error signing message: %v\n", result)
return
}
fmt.Println(fmt.Sprintf("\n\nSignature:\n0x%x", result))
fmt.Printf("Press 'Y' to sign, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
result, ok := httpPostWithParams(fmt.Sprintf("http://%v:%v/signMessage", w.host, w.httpPort), val)
if !ok {
fmt.Printf("Error signing message: %v\n", result)
return
}
fmt.Println(fmt.Sprintf("\n\nSignature:\n0x%x", result))
}
}

func (w *wizard) signTypedData() {
Expand All @@ -50,10 +61,13 @@ func (w *wizard) signTypedData() {
headers := map[string]string{
"SigFormat": "data/typed",
}
result, ok := httpPostWithParamsHeaders(fmt.Sprintf("http://%v:%v/signMessage", w.host, w.httpPort), val, headers)
if !ok {
fmt.Printf("Error signing typed data: %v\n", result)
return
}
fmt.Println(fmt.Sprintf("\n\nSignature:\n0x%x", result))
fmt.Printf("Press 'Y' to sign, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
result, ok := httpPostWithParamsHeaders(fmt.Sprintf("http://%v:%v/signMessage", w.host, w.httpPort), val, headers)
if !ok {
fmt.Printf("Error signing typed data: %v\n", result)
return
}
fmt.Println(fmt.Sprintf("\n\nSignature:\n0x%x", result))
}
}
6 changes: 5 additions & 1 deletion cmd/livepeer_cli/wizard_rounds.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ func (w *wizard) currentRound() (*big.Int, error) {
}

func (w *wizard) initializeRound() {
httpPost(fmt.Sprintf("http://%v:%v/initializeRound", w.host, w.httpPort))
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPost(fmt.Sprintf("http://%v:%v/initializeRound", w.host, w.httpPort))
}
}
24 changes: 20 additions & 4 deletions cmd/livepeer_cli/wizard_ticketbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func (w *wizard) deposit() {
"depositAmount": {depositAmount.String()},
"reserveAmount": {reserveAmount.String()},
}
fmt.Println(httpPostWithParams(fmt.Sprintf("http://%v:%v/fundDepositAndReserve", w.host, w.httpPort), form))
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
fmt.Println(httpPostWithParams(fmt.Sprintf("http://%v:%v/fundDepositAndReserve", w.host, w.httpPort), form))
}

return
}
Expand Down Expand Up @@ -104,7 +108,11 @@ func (w *wizard) unlock() {
return
}

fmt.Println(httpPost(fmt.Sprintf("http://%v:%v/unlock", w.host, w.httpPort)))
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPost(fmt.Sprintf("http://%v:%v/unlock", w.host, w.httpPort))
}
}

func (w *wizard) cancelUnlock() {
Expand Down Expand Up @@ -138,7 +146,11 @@ func (w *wizard) cancelUnlock() {
return
}

fmt.Println(httpPost(fmt.Sprintf("http://%v:%v/cancelUnlock", w.host, w.httpPort)))
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
fmt.Println(httpPost(fmt.Sprintf("http://%v:%v/cancelUnlock", w.host, w.httpPort)))
}
}

func (w *wizard) withdraw() {
Expand Down Expand Up @@ -173,7 +185,11 @@ func (w *wizard) withdraw() {
return
}

fmt.Println(httpPost(fmt.Sprintf("http://%v:%v/withdraw", w.host, w.httpPort)))
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
fmt.Println(httpPost(fmt.Sprintf("http://%v:%v/withdraw", w.host, w.httpPort)))
}
}

func (w *wizard) senderInfo() (info pm.SenderInfo, err error) {
Expand Down
6 changes: 5 additions & 1 deletion cmd/livepeer_cli/wizard_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ func (w *wizard) transferTokens() {
}

func (w *wizard) requestTokens() {
httpPost(fmt.Sprintf("http://%v:%v/requestTokens", w.host, w.httpPort))
w.printGasInfo()
fmt.Printf("Press 'Y' to approve transaction, or any other key to cancel\n")
if strings.ToLower(w.read()) == "y" {
httpPost(fmt.Sprintf("http://%v:%v/requestTokens", w.host, w.httpPort))
}
}
Loading
Loading