diff --git a/wallets/lib/protocols/lnc.js b/wallets/lib/protocols/lnc.js index 420d852f..2e8687e6 100644 --- a/wallets/lib/protocols/lnc.js +++ b/wallets/lib/protocols/lnc.js @@ -19,7 +19,7 @@ export default { '```litcli sessions add --type custom --label --account_id --uri /lnrpc.Lightning/SendPaymentSync```', 'Grab the `pairing_secret_mnemonic` from the output and paste it here.' ], - validate: bip39Validator(), + validate: bip39Validator({ min: 2, max: 10 }), required: true, encrypt: true, editable: false diff --git a/wallets/lib/validate.js b/wallets/lib/validate.js index 237b0d9a..9c394574 100644 --- a/wallets/lib/validate.js +++ b/wallets/lib/validate.js @@ -142,7 +142,7 @@ export const invoiceMacaroonValidator = () => message: 'not an invoice macaroon or an invoicable macaroon' }) -export const bip39Validator = () => +export const bip39Validator = ({ min = 12, max = 24 } = {}) => string() .test({ name: 'bip39', @@ -155,11 +155,11 @@ export const bip39Validator = () => return context.createError({ message: `'${w}' is not a valid pairing phrase word` }) } } - if (words.length < 2) { - return context.createError({ message: 'needs at least two words' }) + if (words.length < min) { + return context.createError({ message: `needs at least ${min} words` }) } - if (words.length > 10) { - return context.createError({ message: 'max 10 words' }) + if (words.length > max) { + return context.createError({ message: `max ${max} words` }) } return true }