Browse Source

fix(closechannel): format funding_txid correctly

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
59a4ac46c6
  1. 601
      app/lnd/config/rpc.proto
  2. 13
      app/lnd/methods/closechannel.js
  3. 2
      app/lnd/push/closechannel.js
  4. 3
      app/reducers/channels.js

601
app/lnd/config/rpc.proto

File diff suppressed because it is too large

13
app/lnd/methods/closechannel.js

@ -1,10 +1,19 @@
import bitcore from 'bitcore-lib'
import pushclosechannel from '../push/closechannel'
const BufferUtil = bitcore.util.buffer
export default function closechannel(lnd, event, payload) {
console.log('payload: ', payload)
const tx = payload.channel_point.funding_txid.match(/.{2}/g).reverse().join('')
const res = {
channel_point: {
funding_txid: BufferUtil.hexToBuffer(tx),
output_index: Number(payload.channel_point.output_index)
}
}
return new Promise((resolve, reject) =>
pushclosechannel(lnd, event, payload)
pushclosechannel(lnd, event, res)
.then(data => resolve(data))
.catch(error => reject(error))
)

2
app/lnd/push/closechannel.js

@ -1,5 +1,4 @@
export default function pushclosechannel(lnd, event, payload) {
console.log('here with payload: ', payload)
return new Promise((resolve, reject) => {
try {
const call = lnd.closeChannel(payload)
@ -9,7 +8,6 @@ export default function pushclosechannel(lnd, event, payload) {
call.on('error', error => event.sender.send('pushclosechannelerror', { error }))
call.on('status', status => event.sender.send('pushclosechannelstatus', { status }))
console.log('call: ', call)
resolve(null, payload)
} catch (error) {
console.log('error: ', error)

3
app/reducers/channels.js

@ -110,9 +110,8 @@ export const pushchannelstatus = () => (dispatch) => {
// Send IPC event for opening a channel
export const closeChannel = ({ channel_point }) => (dispatch) => {
dispatch(closingChannel())
console.log('channel_point: ', channel_point)
const channelPoint = channel_point.split(':')
ipcRenderer.send('lnd', { msg: 'closeChannel', data: { channel_point: { funding_txid_str: channelPoint[0], output_index: parseInt(channelPoint[1]) }, force: true } })
ipcRenderer.send('lnd', { msg: 'closeChannel', data: { channel_point: { funding_txid: channelPoint[0], output_index: channelPoint[1] }, force: true } })
}
// TODO: Decide how to handle streamed updates for closing channels

Loading…
Cancel
Save