166
166
Empty ,
167
167
ExecuteSigningInstructions ,
168
168
ExecuteSigningInstructionsResponse ,
169
+ ExtendDerivationIndex ,
170
+ ExtendDerivationIndexResponse ,
169
171
GatherSigningInfo ,
170
172
GatherSigningInfoResponse ,
171
173
GenerateMnemonicResponse ,
@@ -1879,30 +1881,26 @@ async def get_current_derivation_index(self, request: Empty) -> GetCurrentDeriva
1879
1881
1880
1882
return GetCurrentDerivationIndexResponse (index )
1881
1883
1882
- async def extend_derivation_index (self , request : dict [str , Any ]) -> dict [str , Any ]:
1884
+ @marshal
1885
+ async def extend_derivation_index (self , request : ExtendDerivationIndex ) -> ExtendDerivationIndexResponse :
1883
1886
assert self .service .wallet_state_manager is not None
1884
1887
1885
- # Require a new max derivation index
1886
- if "index" not in request :
1887
- raise ValueError ("Derivation index is required" )
1888
-
1889
1888
# Require that the wallet is fully synced
1890
1889
synced = await self .service .wallet_state_manager .synced ()
1891
1890
if synced is False :
1892
1891
raise ValueError ("Wallet needs to be fully synced before extending derivation index" )
1893
1892
1894
- index = uint32 (request ["index" ])
1895
1893
current : Optional [uint32 ] = await self .service .wallet_state_manager .puzzle_store .get_last_derivation_path ()
1896
1894
1897
1895
# Additional sanity check that the wallet is synced
1898
1896
if current is None :
1899
1897
raise ValueError ("No current derivation record found, unable to extend index" )
1900
1898
1901
1899
# Require that the new index is greater than the current index
1902
- if index <= current :
1900
+ if request . index <= current :
1903
1901
raise ValueError (f"New derivation index must be greater than current index: { current } " )
1904
1902
1905
- if index - current > MAX_DERIVATION_INDEX_DELTA :
1903
+ if request . index - current > MAX_DERIVATION_INDEX_DELTA :
1906
1904
raise ValueError (
1907
1905
"Too many derivations requested. "
1908
1906
f"Use a derivation index less than { current + MAX_DERIVATION_INDEX_DELTA + 1 } "
@@ -1912,14 +1910,13 @@ async def extend_derivation_index(self, request: dict[str, Any]) -> dict[str, An
1912
1910
# to preserve the current last used index, so we call create_more_puzzle_hashes with
1913
1911
# mark_existing_as_used=False
1914
1912
result = await self .service .wallet_state_manager .create_more_puzzle_hashes (
1915
- from_zero = False , mark_existing_as_used = False , up_to_index = index , num_additional_phs = 0
1913
+ from_zero = False , mark_existing_as_used = False , up_to_index = request . index , num_additional_phs = 0
1916
1914
)
1917
1915
await result .commit (self .service .wallet_state_manager )
1918
1916
1919
- updated : Optional [uint32 ] = await self .service .wallet_state_manager .puzzle_store .get_last_derivation_path ()
1920
- updated_index = updated if updated is not None else None
1917
+ updated_index = await self .service .wallet_state_manager .puzzle_store .get_last_derivation_path ()
1921
1918
1922
- return { "success" : True , "index" : updated_index }
1919
+ return ExtendDerivationIndexResponse ( updated_index )
1923
1920
1924
1921
@marshal
1925
1922
async def get_notifications (self , request : GetNotifications ) -> GetNotificationsResponse :
0 commit comments