2

TL;DR: I've setup a private Ethereum node, and I want to send a signed transaction to it. By reading the docs I know that there's an account Manager type which can access a Wallet type which has a SignTx method that I want to use for this purpose. I'm having an issue setting up the account Manager type to begin this process.

The Problem:

The NewManager function requires a type which implements the Backend interface. The problem here is that I can't find any docs describing (accurately) how to initialize an account Manager with a Backend. The only backend available in the account source is SimulatedBackend meant for testing (source: https://github.com/ethereum/go-ethereum/tree/3fa0fa713bc1508835bdecd7dea78ff09803e327/accounts/abi/bind/backends).

What I've tried:

The docs (here: https://github.com/ethereum/go-ethereum/wiki/Native:-Account-management#keystores-from-go) say that one can be initialized this way:

am := accounts.NewManager("/path/to/keystore", accounts.StandardScryptN, accounts.StandardScryptP);

However, it does not compile as the accounts.StandardScryptN and accounts.StandardScryptP do not exist, and when replaced with their integer equivilents (2 and 1 respectively), the compile error states that the keystore path argument ("/path/to/keystore") does not implement the Backend interface, which makes sense. My guess is that the docs are not updated, and because of that the NewManager function cannot compile with these arguments.

Docs for the NewManager type for reference: https://godoc.org/github.com/ethereum/go-ethereum/accounts#NewManager

Question:

Does anyone know how to initialize the account manager correctly to begin signing transactions in Go?

1
  • Figured this out earlier, will update
    – thanos
    Mar 25, 2017 at 1:46

1 Answer 1

1

I discovered that a Manager is not needed to interact with accounts and sign transactions, rather, we can create a keystore, and find accounts and wallets using it's doc methods. We can create a keystore like so:

ks := keystore.NewKeyStore(
    KEYSTORE_DIR,
    keystore.LightScryptN,
    keystore.LightScryptP)

where keystore is the import "github.com/ethereum/go-ethereum/accounts/keystore", and KEYSTORE_DIR is the keystore directory for account private key files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.