Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error -32000 (authentication needed: password or unlock) #8

Open
atifzia opened this issue Apr 2, 2018 · 2 comments
Open

Error -32000 (authentication needed: password or unlock) #8

atifzia opened this issue Apr 2, 2018 · 2 comments

Comments

@atifzia
Copy link

atifzia commented Apr 2, 2018

I think there is nothing wrong with the code below as I unlock the account first and then make transaction

package main

import (
	"fmt"
	"github.com/onrik/ethrpc"
	"log"
	"github.com/ethereum/go-ethereum/accounts/keystore"
	"github.com/ethereum/go-ethereum/accounts"
	"math/big"
)

func main() {
	client:=ethrpc.New("http://localhost:8545")
	_, err := client.Web3ClientVersion()
	if err != nil {
		log.Fatal("Error Connecting To Node : ",err)
	}
	ks := keystore.NewKeyStore(
		"/home/atif/.ethereum/rinkeby/keystore/",
		keystore.LightScryptN,
		keystore.LightScryptP)
	var unlockedAccount accounts.Account
	accs:=ks.Accounts()
	if err:=ks.Unlock(accs[1],"abcd");err==nil{
		unlockedAccount=accs[1]
		fmt.Println("Account Unlocked")
	}
	t:=ethrpc.T{
		From:  unlockedAccount.Address.Hex(),
		To:    "0x92dd679e2d8e107d8122ad5b3c868265e77c8af2",
		Gas:    123456,
		GasPrice:big.NewInt(12400000),
		Value:big.NewInt(20000000000),
		Data:"",
		Nonce:0,
	}
	txid, err := client.EthSendTransaction(t)
	if err != nil {
		log.Fatal("Transaction Error => ",err)
	}
	fmt.Println(txid)
}

What I want
txid of Real Transaction
What is get
Transaction Error => Error -32000 (authentication needed: password or unlock)

@onrik
Copy link
Owner

onrik commented May 26, 2018

Looks like account has not been unlocked. Log error on unlocking.

if err := ks.Unlock(accs[1],"abcd"); err!=nil {
  log.Fatal("Unlock account error ", err)
}

unlockedAccount = accs[1]
fmt.Println("Account Unlocked")

@florianakos
Copy link

Hello,

I encountered the same issue as the OP.
Even though the err was always NIL referring to successful unlock, it seemed to always fail.
I wonder if it's because unlocking it in a Go program momentarily does not unlock the same account on the machine that's running the geth node?

BR,
Flo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants