commit d1aacb60509339040f979c9291e6235d4125351d
parent bafac9dc83dd41c999fc52d88c4c8f352ff92e73
Author: Maran <maran.hidskes@gmail.com>
Date: Sat, 16 Mar 2013 23:40:34 +0100
Merge branch 'master' into feature/label_sync
Diffstat:
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
@@ -805,6 +805,7 @@ class Transaction:
# return the balance for that tx
is_send = False
is_pruned = False
+ is_partial = False
v_in = v_out = v_out_mine = 0
for item in self.inputs:
@@ -818,7 +819,9 @@ class Transaction:
else:
v_in += value
else:
- is_pruned = True
+ is_partial = True
+
+ if not is_send: is_partial = False
for item in self.outputs:
addr, value = item
@@ -826,11 +829,7 @@ class Transaction:
if addr in addresses:
v_out_mine += value
- if not is_pruned:
- # all inputs are mine:
- fee = v_out - v_in
- v = v_out_mine - v_in
- else:
+ if is_pruned:
# some inputs are mine:
fee = None
if is_send:
@@ -838,7 +837,18 @@ class Transaction:
else:
# no input is mine
v = v_out_mine
-
+
+ else:
+ v = v_out_mine - v_in
+
+ if is_partial:
+ # some inputs are mine, but not all
+ fee = None
+ is_send = v < 0
+ else:
+ # all inputs are mine
+ fee = v_out - v_in
+
return is_send, v, fee
def as_dict(self):
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -182,7 +182,7 @@ class Wallet:
return s[0] == 1
def get_master_public_key(self):
- return self.sequences[0].master_public_key
+ return self.config.get("master_public_key")
def get_address_index(self, address):
if address in self.imported_keys.keys():