Skip to content
This repository was archived by the owner on Apr 11, 2022. It is now read-only.

Commit f877705

Browse files
author
fiatjaf
committed
final fixes.
1 parent 01a99ca commit f877705

26 files changed

+466
-1128
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ runcall
1313
static/*bundle*
1414
.pyre
1515
gitdatabase
16+
prodgitdatabase
17+
yarn.lock

.prettierrc.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
arrowParens: avoid
2+
bracketSpacing: false
3+
jsxBracketSameLine: false
4+
printWidth: 80
5+
proseWrap: preserve
6+
semi: false
7+
singleQuote: true
8+
trailingComma: none
9+
useTabs: false

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ static/bundle.js: $(shell find client)
1010
GITHUB_REPO=etleneum/database-dev ./node_modules/.bin/rollup -c
1111

1212
deploy_test: etleneum
13+
GITHUB_REPO=etleneum/database-dev ./node_modules/.bin/rollup -c
14+
CC=$$(which musl-gcc) go build -ldflags='-s -w -linkmode external -extldflags "-static"' -o ./etleneum
1315
ssh root@hulsmann 'systemctl stop etleneum-test'
1416
scp etleneum hulsmann:etleneum-test/etleneum
1517
ssh root@hulsmann 'systemctl start etleneum-test'

account_functions.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,6 @@ func callHmacString(call *data.Call) (res string) {
4949
return
5050
}
5151

52-
// func deleteFailedWithdrawals() error {
53-
// var bolt11s []string
54-
// err := pg.Select(&bolt11s, `SELECT bolt11 FROM withdrawals WHERE NOT fulfilled`)
55-
// if err != nil {
56-
// return err
57-
// }
58-
//
59-
// for _, bolt11 := range bolt11s {
60-
// listpays, err := ln.Call("listpays", bolt11)
61-
// if err != nil {
62-
// return err
63-
// }
64-
// if listpays.Get("pays.#").Int() == 0 || listpays.Get("pays.0.status").String() == "failed" {
65-
// // delete failed withdraw attempt
66-
// pg.Exec("DELETE FROM withdrawals WHERE bolt11 = $1 AND NOT fulfilled", bolt11)
67-
// } else if listpays.Get("pays.0.status").String() == "complete" {
68-
// // mark as not pending anymore
69-
// pg.Exec("UPDATE withdrawals SET fulfilled = true WHERE bolt11 = $1 AND NOT fulfilled", bolt11)
70-
// }
71-
// }
72-
//
73-
// return nil
74-
// }
75-
7652
func hmacAccount(accountId string) string {
7753
mac := hmac.New(sha256.New, []byte(s.SecretKey))
7854
mac.Write([]byte(accountId))

call_functions.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func runCallGlobal(call *data.Call, useBalance bool) (err error) {
6565
callContext := &CallContext{
6666
VisitedContracts: make(map[string]bool),
6767
Funds: make(map[string]int64),
68+
AccountBalances: make(map[string]int64),
6869
}
6970

7071
// actually run the call
@@ -245,7 +246,7 @@ func runCall(call *data.Call, callContext *CallContext, useBalance bool) (err er
245246
}
246247
callContext.Funds[target] = targetContract.Funds + msat
247248
}
248-
} else if target[0] == 'a' {
249+
} else if target[0] == '0' {
249250
// it's an account
250251
if current, ok := callContext.AccountBalances[target]; ok {
251252
callContext.AccountBalances[target] = current + msat
@@ -273,7 +274,7 @@ func runCall(call *data.Call, callContext *CallContext, useBalance bool) (err er
273274
*call,
274275
)
275276
if err != nil {
276-
return fmt.Errorf("error executing lua method: %w", err)
277+
return fmt.Errorf("error executing method: %w", err)
277278
}
278279

279280
newState, err := json.Marshal(newStateO)

client/Account.svelte

Lines changed: 64 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<!-- @format -->
2-
32
<script>
43
import {onMount} from 'svelte'
54
import PromiseWindow from 'promise-window'
65
76
import * as toast from './toast'
87
import QR from './QR.svelte'
98
import account from './accountStore'
10-
import fire from './fire'
119
1210
var es
1311
@@ -70,6 +68,67 @@
7068
}
7169
</script>
7270

71+
<div class="center">
72+
{#if $account.id}
73+
<div style="display: flex; justify-content: space-between;">
74+
<div>
75+
Logged as <b class="account">{$account.id}</b>
76+
</div>
77+
<div style="margin-left: 20px">
78+
<a
79+
href={`https://github.com/etleneum/database/commits/master/accounts/${account.id}`}
80+
target="_blank">account history</a
81+
>
82+
</div>
83+
</div>
84+
<div
85+
style="display: flex; margin-top: 20px; justify-content: space-between;"
86+
>
87+
<p>
88+
Actual balance <b>{($account.balance / 1000).toFixed(3)}</b> satoshi.
89+
</p>
90+
<p>
91+
Can withdraw
92+
<b>{($account.can_withdraw / 1000).toFixed(3)}</b> satoshi.
93+
</p>
94+
<p id="balance-notice" style="flex-shrink: 2">
95+
The withdraw amount is your balance subtracted of an amount of
96+
<em>0.7%</em> reserved to pay for the Lightning withdraw costs. The
97+
actual fee (probably less than that) will be applied once the withdraw
98+
is completed so you'll have more money. Besides that a <em>0.1%</em> platform
99+
fee will also be applied.
100+
</p>
101+
</div>
102+
{#if $account.balance > 0 && $account.lnurl.withdraw}
103+
<QR value={$account.lnurl.withdraw} />
104+
<p>Scan to withdraw.</p>
105+
{/if}
106+
<div><button on:click={logout}>logout</button></div>
107+
{:else if awaitingSeedAuth}
108+
<div class="awaiting-seed-auth">
109+
<img alt="awaiting/loading animation" src="/static/rings.svg" />
110+
</div>
111+
Waiting for login on popup
112+
{:else if $account.lnurl.auth}
113+
<h2>lnurl login</h2>
114+
<QR value={$account.lnurl.auth} />
115+
<p>
116+
Scan/click with
117+
<a target="_blank" href="https://lightning-wallet.com/">BLW</a> or
118+
scan/copy-paste to
119+
<a target="_blank" href="https://t.me/lntxbot">@lntxbot</a> to login.
120+
</p>
121+
<p>
122+
Or
123+
<a
124+
on:click={loginSeedAuth}
125+
href="{SEEDAUTH}/#/lnurl/{$account.lnurl.auth}"
126+
target="_blank">login with username and password</a
127+
>.
128+
</p>
129+
{/if}
130+
</div>
131+
73132
<style>
74133
button {
75134
cursor: pointer;
@@ -88,88 +147,10 @@
88147
.awaiting-seed-auth img {
89148
width: 40%;
90149
}
91-
92150
#balance-notice {
93-
font-size: 12px;
94-
margin: 0 auto 30px;
95-
max-width: 400px;
151+
font-size: 10px;
152+
margin: 0 auto 25px;
153+
max-width: 420px;
96154
text-align: justify;
97155
}
98-
99-
#history {
100-
margin-top: 33px;
101-
}
102-
#history caption {
103-
font-size: 1.2em;
104-
margin-bottom: 14px;
105-
}
106-
#history td {
107-
padding: 0 5px;
108-
}
109-
#history td:nth-child(2) {
110-
text-align: right;
111-
}
112156
</style>
113-
114-
<div class="center">
115-
{#if $account.id}
116-
<p>Logged as <b>{$account.id}</b>.</p>
117-
<p>Actual balance <b>{($account.balance / 1000).toFixed(3)}</b> satoshi.</p>
118-
<p>
119-
Can withdraw
120-
<b>{($account.can_withdraw / 1000).toFixed(3)}</b> satoshi.
121-
</p>
122-
<p id="balance-notice">
123-
The withdraw amount is your balance subtracted of an amount of
124-
<em>0.7%</em> reserved to pay for the Lightning withdraw costs. The actual
125-
fee (probably less than that) will be applied once the withdraw is completed
126-
so you'll have more money. Besides that a <em>0.1%</em> platform fee will
127-
also be applied.
128-
</p>
129-
{#if $account.balance > 0 && $account.lnurl.withdraw}
130-
<QR value="{$account.lnurl.withdraw}" />
131-
<p>Scan to withdraw.</p>
132-
{/if}
133-
<div><button on:click="{logout}">logout</button></div>
134-
{#if $account.history.length}
135-
<table id="history">
136-
<caption>
137-
Transaction history
138-
</caption>
139-
{#each $account.history as entry}
140-
<tr>
141-
<td>{entry.time.split('T').join(' ').replace(/\..*/, '')}</td>
142-
<td><b>{entry.msatoshi / 1000}sat</b></td>
143-
<td>
144-
{#if entry.counterparty[0] == 'c'}
145-
<a href="#/contract/{entry.counterparty}"> {entry.counterparty} </a>
146-
{:else if entry.counterparty == 'burned'}
147-
<img title="burned or used to pay for a call" src="{fire}" />
148-
{:else} {entry.counterparty} {/if}
149-
</td>
150-
</tr>
151-
{/each}
152-
</table>
153-
154-
{/if} {:else if awaitingSeedAuth}
155-
<div class="awaiting-seed-auth"><img src="/static/rings.svg" /></div>
156-
Waiting for login on popup {:else if $account.lnurl.auth}
157-
<h2>lnurl login</h2>
158-
<QR value="{$account.lnurl.auth}" />
159-
<p>
160-
Scan/click with
161-
<a target="_blank" href="https://lightning-wallet.com/">BLW</a> or
162-
scan/copy-paste to
163-
<a target="_blank" href="https://t.me/lntxbot">@lntxbot</a> to login.
164-
</p>
165-
<p>
166-
Or
167-
<a
168-
on:click="{loginSeedAuth}"
169-
href="{SEEDAUTH}/#/lnurl/{$account.lnurl.auth}"
170-
target="_blank"
171-
>login with username and password</a
172-
>.
173-
</p>
174-
{/if}
175-
</div>

client/App.svelte

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<!-- @format -->
2-
32
<script>
43
import {onMount, setContext} from 'svelte'
54
import Router, {link} from 'svelte-spa-router'
65
76
import Home from './Home.svelte'
87
import List from './List.svelte'
98
import View from './View.svelte'
10-
import Call from './Call.svelte'
119
import Create from './Create.svelte'
1210
import Account from './Account.svelte'
1311
import Docs from './Docs.svelte'
@@ -21,12 +19,43 @@
2119
'/contracts': List,
2220
'/create': Create,
2321
'/contract/:ctid': View,
24-
'/call/:callid': Call,
2522
'/account': Account,
2623
'*': NotFound
2724
}
2825
</script>
2926

