Merge 7ac718a2c7 into release/next-userspace

This commit is contained in:
janeway-bot 2021-06-18 08:30:22 +04:00 committed by GitHub
commit 00e4e7c521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 216 additions and 159 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b58e4370952137018415b772323e13638ff1e03ea63d7e72f385ec670d97a82e
size 13844992
oid sha256:e0c05655f47ff81c8d4985a061d3ff57526a436adf25f667432a48c5cd10d438
size 12190347

View File

@ -85,8 +85,7 @@
::
?> ?=([%clients *] pax)
?. (is-whitelisted:hc src.bowl)
~& >>> "btc-provider: blocked client {<src.bowl>}"
[~[[%give %kick ~ ~]] this]
~|("btc-provider: blocked client {<src.bowl>}" !!)
~& > "btc-provider: accepted client {<src.bowl>}"
:- [do-ping:hc]~
this(clients.host-info (~(put in clients.host-info) src.bowl))
@ -195,6 +194,9 @@
::
%ping
[%get-block-info ~]
::
%block-info
[%get-block-info block.act]
==
[~[(req-card act ract)] state]
::
@ -284,6 +286,11 @@
?: =(block.host-info block.r)
~[(send-status [%connected network.host-info block.r fee.r])]
~[(send-status [%new-block network.host-info block.r fee.r blockhash.r blockfilter.r])]
::
%block-info
?> ?=([%get-block-info *] r)
:_ state
~[(send-update [%.y %block-info network.host-info +.r])]
==
::
++ send-status

View File

