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

How do I use the example wallet? #1

Open
songproducer opened this issue Jun 19, 2016 · 1 comment
Open

How do I use the example wallet? #1

songproducer opened this issue Jun 19, 2016 · 1 comment

Comments

@songproducer
Copy link

I filled in the full wallet path and password, but not sure what to put for 'wallet id' and 'simplewallet'.

Would like to set up a basic website using this in Django.

@bigreddmachine
Copy link
Contributor

Thanks for the question!

I had started on much better examples documentation but got distracted by the Chrome wallet and then real life work and had put this down for a few months. I still intend to get back to filling this out with tests and examples but it might not be until later in the summer.

You don't need to do anything with walletID or simplewallet. In the example available, I had set up those variables to be lists of wallets. In other words, if you wanted to use multiple wallets with the package, you could do so by filling out more entries in the user_port, wallet_file, and wallet_pass fields. Then, the example initializes all those wallets with the code:

for i in range(0, len(user_port)):
    walletID.append(pymonero.connections.Wallet(user_host, user_port[i]))
    simplewallet.append(pymonero.SimpleWallet(walletID[i]))

That's why later in the example you see things such as simplewallet[i].

But if you just want to use one wallet, you can initialize the wallets with something like this:

user_host = 'http://127.0.0.1'
user_port = '18082'
wallet_file = '/path/to/monero/wallet.bin'
wallet_pass = 'password'

walletID = pymonero.connections.Wallet(user_host, user_port)
simplewallet = pymonero.SimpleWallet(walletID)

and then do whatever you need, such as

# Print Wallet Balance:
print('\n\nSimple Wallet Balance:\n----------------------')
print('Simple wallet at port ' + user_port[i])
wallet_balance, err = simplewallet[i].get_balance()
if err == 0:
    print(wallet_balance.to_JSON())
else:
    print(wallet_balance.error)

I am not sure I like how it deals with errors right now, so some of this might change in the future.

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

2 participants