27+
<nav>
28+
<a href="#/"> <img alt="etleneum logo" src="/static/icon.png" /></a>
29+
<a href="#/contracts">list contracts</a>
30+
<a href="#/create">create</a>
31+
<a href="#/account">
32+
{#if $account.id}acct:<span class="account">{$account.id}</span
33+
>{:else}login{/if}
34+
</a>
35+
<a href="#/docs">docs</a>
36+
</nav>
37+
<main><Router {routes} /></main>
38+
<footer>
39+
<span>Etleneum.com</span>
40+
<a
41+
href="https://ln.bigsun.xyz/node/02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d"
42+
>
43+
<img
44+
alt="_"
45+
src="https://img.shields.io/badge/dynamic/json?color=orange&label=node%2002bed%E2%80%A6&query=%24%5B0%5D.openchannels&suffix=%20channels&url=https%3A%2F%2Fln.bigsun.xyz%2Fapi%2Fnodes%3Fpubkey%3Deq.02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d%26select%3Dopenchannels"
46+
/>
47+
</a>
48+
<a
49+
href="https://ln.bigsun.xyz/node/02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d"
50+
>
51+
<img
52+
alt="_"
53+
src="https://img.shields.io/badge/dynamic/json?color=blue&label=software&query=%24[0].software&url=https%3A%2F%2Fln.bigsun.xyz%2Fapi%2Fnodes%3Fpubkey%3Deq.02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d%26select%3Dsoftware"
54+
/>
55+
</a>
56+
<a href="/static/terms.txt">Terms</a>
57+
</footer>
58+
3059
<style>
3160
nav {
3261
text-transform: uppercase;
@@ -46,9 +75,6 @@
4675
nav a {
4776
color: inherit;
4877
}
49-
.account {
50-
text-transform: lowercase;
51-
}
5278
main {
5379
margin: 23px auto;
5480
}
@@ -61,33 +87,3 @@
6187
margin: 0 20px;
6288
}
6389
</style>
64-
65-
<nav>
66-
<a href="#/"> <img alt="etleneum logo" src=/static/icon.png></a>
67-
<a href="#/contracts">list contracts</a>
68-
<a href="#/create">create</a>
69-
<a href="#/account">
70-
{#if $account.id}acct:<span class="account">{$account.id}</span
71-
>{:else}login{/if}
72-
</a>
73-
<a href="#/docs">docs</a>
74-
</nav>
75-
<main><Router {routes} /></main>
76-
<footer>
77-
<span>Etleneum.com</span>
78-
<a
79-
href="https://ln.bigsun.xyz/node/02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d"
80-
>
81-
<img
82-
src="https://img.shields.io/badge/dynamic/json?color=orange&label=node%2002bed%E2%80%A6&query=%24%5B0%5D.openchannels&suffix=%20channels&url=https%3A%2F%2Fln.bigsun.xyz%2Fapi%2Fnodes%3Fpubkey%3Deq.02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d%26select%3Dopenchannels"
83-
/>
84-
</a>
85-
<a
86-
href="https://ln.bigsun.xyz/node/02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d"
87-
>
88-
<img
89-
src="https://img.shields.io/badge/dynamic/json?color=blue&label=software&query=%24[0].software&url=https%3A%2F%2Fln.bigsun.xyz%2Fapi%2Fnodes%3Fpubkey%3Deq.02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d%26select%3Dsoftware"
90-
/>
91-
</a>
92-
<a href="/static/terms.txt">Terms</a>
93-
</footer>

0 commit comments

Comments
 (0)