@ -167,13 +167,20 @@
|= [=wire =sign:agent:gall]
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%watch-ack
?~ p.sign `this
%- (slog leaf+"connection rejected by provider ({<src.bowl>})" u.p.sign)
`this
::
%kick
~& >>> "kicked from prov {<src.bowl>}"
?~ prov `this
?: ?& ?=(%set-provider -.wire)
=(host.u.prov src.bowl)
==
`this(prov ~)
:_ this(prov [~ src.bowl %.n])
:~ (watch-provider src.bowl)
(give-update %change-provider `[src.bowl %.n])
==
`this
::
%fact
@ -238,7 +245,6 @@
?> (team:title our.bowl src.bowl)
?- -.comm
%set-provider
|^
?~ provider.comm
?~ prov `state
:_ state(prov ~)
@ -252,20 +258,6 @@
(watch-provider u.provider.comm)
(give-update %change-provider `[u.provider.comm %.n])
==
::
++ watch-provider
|= who=@p
^- card
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
%watch /clients
==
++ leave-provider
|= who=@p
^- card
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
%leave ~
==
--
::
%check-provider
=/ pax /permitted/(scot %p provider.comm)
@ -685,7 +677,6 @@
++ handle-provider-status
|= s=status:bp
^- (quip card _state)
|^
=^ cards state
?~ prov `state
?. =(host.u.prov src.bowl) `state
@ -704,102 +695,146 @@
(give-update %change-provider prov)
cards
==
::
++ on-connected
|= $: p=provider
=network
block=@ud
fee=(unit sats)
blockhash=(unit hexb)
blockfilter=(unit hexb)
==
^- (quip card _state)
:_ %_ state
prov `p(connected %.y)
btc-state [block fee now.bowl]
==
?: ?|(?!(connected.p) (lth block.btc-state block))
;: weld
(retry-pend-piym network)
(retry-poym network)
(retry-addrs network)
(retry-txs network)
(retry-scans network)
retry-ahistorical-txs
::
++ on-connected
|= $: p=provider
=network
block=@ud
fee=(unit sats)
blockhash=(unit hexb)
blockfilter=(unit hexb)
==
^- (quip card _state)
:: request block-info for missing blocks
:: if blockhash or blockfilter are ~ request block-info for current block
::
=| blocks=(list @ud)
=/ gap (sub block block.btc-state)
=? blocks (gth gap 1)
(gulf +(block.btc-state) (dec block))
=? blocks ?|(?=(~ blockhash) ?=(~ blockfilter))
(snoc blocks block)
=? blocks (gth gap 50) ~
::
=/ cards=(list card)
;: weld
:: (retry-addrs network)
retry-ahistorical-txs
(retry-pend-piym network)
(retry-block-info blocks)
==
::
++ retry-ahistorical-txs
^- (list card)
%+ turn ~(tap in ahistorical-txs)
|= =txid
(poke-provider [%tx-info txid])
::
++ retry-scans
|= =network
^- (list card)
%- zing
%+ murn ~(tap by scans)
|= [[=xpub:bc =chyg] =batch]
?. =(network network:(~(got by walts) xpub)) ~
`-:(req-scan batch xpub chyg)
:: +retry-addrs: get info on addresses with unconfirmed UTXOs
::
++ retry-addrs
|= =network
^- (list card)
%- zing
%+ murn ~(val by walts)
|= w=walt
?. =(network network.w) ~
^- (unit (list card))
:- ~
%+ turn ~(tap by wach.w)
|= [a=address *]
(poke-provider [%address-info a])
:: +retry-txs: get info on txs without enough confirmations
::
++ retry-txs
|= =network
^- (list card)
%+ murn ~(tap by history)
|= [=txid =hest]
=/ w (~(get by walts) xpub.hest)
?~ w ~
?. =(network network.u.w) ~
?: (gte confs.hest confs.u.w) ~
`(poke-provider [%tx-info txid])
::
++ retry-poym
|= =network
^- (list card)
?~ txbu.poym ~
=/ w (~(get by walts) xpub.u.txbu.poym)
?~ w ~
?. =(network network.u.w) ~
%+ weld
?~ signed-tx.u.txbu.poym ~
~[(poke-provider [%broadcast-tx u.signed-tx.u.txbu.poym])]
%+ turn txis.u.txbu.poym
|= =txi
(poke-provider [%raw-tx ~(get-txid txb:bl u.txbu.poym)])
:: +retry-pend-piym: check whether txids in pend-piym are in mempool
::
++ retry-pend-piym
|= =network
^- (list card)
%+ murn ~(tap by pend.piym)
|= [=txid p=payment]
=/ w (~(get by walts) xpub.p)
?~ w ~
?. =(network network.u.w) ~
`(poke-provider [%tx-info txid])
--
=? cards ?|(!connected.p (gth gap 0))
;: weld cards
(retry-poym network)
(retry-txs network)
(retry-scans network)
==
=? cards ?&(?=(^ blockhash) ?=(^ blockfilter) (gth gap 0))
(weld cards (retry-filtered-addrs network u.blockhash u.blockfilter))
=? cards (gth gap 50)
(weld cards (retry-addrs network))
:- cards
%_ state
prov `p(connected %.y)
btc-state [block fee now.bowl]
==
::
++ retry-block-info
|= blocks=(list @ud)
%+ turn blocks
|= block=@ud
(poke-provider %block-info `block)
::
++ retry-ahistorical-txs
^- (list card)
%+ turn ~(tap in ahistorical-txs)
|= =txid
(poke-provider [%tx-info txid])
::
++ retry-scans
|= =network
^- (list card)
%- zing
%+ murn ~(tap by scans)
|= [[=xpub:bc =chyg] =batch]
=/ w (~(get by walts) xpub)
?~ w ~
?. =(network network.u.w) ~
`-:(req-scan batch xpub chyg)
:: +retry-addrs: get info on addresses with unconfirmed UTXOs
::
++ retry-addrs
|= =network
^- (list card)
%- zing
%+ murn ~(val by walts)
|= w=walt
?. =(network network.w) ~
^- (unit (list card))
:- ~
%+ turn ~(tap by wach.w)
|= [a=address *]
(poke-provider [%address-info a])
::
::
++ retry-filtered-addrs
|= [=network blockhash=hexb blockfilter=hexb]
^- (list card)
%- zing
%+ murn ~(val by walts)
|= w=walt
^- (unit (list card))
?. =(network network.w) ~
:- ~
%+ murn
%~ tap in
%: all-match:bip-b158:bc
blockfilter
blockhash
::
%+ turn ~(tap by wach.w)
|= [a=address *]
[a (to-script-pubkey:adr:bc a)]
==
|= [a=address spk=hexb]
^- (unit card)
`(poke-provider [%address-info a])
:: +retry-txs: get info on txs without enough confirmations
::
++ retry-txs
|= =network
^- (list card)
%+ murn ~(tap by history)
|= [=txid =hest]
=/ w (~(get by walts) xpub.hest)
?~ w ~
?. =(network network.u.w) ~
?: (gte confs.hest confs.u.w) ~
`(poke-provider [%tx-info txid])
::
++ retry-poym
|= =network
^- (list card)
?~ txbu.poym ~
=/ w (~(get by walts) xpub.u.txbu.poym)
?~ w ~
?. =(network network.u.w) ~
%+ weld
?~ signed-tx.u.txbu.poym ~
~[(poke-provider [%broadcast-tx u.signed-tx.u.txbu.poym])]
%+ turn txis.u.txbu.poym
|= =txi
(poke-provider [%raw-tx ~(get-txid txb:bl u.txbu.poym)])
:: +retry-pend-piym: check whether txids in pend-piym are in mempool
::
++ retry-pend-piym
|= =network
^- (list card)
%+ murn ~(tap by pend.piym)
|= [=txid p=payment]
=/ w (~(get by walts) xpub.p)
?~ w ~
?. =(network network.u.w) ~
`(poke-provider [%tx-info txid])
::
++ handle-provider-update
|= upd=update:bp
@ -833,6 +868,10 @@
:~ (poke-internal [%fail-broadcast-tx txid.p.upd])
(give-update %cancel-tx txid.p.upd)
==
::
%block-info
:_ state
(retry-filtered-addrs network.p.upd blockhash.p.upd blockfilter.p.upd)
==
::
++ handle-tx-info
@ -1082,6 +1121,19 @@
^- card
[%give %fact ~[/all] %btc-wallet-update !>(upd)]
::
++ watch-provider
|= who=@p
^- card
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
%watch /clients
==
++ leave-provider
|= who=@p
^- card
:* %pass /set-provider/[(scot %p who)] %agent [who %btc-provider]
%leave ~
==
::
++ give-initial
^- card
=^ a=(unit address) state

View File

@ -26,6 +26,6 @@
<div id="portal-root"></div>
<script src="/~landscape/js/channel.js"></script>
<script src="/~landscape/js/session.js"></script>
<script src="/~btc/js/bundle/index.a591a96d20f3c4e414b6.js"></script>
<script src="/~btc/js/bundle/index.f7ab13b7db3ec1f8b55a.js"></script>
</body>
</html>

View File

@ -5,8 +5,8 @@
/- glob, *resource
/+ default-agent, verb, dbug
|%
++ landscape-hash 0v2.23tfu.ss2fb.q233c.p9er4.viq93
++ btc-wallet-hash 0v6.e3j9o.e928h.ivsmp.cfkd5.qr44b
++ landscape-hash 0v4.3us6c.ma3il.h5bch.qacg3.70qjl
++ btc-wallet-hash 0v1.9p61c.bd4vn.deevh.0ldbq.fkqo3
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
+$ state-1 [%1 =globs:glob]
+$ all-states

View File

@ -24,6 +24,6 @@
<div id="portal-root"></div>
<script src="/~landscape/js/channel.js"></script>
<script src="/~landscape/js/session.js"></script>
<script src="/~landscape/js/bundle/index.f186ac63932f6baf3113.js"></script>
<script src="/~landscape/js/bundle/index.af45eeaf465dff7d73f1.js"></script>
</body>
</html>

View File

