split create_new_address, so that get_new_address can be used without the context of a wallet
This commit is contained in:
@@ -531,23 +531,26 @@ class Wallet:
|
|||||||
|
|
||||||
|
|
||||||
def create_new_address(self, for_change):
|
def create_new_address(self, for_change):
|
||||||
""" Publickey(type,n) = Master_public_key + H(n|S|type)*point """
|
|
||||||
curve = SECP256k1
|
|
||||||
n = len(self.change_addresses) if for_change else len(self.addresses)
|
n = len(self.change_addresses) if for_change else len(self.addresses)
|
||||||
z = self.get_sequence(n,for_change)
|
address = self.get_new_address(n, for_change)
|
||||||
master_public_key = ecdsa.VerifyingKey.from_string( self.master_public_key, curve = SECP256k1 )
|
|
||||||
pubkey_point = master_public_key.pubkey.point + z*curve.generator
|
|
||||||
public_key2 = ecdsa.VerifyingKey.from_public_point( pubkey_point, curve = SECP256k1 )
|
|
||||||
address = public_key_to_bc_address( '04'.decode('hex') + public_key2.to_string() )
|
|
||||||
if for_change:
|
if for_change:
|
||||||
self.change_addresses.append(address)
|
self.change_addresses.append(address)
|
||||||
else:
|
else:
|
||||||
self.addresses.append(address)
|
self.addresses.append(address)
|
||||||
|
|
||||||
self.history[address] = []
|
self.history[address] = []
|
||||||
|
return address
|
||||||
|
|
||||||
|
def get_new_address(self, n, for_change):
|
||||||
|
""" Publickey(type,n) = Master_public_key + H(n|S|type)*point """
|
||||||
|
curve = SECP256k1
|
||||||
|
z = self.get_sequence(n, for_change)
|
||||||
|
master_public_key = ecdsa.VerifyingKey.from_string( self.master_public_key, curve = SECP256k1 )
|
||||||
|
pubkey_point = master_public_key.pubkey.point + z*curve.generator
|
||||||
|
public_key2 = ecdsa.VerifyingKey.from_public_point( pubkey_point, curve = SECP256k1 )
|
||||||
|
address = public_key_to_bc_address( '04'.decode('hex') + public_key2.to_string() )
|
||||||
print address
|
print address
|
||||||
return address
|
return address
|
||||||
|
|
||||||
|
|
||||||
def change_gap_limit(self, value):
|
def change_gap_limit(self, value):
|
||||||
if value >= self.gap_limit:
|
if value >= self.gap_limit:
|
||||||
|
|||||||
Reference in New Issue
Block a user