From 7b44129a43e46ddf921721570b6d76ec56d64c17 Mon Sep 17 00:00:00 2001 From: pkova Date: Mon, 17 May 2021 18:23:33 +0300 Subject: [PATCH] btc: confirm master ticket on wallet setup --- .../src/js/components/lib/walletModal.js | 57 ++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/pkg/btc-wallet/src/js/components/lib/walletModal.js b/pkg/btc-wallet/src/js/components/lib/walletModal.js index ec2fb4723..099408daa 100644 --- a/pkg/btc-wallet/src/js/components/lib/walletModal.js +++ b/pkg/btc-wallet/src/js/components/lib/walletModal.js @@ -38,9 +38,12 @@ export default class WalletModal extends Component { this.state = { mode: 'masterTicket', masterTicket: '', + confirmedMasterTicket: '', xpub: '', readyToSubmit: false, processingSubmission: false, + confirmingMasterTicket: false, + error: false, } this.checkTicket = this.checkTicket.bind(this); this.checkXPub = this.checkXPub.bind(this); @@ -52,9 +55,15 @@ export default class WalletModal extends Component { checkTicket(e){ // TODO: port over bridge ticket validation logic - let masterTicket = e.target.value; - let readyToSubmit = (masterTicket.length > 0); - this.setState({masterTicket, readyToSubmit}); + if (this.state.confirmingMasterTicket) { + let confirmedMasterTicket = e.target.value; + let readyToSubmit = (confirmedMasterTicket.length > 0); + this.setState({confirmedMasterTicket, readyToSubmit}); + } else { + let masterTicket = e.target.value; + let readyToSubmit = (masterTicket.length > 0); + this.setState({masterTicket, readyToSubmit}); + } } checkXPub(e){ @@ -121,16 +130,30 @@ export default class WalletModal extends Component { master ticket. Learn More - + + {this.state.confirmingMasterTicket && + this.setState({ + confirmingMasterTicket: false, + masterTicket: '', + confirmedMasterTicket: '', + error: false + })}/>} - Master Key + {this.state.confirmingMasterTicket ? 'Confirm Master Key' : 'Master Key'} {(!inputDisabled) ? null : } + {this.state.error && + + + Master tickets do not match + + + } {this.submitMasterTicket(this.state.masterTicket)}} + onClick={() => { + if (!this.state.confirmingMasterTicket) { + this.setState({confirmingMasterTicket: true}); + } else { + if (this.state.masterTicket === this.state.confirmedMasterTicket) { + this.setState({error: false}); + this.submitMasterTicket(this.state.masterTicket); + } else { + this.setState({error: true}); + } + } + }} /> );