Skip to content

Add lst restricted wallet#548

Open
yungwine wants to merge 1 commit into
ton-blockchain:devfrom
yungwine:lst-wallet
Open

Add lst restricted wallet#548
yungwine wants to merge 1 commit into
ton-blockchain:devfrom
yungwine:lst-wallet

Conversation

@yungwine

@yungwine yungwine commented May 6, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for creating and operating an lst_restricted_wallet type, including the extra metadata needed for deployment (treasury + liquid pool addresses) and new deployment flows that depend on ton-http-api.

Changes:

  • Extend nw (new wallet) to accept lst_restricted_wallet parameters and propagate them into wallet creation.
  • Add ton-http-api get-method helper(s) and use them to fetch liquid pool deploy data and to simplify loan amount calculation.
  • Add Fift scripts for lst_restricted_wallet creation and controller StateInit building, and update controller deployment to support lst_restricted_wallet wallets (using init BoC + extra flags).

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/integration/test_wallet_commands.py Adds an integration test case for nw ... lst_restricted_wallet ... arguments and propagation.
mytoncore/mytoncore.py Adds init BoC/extra flag support for wallet signing, introduces ton-http-api get-method helper, and reworks liquid-staking get-method usage.
mytoncore/contracts/lst-restricted-wallet/new-wallet.fif New Fift script to generate an lst_restricted_wallet state/init message and files.
mytoncore/contracts/lst-restricted-wallet/build-controller-init.fif New Fift script to build controller StateInit and save *-init.boc.
modules/wallet.py Extends nw parsing, adds lst_restricted_wallet wallet creation path, and refactors the wallet-creation Fift runner(s).
modules/controller.py Adds direct controller deployment path for lst_restricted_wallet wallets using computed init BoC.
modules/init.py Adds tonHttpApiUrl setting used by the new ton-http-api helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/wallet.py
Comment on lines +187 to +201
def run_new_wallet_fift_args(self, version: str, workchain: int, wallet_path: str, subwallet: int) -> list[str]:
if "v1" in version:
fift_script = "new-wallet.fif"
args = [fift_script, workchain, wallet_path]
args = [fift_script, str(workchain), wallet_path]
elif "v2" in version:
fift_script = "new-wallet-v2.fif"
args = [fift_script, workchain, wallet_path]
args = [fift_script, str(workchain), wallet_path]
elif "v3" in version:
fift_script = "new-wallet-v3.fif"
args = [fift_script, workchain, subwallet, wallet_path]
args = [fift_script, str(workchain), str(subwallet), wallet_path]
else:
raise Exception(f"get_wallet_fift error: fift script for `{version}` not found")
return list(map(str, args))

return self.ton.fift.run(args)

Comment thread modules/wallet.py
Comment on lines +202 to +217
def run_new_lst_restricted_wallet_fift_args(self, workchain: int, wallet_path: str, treasury_addr: str, liquid_pool_addr: str) -> list[str]:
deploy_data = self.ton.get_liquid_pool_deploy_data(liquid_pool_addr)
with (get_package_resource_path('mytoncore', 'contracts/lst-restricted-wallet/wallet-code.boc') as wallet_code_path,
get_package_resource_path('mytoncore', 'contracts/lst-restricted-wallet/new-wallet.fif') as fift_script):
args = [
fift_script,
wallet_code_path,
deploy_data["controller_code_path"],
treasury_addr,
liquid_pool_addr,
self.ton.GetFullConfigAddr(),
self.ton.GetFullElectorAddr(),
str(workchain),
wallet_path,
]
return self.ton.fift.run(args)
Comment thread mytoncore/mytoncore.py
Comment on lines +2993 to +3001
res = requests.post(url, json=data, timeout=5)
res_data = res.json()
if res_data.get("ok") is False:
error = res_data.get("error") or res_data.get("message") or res_data
raise Exception(f"Failed to run get method: {error}. Make sure ton-http-api is enabled (installer -> enable THA)")
result = res_data.get("result")
if result is None or "stack" not in result:
raise Exception(f"Failed to run get method: malformed response: {res_data}")
return result["stack"]
Comment thread mytoncore/mytoncore.py
Comment on lines +3010 to +3014
controller_code_bytes = base64.b64decode(stack[25][1]["bytes"])
controller_code_path = self.tempDir + self.nodeName + "controller-code.boc"
with open(controller_code_path, "wb") as file:
file.write(controller_code_bytes)
return {
Comment thread modules/controller.py
computed_controller_addr, init_boc_path = self._build_liquid_staking_controller_state_init(controller_id)
if computed_controller_addr != expected_controller_addr:
raise Exception(
f"DirectDeployLiquidStakingController error: computed address {computed_controller_addr} does not match pool address {expected_controller_addr}"
@yungwine yungwine force-pushed the lst-wallet branch 2 times, most recently from fe44dc0 to 48dd3b1 Compare May 6, 2026 13:56
simplify and fix lst wallet usage

Wire governance voting into restricted wallet

Add lst restricted wallet operator guide

Pass lst wallet create args explicitly

Add lst restricted wallet create wallet support

Add lst restricted wallet integration notes

Integrate lst restricted wallet deploy flow

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9769b05c5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread mytoncore/mytoncore.py
Comment on lines +2999 to +3001
result = res_data.get("result")
if result is None or "stack" not in result:
raise Exception(f"Failed to run get method: malformed response: {res_data}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle v3 runGetMethod response format

Update this parser to accept the v3 runGetMethod schema (top-level stack) in addition to the v2 wrapper (result.stack). With tonHttpApiUrl set to a modern /api/v3/runGetMethod endpoint, result is absent so this path always raises malformed response, which breaks the new lst_restricted flows that depend on run_ton_http_get_method (wallet/controller deploy data retrieval and CalculateLoanAmount).

Useful? React with 👍 / 👎.

@lucasdylan-art lucasdylan-art left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need to complete idk how

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants