Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support BIP39 seeds for TON #23

Merged
merged 1 commit into from
Feb 24, 2025
Merged

support BIP39 seeds for TON #23

merged 1 commit into from
Feb 24, 2025

Conversation

mkaczanowski
Copy link
Contributor

@mkaczanowski mkaczanowski commented Feb 20, 2025

TL;DR

BIP39 seeds are used by ledger devices and hierarchical wallets. This change is backwards compatible since previously the hdpath had to be empty.

Test plan

run staking operation on main branch:

$ npm run staking-cli -- ton tx delegate-pool 0.1 -c ./config.tonpool.testnet.json -s local -b
https://testnet.tonviewer.com/transaction/6e8898baff49de738b37c3f03f2fc783eefe31b2af2df59a441918449b6f8002

run staking operation on ton_support_bip39_keys branch:

$ npm run staking-cli -- ton tx delegate-pool 0.1 -c ./config.tonpool.testnet.json -s local -b
https://testnet.tonviewer.com/transaction/c54c1da73eafb64597abfe4649a48bde5ab191a50f778246d8ed293ae0353d41

Config:

{
  "delegatorAddress": "0QBDG13T98PFkLCpnXzkSPlrDp39aUUhQXTqFaad5cJU4uaz",
  "validatorAddress": "kQAHBakDk_E7qLlNQZxJDsqj_ruyAFpqarw85tO-c03fK26F",
  "validatorAddress2": "kQCltujow9Sq3ZVPPU6CYGfqwDxYwjlmFGZ1Wt0bAYebio4o",

  "localsigner": {
    "mnemonicPath": "../../mnemonic",
    "accounts": [
      {
        "hdPath": ""
      }
    ]
  },

  "ledger": {
    "bounceable": false,
    "accounts": [
      {
        "hdPath": "m/44'/607'/1'/0'/0'/0'"
      }
    ]
  },

  "networkType": "ton",

  "ton": {
    "rpcUrl": "https://testnet.toncenter.com/api/v2/jsonRPC",
    "allowSeamlessWalletDeployment": true,
    "allowTransferToInactiveAccount": false,
    "minimumExistentialBalance": "0",
    "addressDerivationConfig": {
      "walletContractVersion": 4,
      "workchain": 0,
      "bounceable": false,
      "testOnly": true,
      "urlSafe": true,
      "isBIP39": false
    },
    "blockExplorerUrl": "https://testnet.tonviewer.com"
  }
}

Now, flipping the isBIP39 flag to true, changes the derived address to:

0QBE6UXYLSiYuwCIB1PGYKKtCzTlfaZKikzSdixlsBKmHDJ5

which matches the address generated by the ton go version.

And changing the hd path to:

m/44'/607'/1'/0'/0'/0'

result in the same address that we get on the ledger device, this is:

0QBDG13T98PFkLCpnXzkSPlrDp39aUUhQXTqFaad5cJU4uaz

@mkaczanowski mkaczanowski marked this pull request as ready for review February 22, 2025 20:23
Copy link

@mikalsande mikalsande left a comment

Choose a reason for hiding this comment

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

LGTM! 👍 I can't verify the code generation check, I trust you have tested this thoroughly. For including links to tonutils-go code.

@@ -34,9 +34,8 @@
"dependencies": {
"@chorus-one/signer": "^1.0.0",
"@chorus-one/utils": "^1.0.0",
"@noble/curves": "^1.4.0",
"@ton/crypto": "^3.3.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works everywhere: Browser, NodeJS and React Native

that dep shall be fine

@mkaczanowski mkaczanowski merged commit 6d4239d into main Feb 24, 2025
1 check passed
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.

2 participants