@ -211,19 +211,20 @@
$(last-val (add delta last-val))
:: +all-match: returns all target byts that match
:: - filter: full block filter, with leading N
:: - k: key for siphash (end of blockhash, reversed)
:: - targets: scriptpubkeys to match
::
++ all-match
|= [filter=hexb:bc k=byts targets=(list byts)]
^- (set hexb:bc)
%- ~(gas in *(set hexb:bc))
|= [filter=hexb:bc blockhash=hexb:bc targets=(list [address:bc byts])]
^- (set [address:bc hexb:bc])
=/ k (to-key (trip (to-cord:hxb:bcu blockhash)))
%- ~(gas in *(set [address:bc hexb:bc]))
=/ [p=@ m=@] [p:params m:params]
=/ [n=@ux gcs-set=bits:bc] (parse-filter filter)
=/ target-map=(map @ hexb:bc)
%- ~(gas by *(map @ hexb:bc))
=/ target-map=(map @ [address:bc hexb:bc])
%- ~(gas by *(map @ [address:bc hexb:bc]))
%+ turn targets
|=(t=hexb:bc [(to-range:hsh t (mul n m) k) t])
|= [a=address:bc t=hexb:bc]
[(to-range:hsh t (mul n m) k) a t]
=+ target-hs=(sort ~(tap in ~(key by target-map)) lth)
=+ last-val=0
=| matches=(list @)
@ -244,4 +245,5 @@
=^ delta gcs-set
(de:gol gcs-set p)
$(last-val (add delta last-val))
::
--

View File

@ -3,7 +3,7 @@
:: expose BIP libraries
::
/- sur=bitcoin
/+ bech32=bip-b173, pbt=bip-b174, bcu=bitcoin-utils
/+ bech32=bip-b173, pbt=bip-b174, bcu=bitcoin-utils, bip-b158
=, sur
=, bcu
|%

View File

@ -505,8 +505,10 @@
(mk-url '/getblockcount' '')
::
%get-block-info
=/ param=@t
?~(block.ract '' (rsh [3 2] (scot %ui u.block.ract)))
%- get-request
(mk-url '/getblockinfo' '')
(mk-url '/getblockinfo/' param)
==
++ mk-url
|= [base=@t params=@t]

View File

@ -31,6 +31,7 @@
[%raw-tx txid=hexb]
[%broadcast-tx rawtx=hexb]
[%ping ~]
[%block-info block=(unit @ud)]
==
::
+$ result
@ -38,6 +39,7 @@
[%tx-info =info:tx]
[%raw-tx txid=hexb rawtx=hexb]
[%broadcast-tx txid=hexb broadcast=? included=?]
[%block-info =network block=@ud fee=(unit sats) blockhash=hexb blockfilter=hexb]
==
+$ error
$% [%not-connected status=@ud]
@ -60,7 +62,7 @@
[%get-raw-tx txid=hexb]
[%broadcast-tx rawtx=hexb]
[%get-block-count ~]
[%get-block-info ~]
[%get-block-info block=(unit @ud)]
==
::
+$ result

View File

@ -151,9 +151,11 @@
::
++ check-all-match
|= v=match-vector
=+ k=(to-key blockhash.v)
=/ b=hexb (from-cord:hxb (crip blockhash.v))
=/ inc=(list [address hexb]) (turn inc-spks.v |=(h=hexb [*address h]))
=/ exc=(list [address hexb]) (turn exc-spks.v |=(h=hexb [*address h]))
%+ expect-eq
!>(`(set hexb)`(sy inc-spks.v))
!>(`(set hexb)`(all-match filter.v k (weld inc-spks.v exc-spks.v)))
!>(`(set [address hexb])`(sy inc))
!>(`(set [address hexb])`(all-match filter.v b (weld inc exc)))
--
--

View File

@ -5,4 +5,4 @@ dojo:
it should return with the following hash:
`0v6.e3j9o.e928h.ivsmp.cfkd5.qr44b`
`0v1.9p61c.bd4vn.deevh.0ldbq.fkqo3`

View File

