Bitcoin Forum
May 09, 2024, 03:38:33 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Electrum console scripts - Script #2: List balances  (Read 6127 times)
flatfly (OP)
Legendary
*
Offline Offline

Activity: 1078
Merit: 1016

760930


View Profile
January 19, 2014, 12:56:43 PM
Last edit: March 17, 2014, 09:55:36 AM by flatfly
 #1

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)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715225913
Hero Member
*
Offline Offline

Posts: 1715225913

View Profile Personal Message (Offline)

Ignore
1715225913
Reply with quote  #2

1715225913
Report to moderator
doolittle
Full Member
***
Offline Offline

Activity: 340
Merit: 101


View Profile
January 20, 2014, 09:58:40 AM
 #2

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?
flatfly (OP)
Legendary
*
Offline Offline

Activity: 1078
Merit: 1016

760930


View Profile
January 20, 2014, 06:23:56 PM
 #3

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.
Abdussamad
Legendary
*
Offline Offline

Activity: 3612
Merit: 1564



View Profile
January 22, 2014, 04:06:20 AM
 #4

Nice! Gotta learn python.
doolittle
Full Member
***
Offline Offline

Activity: 340
Merit: 101


View Profile
January 22, 2014, 05:23:46 AM
 #5

Yes indeed Smiley
flatfly (OP)
Legendary
*
Offline Offline

Activity: 1078
Merit: 1016

760930


View Profile
March 17, 2014, 09:55:13 AM
 #6

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
RangerK
Member
**
Offline Offline

Activity: 93
Merit: 10



View Profile WWW
February 18, 2015, 10:41:57 PM
 #7

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.

Cool ---> Who will mine the next 777 Block??? Place your bets at block777.com!!!
RangerK
Member
**
Offline Offline

Activity: 93
Merit: 10



View Profile WWW
February 19, 2015, 07:19:31 AM
 #8

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.

Cool ---> Who will mine the next 777 Block??? Place your bets at block777.com!!!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!