Author

Topic: Electrum console scripts - Script #2: List balances (Read 6135 times)

member
Activity: 93
Merit: 10
I would be deeply grateful if someone would offer me a python script for my situation:

I have an electrum wallet with balances on three different private keys.

I'd like to take the balance from just one private key and send it elsewhere.  This is made easier, perhaps, because that entire balance arrived in just one transaction.

Please help?

If it works, I'll offer a small token of gratitude -- 0.02 btc.
I don't have a python script for that, but there is an easy way to achieve what you want with the Electrum Client.

In your Receive tab, locate the addresses that you don't want to send bitcoins from.  Right-click on each address and select Freeze.  Leaving only the one you want to send from, in the "unfrozen" state.  Send you transaction, like normal.  Electrum will only take from the unfrozen address(es).  If you don't spend all the content of the address, it will return you some change in a new address.  Ensure that you deduct the network transaction fees correctly before sending.  The number should turn red if the total exceed the amount in your address (not enough funds).

When you are done - unfreeze the other addresses.  Cool

1AQjoN1Z9JepYUL6XYaTAHtHwPjR8rsiH2
 

Thank you, sir!  Worked like a charm.  What a cool little feature.

Your gratuity has been sent.  I'm also going to PM you a few coupons for block777.com.
member
Activity: 93
Merit: 10
I would be deeply grateful if someone would offer me a python script for my situation:

I have an electrum wallet with balances on three different private keys.

I'd like to take the balance from just one private key and send it elsewhere.  This is made easier, perhaps, because that entire balance arrived in just one transaction.

Please help?

If it works, I'll offer a small token of gratitude -- 0.02 btc.
legendary
Activity: 1092
Merit: 1016
760930
A little one-liner to list your addresses and their balances:

Code:
for x in listaddresses(): print x + '\t' + str(getaddressbalance(x))

Note: Uses the new getaddressbalance feature added in 1.9.8
full member
Activity: 340
Merit: 101
Yes indeed Smiley
legendary
Activity: 3682
Merit: 1580
Nice! Gotta learn python.
legendary
Activity: 1092
Merit: 1016
760930
I am not a python or electrum expert. So to me this script is not easy at all. Sad
Can you explain a couple of things? For example:
  • getservers: it is a console-command. getservers(). How can you add another function to it?
  • Keys() is not a console function. Where does it come from?
  • Where are time and socket imported from? Are these standard libraries? Is it possible to add new packages to the standard embedded electrum python interpreter?

As a sidenote: How many servers are there in Europe? Who are the guys running them?

In a nutshell:
 - the getservers() function returns a dict. keys() is a standard dict method.
 - yes, time and socket are standard libraries.

Sorry for not going into more detail - I have very limited free time these days.
Feel free to google for more information, or wait for others to chime in with more help.
full member
Activity: 340
Merit: 101
I am not a python or electrum expert. So to me this script is not easy at all. Sad
Can you explain a couple of things? For example:
  • getservers: it is a console-command. getservers(). How can you add another function to it?
  • Keys() is not a console function. Where does it come from?
  • Where are time and socket imported from? Are these standard libraries? Is it possible to add new packages to the standard embedded electrum python interpreter?

As a sidenote: How many servers are there in Europe? Who are the guys running them?
legendary
Activity: 1092
Merit: 1016
760930
Here's a quick little script to find out what servers have lowest latency for you.

For instance, for users in Europe, the top 2 servers consistently are:

0.015s   electrum.icetwy.re                
0.016s   electrum.cafebitcoin.com
       


Code:
'''
 *   Python 2.x source - By flatfly (GPG ID: 0xF91975FF)
 *
 *   No warranty, explicit or implicit, provided.
'''

import socket, time

best = 5      
ax = getservers().keys()
print 'quicktesting ' + str(len(ax)) + ' servers...'
print '\n\n'
    
for host in ax:

  try:
    s=socket.socket()
    s.settimeout(1)
    t0 = time.time()
    s.connect((host, 50002))
    t1 = time.time()
    delta = t1-t0
    print host.ljust(35) + '{:6.3f}s'.format(delta)
    if delta < best:  
      best = delta
      best_host = host
    s.close()  
  except:
    pass  

print '\n'
print 'lowest latency: '
print best_host.ljust(35) + '{:6.3f}s'.format(best)
Jump to: