mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-19 02:10:59 +08:00
added support for sweeping btc wallets
This commit is contained in:
@@ -11,10 +11,10 @@ import requests
|
||||
from config import MONGODB_URI, OLD_DB, FRONTEND_SECRET
|
||||
|
||||
from encrypt import bip38_decrypt
|
||||
|
||||
from coinkit import BitcoinKeypair, NamecoinKeypair
|
||||
|
||||
from commontools import log
|
||||
from coinrpc import bitcoind
|
||||
|
||||
#-----------------------------------
|
||||
from pymongo import MongoClient
|
||||
@@ -37,8 +37,12 @@ def sweep_btc(transfer_user):
|
||||
if new_user is None:
|
||||
return
|
||||
|
||||
|
||||
old_user = old_users.find_one({'username':new_user['username']})
|
||||
|
||||
if old_user is None:
|
||||
return
|
||||
|
||||
new_btc_address = new_user['bitcoin_address']
|
||||
old_btc_address = json.loads(old_user['profile'])['bitcoin']['address']
|
||||
|
||||
@@ -49,11 +53,20 @@ def sweep_btc(transfer_user):
|
||||
if old_btc_address == keypair.address():
|
||||
balance = fetch_balance(old_btc_address)
|
||||
|
||||
if balance is None:
|
||||
return True
|
||||
|
||||
if balance > float(0):
|
||||
log.debug(new_user['username'])
|
||||
log.debug("old btc address: " + old_btc_address)
|
||||
#print bitcoind.unlock_wallet()
|
||||
#print bitcoind.importprivkey(keypair.wif_pk())
|
||||
log.debug("final balance: %s", balance)
|
||||
log.debug('-' * 5)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
#-----------------------------------
|
||||
def fetch_balance(btc_address):
|
||||
|
||||
@@ -64,9 +77,3 @@ def fetch_balance(btc_address):
|
||||
|
||||
return r.json()['final_balance'] * 0.00000001 #convert to BTC from Satoshis
|
||||
|
||||
#-----------------------------------
|
||||
if __name__ == '__main__':
|
||||
|
||||
for i in transfer.find():
|
||||
sweep_btc(i)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user