Create/Restore Wallet

This article describes how to create/restore a wallet.

⚠️The wallet create/restore method must be preceded by the previous initialization.

Create Wallet

Creating Wallet

If you don't have a wallet, you can create a new one with the parameters 'wallet name' and 'wallet password'

  • Wallet password can only be a "6-digit string of integers".

  • A user can only create one wallet.

let walletId: Int = try await fncyWallet.makeWallet(
walletNm: "wallet name", 
pinNumber : "wallet password" // A 6-digit string of integers
)

Setting Wallet Restore Questions/Answers

If a user loses the password to the wallet, the assets in that wallet are lost forever.

However, if a user has registered a wallet restore question/answer, users can recover their wallet using that answer as a recovery key.

Requesting List of Wallet Restore Questions

The recovery key for restoring your wallet is a pair of selected questions and answers.

First, select a restore question by requesting for a list of questions to choose from.

let array: [FncyQuestion] = try await fncyWallet.getQuestionList(
pageNo: 1,
pageSize: 20
)

See Also

getQuestionList

FncyQuestion

Registering Wallet Restore Questions/Answers

You can register a wallet restore question/answer using the number of the question (questionSeq), the content of the answer, and the wallet's password.

let isSuccess: Bool = try await fncyWallet.postRegisterRestorationKey(
wid: wid, //If makeWallet() succeeds, wid is returned in the result.
questionSeq: questionSeq, //user-selected seq from the list of questions returned by getQuesetionList()
answer = "Backup Question's Answers",
pinNumber: "Wallet Password"
)

See Also

postRegisterRestorationKey

FncyQuestion

Restoring Wallet

If a user forgets their wallet password, they can change their wallet password and recover their wallet if they have a registered wallet recovery question/answer pair.

Calling User's Registered Questions

If you have a registered wallet restore question/answer pair, you can request a registered wallet restore questions.

let result: FncyQuestion = try await fncyWallet.getResetQuestion()

See Also

getResetQuestion

FncyQuestion

Entering Question's Answers and New Password

You can change the wallet password and recover the wallet by using the restore wallet answer and the new wallet password.

let isSuccess: Bool = try await fncyWallet.postResetQuestion(
answer: "Backup Question's Answers",
newPinNumber: "New Wallet Password"
)

See Also

postResetQuestion

Change Wallet Password

You can change your wallet password using the current wallet password and the new wallet password.

Changing Wallet Password

let isSuccess: Bool = try await fncyWallet.resetWalletPin(
oldPinNumber: "Current Wallet Password", 
newPinNumber: "New Wallet Password"
)

See Also

resetWalletPin