From 1a6a8c3660e926023e9fe03151e75428a02fc576 Mon Sep 17 00:00:00 2001 From: yoss1x Date: Mon, 4 Mar 2019 10:24:23 +0200 Subject: [PATCH 1/4] Add on-chain withdraw UI --- CHANGELOG.md | 2 ++ client/src/intent.js | 14 +++++++-- client/src/model.js | 6 ++-- client/src/rpc.js | 5 ++-- client/src/view.js | 3 +- client/src/views/{onchain.js => deposit.js} | 0 client/src/views/index.js | 3 +- client/src/views/node.js | 5 +++- client/src/views/withdraw.js | 32 +++++++++++++++++++++ client/styl/style.styl | 2 +- 10 files changed, 62 insertions(+), 10 deletions(-) rename client/src/views/{onchain.js => deposit.js} (100%) create mode 100644 client/src/views/withdraw.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 4550558b..1d3eaa6e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +- ui: Add a new interface for withdrawing on-chain funds + ## 0.2.5 - 2019-02-24 - Use the compact alphanumeric QR encoding mode for bech32 addresses diff --git a/client/src/intent.js b/client/src/intent.js index b78aee3d..0db800c4 100644 --- a/client/src/intent.js +++ b/client/src/intent.js @@ -23,6 +23,7 @@ module.exports = ({ DOM, route, conf$, scan$, urihandler$ }) => { , goNewChan$ = route('/channels/new') , goDeposit$ = route('/deposit').mapTo('bech32') .merge(click('[data-newaddr-type]').map(e => e.ownerTarget.dataset.newaddrType)) + , goWithdraw$ = route('/withdraw') // Display and confirm payment requests (from QR, lightning: URIs and manual entry) , viewPay$ = O.merge(scan$, urihandler$).map(parseUri).filter(x => !!x) @@ -71,11 +72,19 @@ module.exports = ({ DOM, route, conf$, scan$, urihandler$ }) => { .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)) + .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) return { conf$, page$ - , goHome$, goScan$, goSend$, goRecv$, goNode$, goLogs$, goRpc$, goDeposit$ + , goHome$, goScan$, goSend$, goRecv$, goNode$, goLogs$, goRpc$, goDeposit$, goWithdraw$ , goChan$, goNewChan$ , viewPay$, confPay$ , execRpc$, clrHist$ @@ -83,6 +92,7 @@ module.exports = ({ DOM, route, conf$, scan$, urihandler$ }) => { , togExp$, togTheme$, togUnit$ , feedStart$, togFeed$ , togChan$, updChan$, openChan$, closeChan$, fundMaxChan$ + , execWithdraw$, withdrawAll$ , dismiss$ } } diff --git a/client/src/model.js b/client/src/model.js index b8fdfb75..71948658 100644 --- a/client/src/model.js +++ b/client/src/model.js @@ -22,10 +22,11 @@ const module.exports = ({ dismiss$, togExp$, togTheme$, togUnit$, page$, goHome$, goRecv$, goChan$ , amtVal$, execRpc$, execRes$, clrHist$, feedStart$: feedStart_$, togFeed$, togChan$ - , fundMaxChan$ + , fundMaxChan$, withdrawAll$ , conf$: savedConf$ , req$$, error$, invoice$, incoming$, outgoing$, payments$, invoices$, funds$ , funded$, closed$ + , withdrawn$ , btcusd$, info$, peers$ }) => { const @@ -68,6 +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}` ]) , dismiss$.mapTo(null) ) // hide "connection lost" errors when we get back online @@ -171,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$ + , fundMaxChan$, withdrawAll$ , msatusd$, btcusd$: btcusd$.startWith(null) }).shareReplay(1) } diff --git a/client/src/rpc.js b/client/src/rpc.js index e7a149bf..68d63f22 100644 --- a/client/src/rpc.js +++ b/client/src/rpc.js @@ -30,6 +30,7 @@ exports.parseRes = ({ HTTP, SSE }) => { , invoice$: reply('invoice').map(r => ({ ...r.body, ...r.request.ctx })) , outgoing$: reply('pay').map(r => ({ ...r.body, ...r.request.ctx })) , newaddr$: reply('newaddr').map(r => ({ address: r.body.address, type: r.request.send.params[0] })) + , withdrawn$: reply('withdraw').map(r => ({tx: r.body.tx, txid: r.body.txid})) , funded$: reply('connectfund').map(r => r.body) , closed$: reply('closeget').map(r => r.body) , execRes$: reply('console').map(r => ({ ...r.request.send, res: r.body })) @@ -43,7 +44,7 @@ exports.parseRes = ({ HTTP, SSE }) => { // RPC commands to send // NOTE: "connectfund" and "closeget" are custom rpc commands provided by the Spark server. -exports.makeReq = ({ viewPay$, confPay$, newInv$, goLogs$, goChan$, goNewChan$, goDeposit$, updChan$, openChan$, closeChan$, execRpc$ }) => O.merge( +exports.makeReq = ({ viewPay$, confPay$, newInv$, goLogs$, goChan$, goNewChan$, execWithdraw$, goDeposit$, updChan$, openChan$, closeChan$, execRpc$ }) => O.merge( viewPay$.map(bolt11 => [ 'decodepay', [ bolt11 ], { bolt11 } ]) , confPay$.map(pay => [ 'pay', [ pay.bolt11, ...(pay.custom_msat ? [ pay.custom_msat ] : []) ], pay ]) , newInv$.map(inv => [ 'invoice', [ inv.msatoshi, inv.label, inv.description, INVOICE_TTL ], inv ]) @@ -52,7 +53,7 @@ exports.makeReq = ({ viewPay$, confPay$, newInv$, goLogs$, goChan$, goNewChan$, , updChan$.mapTo( [ 'listpeers' ] ) , openChan$.map(d => [ 'connectfund', [ d.nodeuri, d.channel_capacity_sat, d.feerate ] ]) , closeChan$.map(d => [ 'closeget', [ d.peerid, d.chanid ] ]) - +, execWithdraw$.map(d => [ 'withdraw', [ d.address, d.amount_sat, d.feerate ] ]) , goDeposit$.map(type => [ 'newaddr', [ type ] ]) , timer(60000).mapTo( [ 'listinvoices', [], { bg: true } ]) diff --git a/client/src/view.js b/client/src/view.js index f1720616..379fea5e 100644 --- a/client/src/view.js +++ b/client/src/view.js @@ -6,7 +6,7 @@ import themeColors from '../theme-colors.json' const isFunc = x => typeof x == 'function' // DOM view -exports.vdom = ({ state$, goHome$, goScan$, goSend$, goRecv$, goChan$, goNewChan$, goNode$, goRpc$, payreq$, invoice$, newaddr$, logs$ }) => { +exports.vdom = ({ state$, goHome$, goScan$, goSend$, goRecv$, goChan$, goNewChan$, goWithdraw$, goNode$, goRpc$, payreq$, invoice$, newaddr$, logs$ }) => { const body$ = O.merge( // user actions goHome$.startWith(1).mapTo(views.home) @@ -15,6 +15,7 @@ exports.vdom = ({ state$, goHome$, goScan$, goSend$, goRecv$, goChan$, goNewChan , goRecv$.mapTo(views.recv) , goChan$.mapTo(views.channels) , goNewChan$.mapTo(views.newChannel) + , goWithdraw$.mapTo(views.withdraw) , goNode$.mapTo(views.nodeInfo) , goRpc$.mapTo(views.rpc) diff --git a/client/src/views/onchain.js b/client/src/views/deposit.js similarity index 100% rename from client/src/views/onchain.js rename to client/src/views/deposit.js diff --git a/client/src/views/index.js b/client/src/views/index.js index d4499828..f4793143 100644 --- a/client/src/views/index.js +++ b/client/src/views/index.js @@ -5,6 +5,7 @@ module.exports = { , ...require('./recv') , ...require('./node') , ...require('./channels') -, ...require('./onchain') +, ...require('./deposit') +, ...require('./withdraw') , ...require('./expert') } diff --git a/client/src/views/node.js b/client/src/views/node.js index e2f9d56f..7f4585df 100644 --- a/client/src/views/node.js +++ b/client/src/views/node.js @@ -23,8 +23,11 @@ exports.nodeInfo = async ({ info, peers, conf: { expert } }) => { process.env.BUILD_TARGET != 'web' ? a('.btn.btn-secondary.btn-sm', { attrs: { href: 'settings.html', rel: 'external' }}, 'Server settings') : '' , ' ' , a('.btn.btn-secondary.btn-sm', { attrs: { href: '#/channels' }}, 'Channels') - , ' ' + ]) + , p('.text-center.mt-4', [ , a('.btn.btn-secondary.btn-sm', { attrs: { href: '#/deposit' }}, 'Deposit') + , ' ' + , a('.btn.btn-secondary.btn-sm', { attrs: { href: '#/withdraw' }}, 'Withdraw') ]) , expert ? yaml(info) : '' ]) diff --git a/client/src/views/withdraw.js b/client/src/views/withdraw.js new file mode 100644 index 00000000..a3381ffe --- /dev/null +++ b/client/src/views/withdraw.js @@ -0,0 +1,32 @@ +import { div, h2, span, button, form, input } from '@cycle/dom' +import { formGroup, amountField, fancyCheckbox } from './util' + +export const withdraw = ({ amtData, withdrawAll, obalance, unitf, conf: { unit, expert } }) => { + const availText = obalance != null ? `Available: ${unitf(obalance)}` : '' + + return form({ attrs: { do: 'exec-withdraw' } }, [ + h2('On-chain withdraw') + + , formGroup('Address', input('.form-control.form-control-lg' , { attrs: { + name: 'address', required: true } })) + + , formGroup('Withdraw Amount', div([ + !withdrawAll + ? 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') + ])) + + , expert ? formGroup('Fee rate', input('.form-control.form-control-lg' + , { attrs: { type: 'text', name: 'feerate', placeholder: '(optional)' + , pattern: '[0-9]+(perk[bw])?|slow|normal|urgent' } })) : '' + + , div('.form-buttons', [ + button('.btn.btn-lg.btn-primary', { attrs: { type: 'submit' } }, 'Withdraw') + ]) + ]) + } \ No newline at end of file diff --git a/client/styl/style.styl b/client/styl/style.styl index c8e7448e..58c7b1f5 100644 --- a/client/styl/style.styl +++ b/client/styl/style.styl @@ -96,7 +96,7 @@ html .alert font-size 0.9rem font-weight 400 - word-break break-word + word-wrap break-word .btn-link cursor pointer From be5c531b540be503c6b170d3fea5a907a77d9632 Mon Sep 17 00:00:00 2001 From: yoss1x Date: Wed, 6 Mar 2019 01:46:04 +0200 Subject: [PATCH 2/4] Unite deposit and withdraw under onchain.js --- client/src/views/deposit.js | 30 ------------------ client/src/views/index.js | 3 +- client/src/views/onchain.js | 60 ++++++++++++++++++++++++++++++++++++ client/src/views/withdraw.js | 32 ------------------- 4 files changed, 61 insertions(+), 64 deletions(-) delete mode 100644 client/src/views/deposit.js create mode 100644 client/src/views/onchain.js delete mode 100644 client/src/views/withdraw.js diff --git a/client/src/views/deposit.js b/client/src/views/deposit.js deleted file mode 100644 index 5eca237b..00000000 --- a/client/src/views/deposit.js +++ /dev/null @@ -1,30 +0,0 @@ -import { div, img, h2, h4, small, a, button, p } from '@cycle/dom' -import { yaml, qruri } from './util' - -const labelType = { bech32: 'Bech32', 'p2sh-segwit': 'P2SH' } - , otherType = { bech32: 'p2sh-segwit', 'p2sh-segwit': 'bech32' } - -// Encode bech32 as uppercase to enable the more compact alphanumeric QR mode -const addrQr = (address, type) => qruri(`bitcoin:${type == 'bech32' ? address.toUpperCase() : address}`) - -export const deposit = ({ address, type }) => addrQr(address, type).then(qr => ({ funds, obalance, unitf, conf: { expert } }) => - div('.onchain-deposit', [ - div('.row', [ - div('.col-sm-6.text-center', [ - h2('On-chain deposit') - , p(`To add funds to your Lightning node, send a payment to the ${labelType[type]} address below:`) - , h4('.break-all.my-3', address) - ]) - , div('.col-sm-6.text-center', [ - img('.qr', { attrs: { src: qr } }) - ]) - ]) - , div('.my-4.text-center', [ - a('.btn.btn-primary.btn-lg.mb-1', { attrs: { href: `bitcoin:${address}` } }, 'Open wallet') - , ' ' - , button('.btn.btn-secondary.btn-lg.mb-1', { dataset: { newaddrType: otherType[type] } }, `Switch to ${labelType[otherType[type]]}`) - ]) - , p('.text-center', `Current on-chain balance: ${ unitf(obalance) }`) - , p('.text-muted.small', 'Note: c-lightning does not process unconfirmed payments. You will not receive a notification for the payment, please check back once its confirmed.') - , expert ? yaml({ outputs: funds && funds.outputs }) : '' - ])) diff --git a/client/src/views/index.js b/client/src/views/index.js index f4793143..d4499828 100644 --- a/client/src/views/index.js +++ b/client/src/views/index.js @@ -5,7 +5,6 @@ module.exports = { , ...require('./recv') , ...require('./node') , ...require('./channels') -, ...require('./deposit') -, ...require('./withdraw') +, ...require('./onchain') , ...require('./expert') } diff --git a/client/src/views/onchain.js b/client/src/views/onchain.js new file mode 100644 index 00000000..4ec6d243 --- /dev/null +++ b/client/src/views/onchain.js @@ -0,0 +1,60 @@ +import { div, img, h2, h4, span, a, p, button, form, input } from '@cycle/dom' +import { yaml, qruri, formGroup, amountField, fancyCheckbox} from './util' + +const labelType = { bech32: 'Bech32', 'p2sh-segwit': 'P2SH' } + , otherType = { bech32: 'p2sh-segwit', 'p2sh-segwit': 'bech32' } + +// Encode bech32 as uppercase to enable the more compact alphanumeric QR mode +const addrQr = (address, type) => qruri(`bitcoin:${type == 'bech32' ? address.toUpperCase() : address}`) + +export const deposit = ({ address, type }) => addrQr(address, type).then(qr => ({ funds, obalance, unitf, conf: { expert } }) => + div('.onchain-deposit', [ + div('.row', [ + div('.col-sm-6.text-center', [ + h2('On-chain deposit') + , p(`To add funds to your Lightning node, send a payment to the ${labelType[type]} address below:`) + , h4('.break-all.my-3', address) + ]) + , div('.col-sm-6.text-center', [ + img('.qr', { attrs: { src: qr } }) + ]) + ]) + , div('.my-4.text-center', [ + a('.btn.btn-primary.btn-lg.mb-1', { attrs: { href: `bitcoin:${address}` } }, 'Open wallet') + , ' ' + , button('.btn.btn-secondary.btn-lg.mb-1', { dataset: { newaddrType: otherType[type] } }, `Switch to ${labelType[otherType[type]]}`) + ]) + , p('.text-center', `Current on-chain balance: ${ unitf(obalance) }`) + , p('.text-muted.small', 'Note: c-lightning does not process unconfirmed payments. You will not receive a notification for the payment, please check back once its confirmed.') + , expert ? yaml({ outputs: funds && funds.outputs }) : '' + ])) + + export const withdraw = ({ amtData, withdrawAll, obalance, unitf, conf: { unit, expert } }) => { + const availText = obalance != null ? `Available: ${unitf(obalance)}` : '' + + return form({ attrs: { do: 'exec-withdraw' } }, [ + h2('On-chain withdraw') + + , formGroup('Address', input('.form-control.form-control-lg' , { attrs: { + name: 'address', required: true } })) + + , formGroup('Withdraw Amount', div([ + !withdrawAll + ? 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') + ])) + + , expert ? formGroup('Fee rate', input('.form-control.form-control-lg' + , { attrs: { type: 'text', name: 'feerate', placeholder: '(optional)' + , pattern: '[0-9]+(perk[bw])?|slow|normal|urgent' } })) : '' + + , div('.form-buttons', [ + button('.btn.btn-lg.btn-primary', { attrs: { type: 'submit' } }, 'Withdraw') + ]) + ]) + } \ No newline at end of file diff --git a/client/src/views/withdraw.js b/client/src/views/withdraw.js deleted file mode 100644 index a3381ffe..00000000 --- a/client/src/views/withdraw.js +++ /dev/null @@ -1,32 +0,0 @@ -import { div, h2, span, button, form, input } from '@cycle/dom' -import { formGroup, amountField, fancyCheckbox } from './util' - -export const withdraw = ({ amtData, withdrawAll, obalance, unitf, conf: { unit, expert } }) => { - const availText = obalance != null ? `Available: ${unitf(obalance)}` : '' - - return form({ attrs: { do: 'exec-withdraw' } }, [ - h2('On-chain withdraw') - - , formGroup('Address', input('.form-control.form-control-lg' , { attrs: { - name: 'address', required: true } })) - - , formGroup('Withdraw Amount', div([ - !withdrawAll - ? 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') - ])) - - , expert ? formGroup('Fee rate', input('.form-control.form-control-lg' - , { attrs: { type: 'text', name: 'feerate', placeholder: '(optional)' - , pattern: '[0-9]+(perk[bw])?|slow|normal|urgent' } })) : '' - - , div('.form-buttons', [ - button('.btn.btn-lg.btn-primary', { attrs: { type: 'submit' } }, 'Withdraw') - ]) - ]) - } \ No newline at end of file From 9b9804c43924fe95f8bbb7a36abe1cc4ea088be2 Mon Sep 17 00:00:00 2001 From: yoss1x Date: Wed, 6 Mar 2019 02:01:44 +0200 Subject: [PATCH 3/4] Merge fundMaxChan$ and withdrawAll$ into a single stream --- client/src/intent.js | 24 ++++++++++++------------ client/src/model.js | 6 +++--- client/src/views/channels.js | 6 +++--- client/src/views/onchain.js | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/client/src/intent.js b/client/src/intent.js index 0db800c4..00ecc0e2 100644 --- a/client/src/intent.js +++ b/client/src/intent.js @@ -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$ } } diff --git a/client/src/model.js b/client/src/model.js index 71948658..a73f5729 100644 --- a/client/src/model.js +++ b/client/src/model.js @@ -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$ @@ -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 @@ -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) } diff --git a/client/src/views/channels.js b/client/src/views/channels.js index e8534887..c62b5df0 100644 --- a/client/src/views/channels.js +++ b/client/src/views/channels.js @@ -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' } }, [ @@ -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' diff --git a/client/src/views/onchain.js b/client/src/views/onchain.js index 4ec6d243..ace6fea7 100644 --- a/client/src/views/onchain.js +++ b/client/src/views/onchain.js @@ -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' } @@ -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' } }, [ @@ -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' From b7d9f7047622d14a68a1d15041297dcda5b73300 Mon Sep 17 00:00:00 2001 From: yoss1x Date: Wed, 6 Mar 2019 02:14:17 +0200 Subject: [PATCH 4/4] Don't keep withdraw tx body --- client/src/rpc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/rpc.js b/client/src/rpc.js index 68d63f22..2199360b 100644 --- a/client/src/rpc.js +++ b/client/src/rpc.js @@ -30,7 +30,7 @@ exports.parseRes = ({ HTTP, SSE }) => { , invoice$: reply('invoice').map(r => ({ ...r.body, ...r.request.ctx })) , outgoing$: reply('pay').map(r => ({ ...r.body, ...r.request.ctx })) , newaddr$: reply('newaddr').map(r => ({ address: r.body.address, type: r.request.send.params[0] })) - , withdrawn$: reply('withdraw').map(r => ({tx: r.body.tx, txid: r.body.txid})) + , withdrawn$: reply('withdraw').map(r => ({ txid: r.body.txid })) , funded$: reply('connectfund').map(r => r.body) , closed$: reply('closeget').map(r => r.body) , execRes$: reply('console').map(r => ({ ...r.request.send, res: r.body }))