Example #1
0
def create_wallet():
    """
    Create an electrum wallet if it does not exist
    :return: 
    """
    if not os.path.isfile(WALLET_FILE):
        print("Creating wallet")
        config = electrum.SimpleConfig()
        storage = WalletStorage(config.get_wallet_path())
        passphrase = config.get('passphrase', '')
        seed = Mnemonic('en').make_seed()
        k = keystore.from_seed(seed, passphrase)
        k.update_password(None, None)
        storage.put('keystore', k.dump())
        storage.put('wallet_type', 'standard')
        storage.put('use_encryption', False)
        storage.write()
        wallet = ElectrumWallet(storage)
        wallet.synchronize()
        print("Your wallet generation seed is:\n\"%s\"" % seed)
        print(
            "Please keep it in a safe place; if you lose it, you will not be able to restore your wallet."
        )
        wallet.storage.write()
        print("Wallet saved in '%s'" % wallet.storage.path)
    else:
        print("Wallet already present")
Example #2
0
    def __init__(self, server = None, proxy = None):
        options={}
#        options['electrum_path'] = os.environ['HOME'] + '/.electrum'
        options['electrum_path'] = script_dir
        self.conf = electrum.SimpleConfig(options)
        if None != server:
            self.conf.set_key('server', server, False)
        if None != proxy:
            self.conf.set_key('proxy', proxy, False)
        if None != server and None != proxy:
            self.conf.set_key('auto_cycle', False, False)
        else:
            self.conf.set_key('auto_cycle', True, False)
        print 'server: ', self.conf.get('server')
        print 'proxy:  ', self.conf.get('proxy')
#        self.sock = electrum.daemon.get_daemon(self.conf, True)
#        self.netw = electrum.NetworkProxy(self.sock, self.conf)
        self.netw = electrum.Network(self.conf)
        self.netw.start()
Example #3
0
    conn.close()
    print "database closed"



if __name__ == '__main__':

    if len(sys.argv) > 1:
        cmd = sys.argv[1]
        params = sys.argv[2:] + [my_password]
        ret = send_command(cmd, params)
        sys.exit(ret)

    # start network
    c = electrum.SimpleConfig({'wallet_path':wallet_path})
    daemon_socket = electrum.daemon.get_daemon(c, True)
    network = electrum.NetworkProxy(daemon_socket, config)
    network.start()

    # wait until connected
    while network.is_connecting():
        time.sleep(0.1)

    if not network.is_connected():
        print "daemon is not connected"
        sys.exit(1)

    # create watching_only wallet
    storage = electrum.WalletStorage(c)
    if not storage.file_exists:
Example #4
0
# other addresses belong to you because the same account balances are being
# transferred. Similarly, a large increase in the number of small-value
# transactions in the blockchain in a given block is another piece of
# information that can be used to correlate the addresses as probably belonging
# to the same owner. For these reasons and others, splitting up the
# transactions into separate blocks helps to obfuscate your presence at least a
# little.

max_transactions = 1000

# sudo apt-get install electrum
# https://bitcointalk.org/index.php?topic=612143.0
import electrum

# load default electrum configuration
config = electrum.SimpleConfig()
storage = electrum.wallet.WalletStorage(config)
wallet = electrum.wallet.Wallet(storage)

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
log = logging.getLogger(__name__)


def get_total_balance(wallet=wallet):
    """
    :return: total balance in satoshis (confirmed)
    """
    #return wallet.get_account_balance(0)[0]
    return wallet.get_balance()[0]