Skip to content

Commit

Permalink
Merge fundMaxChan$ and withdrawAll$ into a single stream
Browse files Browse the repository at this point in the history
  • Loading branch information
yoss1x committed Mar 6, 2019
1 parent be5c531 commit 9b9804c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions client/src/intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,29 @@ module.exports = ({ DOM, route, conf$, scan$, urihandler$ }) => {
.share()
, openChan$ = submit('[do=open-channel]')
.map(d => ({ ...d, channel_capacity_sat: toSatCapacity(d.channel_capacity_msat) }))
, fundMaxChan$ = on('[name=channel-fund-max]', 'input')
.map(e => e.target.checked)
.merge(goNewChan$.mapTo(false))
.startWith(false)


// Withdraw
, execWithdraw$ = submit('[do=exec-withdraw]')
.map(d => ({ ...d, amount_sat: toSatCapacity(d.amount_sat) }))
, withdrawAll$ = on('[name=withdraw-all]', 'input')
.map(e => e.target.checked)
.merge(goWithdraw$.mapTo(false))
.startWith(false)

, fundMax$ = O.merge(
on('[name=channel-fund-max]', 'input')
, on('[name=withdraw-fund-max]', 'input'))
.map(e => e.target.checked)
.merge(goNewChan$.mapTo(false))
.merge(goWithdraw$.mapTo(false))
.startWith(false)

return { conf$, page$
, goHome$, goScan$, goSend$, goRecv$, goNode$, goLogs$, goRpc$, goDeposit$, goWithdraw$
, goHome$, goScan$, goSend$, goRecv$, goNode$, goLogs$, goRpc$, goDeposit$
, goChan$, goNewChan$
, viewPay$, confPay$
, execRpc$, clrHist$
, newInv$, amtVal$
, togExp$, togTheme$, togUnit$
, feedStart$, togFeed$
, togChan$, updChan$, openChan$, closeChan$, fundMaxChan$
, execWithdraw$, withdrawAll$
, togChan$, updChan$, openChan$, closeChan$
, goWithdraw$, execWithdraw$, fundMax$
, dismiss$
}
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const

module.exports = ({ dismiss$, togExp$, togTheme$, togUnit$, page$, goHome$, goRecv$, goChan$
, amtVal$, execRpc$, execRes$, clrHist$, feedStart$: feedStart_$, togFeed$, togChan$
, fundMaxChan$, withdrawAll$
, fundMax$
, conf$: savedConf$
, req$$, error$, invoice$, incoming$, outgoing$, payments$, invoices$, funds$
, funded$, closed$
Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports = ({ dismiss$, togExp$, togTheme$, togUnit$, page$, goHome$, goRe
, outgoing$.map(p => [ 'success', `Sent payment of @{{${p.msatoshi}}}` ])
, funded$.map(c => [ 'success', `Opening channel for @{{${c.chan.msatoshi_total}}}, awaiting on-chain confirmation` ])
, closed$.map(c => [ 'success', `Channel ${c.chan.short_channel_id || c.chan.channel_id} is closing` ])
, withdrawn$.map(w => [ 'success', `Withdraw completed. t word-wrap: break-word;word-wrap: break-word; xid: ${w.txid}` ])
, withdrawn$.map(w => [ 'success', `Withdraw sent. txid: ${w.txid}` ])
, dismiss$.mapTo(null)
)
// hide "connection lost" errors when we get back online
Expand Down Expand Up @@ -173,7 +173,7 @@ module.exports = ({ dismiss$, togExp$, togTheme$, togUnit$, page$, goHome$, goRe
, info$: info$.startWith(null), peers$: peers$.startWith(null), channels$: channels$.startWith(null)
, feed$: feed$.startWith(null), feedStart$, feedActive$
, amtData$, chanActive$, rpcHist$
, fundMaxChan$, withdrawAll$
, fundMax$
, msatusd$, btcusd$: btcusd$.startWith(null)
}).shareReplay(1)
}
6 changes: 3 additions & 3 deletions client/src/views/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const channels = ({ channels, chanActive, unitf, info, conf: { expert } }
])
}

export const newChannel = ({ amtData, fundMaxChan, obalance, unitf, conf: { unit, expert } }) => {
export const newChannel = ({ amtData, fundMax, obalance, unitf, conf: { unit, expert } }) => {
const availText = obalance != null ? `Available: ${unitf(obalance)}` : ''

return form({ attrs: { do: 'open-channel' } }, [
Expand All @@ -55,14 +55,14 @@ export const newChannel = ({ amtData, fundMaxChan, obalance, unitf, conf: { unit
name: 'nodeuri', placeholder: 'nodeid@host[:port]', required: true } }))

, formGroup('Channel funding', div([
!fundMaxChan
!fundMax
? amountField(amtData, 'channel_capacity_msat', true, availText)
: div('.input-group', [
input({ attrs: { type: 'hidden', name: 'channel_capacity_msat', value: 'all' } })
, input('.form-control.form-control-lg.disabled', { attrs: { disabled: true, placeholder: availText } })
, div('.input-group-append.toggle-unit', span('.input-group-text', unit))
])
, fancyCheckbox('channel-fund-max', 'Fund maximum', fundMaxChan, '.btn-sm')
, fancyCheckbox('channel-fund-max', 'Fund maximum', fundMax, '.btn-sm')
]))

, expert ? formGroup('Fee rate', input('.form-control.form-control-lg'
Expand Down
8 changes: 4 additions & 4 deletions client/src/views/onchain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { div, img, h2, h4, span, a, p, button, form, input } from '@cycle/dom'
import { yaml, qruri, formGroup, amountField, fancyCheckbox} from './util'
import { yaml, qruri, formGroup, amountField, fancyCheckbox } from './util'

const labelType = { bech32: 'Bech32', 'p2sh-segwit': 'P2SH' }
, otherType = { bech32: 'p2sh-segwit', 'p2sh-segwit': 'bech32' }
Expand Down Expand Up @@ -29,7 +29,7 @@ export const deposit = ({ address, type }) => addrQr(address, type).then(qr => (
, expert ? yaml({ outputs: funds && funds.outputs }) : ''
]))

export const withdraw = ({ amtData, withdrawAll, obalance, unitf, conf: { unit, expert } }) => {
export const withdraw = ({ amtData, fundMax, obalance, unitf, conf: { unit, expert } }) => {
const availText = obalance != null ? `Available: ${unitf(obalance)}` : ''

return form({ attrs: { do: 'exec-withdraw' } }, [
Expand All @@ -39,14 +39,14 @@ export const deposit = ({ address, type }) => addrQr(address, type).then(qr => (
name: 'address', required: true } }))

, formGroup('Withdraw Amount', div([
!withdrawAll
!fundMax
? amountField(amtData, 'amount_sat', true, availText)
: div('.input-group', [
input({ attrs: { type: 'hidden', name: 'amount_sat', value: 'all' } })
, input('.form-control.form-control-lg.disabled', { attrs: { disabled: true, placeholder: availText } })
, div('.input-group-append.toggle-unit', span('.input-group-text', unit))
])
, fancyCheckbox('withdraw-all', 'Withdraw All', withdrawAll, '.btn-sm')
, fancyCheckbox('withdraw-fund-max', 'Withdraw All', fundMax, '.btn-sm')
]))

, expert ? formGroup('Fee rate', input('.form-control.form-control-lg'
Expand Down

0 comments on commit 9b9804c

Please sign in to comment.