mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
make constructor of cython HDNode struct more explicit
This commit is contained in:
parent
0331a1c454
commit
5cd4531312
@ -5,12 +5,14 @@ cdef class HDNode:
|
||||
|
||||
cdef c.HDNode node
|
||||
|
||||
def __init__(self, initializer):
|
||||
if isinstance(initializer, HDNode):
|
||||
self.node = (<HDNode>initializer).node
|
||||
elif isinstance(initializer, str) :
|
||||
if c.hdnode_deserialize(initializer, cython.address(self.node)) != 0:
|
||||
def __init__(self, str serialized = None, HDNode copyfrom = None):
|
||||
if copyfrom is not None:
|
||||
self.node = copyfrom.node
|
||||
elif serialized is not None:
|
||||
if c.hdnode_deserialize(serialized, cython.address(self.node)) != 0:
|
||||
raise Exception('Invalid xpub/xprv provided')
|
||||
else:
|
||||
raise Exception('Need to provide serialized or node parameter')
|
||||
|
||||
def xpub(self):
|
||||
cdef char[120] string
|
||||
@ -28,11 +30,11 @@ cdef class HDNode:
|
||||
return str(string)
|
||||
|
||||
def public_ckd(self, int i):
|
||||
x = HDNode(self)
|
||||
x = HDNode(copyfrom=self)
|
||||
c.hdnode_public_ckd(cython.address(x.node), i)
|
||||
return x
|
||||
|
||||
def private_ckd(self, int i):
|
||||
x = HDNode(self)
|
||||
x = HDNode(copyfrom=self)
|
||||
c.hdnode_private_ckd(cython.address(x.node), i)
|
||||
return x
|
||||
|
Loading…
Reference in New Issue
Block a user