Merge remote-tracking branch 'lnbits/fix/offlineshop_fiat_decimals' into fix/offlineshop_fiat_decimals

This commit is contained in:
Tiago vasconcelos 2022-07-28 11:09:06 +01:00
commit 4ca701a442
34 changed files with 91 additions and 45 deletions

View File

@ -16,9 +16,9 @@ jobs:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Setup Regtest - name: Setup Regtest
run: | run: |
docker build -t lnbits-legend .
git clone https://github.com/lnbits/legend-regtest-enviroment.git docker git clone https://github.com/lnbits/legend-regtest-enviroment.git docker
cd docker cd docker
git checkout removelnbits
chmod +x ./tests chmod +x ./tests
./tests ./tests
sudo chmod -R a+rwx . sudo chmod -R a+rwx .
@ -39,8 +39,8 @@ jobs:
LNBITS_DATA_FOLDER: ./data LNBITS_DATA_FOLDER: ./data
LNBITS_BACKEND_WALLET_CLASS: LndRestWallet LNBITS_BACKEND_WALLET_CLASS: LndRestWallet
LND_REST_ENDPOINT: https://localhost:8081/ LND_REST_ENDPOINT: https://localhost:8081/
LND_REST_CERT: docker/data/lnd-1/tls.cert LND_REST_CERT: ./docker/data/lnd-1/tls.cert
LND_REST_MACAROON: docker/data/lnd-1/data/chain/bitcoin/regtest/admin.macaroon LND_REST_MACAROON: ./docker/data/lnd-1/data/chain/bitcoin/regtest/admin.macaroon
run: | run: |
sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data
make test-real-wallet make test-real-wallet
@ -57,9 +57,9 @@ jobs:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Setup Regtest - name: Setup Regtest
run: | run: |
docker build -t lnbits-legend .
git clone https://github.com/lnbits/legend-regtest-enviroment.git docker git clone https://github.com/lnbits/legend-regtest-enviroment.git docker
cd docker cd docker
git checkout removelnbits
chmod +x ./tests chmod +x ./tests
./tests ./tests
sudo chmod -R a+rwx . sudo chmod -R a+rwx .
@ -79,7 +79,7 @@ jobs:
PORT: 5123 PORT: 5123
LNBITS_DATA_FOLDER: ./data LNBITS_DATA_FOLDER: ./data
LNBITS_BACKEND_WALLET_CLASS: CLightningWallet LNBITS_BACKEND_WALLET_CLASS: CLightningWallet
CLIGHTNING_RPC: docker/data/clightning-1/regtest/lightning-rpc CLIGHTNING_RPC: ./docker/data/clightning-1/regtest/lightning-rpc
run: | run: |
sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data
make test-real-wallet make test-real-wallet

View File

