Layer 231
WalletReplaceWallet
Replace the user's built-in wallet, either with a newly generated one (input Wallet New) or with an existing TON wallet imported by its public key (input Wallet Imported). Importing requires an ownership proof built from wallet. get Proof Challenge; the 2 FA password may be required.
method
wallet.replaceWallet#d8c72eec flags:# wallet:InputWalletReplacement password:flags.0?InputCheckPasswordSRP = WalletState;
Parameters
| Name | Type | Description |
|---|---|---|
| Wallet | InputWalletReplacement | Replacement wallet: input Wallet New to create a new one, or input Wallet Imported with the imported wallet's public key and ownership proof |
| Password | flags.0?InputCheckPasswordSRP | SRP proof of the user's 2 FA password, if required |
Returns
WalletStateGogram Example
// Import an existing TON wallet. importedPub is its public key; tonProofSignature signs // the wallet.getProofChallenge payload with the matching private key. pwd, _ := client.AccountGetPassword() srp, _ := tg.GetInputCheckPassword("my-2fa-password", pwd) state, err := client.WalletReplaceWallet(&tg.InputWalletImported{ PublicKey: importedPub, Proof: &tg.WalletOwnershipProof{Timestamp: int32(time.Now().Unix()), Signature: tonProofSignature}, }, srp) if err != nil { log.Fatal(err) } if s, ok := state.(*tg.WalletStateObj); ok { fmt.Println("active wallet:", s.Address) } // Use &tg.InputWalletNew{} to create a fresh wallet instead.