@ -28,15 +28,7 @@ export default class Balance extends Component {
copyAddress(arg) {
let address = this.props.state.address;
function listener(e) {
e.clipboardData.setData('text/plain', address);
e.preventDefault();
}
document.addEventListener('copy', listener);
document.execCommand('copy');
document.removeEventListener('copy', listener);
navigator.clipboard.writeText(address);
this.props.api.btcWalletCommand({'gen-new-address': null});
if (arg === 'button'){
@ -122,8 +114,7 @@ export default class Balance extends Component {
style={{cursor: sendDisabled ? "default" : "pointer" }}
borderColor="none"
borderRadius="24px"
py="24px"
px="24px"
height="48px"
onClick={() => this.setState({sending: true})}
/>
<Button children={(this.state.copiedButton) ? "Address Copied!" : "Copy Address"}
@ -136,8 +127,7 @@ export default class Balance extends Component {
style={{cursor: (this.state.copiedButton) ? "default" : "pointer"}}
borderColor="none"
borderRadius="24px"
py="24px"
px="24px"
height="48px"
onClick={() => {this.copyAddress('button')}}
/>
</Row>

View File

@ -23,6 +23,9 @@ export default class Body extends Component {
}
render() {
const cardWidth = window.innerWidth <= 475 ? '350px' : '400px'
if (!this.props.loaded) {
return (
<Box display="flex" width="100%" height="100%" alignItems="center" justifyContent="center">
@ -41,7 +44,7 @@ export default class Body extends Component {
<Col
display='flex'
flexDirection='column'
width='400px'
width={cardWidth}
>
<Header settings={true} state={this.props.state}/>
<Settings state={this.props.state}
@ -54,7 +57,7 @@ export default class Body extends Component {
<Col
display='flex'
flexDirection='column'
width='400px'
width={cardWidth}
>
<Header settings={false} state={this.props.state}/>
{ (!this.props.warning) ? null : <Warning api={this.props.api}/>}

View File

@ -221,10 +221,12 @@ export default class BridgeInvoice extends Component {
mr={3}
fontSize={1}
borderRadius='24px'
py='24px'
px='24px'
border='none'
height='48px'
onClick={() => this.sendBitcoin(txHex)}
disabled={!this.state.ready || error}
disabled={!this.state.ready || error || this.state.broadcasting}
color={(this.state.ready && !error && !this.state.broadcasting) ? "white" : "lighterGray"}
backgroundColor={(this.state.ready && !error && !this.state.broadcasting) ? "green" : "veryLightGray"}
style={{cursor: (this.state.ready && !error) ? "pointer" : "default"}}
/>
{this.state.broadcasting ? <LoadingSpinner mr={3}/> : null}

View File

@ -276,8 +276,7 @@ export default class Invoice extends Component {
borderRadius='24px'
color={(this.state.ready && !error && !this.state.broadcasting) ? "white" : "lighterGray"}
backgroundColor={(this.state.ready && !error && !this.state.broadcasting) ? "green" : "veryLightGray"}
py='24px'
px='24px'
height='48px'
onClick={() => this.sendBitcoin(this.state.masterTicket, psbt)}
disabled={!this.state.ready || error || this.state.broadcasting}
style={{cursor: (this.state.ready && !error && !this.state.broadcasting) ? "pointer" : "default"}}

View File

@ -430,8 +430,7 @@ export default class Send extends Component {
fontWeight='bold'
borderRadius='24px'
mr={2}
py='24px'
px='24px'
height='48px'
onClick={() => this.toggleSignMethod(choosingSignMethod)}
color={signReady ? 'white' : 'lighterGray'}
backgroundColor={signReady ? 'rgba(33, 157, 255, 0.2)' : 'veryLightGray'}

View File

@ -20,8 +20,7 @@ export default function Signer(props) {
fontWeight='bold'
cursor='pointer'
color={(signMethod === 'masterTicket') ? 'blue' : 'lightBlue'}
py='24px'
px='24px'
height='48px'
onClick={() => setSignMethod('masterTicket')}
children='Sign with Master Ticket' />
<Button
@ -30,8 +29,7 @@ export default function Signer(props) {
fontWeight='bold'
cursor='pointer'
color={(signMethod === 'bridge') ? 'blue' : 'lightBlue'}
py='24px'
px='24px'
height='48px'
onClick={() => setSignMethod('bridge')}
children='Sign with Bridge' />
</Box>
@ -42,8 +40,7 @@ export default function Signer(props) {
fontSize={1}
fontWeight='bold'
borderRadius='24px'
py='24px'
px='24px'
height='48px'
onClick={initPayment}
color={signReady ? 'white' : 'lighterGray'}
backgroundColor={signReady ? 'blue' : 'veryLightGray'}