FAQ
Why is window.bitshares missing?
The usual causes are opening the page with file://, serving it over plain http (other than localhost), putting it in an iframe, or not having the extension installed or enabled. Open it as a top-level window on http://localhost or https, and check that the CubWallet icon is available in the toolbar. Also listen for bitshares#initialized so you do not decide too early.
Why does bts_accounts return an empty array?
The user may not have called bts_requestAccounts yet, they may have rejected the connect window, the wallet may be locked, or they may have switched to a network that this origin has not been authorized on. While the wallet is locked, this method returns [] even if a permission already exists. Check bts_chainId and try again after unlock.
The site is connected, but signing still fails.
A watch-only account can appear in the authorized list but cannot sign. The error is 账户 <id> 在钱包中没有私钥. Ask the user to pick an account that has a key, or to import the key into the wallet.
Also, fields such as from, seller and fee_paying_account must be account ids that are authorized for this origin. An unauthorized account yields 账户 <id> 未授权给此站点.
What is the difference between the transaction expiration and an order expiration?
The transaction expiration is set by the wallet to about 10 minutes after the head block. It limits how long that signed transaction remains valid; the dApp cannot change it. The expiration on limit_order_create is how long the order stays on the market, and you set it in the operation.
Can I pass an account name instead of an account id?
No. Operation fields must be object ids such as 1.2.x. The test dApp talks to a public node to resolve a name you type into an id, then sends that id to the wallet. If your dApp also accepts names, you must resolve them yourself and check the chain id first.
How does the page know the user switched accounts?
Call bts_accounts again whenever you need to display accounts. A network switch or an unlock can also change the list; refresh in those event handlers.
How do I disconnect?
Clear the account state you stored on the page. That does not remove the site permission in the wallet; the user can revoke a site from the wallet settings. There is currently no dApp method to revoke a permission.
Which method should I use while testing?
Prefer bts_signTransaction (sign only, no broadcast) during development, and reject or sign-only in the approval window. Do not call bts_signAndBroadcast on mainnet without a deliberate confirmation. The official test dApp marks broadcast buttons separately and calls the method only after another click.
CubWallet