Browse Source
feat(wallet): apply fastest fee for onchain txs
renovate/lint-staged-8.x
Tom Kirkpatrick
6 years ago
No known key found for this signature in database
GPG Key ID: 72203A8EC5967EA8
4 changed files with
12 additions and
7 deletions
-
app/components/Pay/Pay.js
-
app/components/Pay/PaySummaryOnChain.js
-
app/lib/lnd/methods/walletController.js
-
app/reducers/transaction.js
|
|
@ -131,6 +131,7 @@ class Pay extends React.Component { |
|
|
|
isQueryingFees: false, |
|
|
|
isQueryingRoutes: false, |
|
|
|
nodes: [], |
|
|
|
onchainFees: {}, |
|
|
|
routes: [] |
|
|
|
} |
|
|
|
|
|
|
@ -186,13 +187,14 @@ class Pay extends React.Component { |
|
|
|
*/ |
|
|
|
onSubmit = values => { |
|
|
|
const { currentStep, isOnchain } = this.state |
|
|
|
const { cryptoCurrency, payInvoice, sendCoins } = this.props |
|
|
|
const { cryptoCurrency, onchainFees, payInvoice, sendCoins } = this.props |
|
|
|
if (currentStep === 'summary') { |
|
|
|
return isOnchain |
|
|
|
? sendCoins({ |
|
|
|
value: values.amountCrypto, |
|
|
|
addr: values.payReq, |
|
|
|
currency: cryptoCurrency |
|
|
|
currency: cryptoCurrency, |
|
|
|
satPerByte: onchainFees.fastestFee |
|
|
|
}) |
|
|
|
: payInvoice(values.payReq) |
|
|
|
} else { |
|
|
|
|
|
@ -51,7 +51,7 @@ class PaySummaryOnChain extends React.Component { |
|
|
|
onchainFees: {} |
|
|
|
} |
|
|
|
|
|
|
|
componenDidMount() { |
|
|
|
componentDidMount() { |
|
|
|
const { queryFees } = this.props |
|
|
|
queryFees() |
|
|
|
} |
|
|
|
|
|
@ -74,9 +74,9 @@ export function getTransactions(lnd) { |
|
|
|
* @param {[type]} amount [description] |
|
|
|
* @return {[type]} [description] |
|
|
|
*/ |
|
|
|
export function sendCoins(lnd, { addr, amount }) { |
|
|
|
export function sendCoins(lnd, { addr, amount, target_conf, sat_per_byte }) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
lnd.sendCoins({ addr, amount }, (err, data) => { |
|
|
|
lnd.sendCoins({ addr, amount, target_conf, sat_per_byte }, (err, data) => { |
|
|
|
if (err) { |
|
|
|
return reject(err) |
|
|
|
} |
|
|
|
|
|
@ -86,13 +86,16 @@ export const receiveTransactions = (event, { transactions }) => (dispatch, getSt |
|
|
|
dispatch(fetchBalance()) |
|
|
|
} |
|
|
|
|
|
|
|
export const sendCoins = ({ value, addr, currency }) => dispatch => { |
|
|
|
export const sendCoins = ({ value, addr, currency, targetConf, satPerByte }) => dispatch => { |
|
|
|
// backend needs amount in satoshis no matter what currency we are using
|
|
|
|
const amount = btc.convert(currency, 'sats', value) |
|
|
|
|
|
|
|
// submit the transaction to LND
|
|
|
|
dispatch(sendTransaction()) |
|
|
|
ipcRenderer.send('lnd', { msg: 'sendCoins', data: { amount, addr } }) |
|
|
|
ipcRenderer.send('lnd', { |
|
|
|
msg: 'sendCoins', |
|
|
|
data: { amount, addr, currency, target_conf: targetConf, sat_per_byte: satPerByte } |
|
|
|
}) |
|
|
|
|
|
|
|
// Close the form modal once the payment was sent to LND
|
|
|
|
// we will do the loading/success UX on the main page
|
|
|
|