-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add on-chain withdraw UI #69
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}` ]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like something slipped in here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Completed" could imply "confirmed", which isn't true at this point. How about "sent" instead "completed"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both fixed |
||
, 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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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})) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have use for the full There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
, 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 } ]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ module.exports = { | |
, ...require('./recv') | ||
, ...require('./node') | ||
, ...require('./channels') | ||
, ...require('./onchain') | ||
, ...require('./deposit') | ||
, ...require('./withdraw') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe have both views under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
, ...require('./expert') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
]) | ||
]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps
fundMaxChan$
andwithdrawAll$
could be unified to a single stream offundMax$
, used both in the channel creation and withdraw pages?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way?
spark-wallet/client/src/intent.js
Line 78 in b7d9f70