mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
Validate address with bitcoin library (#110)
REF: Wrap tx creation in a try catch
This commit is contained in:
parent
0bb9c4d95b
commit
c1ff80aee9
1 changed files with 12 additions and 9 deletions
|
@ -151,6 +151,7 @@ export default class SendDetails extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
async createTransaction() {
|
async createTransaction() {
|
||||||
|
this.setState({ isLoading: true });
|
||||||
let error = false;
|
let error = false;
|
||||||
let requestedSatPerByte = this.state.fee.toString().replace(/\D/g, '');
|
let requestedSatPerByte = this.state.fee.toString().replace(/\D/g, '');
|
||||||
|
|
||||||
|
@ -174,7 +175,16 @@ export default class SendDetails extends Component {
|
||||||
console.log('validation error');
|
console.log('validation error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
bitcoin.address.toOutputScript(this.state.address);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('validation error');
|
||||||
|
console.log(err);
|
||||||
|
error = loc.send.details.address_field_is_not_valid;
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
this.setState({ isLoading: false });
|
||||||
alert(error);
|
alert(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -205,14 +215,7 @@ export default class SendDetails extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
let startTime = Date.now();
|
let startTime = Date.now();
|
||||||
try {
|
tx = this.state.fromWallet.createTx(utxo, this.state.amount, fee, this.state.address, this.state.memo);
|
||||||
tx = this.state.fromWallet.createTx(utxo, this.state.amount, fee, this.state.address, this.state.memo);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
alert(loc.send.details.create_tx_error);
|
|
||||||
this.setState({ isLoading: false });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let endTime = Date.now();
|
let endTime = Date.now();
|
||||||
console.log('create tx ', (endTime - startTime) / 1000, 'sec');
|
console.log('create tx ', (endTime - startTime) / 1000, 'sec');
|
||||||
|
|
||||||
|
@ -246,7 +249,7 @@ export default class SendDetails extends Component {
|
||||||
await BlueApp.saveToDisk();
|
await BlueApp.saveToDisk();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
alert(loc.send.details.create_tx_error);
|
alert(err);
|
||||||
this.setState({ isLoading: false });
|
this.setState({ isLoading: false });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue