Skip to content

Commit

Permalink
dev(regtest): add funds to dummy wallet during initialization of loca…
Browse files Browse the repository at this point in the history
…l setup
  • Loading branch information
theborakompanioni committed Jul 6, 2023
1 parent 308a43b commit 860f2d4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 5 additions & 1 deletion docker/regtest/init-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
. "$script_dir/fund-wallet.sh" --container jm_regtest_joinmarket2 --unmatured --blocks 50
. "$script_dir/fund-wallet.sh" --container jm_regtest_joinmarket3 --unmatured --blocks 50

# first address (m/84'/1'/0'/0/0) of seed 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
# this is useful if you "import an existing wallet" and verify rescanning the chain works as expected.
dummy_wallet_address='bcrt1q6rz28mcfaxtmd6v789l9rrlrusdprr9pz3cppk'
# make block rewards spendable: 100 + 5 (default of `taker_utxo_age`) + 1 = 106
. "$script_dir/mine-block.sh" 106 &>/dev/null
. "$script_dir/mine-block.sh" 6 "$dummy_wallet_address" &>/dev/null
. "$script_dir/mine-block.sh" 100 &>/dev/null

start_maker() {
local base_url; base_url=${1:-}
Expand Down
7 changes: 4 additions & 3 deletions src/components/CreateWallet.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { act } from 'react-dom/test-utils'
import { __testSetDebugFeatureEnabled } from '../constants/debugFeatures'

import * as apiMock from '../libs/JmWalletApi'
import { DUMMY_MNEMONIC_PHRASE } from '../utils'

import CreateWallet from './CreateWallet'

Expand Down Expand Up @@ -92,7 +93,7 @@ describe('<CreateWallet />', () => {
Promise.resolve({
walletname: `${testWalletName}.jmdat`,
token: 'ANY_TOKEN',
seedphrase: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
seedphrase: DUMMY_MNEMONIC_PHRASE,
}),
})

Expand Down Expand Up @@ -125,7 +126,7 @@ describe('<CreateWallet />', () => {
Promise.resolve({
walletname: `${testWalletName}.jmdat`,
token: 'ANY_TOKEN',
seedphrase: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
seedphrase: DUMMY_MNEMONIC_PHRASE,
}),
})

Expand Down Expand Up @@ -167,7 +168,7 @@ describe('<CreateWallet />', () => {
Promise.resolve({
walletname: `${testWalletName}.jmdat`,
token: 'ANY_TOKEN',
seedphrase: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
seedphrase: DUMMY_MNEMONIC_PHRASE,
}),
})

Expand Down
9 changes: 2 additions & 7 deletions src/components/ImportWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import MnemonicWordInput from './MnemonicWordInput'
import WalletCreationConfirmation from './WalletCreationConfirmation'
import { isDebugFeatureEnabled } from '../constants/debugFeatures'
import { routes } from '../constants/routes'
import { JM_WALLET_FILE_EXTENSION, walletDisplayName } from '../utils'
import { DUMMY_MNEMONIC_PHRASE, JM_WALLET_FILE_EXTENSION, walletDisplayName } from '../utils'
import styles from './ImportWallet.module.css'

const fillerMnemonicPhrase =
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'

const MnemonicPhraseInputForm = ({ onSubmit }: { onSubmit: (mnemonicPhrase: string) => void }) => {
const { t } = useTranslation()
const [mnemonicPhraseWords, setMnemonicPhraseWords] = useState(new Array<string>(12).fill(''))
Expand Down Expand Up @@ -86,9 +83,7 @@ const MnemonicPhraseInputForm = ({ onSubmit }: { onSubmit: (mnemonicPhrase: stri
<rb.Button
variant="outline-dark"
className={styles.button}
onClick={() => {
setMnemonicPhraseWords(fillerMnemonicPhrase.split(' '))
}}
onClick={() => setMnemonicPhraseWords(DUMMY_MNEMONIC_PHRASE.split(' '))}
disabled={false}
>
{t('import_wallet.fill_with')}
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const SATS: Unit = 'sats'

export const JM_WALLET_FILE_EXTENSION = '.jmdat'

export const DUMMY_MNEMONIC_PHRASE =
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'

export const sanitizeWalletName = (name: string) => name.replace(JM_WALLET_FILE_EXTENSION, '')

export const walletDisplayName = (name: string) => sanitizeWalletName(name)
Expand Down

0 comments on commit 860f2d4

Please sign in to comment.