Author

Topic: Sweep private key in Python program (Read 702 times)

hero member
Activity: 865
Merit: 1006
May 31, 2017, 05:48:00 AM
#6
It is an old post but I continue to have the same problem.
Any ideas?
hero member
Activity: 865
Merit: 1006
July 02, 2016, 12:43:31 PM
#5
Any Idea??'

Thanks
hero member
Activity: 865
Merit: 1006
June 25, 2016, 04:04:55 PM
#4
What do you need precisely?

My code don't work  Angry Angry Angry

I have a private key in format "5J3NjusByyNidYsWxXXXXXXXXXXXXX"
This private key have founds.
I need to make a program in python to sweep (transfer the total founds in another address) this founds to my electrum wallet.

I test to:

Code:
import os
import time
from electrum import Network, Transaction

n = Network()
n.start()

Transaction.sweep(["5J3NjusByyNidYsWxa8CyeX7mqXXXXXXXXXXXXXXXXXXXX"],n,"19yZZdxnmtULAAv8XXXXXXXXXXXXX" ,"0.000001")

But don't work.
I see this error:

Traceback (most recent call last):
  File "ProvaTry.py", line 11, in
    Transaction.sweep(["5J3NjusByyNidYsWxa8CyeX7mqm4vXXXXXXXXXXXXXXXXXX"],n,"19yZZdxnmtULXXXXXXXXXXXXX" ,"0.000001")
  File "/usr/local/lib/python2.7/dist-packages/electrum/transaction.py", line 564, in sweep
    u = network.synchronous_get(('blockchain.address.listunspent',[address]))
  File "/usr/local/lib/python2.7/dist-packages/electrum/network.py", line 830, in synchronous_get
    raise BaseException('Server did not answer')
BaseException: Server did not answer

Any solution???

Thanks
hero member
Activity: 865
Merit: 1006
June 25, 2016, 02:56:57 AM
#3
What do you need precisely?

Sorry

I've solved the problem.
I put here the code if it can serve to someone else.
a greeting

Code:
import os

def electrum_sweep(electrumPKey):
try:
print ('### START ELECTRUM DAEMON ##')
os.system('electrum daemon start')
time.sleep(30)
print ('###  SWEEP ###')
os.system('electrum sweep ' + electrumPKey + ' YOUR ADDRESS TO RECEIVE BITCOINS')
time.sleep(30)
print ('### STOP ELECTRUM DAEMON ###')
os.system('electrum daemon stop')
print ('*** SWEEP PROCESS OK ***')
except:
print ('### ERROR SWEEP ###')
member
Activity: 80
Merit: 14
June 24, 2016, 05:07:15 PM
#2
What do you need precisely?
hero member
Activity: 865
Merit: 1006
June 23, 2016, 03:41:21 AM
#1
Hello

I'm doing a program in python 2.7 and I need to make a sweep private key.
I have searched but can not find information.
Some help?

Thanks
Jump to: