Configurable bip39 validation (#2574)
This commit is contained in:
parent
a3657740a8
commit
b4298ca866
@ -19,7 +19,7 @@ export default {
|
|||||||
'```litcli sessions add --type custom --label <your label> --account_id <account_id> --uri /lnrpc.Lightning/SendPaymentSync```',
|
'```litcli sessions add --type custom --label <your label> --account_id <account_id> --uri /lnrpc.Lightning/SendPaymentSync```',
|
||||||
'Grab the `pairing_secret_mnemonic` from the output and paste it here.'
|
'Grab the `pairing_secret_mnemonic` from the output and paste it here.'
|
||||||
],
|
],
|
||||||
validate: bip39Validator(),
|
validate: bip39Validator({ min: 2, max: 10 }),
|
||||||
required: true,
|
required: true,
|
||||||
encrypt: true,
|
encrypt: true,
|
||||||
editable: false
|
editable: false
|
||||||
|
@ -142,7 +142,7 @@ export const invoiceMacaroonValidator = () =>
|
|||||||
message: 'not an invoice macaroon or an invoicable macaroon'
|
message: 'not an invoice macaroon or an invoicable macaroon'
|
||||||
})
|
})
|
||||||
|
|
||||||
export const bip39Validator = () =>
|
export const bip39Validator = ({ min = 12, max = 24 } = {}) =>
|
||||||
string()
|
string()
|
||||||
.test({
|
.test({
|
||||||
name: 'bip39',
|
name: 'bip39',
|
||||||
@ -155,11 +155,11 @@ export const bip39Validator = () =>
|
|||||||
return context.createError({ message: `'${w}' is not a valid pairing phrase word` })
|
return context.createError({ message: `'${w}' is not a valid pairing phrase word` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (words.length < 2) {
|
if (words.length < min) {
|
||||||
return context.createError({ message: 'needs at least two words' })
|
return context.createError({ message: `needs at least ${min} words` })
|
||||||
}
|
}
|
||||||
if (words.length > 10) {
|
if (words.length > max) {
|
||||||
return context.createError({ message: 'max 10 words' })
|
return context.createError({ message: `max ${max} words` })
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user