1
0

sweep privkeys in gui

This commit is contained in:
ThomasV
2014-05-01 17:35:01 +02:00
parent b21cfc2746
commit 46c0dda3b9
3 changed files with 54 additions and 13 deletions

View File

@@ -264,18 +264,8 @@ class Commands:
def sweep(self, privkey, to_address, fee = 0.0001):
pubkey = public_key_from_private_key(privkey)
address = address_from_private_key(privkey)
pay_script = Transaction.pay_script(address)
unspent = self.network.synchronous_get([ ('blockchain.address.listunspent',[address])])[0]
if not unspent:
return
total = sum( map(lambda x:int(x.get('value')), unspent) ) - int(Decimal(fee)*100000000)
inputs = map(lambda i: {'prevout_hash': i['tx_hash'], 'prevout_n':i['tx_pos'], 'scriptPubKey':pay_script, 'redeemPubkey':pubkey}, unspent)
outputs = [(to_address, total)]
tx = Transaction.from_io(inputs, outputs)
tx.sign({ pubkey:privkey })
return tx
fee = int(Decimal(fee)*100000000)
return Transaction.sweep([privkey], self.network, to_address, fee)
def signmessage(self, address, message):