get_pubkey_from_x
[electrum-nvc.git] / lib / account.py
index 3b7ca9e..37ddc60 100644 (file)
@@ -147,20 +147,23 @@ class BIP32_Account(Account):
     def first_address(self):
         return self.get_address(0,0)
 
-    def get_pubkey(self, xpub, for_change, n):
+    def get_master_pubkeys(self):
+        return [self.xpub]
+
+    def get_pubkey_from_x(self, xpub, for_change, n):
         _, _, _, c, cK = deserialize_xkey(xpub)
         for i in [for_change, n]:
             cK, c = CKD_pub(cK, c, i)
         return cK.encode('hex')
 
-    def redeem_script(self, sequence):
-        return None
-
     def get_pubkeys(self, sequence):
-        return [self.get_pubkey(self.xpub, *sequence)]
+        return sorted(map(lambda x: self.get_pubkey_from_x(x, *sequence), self.get_master_pubkeys()))
 
-    def get_master_pubkeys(self):
-        return [self.xpub]
+    def get_pubkey(self, for_change, n):
+        return self.get_pubkeys((for_change, n))[0]
+
+    def redeem_script(self, sequence):
+        return None
 
     def get_type(self):
         return _('Standard 1 of 1')
@@ -189,9 +192,6 @@ class BIP32_Account_2of2(BIP32_Account):
         address = hash_160_to_bc_address(hash_160(self.redeem_script((for_change, n)).decode('hex')), 5)
         return address
 
-    def get_pubkeys(self, sequence):
-        return sorted([ self.get_pubkey(self.xpub, *sequence ), self.get_pubkey(self.xpub2, *sequence )])
-
     def get_master_pubkeys(self):
         return [self.xpub, self.xpub2]
 
@@ -210,9 +210,6 @@ class BIP32_Account_2of3(BIP32_Account_2of2):
         d['xpub3'] = self.xpub3
         return d
 
-    def get_pubkeys(self, sequence):
-        return sorted([ self.get_pubkey(self.xpub, *sequence ), self.get_pubkey(self.xpub2, *sequence ), self.get_pubkey(self.xpub3, *sequence )])
-
     def get_master_pubkeys(self):
         return [self.xpub, self.xpub2, self.xpub3]