Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 77b8496

Browse files
bulenttastanbryanvu
authored andcommitted
Disable amount field for invoice payment requests
1 parent da3c704 commit 77b8496

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

packages/lightning-core/common/Input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Input extends React.Component {
2727

2828
render() {
2929
const { name, right, left, type, placeholder, value, sanitizeReturn,
30-
onChange, outlineColor, fullWidth } = this.props
30+
onChange, outlineColor, fullWidth, disabled } = this.props
3131
const styles = reactCSS({
3232
'default': {
3333
bg: {
@@ -74,8 +74,8 @@ export class Input extends React.Component {
7474
type={ type }
7575
placeholder={ placeholder }
7676
value={ value }
77+
disabled={ disabled }
7778
onChange={ handleChange }
78-
7979
onFocus={ this.handleFocus }
8080
onBlur={ this.handleBlur }
8181
/>

packages/lightning-core/pay/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const Pay = ({ onMakePayment, onDecodePaymentRequest, onEditForm,
1919
placeholder: 'Payment Request / Bitcoin Address',
2020
required: true,
2121
component: Input,
22-
22+
2323
},
2424
{
2525
name: 'amount',
@@ -28,7 +28,7 @@ export const Pay = ({ onMakePayment, onDecodePaymentRequest, onEditForm,
2828
component: CurrencyInput,
2929
},
3030
]
31-
31+
3232
const menu = new Menu()
3333
menu.append(new MenuItem({ label: 'Paste', role: 'paste' }))
3434
const handleMenu = () => menu.popup(remote.getCurrentWindow())
@@ -48,11 +48,14 @@ export const Pay = ({ onMakePayment, onDecodePaymentRequest, onEditForm,
4848
}
4949

5050
const handleChange = (change) => {
51+
fields[1].disabled = false
5152
if (change.address) {
5253
const paymentRequest = sanitizePaymentRequest(change.address)
5354
onDecodePaymentRequest({ paymentRequest })
5455
.then((decoded) => {
5556
const amount = decoded.num_satoshis
57+
// Disable the amount field when using payment requests
58+
fields[1].disabled = true
5659
onEditForm('pay', { amount })
5760
})
5861
.catch(console.error)
@@ -66,7 +69,7 @@ export const Pay = ({ onMakePayment, onDecodePaymentRequest, onEditForm,
6669
body="Lightning payments will be instant, while on-chain Bitcoin
6770
transactions require at least one confirmation (approx. 10 mins)"
6871
/>
69-
<div onContextMenu={ handleMenu } >
72+
<div onContextMenu={ handleMenu } >
7073
<Form
7174
name="pay"
7275
fields={ fields }

packages/lightning-forms/components/Field.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import reactCSS from 'reactcss'
33

44
export const Field = ({ name, type, placeholder, value, component, onChange,
5-
errorText, error }) => {
5+
disabled, errorText, error }) => {
66
const styles = reactCSS({
77
'default': {
88
field: {
@@ -31,6 +31,7 @@ export const Field = ({ name, type, placeholder, value, component, onChange,
3131
type={ type }
3232
placeholder={ placeholder }
3333
value={ value }
34+
disabled={ disabled }
3435
onChange={ handleChange }
3536
outlineColor={ error && 'rgba(213, 61, 80, 0.3)' }
3637
/>

0 commit comments

Comments
 (0)