@ -7,7 +7,7 @@ LNbits
![Lightning network wallet](https://i.imgur.com/EHvK6Lq.png) ![Lightning network wallet](https://i.imgur.com/EHvK6Lq.png)
# LNbits v0.3 BETA, free and open-source lightning-network wallet/accounts system # LNbits v0.9 BETA, free and open-source lightning-network wallet/accounts system
(Join us on [https://t.me/lnbits](https://t.me/lnbits)) (Join us on [https://t.me/lnbits](https://t.me/lnbits))

View File

@ -17,7 +17,6 @@ A backend wallet can be configured using the following LNbits environment variab
### CLightning ### CLightning
Using this wallet requires the installation of the `pylightning` Python package. Using this wallet requires the installation of the `pylightning` Python package.
If you want to use LNURLp you should use SparkWallet because of an issue with description_hash and CLightning.
- `LNBITS_BACKEND_WALLET_CLASS`: **CLightningWallet** - `LNBITS_BACKEND_WALLET_CLASS`: **CLightningWallet**
- `CLIGHTNING_RPC`: /file/path/lightning-rpc - `CLIGHTNING_RPC`: /file/path/lightning-rpc

View File

@ -45,7 +45,14 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
""" """
configure_logger() configure_logger()
app = FastAPI() app = FastAPI(
title="LNbits API",
description="API for LNbits, the free and open source bitcoin wallet and accounts system with plugins.",
license_info={
"name": "MIT License",
"url": "https://raw.githubusercontent.com/lnbits/lnbits-legend/main/LICENSE",
},
)
app.mount("/static", StaticFiles(packages=[("lnbits", "static")]), name="static") app.mount("/static", StaticFiles(packages=[("lnbits", "static")]), name="static")
app.mount( app.mount(
"/core/static", "/core/static",

View File

@ -62,4 +62,5 @@
</p> </p>
</q-card-section> </q-card-section>
</q-card> </q-card>
<q-btn flat label="Swagger API" type="a" href="../docs#/Bleskomat"></q-btn>
</q-expansion-item> </q-expansion-item>

View File

@ -14,6 +14,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/copilot"></q-btn>
<q-expansion-item group="api" dense expand-separator label="Create copilot"> <q-expansion-item group="api" dense expand-separator label="Create copilot">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -34,6 +34,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/discordbot"></q-btn>
<q-expansion-item group="api" dense expand-separator label="GET users"> <q-expansion-item group="api" dense expand-separator label="GET users">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -16,7 +16,7 @@ async def create_ticket(
INSERT INTO events.ticket (id, wallet, event, name, email, registered, paid) INSERT INTO events.ticket (id, wallet, event, name, email, registered, paid)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
""", """,
(payment_hash, wallet, event, name, email, False, False), (payment_hash, wallet, event, name, email, False, True),
) )
ticket = await get_ticket(payment_hash) ticket = await get_ticket(payment_hash)

View File

@ -20,4 +20,5 @@
</p> </p>
</q-card-section> </q-card-section>
</q-card> </q-card>
<q-btn flat label="Swagger API" type="a" href="../docs#/events"></q-btn>
</q-expansion-item> </q-expansion-item>

View File

@ -135,15 +135,7 @@
var self = this var self = this
axios axios
.post( .get('/events/api/v1/tickets/' + '{{ event_id }}')
'/events/api/v1/tickets/' + '{{ event_id }}/{{ event_price }}',
{
event: '{{ event_id }}',
event_name: '{{ event_name }}',
name: self.formDialog.data.name,
email: self.formDialog.data.email
}
)
.then(function (response) { .then(function (response) {
self.paymentReq = response.data.payment_request self.paymentReq = response.data.payment_request
self.paymentCheck = response.data.payment_hash self.paymentCheck = response.data.payment_hash
@ -161,7 +153,17 @@
paymentChecker = setInterval(function () { paymentChecker = setInterval(function () {
axios axios
.get('/events/api/v1/tickets/' + self.paymentCheck) .post(
'/events/api/v1/tickets/' +
'{{ event_id }}/' +
self.paymentCheck,
{
event: '{{ event_id }}',
event_name: '{{ event_name }}',
name: self.formDialog.data.name,
email: self.formDialog.data.email
}
)
.then(function (res) { .then(function (res) {
if (res.data.paid) { if (res.data.paid) {
clearInterval(paymentChecker) clearInterval(paymentChecker)

View File

@ -133,7 +133,10 @@
var self = this var self = this
LNbits.api LNbits.api
.request('GET', '/events/api/v1/register/ticket/' + res) .request(
'GET',
'/events/api/v1/register/ticket/' + res.split('//')[1]
)
.then(function (response) { .then(function (response) {
self.$q.notify({ self.$q.notify({
type: 'positive', type: 'positive',

View File

@ -13,9 +13,8 @@
<br /> <br />
<qrcode <qrcode
:value="'{{ ticket_id }}'" :value="'ticket://{{ ticket_id }}'"
:options="{width: 340}" :options="{width: 500}"
class="rounded-borders"
></qrcode> ></qrcode>
<br /> <br />
<q-btn @click="printWindow" color="grey" class="q-ml-auto"> <q-btn @click="printWindow" color="grey" class="q-ml-auto">

View File

@ -97,8 +97,8 @@ async def api_tickets(
return [ticket.dict() for ticket in await get_tickets(wallet_ids)] return [ticket.dict() for ticket in await get_tickets(wallet_ids)]
@events_ext.post("/api/v1/tickets/{event_id}/{sats}") @events_ext.get("/api/v1/tickets/{event_id}")
async def api_ticket_make_ticket(event_id, sats, data: CreateTicket): async def api_ticket_make_ticket(event_id):
event = await get_event(event_id) event = await get_event(event_id)
if not event: if not event:
raise HTTPException( raise HTTPException(
@ -107,13 +107,22 @@ async def api_ticket_make_ticket(event_id, sats, data: CreateTicket):
try: try:
payment_hash, payment_request = await create_invoice( payment_hash, payment_request = await create_invoice(
wallet_id=event.wallet, wallet_id=event.wallet,
amount=int(sats), amount=event.price_per_ticket,
memo=f"{event_id}", memo=f"{event_id}",
extra={"tag": "events"}, extra={"tag": "events"},
) )
except Exception as e: except Exception as e:
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(e)) raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(e))
return {"payment_hash": payment_hash, "payment_request": payment_request}
@events_ext.post("/api/v1/tickets/{event_id}/{payment_hash}")
async def api_ticket_send_ticket(event_id, payment_hash, data: CreateTicket):
event = await get_event(event_id)
try:
status = await api_payment(payment_hash)
if status["paid"]:
ticket = await create_ticket( ticket = await create_ticket(
payment_hash=payment_hash, payment_hash=payment_hash,
wallet=event.wallet, wallet=event.wallet,
@ -124,20 +133,10 @@ async def api_ticket_make_ticket(event_id, sats, data: CreateTicket):
if not ticket: if not ticket:
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail=f"Event could not be fetched." status_code=HTTPStatus.NOT_FOUND,
detail=f"Event could not be fetched.",
) )
return {"payment_hash": payment_hash, "payment_request": payment_request}
@events_ext.get("/api/v1/tickets/{payment_hash}")
async def api_ticket_send_ticket(payment_hash):
ticket = await get_ticket(payment_hash)
try:
status = await api_payment(payment_hash)
if status["paid"]:
await set_ticket_paid(payment_hash=payment_hash)
return {"paid": True, "ticket_id": ticket.id} return {"paid": True, "ticket_id": ticket.id}
except Exception: except Exception:
raise HTTPException(status_code=HTTPStatus.NOT_FOUND, detail="Not paid") raise HTTPException(status_code=HTTPStatus.NOT_FOUND, detail="Not paid")

View File

@ -24,6 +24,8 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/jukebox"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List jukeboxes"> <q-expansion-item group="api" dense expand-separator label="List jukeboxes">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -17,6 +17,8 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/livestream"></q-btn>
<q-expansion-item <q-expansion-item
group="api" group="api"
dense dense

View File

@ -31,6 +31,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/lnaddress"></q-btn>
<q-expansion-item group="api" dense expand-separator label="GET domains"> <q-expansion-item group="api" dense expand-separator label="GET domains">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -31,5 +31,6 @@
</li> </li>
</ul> </ul>
</q-card-section> </q-card-section>
<q-btn flat label="Swagger API" type="a" href="../docs#/lndhub"></q-btn>
</q-card> </q-card>
</q-expansion-item> </q-expansion-item>

View File

@ -19,4 +19,5 @@
</p> </p>
</q-card-section> </q-card-section>
</q-card> </q-card>
<q-btn flat label="Swagger API" type="a" href="../docs#/lnticket"></q-btn>
</q-expansion-item> </q-expansion-item>

View File

@ -17,6 +17,12 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn
flat
label="Swagger API"
type="a"
href="../docs#/lnurldevice"
></q-btn>
<q-expansion-item <q-expansion-item
group="api" group="api"
dense dense

View File

@ -4,6 +4,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/lnurlp"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List pay links"> <q-expansion-item group="api" dense expand-separator label="List pay links">
<q-card> <q-card>
<q-card-section> <q-card-section>
@ -51,6 +52,7 @@
expand-separator expand-separator
label="Create a pay link" label="Create a pay link"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/lnurlp"></q-btn>
<q-card> <q-card>
<q-card-section> <q-card-section>
<code><span class="text-green">POST</span> /lnurlp/api/v1/links</code> <code><span class="text-green">POST</span> /lnurlp/api/v1/links</code>

View File

@ -2,5 +2,5 @@
"name": "LNURLPayout", "name": "LNURLPayout",
"short_description": "Autodump wallet funds to LNURLpay", "short_description": "Autodump wallet funds to LNURLpay",
"icon": "exit_to_app", "icon": "exit_to_app",
"contributors": ["arcbtc"] "contributors": ["arcbtc","talvasconcelos"]
} }

View File

@ -4,6 +4,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/lnurlpayout"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List lnurlpayout"> <q-expansion-item group="api" dense expand-separator label="List lnurlpayout">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -47,6 +47,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/offlineshop"></q-btn>
<q-expansion-item <q-expansion-item
group="api" group="api"
dense dense

View File

@ -4,6 +4,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/paywall"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List paywalls"> <q-expansion-item group="api" dense expand-separator label="List paywalls">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -4,6 +4,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/satsdice"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List satsdices"> <q-expansion-item group="api" dense expand-separator label="List satsdices">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -15,6 +15,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/satspay"></q-btn>
<q-expansion-item group="api" dense expand-separator label="Create charge"> <q-expansion-item group="api" dense expand-separator label="Create charge">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -28,6 +28,12 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn
flat
label="Swagger API"
type="a"
href="../docs#/splitpayments"
></q-btn>
<q-expansion-item <q-expansion-item
group="api" group="api"
dense dense

View File

@ -15,4 +15,5 @@
> >
</p> </p>
</q-card-section> </q-card-section>
<q-btn flat label="Swagger API" type="a" href="../docs#/streamalerts"></q-btn>
</q-card> </q-card>

View File

@ -22,5 +22,6 @@
> >
</p> </p>
</q-card-section> </q-card-section>
<q-btn flat label="Swagger API" type="a" href="../docs#/subdomains"></q-btn>
</q-card> </q-card>
</q-expansion-item> </q-expansion-item>

View File

@ -12,4 +12,5 @@
> >
</p> </p>
</q-card-section> </q-card-section>
<q-btn flat label="Swagger API" type="a" href="../docs#/tipjar"></q-btn>
</q-card> </q-card>

View File

@ -4,6 +4,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/tpos"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List TPoS"> <q-expansion-item group="api" dense expand-separator label="List TPoS">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -28,6 +28,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/usermanager"></q-btn>
<q-expansion-item group="api" dense expand-separator label="GET users"> <q-expansion-item group="api" dense expand-separator label="GET users">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -20,6 +20,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/watchonly"></q-btn>
<q-expansion-item group="api" dense expand-separator label="List wallets"> <q-expansion-item group="api" dense expand-separator label="List wallets">
<q-card> <q-card>
<q-card-section> <q-card-section>

View File

@ -4,6 +4,7 @@
label="API info" label="API info"
:content-inset-level="0.5" :content-inset-level="0.5"
> >
<q-btn flat label="Swagger API" type="a" href="../docs#/withdraw"></q-btn>
<q-expansion-item <q-expansion-item
group="api" group="api"
dense dense