jam
jam copied to clipboard
feat: Add support for 24-word mnemonic phrases and fix API headers
Summary
This PR adds support for importing wallets using 24-word mnemonic phrases (in addition to the existing 12-word support) and fixes missing Content-Type headers in API requests that were causing 400 Bad Request errors.
Changes
1. 24-Word Mnemonic Support (ImportWallet.tsx)
- Added a radio button selector to choose between 12-word and 24-word mnemonic phrases
- Added
phraseLengthfield to form state to track the selected phrase length - Updated mnemonic validation to properly validate variable-length phrases
- Improved dummy mnemonic generation to work with both 12 and 24-word phrases
- Added
wallettype: 'sw-fb'parameter to the wallet recovery API call
2. API Header Fixes (JmWalletApi.ts)
- Added missing
Content-Type: application/jsonheaders to all POST requests:/v1/token/v1/wallet/create/v1/wallet/recover/v1/wallet/{walletFileName}/unlock/v1/wallet/{walletFileName}/maker/start/v1/wallet/{walletFileName}/taker/direct-send/v1/wallet/{walletFileName}/taker/coinjoin/v1/wallet/{walletFileName}/freeze/v1/wallet/{walletFileName}/taker/schedule/v1/wallet/{walletFileName}/configset/v1/wallet/{walletFileName}/configget
Motivation
- 24-word support: BIP39 standard supports both 12 and 24-word mnemonic phrases. Users with 24-word phrases were unable to import their wallets.
- API headers: The JoinMarket API expects
Content-Type: application/jsonheaders for POST requests with JSON bodies. Missing headers were causing 400 Bad Request errors during wallet operations.
Testing
- [x] Manually tested importing wallet with 12-word mnemonic phrase
- [x] Manually tested importing wallet with 24-word mnemonic phrase
- [x] Verified API requests now include proper Content-Type headers
- [x] Code formatted with Prettier (pre-commit hook)