@@ -26,30 +26,27 @@ <h1 class="title">Package <code>substrateinterface</code></h1>
26
26
< summary >
27
27
< span > Expand source code</ span >
28
28
</ summary >
29
- < pre > < code class ="python "> # Python Substrate Interface
29
+ < pre > < code class ="python "> # Python Substrate Interface Library
30
30
#
31
- # Copyright 2018-2020 openAware BV (NL).
32
- # This file is part of Polkascan.
31
+ # Copyright 2018-2020 Stichting Polkascan (Polkascan Foundation).
33
32
#
34
- # Polkascan is free software: you can redistribute it and/or modify
35
- # it under the terms of the GNU General Public License as published by
36
- # the Free Software Foundation, either version 3 of the License, or
37
- # (at your option) any later version.
33
+ # Licensed under the Apache License, Version 2.0 (the "License");
34
+ # you may not use this file except in compliance with the License.
35
+ # You may obtain a copy of the License at
38
36
#
39
- # Polkascan is distributed in the hope that it will be useful,
40
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
41
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42
- # GNU General Public License for more details.
37
+ # http://www.apache.org/licenses/LICENSE-2.0
43
38
#
44
- # You should have received a copy of the GNU General Public License
45
- # along with Polkascan. If not, see <http://www.gnu.org/licenses/>.
39
+ # Unless required by applicable law or agreed to in writing, software
40
+ # distributed under the License is distributed on an "AS IS" BASIS,
41
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ # See the License for the specific language governing permissions and
43
+ # limitations under the License.
46
44
47
45
import asyncio
48
46
import binascii
49
47
import json
50
48
import logging
51
49
import re
52
- from hashlib import blake2b
53
50
54
51
import requests
55
52
import websockets
@@ -74,8 +71,6 @@ <h1 class="title">Package <code>substrateinterface</code></h1>
74
71
75
72
class Keypair:
76
73
77
- chain_code = b"SchnorrRistrettoHDKD"
78
-
79
74
def __init__(self, ss58_address=None, public_key=None, private_key=None, address_type=42):
80
75
81
76
if ss58_address and not public_key:
@@ -111,32 +106,14 @@ <h1 class="title">Package <code>substrateinterface</code></h1>
111
106
return bip39_generate(words)
112
107
113
108
@classmethod
114
- def create_from_mnemonic(cls, mnemonic, hard_path=None, address_type=42):
109
+ def create_from_mnemonic(cls, mnemonic, address_type=42):
115
110
seed_array = bip39_to_mini_secret(mnemonic, "")
116
111
117
- if hard_path:
118
- # Get private and public key from seed
119
- public_key, private_key = sr25519.pair_from_seed(bytes(seed_array))
120
-
121
- # Private derivation
122
- _, child_pubkey, child_privkey = sr25519.derive_keypair(
123
- (public_key, public_key, private_key),
124
- hard_path.encode()
125
- )
126
-
127
- return cls.create_from_private_key(
128
- private_key=child_privkey.hex(),
129
- public_key=child_pubkey.hex(),
130
- address_type=address_type
131
- )
132
-
133
- else:
134
-
135
- keypair = cls.create_from_seed(
136
- seed_hex=binascii.hexlify(bytearray(seed_array)).decode("ascii"),
137
- address_type=address_type
138
- )
139
- keypair.mnemonic = mnemonic
112
+ keypair = cls.create_from_seed(
113
+ seed_hex=binascii.hexlify(bytearray(seed_array)).decode("ascii"),
114
+ address_type=address_type
115
+ )
116
+ keypair.mnemonic = mnemonic
140
117
141
118
return keypair
142
119
@@ -321,7 +298,7 @@ <h1 class="title">Package <code>substrateinterface</code></h1>
321
298
else:
322
299
ws_result.update(json.loads(await websocket.recv()))
323
300
324
- asyncio.get_event_loop().run_until_complete (ws_request(payload))
301
+ asyncio.run (ws_request(payload))
325
302
json_body = ws_result
326
303
327
304
else:
@@ -1914,8 +1891,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1914
1891
</ summary >
1915
1892
< pre > < code class ="python "> class Keypair:
1916
1893
1917
- chain_code = b"SchnorrRistrettoHDKD"
1918
-
1919
1894
def __init__(self, ss58_address=None, public_key=None, private_key=None, address_type=42):
1920
1895
1921
1896
if ss58_address and not public_key:
@@ -1951,32 +1926,14 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1951
1926
return bip39_generate(words)
1952
1927
1953
1928
@classmethod
1954
- def create_from_mnemonic(cls, mnemonic, hard_path=None, address_type=42):
1929
+ def create_from_mnemonic(cls, mnemonic, address_type=42):
1955
1930
seed_array = bip39_to_mini_secret(mnemonic, "")
1956
1931
1957
- if hard_path:
1958
- # Get private and public key from seed
1959
- public_key, private_key = sr25519.pair_from_seed(bytes(seed_array))
1960
-
1961
- # Private derivation
1962
- _, child_pubkey, child_privkey = sr25519.derive_keypair(
1963
- (public_key, public_key, private_key),
1964
- hard_path.encode()
1965
- )
1966
-
1967
- return cls.create_from_private_key(
1968
- private_key=child_privkey.hex(),
1969
- public_key=child_pubkey.hex(),
1970
- address_type=address_type
1971
- )
1972
-
1973
- else:
1974
-
1975
- keypair = cls.create_from_seed(
1976
- seed_hex=binascii.hexlify(bytearray(seed_array)).decode("ascii"),
1977
- address_type=address_type
1978
- )
1979
- keypair.mnemonic = mnemonic
1932
+ keypair = cls.create_from_seed(
1933
+ seed_hex=binascii.hexlify(bytearray(seed_array)).decode("ascii"),
1934
+ address_type=address_type
1935
+ )
1936
+ keypair.mnemonic = mnemonic
1980
1937
1981
1938
return keypair
1982
1939
@@ -2038,17 +1995,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
2038
1995
2039
1996
return sr25519.verify(signature, data, bytes.fromhex(self.public_key[2:]))</ code > </ pre >
2040
1997
</ details >
2041
- < h3 > Class variables</ h3 >
2042
- < dl >
2043
- < dt id ="substrateinterface.Keypair.chain_code "> < code class ="name "> var < span class ="ident "> chain_code</ span > </ code > </ dt >
2044
- < dd >
2045
- < div class ="desc "> </ div >
2046
- </ dd >
2047
- </ dl >
2048
1998
< h3 > Static methods</ h3 >
2049
1999
< dl >
2050
2000
< dt id ="substrateinterface.Keypair.create_from_mnemonic "> < code class ="name flex ">
2051
- < span > def < span class ="ident "> create_from_mnemonic</ span > </ span > (< span > mnemonic, hard_path=None, address_type=42)</ span >
2001
+ < span > def < span class ="ident "> create_from_mnemonic</ span > </ span > (< span > mnemonic, address_type=42)</ span >
2052
2002
</ code > </ dt >
2053
2003
< dd >
2054
2004
< div class ="desc "> </ div >
@@ -2057,32 +2007,14 @@ <h3>Static methods</h3>
2057
2007
< span > Expand source code</ span >
2058
2008
</ summary >
2059
2009
< pre > < code class ="python "> @classmethod
2060
- def create_from_mnemonic(cls, mnemonic, hard_path=None, address_type=42):
2010
+ def create_from_mnemonic(cls, mnemonic, address_type=42):
2061
2011
seed_array = bip39_to_mini_secret(mnemonic, "")
2062
2012
2063
- if hard_path:
2064
- # Get private and public key from seed
2065
- public_key, private_key = sr25519.pair_from_seed(bytes(seed_array))
2066
-
2067
- # Private derivation
2068
- _, child_pubkey, child_privkey = sr25519.derive_keypair(
2069
- (public_key, public_key, private_key),
2070
- hard_path.encode()
2071
- )
2072
-
2073
- return cls.create_from_private_key(
2074
- private_key=child_privkey.hex(),
2075
- public_key=child_pubkey.hex(),
2076
- address_type=address_type
2077
- )
2078
-
2079
- else:
2080
-
2081
- keypair = cls.create_from_seed(
2082
- seed_hex=binascii.hexlify(bytearray(seed_array)).decode("ascii"),
2083
- address_type=address_type
2084
- )
2085
- keypair.mnemonic = mnemonic
2013
+ keypair = cls.create_from_seed(
2014
+ seed_hex=binascii.hexlify(bytearray(seed_array)).decode("ascii"),
2015
+ address_type=address_type
2016
+ )
2017
+ keypair.mnemonic = mnemonic
2086
2018
2087
2019
return keypair</ code > </ pre >
2088
2020
</ details >
@@ -2359,7 +2291,7 @@ <h2 id="parameters">Parameters</h2>
2359
2291
else:
2360
2292
ws_result.update(json.loads(await websocket.recv()))
2361
2293
2362
- asyncio.get_event_loop().run_until_complete (ws_request(payload))
2294
+ asyncio.run (ws_request(payload))
2363
2295
json_body = ws_result
2364
2296
2365
2297
else:
@@ -6010,7 +5942,7 @@ <h2 id="returns">Returns</h2>
6010
5942
else:
6011
5943
ws_result.update(json.loads(await websocket.recv()))
6012
5944
6013
- asyncio.get_event_loop().run_until_complete (ws_request(payload))
5945
+ asyncio.run (ws_request(payload))
6014
5946
json_body = ws_result
6015
5947
6016
5948
else:
@@ -6420,7 +6352,6 @@ <h1>Index</h1>
6420
6352
< li >
6421
6353
< h4 > < code > < a title ="substrateinterface.Keypair " href ="#substrateinterface.Keypair "> Keypair</ a > </ code > </ h4 >
6422
6354
< ul class ="">
6423
- < li > < code > < a title ="substrateinterface.Keypair.chain_code " href ="#substrateinterface.Keypair.chain_code "> chain_code</ a > </ code > </ li >
6424
6355
< li > < code > < a title ="substrateinterface.Keypair.create_from_mnemonic " href ="#substrateinterface.Keypair.create_from_mnemonic "> create_from_mnemonic</ a > </ code > </ li >
6425
6356
< li > < code > < a title ="substrateinterface.Keypair.create_from_private_key " href ="#substrateinterface.Keypair.create_from_private_key "> create_from_private_key</ a > </ code > </ li >
6426
6357
< li > < code > < a title ="substrateinterface.Keypair.create_from_seed " href ="#substrateinterface.Keypair.create_from_seed "> create_from_seed</ a > </ code > </ li >
0 commit comments