X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=lib%2Fwallet.py;h=2d2ba93acba7043536b329fb39c74faccd051da3;hb=6ad1c46aa55f2f54cb5a3f58d8b3df7fd9bb25f3;hp=a3dbdf7fbddc25321939b07a0e5e8092096e0697;hpb=a89abee9690b011031b20c39dc1d48a4b9ec1ceb;p=electrum-nvc.git diff --git a/lib/wallet.py b/lib/wallet.py index a3dbdf7..2d2ba93 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -207,8 +207,8 @@ class Abstract_Wallet: tx.add_pubkey_addresses(self.transactions) # outputs of tx: inputs of tx2 - for x, v in tx.outputs: - if x.startswith('pubkey:'): + for type, x, v in tx.outputs: + if type == 'pubkey': for tx2 in self.transactions.values(): tx2.add_pubkey_addresses({h:tx}) @@ -354,12 +354,6 @@ class Abstract_Wallet: raise Exception("Address not found", address) - def getpubkeys(self, addr): - assert is_address(addr) and self.is_mine(addr) - account, sequence = self.get_address_index(addr) - a = self.accounts[account] - return a.get_pubkeys( sequence ) - def get_private_key(self, address, password): if self.is_watching_only(): return [] @@ -386,7 +380,6 @@ class Abstract_Wallet: mpk = [ self.master_public_keys[k] for k in self.master_private_keys.keys() ] for xpub, sequence in xpub_list: if xpub in mpk: - print "can sign", xpub return True return False @@ -410,9 +403,7 @@ class Abstract_Wallet: break else: continue - - addr = account.get_address(*sequence) - pk = self.get_private_key(addr, password) + pk = account.get_private_key(sequence, self, password) for sec in pk: pubkey = public_key_from_private_key(sec) keypairs[pubkey] = sec @@ -657,7 +648,7 @@ class Abstract_Wallet: # Insert the change output at a random position in the outputs posn = random.randint(0, len(outputs)) - outputs[posn:posn] = [( change_addr, change_amount)] + outputs[posn:posn] = [( 'address', change_addr, change_amount)] return outputs def get_history(self, address): @@ -781,11 +772,12 @@ class Abstract_Wallet: return default_label def make_unsigned_transaction(self, outputs, fee=None, change_addr=None, domain=None, coins=None ): - for address, x in outputs: - if address.startswith('OP_RETURN:'): + for type, address, x in outputs: + if type == 'op_return': continue - assert is_address(address), "Address " + address + " is invalid!" - amount = sum( map(lambda x:x[1], outputs) ) + if type == 'address': + assert is_address(address), "Address " + address + " is invalid!" + amount = sum( map(lambda x:x[2], outputs) ) inputs, total, fee = self.choose_tx_inputs( amount, fee, len(outputs), domain, coins ) if not inputs: raise ValueError("Not enough funds") @@ -1286,11 +1278,8 @@ class NewWallet(Deterministic_Wallet): return 'm/' in self.master_private_keys.keys() def get_master_public_key(self): - if self.is_watching_only(): - return self.master_public_keys["m/0'"] - else: - return self.master_public_keys["m/"] - + """xpub of the main account""" + return self.master_public_keys.get("m/0'") def get_master_public_keys(self): out = {} @@ -1571,8 +1560,8 @@ class Wallet(object): config = storage.config self.wallet_types = [ - ('standard', ("Standard wallet"), OldWallet), - ('imported', ("Imported wallet"), Imported_Wallet), + ('standard', ("Standard wallet"), NewWallet if config.get('bip32') else OldWallet), + ('imported', ("Imported wallet"), Imported_Wallet), ('2of2', ("Multisig wallet (2 of 2)"), Wallet_2of2), ('2of3', ("Multisig wallet (2 of 3)"), Wallet_2of3) ]