Merge branch 'main' into diagon-alley
This commit is contained in:
commit
71d643260c
31 changed files with 2568 additions and 140 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
FROM python:3.9-slim
|
FROM python:3.9-slim
|
||||||
|
RUN apt-get clean
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get install -y curl
|
RUN apt-get install -y curl pkg-config build-essential
|
||||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||||
ENV PATH="/root/.local/bin:$PATH"
|
ENV PATH="/root/.local/bin:$PATH"
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ By default, LNbits will use SQLite as its database. You can also use PostgreSQL
|
||||||
|
|
||||||
## Option 1 (recommended): poetry
|
## Option 1 (recommended): poetry
|
||||||
|
|
||||||
|
If you have problems installing LNbits using these instructions, please have a look at the [Troubleshooting](#troubleshooting) section.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/lnbits/lnbits-legend.git
|
git clone https://github.com/lnbits/lnbits-legend.git
|
||||||
cd lnbits-legend/
|
cd lnbits-legend/
|
||||||
|
|
@ -26,12 +28,11 @@ curl -sSL https://install.python-poetry.org | python3 -
|
||||||
export PATH="/home/ubuntu/.local/bin:$PATH" # or whatever is suggested in the poetry install notes printed to terminal
|
export PATH="/home/ubuntu/.local/bin:$PATH" # or whatever is suggested in the poetry install notes printed to terminal
|
||||||
poetry env use python3.9
|
poetry env use python3.9
|
||||||
poetry install --no-dev
|
poetry install --no-dev
|
||||||
|
poetry run python build.py
|
||||||
|
|
||||||
mkdir data
|
mkdir data
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
sudo nano .env # set funding source
|
nano .env # set funding source
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Running the server
|
#### Running the server
|
||||||
|
|
@ -176,13 +177,15 @@ Problems installing? These commands have helped us install LNbits.
|
||||||
```sh
|
```sh
|
||||||
sudo apt install pkg-config libffi-dev libpq-dev
|
sudo apt install pkg-config libffi-dev libpq-dev
|
||||||
|
|
||||||
|
# build essentials for debian/ubuntu
|
||||||
|
sudo apt install python3.9-dev gcc build-essential
|
||||||
|
|
||||||
# if the secp256k1 build fails:
|
# if the secp256k1 build fails:
|
||||||
# if you used venv
|
|
||||||
./venv/bin/pip install setuptools wheel
|
|
||||||
# if you used poetry
|
# if you used poetry
|
||||||
poetry add setuptools wheel
|
poetry add setuptools wheel
|
||||||
# build essentials for debian/ubuntu
|
|
||||||
sudo apt install python3-dev gcc build-essential
|
# if you used venv
|
||||||
|
./venv/bin/pip install setuptools wheel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Optional: PostgreSQL database
|
### Optional: PostgreSQL database
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,15 @@ async def delete_payment(checking_id: str, conn: Optional[Connection] = None) ->
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def delete_wallet_payment(
|
||||||
|
checking_id: str, wallet_id: str, conn: Optional[Connection] = None
|
||||||
|
) -> None:
|
||||||
|
await (conn or db).execute(
|
||||||
|
"DELETE FROM apipayments WHERE checking_id = ? AND wallet = ?",
|
||||||
|
(checking_id, wallet_id),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def check_internal(
|
async def check_internal(
|
||||||
payment_hash: str, conn: Optional[Connection] = None
|
payment_hash: str, conn: Optional[Connection] = None
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ class Payment(BaseModel):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Deleting outgoing failed payment {self.checking_id}: {status}"
|
f"Deleting outgoing failed payment {self.checking_id}: {status}"
|
||||||
)
|
)
|
||||||
await self.delete()
|
await self.delete(conn)
|
||||||
elif not status.pending:
|
elif not status.pending:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Marking '{'in' if self.is_in else 'out'}' {self.checking_id} as not pending anymore: {status}"
|
f"Marking '{'in' if self.is_in else 'out'}' {self.checking_id} as not pending anymore: {status}"
|
||||||
|
|
@ -182,10 +182,10 @@ class Payment(BaseModel):
|
||||||
await self.update_status(status, conn=conn)
|
await self.update_status(status, conn=conn)
|
||||||
return status
|
return status
|
||||||
|
|
||||||
async def delete(self) -> None:
|
async def delete(self, conn: Optional[Connection] = None) -> None:
|
||||||
from .crud import delete_payment
|
from .crud import delete_payment
|
||||||
|
|
||||||
await delete_payment(self.checking_id)
|
await delete_payment(self.checking_id, conn=conn)
|
||||||
|
|
||||||
|
|
||||||
class BalanceCheck(BaseModel):
|
class BalanceCheck(BaseModel):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from . import db
|
||||||
from .crud import (
|
from .crud import (
|
||||||
check_internal,
|
check_internal,
|
||||||
create_payment,
|
create_payment,
|
||||||
delete_payment,
|
delete_wallet_payment,
|
||||||
get_wallet,
|
get_wallet,
|
||||||
get_wallet_payment,
|
get_wallet_payment,
|
||||||
update_payment_details,
|
update_payment_details,
|
||||||
|
|
@ -221,7 +221,7 @@ async def pay_invoice(
|
||||||
logger.warning(f"backend sent payment failure")
|
logger.warning(f"backend sent payment failure")
|
||||||
async with db.connect() as conn:
|
async with db.connect() as conn:
|
||||||
logger.debug(f"deleting temporary payment {temp_id}")
|
logger.debug(f"deleting temporary payment {temp_id}")
|
||||||
await delete_payment(temp_id, conn=conn)
|
await delete_wallet_payment(temp_id, wallet_id, conn=conn)
|
||||||
raise PaymentFailure(
|
raise PaymentFailure(
|
||||||
f"payment failed: {payment.error_message}"
|
f"payment failed: {payment.error_message}"
|
||||||
or "payment failed, but backend didn't give us an error message"
|
or "payment failed, but backend didn't give us an error message"
|
||||||
|
|
|
||||||
|
|
@ -369,9 +369,9 @@ new Vue({
|
||||||
decodeRequest: function () {
|
decodeRequest: function () {
|
||||||
this.parse.show = true
|
this.parse.show = true
|
||||||
let req = this.parse.data.request.toLowerCase()
|
let req = this.parse.data.request.toLowerCase()
|
||||||
if (this.parse.data.request.startsWith('lightning:')) {
|
if (this.parse.data.request.toLowerCase().startsWith('lightning:')) {
|
||||||
this.parse.data.request = this.parse.data.request.slice(10)
|
this.parse.data.request = this.parse.data.request.slice(10)
|
||||||
} else if (this.parse.data.request.startsWith('lnurl:')) {
|
} else if (this.parse.data.request.toLowerCase().startsWith('lnurl:')) {
|
||||||
this.parse.data.request = this.parse.data.request.slice(6)
|
this.parse.data.request = this.parse.data.request.slice(6)
|
||||||
} else if (req.indexOf('lightning=lnurl1') !== -1) {
|
} else if (req.indexOf('lightning=lnurl1') !== -1) {
|
||||||
this.parse.data.request = this.parse.data.request
|
this.parse.data.request = this.parse.data.request
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@
|
||||||
<q-card class="q-pa-lg">
|
<q-card class="q-pa-lg">
|
||||||
<h6 class="q-my-md text-primary">Warning</h6>
|
<h6 class="q-my-md text-primary">Warning</h6>
|
||||||
<p>
|
<p>
|
||||||
Login functionality to be released in v0.2, for now,
|
Login functionality to be released in a future update, for now,
|
||||||
<strong
|
<strong
|
||||||
>make sure you bookmark this page for future access to your
|
>make sure you bookmark this page for future access to your
|
||||||
wallet</strong
|
wallet</strong
|
||||||
|
|
|
||||||
|
|
@ -153,14 +153,18 @@ async def get_key_type(
|
||||||
LNBITS_ADMIN_USERS and wallet.wallet.user not in LNBITS_ADMIN_USERS
|
LNBITS_ADMIN_USERS and wallet.wallet.user not in LNBITS_ADMIN_USERS
|
||||||
) and (LNBITS_ADMIN_EXTENSIONS and pathname in LNBITS_ADMIN_EXTENSIONS):
|
) and (LNBITS_ADMIN_EXTENSIONS and pathname in LNBITS_ADMIN_EXTENSIONS):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.UNAUTHORIZED, detail="User not authorized."
|
status_code=HTTPStatus.FORBIDDEN,
|
||||||
|
detail="User not authorized for this extension.",
|
||||||
)
|
)
|
||||||
return wallet
|
return wallet
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
if e.status_code == HTTPStatus.BAD_REQUEST:
|
if e.status_code == HTTPStatus.BAD_REQUEST:
|
||||||
raise
|
raise
|
||||||
if e.status_code == HTTPStatus.UNAUTHORIZED:
|
elif e.status_code == HTTPStatus.UNAUTHORIZED:
|
||||||
|
# we pass this in case it is not an invoice key, nor an admin key, and then return NOT_FOUND at the end of this block
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -19,42 +19,25 @@ async def create_ticket(
|
||||||
(payment_hash, wallet, event, name, email, False, True),
|
(payment_hash, wallet, event, name, email, False, True),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# UPDATE EVENT DATA ON SOLD TICKET
|
||||||
|
eventdata = await get_event(event)
|
||||||
|
assert eventdata, "Couldn't get event from ticket being paid"
|
||||||
|
sold = eventdata.sold + 1
|
||||||
|
amount_tickets = eventdata.amount_tickets - 1
|
||||||
|
await db.execute(
|
||||||
|
"""
|
||||||
|
UPDATE events.events
|
||||||
|
SET sold = ?, amount_tickets = ?
|
||||||
|
WHERE id = ?
|
||||||
|
""",
|
||||||
|
(sold, amount_tickets, event),
|
||||||
|
)
|
||||||
|
|
||||||
ticket = await get_ticket(payment_hash)
|
ticket = await get_ticket(payment_hash)
|
||||||
assert ticket, "Newly created ticket couldn't be retrieved"
|
assert ticket, "Newly created ticket couldn't be retrieved"
|
||||||
return ticket
|
return ticket
|
||||||
|
|
||||||
|
|
||||||
async def set_ticket_paid(payment_hash: str) -> Tickets:
|
|
||||||
row = await db.fetchone("SELECT * FROM events.ticket WHERE id = ?", (payment_hash,))
|
|
||||||
if row[6] != True:
|
|
||||||
await db.execute(
|
|
||||||
"""
|
|
||||||
UPDATE events.ticket
|
|
||||||
SET paid = true
|
|
||||||
WHERE id = ?
|
|
||||||
""",
|
|
||||||
(payment_hash,),
|
|
||||||
)
|
|
||||||
|
|
||||||
eventdata = await get_event(row[2])
|
|
||||||
assert eventdata, "Couldn't get event from ticket being paid"
|
|
||||||
|
|
||||||
sold = eventdata.sold + 1
|
|
||||||
amount_tickets = eventdata.amount_tickets - 1
|
|
||||||
await db.execute(
|
|
||||||
"""
|
|
||||||
UPDATE events.events
|
|
||||||
SET sold = ?, amount_tickets = ?
|
|
||||||
WHERE id = ?
|
|
||||||
""",
|
|
||||||
(sold, amount_tickets, row[2]),
|
|
||||||
)
|
|
||||||
|
|
||||||
ticket = await get_ticket(payment_hash)
|
|
||||||
assert ticket, "Newly updated ticket couldn't be retrieved"
|
|
||||||
return ticket
|
|
||||||
|
|
||||||
|
|
||||||
async def get_ticket(payment_hash: str) -> Optional[Tickets]:
|
async def get_ticket(payment_hash: str) -> Optional[Tickets]:
|
||||||
row = await db.fetchone("SELECT * FROM events.ticket WHERE id = ?", (payment_hash,))
|
row = await db.fetchone("SELECT * FROM events.ticket WHERE id = ?", (payment_hash,))
|
||||||
return Tickets(**row) if row else None
|
return Tickets(**row) if row else None
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ from .crud import (
|
||||||
get_ticket,
|
get_ticket,
|
||||||
get_tickets,
|
get_tickets,
|
||||||
reg_ticket,
|
reg_ticket,
|
||||||
set_ticket_paid,
|
|
||||||
update_event,
|
update_event,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ animals = [
|
||||||
"duck",
|
"duck",
|
||||||
"eagle",
|
"eagle",
|
||||||
"flamingo",
|
"flamingo",
|
||||||
"gorila",
|
"gorilla",
|
||||||
"hamster",
|
"hamster",
|
||||||
"iguana",
|
"iguana",
|
||||||
"jaguar",
|
"jaguar",
|
||||||
"koala",
|
"koala",
|
||||||
"llama",
|
"llama",
|
||||||
"macaroni penguim",
|
"macaroni penguin",
|
||||||
"numbat",
|
"numbat",
|
||||||
"octopus",
|
"octopus",
|
||||||
"platypus",
|
"platypus",
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,9 @@
|
||||||
hide-dropdown-icon
|
hide-dropdown-icon
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
new-value-mode="add-unique"
|
new-value-mode="add-unique"
|
||||||
label="Tip % Options"
|
label="Tip % Options (hit enter to add values)"
|
||||||
></q-select>
|
><q-tooltip>Hit enter to add values</q-tooltip></q-select
|
||||||
|
>
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@
|
||||||
name="check"
|
name="check"
|
||||||
transition-show="fade"
|
transition-show="fade"
|
||||||
class="text-light-green"
|
class="text-light-green"
|
||||||
style="font-size: 40em"
|
style="font-size: min(90vw, 40em)"
|
||||||
></q-icon>
|
></q-icon>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</q-page>
|
</q-page>
|
||||||
|
|
@ -294,6 +294,7 @@
|
||||||
exchangeRate: null,
|
exchangeRate: null,
|
||||||
stack: [],
|
stack: [],
|
||||||
tipAmount: 0.0,
|
tipAmount: 0.0,
|
||||||
|
hasNFC: false,
|
||||||
nfcTagReading: false,
|
nfcTagReading: false,
|
||||||
invoiceDialog: {
|
invoiceDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
|
|
@ -370,7 +371,7 @@
|
||||||
this.showInvoice()
|
this.showInvoice()
|
||||||
},
|
},
|
||||||
submitForm: function () {
|
submitForm: function () {
|
||||||
if (this.tip_options.length) {
|
if (this.tip_options && this.tip_options.length) {
|
||||||
this.showTipModal()
|
this.showTipModal()
|
||||||
} else {
|
} else {
|
||||||
this.showInvoice()
|
this.showInvoice()
|
||||||
|
|
@ -413,9 +414,6 @@
|
||||||
dialog.show = false
|
dialog.show = false
|
||||||
|
|
||||||
self.complete.show = true
|
self.complete.show = true
|
||||||
setTimeout(function () {
|
|
||||||
self.complete.show = false
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 3000)
|
}, 3000)
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ async def create_watch_wallet(w: WalletAccount) -> WalletAccount:
|
||||||
type,
|
type,
|
||||||
address_no,
|
address_no,
|
||||||
balance,
|
balance,
|
||||||
network
|
network,
|
||||||
|
meta
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(
|
(
|
||||||
wallet_id,
|
wallet_id,
|
||||||
|
|
@ -37,6 +38,7 @@ async def create_watch_wallet(w: WalletAccount) -> WalletAccount:
|
||||||
w.address_no,
|
w.address_no,
|
||||||
w.balance,
|
w.balance,
|
||||||
w.network,
|
w.network,
|
||||||
|
w.meta,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,3 +93,10 @@ async def m006_drop_mempool_table(db):
|
||||||
Mempool data is now part of `config`
|
Mempool data is now part of `config`
|
||||||
"""
|
"""
|
||||||
await db.execute("DROP TABLE watchonly.mempool;")
|
await db.execute("DROP TABLE watchonly.mempool;")
|
||||||
|
|
||||||
|
|
||||||
|
async def m007_add_wallet_meta_data(db):
|
||||||
|
"""
|
||||||
|
Add 'meta' for storing various metadata about the wallet
|
||||||
|
"""
|
||||||
|
await db.execute("ALTER TABLE watchonly.wallets ADD COLUMN meta TEXT DEFAULT '{}';")
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class CreateWallet(BaseModel):
|
||||||
masterpub: str = Query("")
|
masterpub: str = Query("")
|
||||||
title: str = Query("")
|
title: str = Query("")
|
||||||
network: str = "Mainnet"
|
network: str = "Mainnet"
|
||||||
|
meta: str = "{}"
|
||||||
|
|
||||||
|
|
||||||
class WalletAccount(BaseModel):
|
class WalletAccount(BaseModel):
|
||||||
|
|
@ -21,6 +22,7 @@ class WalletAccount(BaseModel):
|
||||||
balance: int
|
balance: int
|
||||||
type: Optional[str] = ""
|
type: Optional[str] = ""
|
||||||
network: str = "Mainnet"
|
network: str = "Mainnet"
|
||||||
|
meta: str = "{}"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_row(cls, row: Row) -> "WalletAccount":
|
def from_row(cls, row: Row) -> "WalletAccount":
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,18 @@ async function payment(path) {
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const p2trUtxo = this.utxos.find(
|
||||||
|
u => u.selected && u.accountType === 'p2tr'
|
||||||
|
)
|
||||||
|
if (p2trUtxo) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Taproot Signing not supported yet!',
|
||||||
|
caption: 'Please manually deselect the Taproot UTXOs',
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!this.serialSignerRef.isAuthenticated()) {
|
if (!this.serialSignerRef.isAuthenticated()) {
|
||||||
await this.serialSignerRef.hwwShowPasswordDialog()
|
await this.serialSignerRef.hwwShowPasswordDialog()
|
||||||
const authenticated = await this.serialSignerRef.isAuthenticating()
|
const authenticated = await this.serialSignerRef.isAuthenticating()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<div>
|
||||||
|
<div v-if="done">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">Seed Input Done</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-3 q-pt-sm">Word Count</div>
|
||||||
|
<div class="col-6 q-pr-lg">
|
||||||
|
<q-select
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model="wordCount"
|
||||||
|
type="number"
|
||||||
|
label="Word Count"
|
||||||
|
:options="wordCountOptions"
|
||||||
|
@input="initWords"
|
||||||
|
></q-select>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 q-pr-lg"></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-3 q-pr-lg"></div>
|
||||||
|
<div class="col-6">Enter word at position: {{actualPosition}}</div>
|
||||||
|
<div class="col-3 q-pr-lg"></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-3 q-pr-lg">
|
||||||
|
<q-btn
|
||||||
|
v-if="currentPosition > 0"
|
||||||
|
@click="previousPosition"
|
||||||
|
unelevated
|
||||||
|
class="btn-full"
|
||||||
|
color="secondary"
|
||||||
|
>Previous</q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 q-pr-lg">
|
||||||
|
<q-select
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
use-input
|
||||||
|
hide-selected
|
||||||
|
fill-input
|
||||||
|
input-debounce="0"
|
||||||
|
v-model="currentWord"
|
||||||
|
:options="options"
|
||||||
|
@filter="filterFn"
|
||||||
|
@input-value="setModel"
|
||||||
|
></q-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-3 q-pr-lg">
|
||||||
|
<q-btn
|
||||||
|
v-if="currentPosition < wordCount - 1"
|
||||||
|
@click="nextPosition"
|
||||||
|
unelevated
|
||||||
|
class="btn-full"
|
||||||
|
color="secondary"
|
||||||
|
>Next</q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
v-else
|
||||||
|
@click="seedInputDone"
|
||||||
|
unelevated
|
||||||
|
class="btn-full"
|
||||||
|
color="primary"
|
||||||
|
>Done</q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<q-linear-progress
|
||||||
|
:value="currentPosition / (wordCount -1)"
|
||||||
|
size="5px"
|
||||||
|
color="primary"
|
||||||
|
class="q-mt-sm"
|
||||||
|
></q-linear-progress>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
async function seedInput(path) {
|
||||||
|
const template = await loadTemplateAsync(path)
|
||||||
|
Vue.component('seed-input', {
|
||||||
|
name: 'seed-input',
|
||||||
|
template,
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
actualPosition: function () {
|
||||||
|
return this.words[this.currentPosition].position
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
wordCountOptions: ['12', '15', '18', '21', '24'],
|
||||||
|
wordCount: 24,
|
||||||
|
words: [],
|
||||||
|
currentPosition: 0,
|
||||||
|
stringOptions: [],
|
||||||
|
options: [],
|
||||||
|
currentWord: '',
|
||||||
|
done: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
filterFn(val, update, abort) {
|
||||||
|
update(() => {
|
||||||
|
const needle = val.toLocaleLowerCase()
|
||||||
|
this.options = this.stringOptions
|
||||||
|
.filter(v => v.toLocaleLowerCase().indexOf(needle) != -1)
|
||||||
|
.sort((a, b) => {
|
||||||
|
if (a.startsWith(needle)) {
|
||||||
|
if (b.startsWith(needle)) {
|
||||||
|
return a - b
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
} else {
|
||||||
|
if (b.startsWith(needle)) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return a - b
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
initWords() {
|
||||||
|
const words = []
|
||||||
|
for (let i = 1; i <= this.wordCount; i++) {
|
||||||
|
words.push({
|
||||||
|
position: i,
|
||||||
|
value: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.currentPosition = 0
|
||||||
|
this.words = _.shuffle(words)
|
||||||
|
},
|
||||||
|
setModel(val) {
|
||||||
|
this.currentWord = val
|
||||||
|
this.words[this.currentPosition].value = this.currentWord
|
||||||
|
},
|
||||||
|
nextPosition() {
|
||||||
|
if (this.currentPosition < this.wordCount - 1) {
|
||||||
|
this.currentPosition++
|
||||||
|
}
|
||||||
|
this.currentWord = this.words[this.currentPosition].value
|
||||||
|
},
|
||||||
|
previousPosition() {
|
||||||
|
if (this.currentPosition > 0) {
|
||||||
|
this.currentPosition--
|
||||||
|
}
|
||||||
|
this.currentWord = this.words[this.currentPosition].value
|
||||||
|
},
|
||||||
|
seedInputDone() {
|
||||||
|
const badWordPositions = this.words
|
||||||
|
.filter(w => !w.value || !this.stringOptions.includes(w.value))
|
||||||
|
.map(w => w.position)
|
||||||
|
if (badWordPositions.length) {
|
||||||
|
this.$q.notify({
|
||||||
|
timeout: 10000,
|
||||||
|
type: 'warning',
|
||||||
|
message:
|
||||||
|
'The seed has incorrect words. Please check at these positions: ',
|
||||||
|
caption: 'Position: ' + badWordPositions.join(', ')
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const mnemonic = this.words
|
||||||
|
.sort((a, b) => a.position - b.position)
|
||||||
|
.map(w => w.value)
|
||||||
|
.join(' ')
|
||||||
|
this.$emit('on-seed-input-done', mnemonic)
|
||||||
|
this.done = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
created: async function () {
|
||||||
|
this.stringOptions = bip39WordList
|
||||||
|
this.initWords()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -170,6 +170,31 @@
|
||||||
type="password"
|
type="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
></q-input>
|
></q-input>
|
||||||
|
<q-separator></q-separator>
|
||||||
|
<q-toggle
|
||||||
|
label="Passphrase (optional)"
|
||||||
|
color="secodary"
|
||||||
|
v-model="hww.hasPassphrase"
|
||||||
|
></q-toggle>
|
||||||
|
<q-input
|
||||||
|
v-if="hww.hasPassphrase"
|
||||||
|
v-model.trim="hww.passphrase"
|
||||||
|
filled
|
||||||
|
:type="hww.showPassphrase ? 'text' : 'password'"
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
label="Passphrase"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon
|
||||||
|
:name="hww.showPassphrase ? 'visibility' : 'visibility_off'"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="hww.showPassphrase = !hww.showPassphrase"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<q-btn
|
<q-btn
|
||||||
|
|
@ -351,6 +376,18 @@
|
||||||
|
|
||||||
<q-dialog v-model="showConsole" position="top">
|
<q-dialog v-model="showConsole" position="top">
|
||||||
<q-card class="q-pa-lg q-pt-xl">
|
<q-card class="q-pa-lg q-pt-xl">
|
||||||
|
<div class="row q-mt-lg q-mb-lg">
|
||||||
|
<div class="col">
|
||||||
|
<q-badge
|
||||||
|
class="text-subtitle2 float-right"
|
||||||
|
color="yellow"
|
||||||
|
text-color="black"
|
||||||
|
>
|
||||||
|
Open the browser Developer Console for more Details!
|
||||||
|
</q-badge>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
|
|
@ -361,16 +398,29 @@
|
||||||
cols="200"
|
cols="200"
|
||||||
label="Console"
|
label="Console"
|
||||||
></q-input>
|
></q-input>
|
||||||
|
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
<q-dialog v-model="hww.showSeedDialog" position="top">
|
<q-dialog v-model="hww.showSeedDialog" @hide="closeSeedDialog" position="top">
|
||||||
<q-card class="q-pa-lg q-pt-xl">
|
<q-card class="q-pa-lg q-pt-xl">
|
||||||
<span>Check word at position {{hww.seedWordPosition}} on display</span>
|
<span>Check word at position {{hww.seedWordPosition}} on device</span>
|
||||||
|
<div class="row q-mt-lg">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-toggle
|
||||||
|
label="Show Seed Word"
|
||||||
|
color="secodary"
|
||||||
|
v-model="hww.showSeedWord"
|
||||||
|
></q-toggle>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="hww.showSeedWord" class="row q-mt-lg">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input readonly v-model.trim="hww.seedWord"></q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
|
@ -409,48 +459,35 @@
|
||||||
>
|
>
|
||||||
For test purposes only. Do not enter word list with real funds!!!
|
For test purposes only. Do not enter word list with real funds!!!
|
||||||
</q-badge>
|
</q-badge>
|
||||||
<br /><br /><br />
|
|
||||||
<span>Enter new word list separated by space</span>
|
|
||||||
<q-input
|
|
||||||
v-model.trim="hww.mnemonic"
|
|
||||||
filled
|
|
||||||
:type="hww.showMnemonic ? 'text' : 'password'"
|
|
||||||
filled
|
|
||||||
dense
|
|
||||||
label="Word List"
|
|
||||||
>
|
|
||||||
<template v-slot:append>
|
|
||||||
<q-icon
|
|
||||||
:name="hww.showMnemonic ? 'visibility' : 'visibility_off'"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="hww.showMnemonic = !hww.showMnemonic"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
<br />
|
<br />
|
||||||
<q-toggle
|
<q-toggle
|
||||||
label="Passphrase (optional)"
|
label="Enter word list separated by space"
|
||||||
color="secodary"
|
color="secodary"
|
||||||
v-model="hww.hasPassphrase"
|
v-model="hww.quickMnemonicInput"
|
||||||
></q-toggle>
|
></q-toggle>
|
||||||
<br />
|
<br />
|
||||||
<q-input
|
|
||||||
v-if="hww.hasPassphrase"
|
<div v-if="hww.quickMnemonicInput">
|
||||||
v-model.trim="hww.passphrase"
|
<q-input
|
||||||
filled
|
v-model.trim="hww.mnemonic"
|
||||||
:type="hww.showPassphrase ? 'text' : 'password'"
|
filled
|
||||||
filled
|
:type="hww.showMnemonic ? 'text' : 'password'"
|
||||||
dense
|
filled
|
||||||
label="Passphrase"
|
dense
|
||||||
>
|
label="Word List"
|
||||||
<template v-slot:append>
|
>
|
||||||
<q-icon
|
<template v-slot:append>
|
||||||
:name="hww.showPassphrase ? 'visibility' : 'visibility_off'"
|
<q-icon
|
||||||
class="cursor-pointer"
|
:name="hww.showMnemonic ? 'visibility' : 'visibility_off'"
|
||||||
@click="hww.showPassphrase = !hww.showPassphrase"
|
class="cursor-pointer"
|
||||||
/>
|
@click="hww.showMnemonic = !hww.showMnemonic"
|
||||||
</template>
|
/>
|
||||||
</q-input>
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<seed-input v-else @on-seed-input-done="seedInputDone"></seed-input>
|
||||||
|
<br />
|
||||||
<q-separator></q-separator>
|
<q-separator></q-separator>
|
||||||
<br />
|
<br />
|
||||||
<span>Enter new password (8 numbers/letters)</span>
|
<span>Enter new password (8 numbers/letters)</span>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ async function serialSigner(path) {
|
||||||
showPassword: false,
|
showPassword: false,
|
||||||
mnemonic: null,
|
mnemonic: null,
|
||||||
showMnemonic: false,
|
showMnemonic: false,
|
||||||
|
quickMnemonicInput: false,
|
||||||
passphrase: null,
|
passphrase: null,
|
||||||
showPassphrase: false,
|
showPassphrase: false,
|
||||||
hasPassphrase: false,
|
hasPassphrase: false,
|
||||||
|
|
@ -38,6 +39,8 @@ async function serialSigner(path) {
|
||||||
psbtSentResolve: null,
|
psbtSentResolve: null,
|
||||||
xpubResolve: null,
|
xpubResolve: null,
|
||||||
seedWordPosition: 1,
|
seedWordPosition: 1,
|
||||||
|
seedWord: null,
|
||||||
|
showSeedWord: false,
|
||||||
showSeedDialog: false,
|
showSeedDialog: false,
|
||||||
// config: null,
|
// config: null,
|
||||||
|
|
||||||
|
|
@ -172,6 +175,10 @@ async function serialSigner(path) {
|
||||||
isAuthenticated: function () {
|
isAuthenticated: function () {
|
||||||
return this.hww.authenticated
|
return this.hww.authenticated
|
||||||
},
|
},
|
||||||
|
|
||||||
|
seedInputDone: function (mnemonic) {
|
||||||
|
this.hww.mnemonic = mnemonic
|
||||||
|
},
|
||||||
isAuthenticating: function () {
|
isAuthenticating: function () {
|
||||||
if (this.isAuthenticated()) return false
|
if (this.isAuthenticated()) return false
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
|
@ -374,6 +381,10 @@ async function serialSigner(path) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
closeSeedDialog: function () {
|
||||||
|
this.hww.seedWord = null
|
||||||
|
this.hww.showSeedWord = false
|
||||||
|
},
|
||||||
hwwConfirmNext: async function () {
|
hwwConfirmNext: async function () {
|
||||||
this.hww.confirm.outputIndex += 1
|
this.hww.confirm.outputIndex += 1
|
||||||
if (this.hww.confirm.outputIndex >= this.tx.outputs.length) {
|
if (this.hww.confirm.outputIndex >= this.tx.outputs.length) {
|
||||||
|
|
@ -403,7 +414,10 @@ async function serialSigner(path) {
|
||||||
},
|
},
|
||||||
hwwLogin: async function () {
|
hwwLogin: async function () {
|
||||||
try {
|
try {
|
||||||
await this.sendCommandSecure(COMMAND_PASSWORD, [this.hww.password])
|
await this.sendCommandSecure(COMMAND_PASSWORD, [
|
||||||
|
this.hww.password,
|
||||||
|
this.hww.passphrase
|
||||||
|
])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
|
|
@ -414,7 +428,9 @@ async function serialSigner(path) {
|
||||||
} finally {
|
} finally {
|
||||||
this.hww.showPasswordDialog = false
|
this.hww.showPasswordDialog = false
|
||||||
this.hww.password = null
|
this.hww.password = null
|
||||||
|
this.hww.passphrase = null
|
||||||
this.hww.showPassword = false
|
this.hww.showPassword = false
|
||||||
|
this.hww.showPassphrase = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleLoginResponse: function (res = '') {
|
handleLoginResponse: function (res = '') {
|
||||||
|
|
@ -449,6 +465,22 @@ async function serialSigner(path) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
hwwShowAddress: async function (path, address) {
|
||||||
|
try {
|
||||||
|
await this.sendCommandSecure(COMMAND_ADDRESS, [
|
||||||
|
this.network,
|
||||||
|
path,
|
||||||
|
address
|
||||||
|
])
|
||||||
|
} catch (error) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Failed to logout from Hardware Wallet!',
|
||||||
|
caption: `${error}`,
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
handleLogoutResponse: function (res = '') {
|
handleLogoutResponse: function (res = '') {
|
||||||
const authenticated = !(res.trim() === '1')
|
const authenticated = !(res.trim() === '1')
|
||||||
if (this.hww.authenticated && !authenticated) {
|
if (this.hww.authenticated && !authenticated) {
|
||||||
|
|
@ -796,21 +828,15 @@ async function serialSigner(path) {
|
||||||
await this.sendCommandSecure(COMMAND_SEED, [this.hww.seedWordPosition])
|
await this.sendCommandSecure(COMMAND_SEED, [this.hww.seedWordPosition])
|
||||||
},
|
},
|
||||||
handleShowSeedResponse: function (res = '') {
|
handleShowSeedResponse: function (res = '') {
|
||||||
const args = res.trim().split(' ')
|
const [pos, word] = res.trim().split(' ')
|
||||||
|
this.hww.seedWord = `${pos}. ${word}`
|
||||||
|
this.hww.seedWordPosition = pos
|
||||||
},
|
},
|
||||||
hwwRestore: async function () {
|
hwwRestore: async function () {
|
||||||
try {
|
try {
|
||||||
let mnemonicWithPassphrase = this.hww.mnemonic
|
|
||||||
if (
|
|
||||||
this.hww.hasPassphrase &&
|
|
||||||
this.hww.passphrase &&
|
|
||||||
this.hww.passphrase.length
|
|
||||||
) {
|
|
||||||
mnemonicWithPassphrase += '/' + this.hww.passphrase
|
|
||||||
}
|
|
||||||
await this.sendCommandSecure(COMMAND_RESTORE, [
|
await this.sendCommandSecure(COMMAND_RESTORE, [
|
||||||
this.hww.password,
|
this.hww.password,
|
||||||
mnemonicWithPassphrase
|
this.hww.mnemonic
|
||||||
])
|
])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
|
|
@ -822,7 +848,6 @@ async function serialSigner(path) {
|
||||||
} finally {
|
} finally {
|
||||||
this.hww.showRestoreDialog = false
|
this.hww.showRestoreDialog = false
|
||||||
this.hww.mnemonic = null
|
this.hww.mnemonic = null
|
||||||
this.hww.passphrase = null
|
|
||||||
this.hww.showMnemonic = false
|
this.hww.showMnemonic = false
|
||||||
this.hww.password = null
|
this.hww.password = null
|
||||||
this.hww.confirmedPassword = null
|
this.hww.confirmedPassword = null
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,13 @@
|
||||||
<q-badge v-if="props.row.isChange" color="orange" class="q-mr-md">
|
<q-badge v-if="props.row.isChange" color="orange" class="q-mr-md">
|
||||||
change
|
change
|
||||||
</q-badge>
|
</q-badge>
|
||||||
|
<q-badge
|
||||||
|
v-if="props.row.accountType === 'p2tr'"
|
||||||
|
color="yellow"
|
||||||
|
text-color="black"
|
||||||
|
>
|
||||||
|
taproot
|
||||||
|
</q-badge>
|
||||||
</div>
|
</div>
|
||||||
</q-td>
|
</q-td>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@
|
||||||
>New Receive Address</q-btn
|
>New Receive Address</q-btn
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
{{getAccountDescription(props.row.type)}}
|
{{getAccountDescription(props.row.type)}}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -124,15 +125,56 @@
|
||||||
|
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
<div class="row items-center no-wrap q-mb-md">
|
||||||
<div class="col-2 q-pr-lg">Master Pubkey:</div>
|
<div class="col-2 q-pr-lg">Master Pubkey:</div>
|
||||||
<div class="col-8">
|
<div class="col-7 q-pr-lg">
|
||||||
<q-input
|
<q-input v-model="props.row.masterpub" filled readonly />
|
||||||
v-model="props.row.masterpub"
|
</div>
|
||||||
filled
|
<div class="col-1">
|
||||||
readonly
|
<q-btn
|
||||||
type="textarea"
|
unelevated
|
||||||
/>
|
dense
|
||||||
|
size="md"
|
||||||
|
icon="qr_code"
|
||||||
|
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||||
|
@click="openQrCodeDialog(props.row.masterpub)"
|
||||||
|
></q-btn>
|
||||||
|
</div>
|
||||||
|
<div class="col-2 q-pr-lg">
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
color="grey"
|
||||||
|
icon="content_copy"
|
||||||
|
@click="copyText(props.row.masterpub)"
|
||||||
|
class="q-ml-sm"
|
||||||
|
></q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="props.row.meta?.xpub"
|
||||||
|
class="row items-center no-wrap q-mb-md"
|
||||||
|
>
|
||||||
|
<div class="col-2 q-pr-lg">XPub:</div>
|
||||||
|
<div class="col-7 q-pr-lg">
|
||||||
|
<q-input v-model="props.row.meta.xpub" filled readonly />
|
||||||
|
</div>
|
||||||
|
<div class="col-1">
|
||||||
|
<q-btn
|
||||||
|
unelevated
|
||||||
|
dense
|
||||||
|
size="md"
|
||||||
|
icon="qr_code"
|
||||||
|
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||||
|
@click="openQrCodeDialog(props.row.meta.xpub)"
|
||||||
|
></q-btn>
|
||||||
|
</div>
|
||||||
|
<div class="col-2 q-pr-lg">
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
color="grey"
|
||||||
|
icon="content_copy"
|
||||||
|
@click="copyText(props.row.meta.xpub)"
|
||||||
|
class="q-ml-sm"
|
||||||
|
></q-btn>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-2 q-pr-lg"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
<div class="row items-center no-wrap q-mb-md">
|
||||||
<div class="col-2 q-pr-lg">Last Address Index:</div>
|
<div class="col-2 q-pr-lg">Last Address Index:</div>
|
||||||
|
|
@ -229,4 +271,15 @@
|
||||||
</q-form>
|
</q-form>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
<q-dialog v-model="showQrCodeDialog" position="top">
|
||||||
|
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||||
|
<q-responsive :ratio="1" class="q-mx-xl q-mb-md">
|
||||||
|
<qrcode
|
||||||
|
:value="qrCodeValue"
|
||||||
|
:options="{width: 800}"
|
||||||
|
class="rounded-borders"
|
||||||
|
></qrcode>
|
||||||
|
</q-responsive>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ async function walletList(path) {
|
||||||
return {
|
return {
|
||||||
walletAccounts: [],
|
walletAccounts: [],
|
||||||
address: {},
|
address: {},
|
||||||
|
showQrCodeDialog: false,
|
||||||
|
qrCodeValue: null,
|
||||||
formDialog: {
|
formDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
|
|
||||||
|
|
@ -118,9 +120,11 @@ async function walletList(path) {
|
||||||
},
|
},
|
||||||
createWalletAccount: async function (data) {
|
createWalletAccount: async function (data) {
|
||||||
try {
|
try {
|
||||||
|
const meta = {accountPath: this.accountPath}
|
||||||
if (this.formDialog.useSerialPort) {
|
if (this.formDialog.useSerialPort) {
|
||||||
const {xpub, fingerprint} = await this.fetchXpubFromHww()
|
const {xpub, fingerprint} = await this.fetchXpubFromHww()
|
||||||
if (!xpub) return
|
if (!xpub) return
|
||||||
|
meta.xpub = xpub
|
||||||
const path = this.accountPath.substring(2)
|
const path = this.accountPath.substring(2)
|
||||||
const outputType = this.formDialog.addressType.id
|
const outputType = this.formDialog.addressType.id
|
||||||
if (outputType === 'sh') {
|
if (outputType === 'sh') {
|
||||||
|
|
@ -129,6 +133,7 @@ async function walletList(path) {
|
||||||
data.masterpub = `${outputType}([${fingerprint}/${path}]${xpub}/{0,1}/*)`
|
data.masterpub = `${outputType}([${fingerprint}/${path}]${xpub}/{0,1}/*)`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data.meta = JSON.stringify(meta)
|
||||||
const response = await LNbits.api.request(
|
const response = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
'/watchonly/api/v1/wallet',
|
'/watchonly/api/v1/wallet',
|
||||||
|
|
@ -233,7 +238,7 @@ async function walletList(path) {
|
||||||
const addressData = mapAddressesData(data)
|
const addressData = mapAddressesData(data)
|
||||||
|
|
||||||
addressData.note = `Shared on ${currentDateTime()}`
|
addressData.note = `Shared on ${currentDateTime()}`
|
||||||
const lastAcctiveAddress =
|
const lastActiveAddress =
|
||||||
this.addresses
|
this.addresses
|
||||||
.filter(
|
.filter(
|
||||||
a =>
|
a =>
|
||||||
|
|
@ -243,11 +248,11 @@ async function walletList(path) {
|
||||||
addressData.gapLimitExceeded =
|
addressData.gapLimitExceeded =
|
||||||
!addressData.isChange &&
|
!addressData.isChange &&
|
||||||
addressData.addressIndex >
|
addressData.addressIndex >
|
||||||
lastAcctiveAddress.addressIndex + DEFAULT_RECEIVE_GAP_LIMIT
|
lastActiveAddress.addressIndex + DEFAULT_RECEIVE_GAP_LIMIT
|
||||||
|
|
||||||
const wallet = this.walletAccounts.find(w => w.id === walletId) || {}
|
const wallet = this.walletAccounts.find(w => w.id === walletId) || {}
|
||||||
wallet.address_no = addressData.addressIndex
|
wallet.address_no = addressData.addressIndex
|
||||||
this.$emit('new-receive-address', addressData)
|
this.$emit('new-receive-address', {addressData, wallet})
|
||||||
},
|
},
|
||||||
showAddAccountDialog: function () {
|
showAddAccountDialog: function () {
|
||||||
this.formDialog.show = true
|
this.formDialog.show = true
|
||||||
|
|
@ -283,6 +288,20 @@ async function walletList(path) {
|
||||||
const addressType =
|
const addressType =
|
||||||
this.addressTypeOptions.find(t => t.id === value.id) || {}
|
this.addressTypeOptions.find(t => t.id === value.id) || {}
|
||||||
this.accountPath = addressType[`path${this.network}`]
|
this.accountPath = addressType[`path${this.network}`]
|
||||||
|
},
|
||||||
|
// todo: bad. base.js not present in custom components
|
||||||
|
copyText: function (text, message, position) {
|
||||||
|
var notify = this.$q.notify
|
||||||
|
Quasar.utils.copyToClipboard(text).then(function () {
|
||||||
|
notify({
|
||||||
|
message: message || 'Copied to clipboard!',
|
||||||
|
position: position || 'bottom'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
openQrCodeDialog: function (qrCodeValue) {
|
||||||
|
this.qrCodeValue = qrCodeValue
|
||||||
|
this.showQrCodeDialog = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
created: async function () {
|
||||||
|
|
|
||||||
2050
lnbits/extensions/watchonly/static/js/bip39-word-list.js
Normal file
2050
lnbits/extensions/watchonly/static/js/bip39-word-list.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -7,6 +7,7 @@ const watchOnly = async () => {
|
||||||
await history('static/components/history/history.html')
|
await history('static/components/history/history.html')
|
||||||
await utxoList('static/components/utxo-list/utxo-list.html')
|
await utxoList('static/components/utxo-list/utxo-list.html')
|
||||||
await feeRate('static/components/fee-rate/fee-rate.html')
|
await feeRate('static/components/fee-rate/fee-rate.html')
|
||||||
|
await seedInput('static/components/seed-input/seed-input.html')
|
||||||
await sendTo('static/components/send-to/send-to.html')
|
await sendTo('static/components/send-to/send-to.html')
|
||||||
await payment('static/components/payment/payment.html')
|
await payment('static/components/payment/payment.html')
|
||||||
await serialSigner('static/components/serial-signer/serial-signer.html')
|
await serialSigner('static/components/serial-signer/serial-signer.html')
|
||||||
|
|
@ -172,10 +173,6 @@ const watchOnly = async () => {
|
||||||
this.$refs.paymentRef.updateSignedPsbt(psbtBase64)
|
this.$refs.paymentRef.updateSignedPsbt(psbtBase64)
|
||||||
},
|
},
|
||||||
|
|
||||||
//################### SERIAL PORT ###################
|
|
||||||
|
|
||||||
//################### HARDWARE WALLET ###################
|
|
||||||
|
|
||||||
//################### UTXOs ###################
|
//################### UTXOs ###################
|
||||||
scanAllAddresses: async function () {
|
scanAllAddresses: async function () {
|
||||||
await this.refreshAddresses()
|
await this.refreshAddresses()
|
||||||
|
|
@ -227,7 +224,7 @@ const watchOnly = async () => {
|
||||||
newAddr => !this.addresses.find(a => a.address === newAddr.address)
|
newAddr => !this.addresses.find(a => a.address === newAddr.address)
|
||||||
)
|
)
|
||||||
|
|
||||||
const lastAcctiveAddress =
|
const lastActiveAddress =
|
||||||
uniqueAddresses.filter(a => !a.isChange && a.hasActivity).pop() ||
|
uniqueAddresses.filter(a => !a.isChange && a.hasActivity).pop() ||
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
@ -237,7 +234,7 @@ const watchOnly = async () => {
|
||||||
a.gapLimitExceeded =
|
a.gapLimitExceeded =
|
||||||
!a.isChange &&
|
!a.isChange &&
|
||||||
a.addressIndex >
|
a.addressIndex >
|
||||||
lastAcctiveAddress.addressIndex + DEFAULT_RECEIVE_GAP_LIMIT
|
lastActiveAddress.addressIndex + DEFAULT_RECEIVE_GAP_LIMIT
|
||||||
})
|
})
|
||||||
this.addresses.push(...uniqueAddresses)
|
this.addresses.push(...uniqueAddresses)
|
||||||
}
|
}
|
||||||
|
|
@ -380,6 +377,26 @@ const watchOnly = async () => {
|
||||||
showAddressDetails: function (addressData) {
|
showAddressDetails: function (addressData) {
|
||||||
this.openQrCodeDialog(addressData)
|
this.openQrCodeDialog(addressData)
|
||||||
},
|
},
|
||||||
|
showAddressDetailsWithConfirmation: function ({addressData, wallet}) {
|
||||||
|
this.showAddressDetails(addressData)
|
||||||
|
if (this.$refs.serialSigner.isConnected()) {
|
||||||
|
if (this.$refs.serialSigner.isAuthenticated()) {
|
||||||
|
if (wallet.meta?.accountPath) {
|
||||||
|
const branchIndex = addressData.isChange ? 1 : 0
|
||||||
|
const path =
|
||||||
|
wallet.meta.accountPath +
|
||||||
|
`/${branchIndex}/${addressData.addressIndex}`
|
||||||
|
this.$refs.serialSigner.hwwShowAddress(path, addressData.address)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Please login in order to confirm address on device',
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
initUtxos: function (addresses) {
|
initUtxos: function (addresses) {
|
||||||
if (!this.fetchedUtxos && addresses.length) {
|
if (!this.fetchedUtxos && addresses.length) {
|
||||||
this.fetchedUtxos = true
|
this.fetchedUtxos = true
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ const mapWalletAccount = function (o) {
|
||||||
'YYYY-MM-DD HH:mm'
|
'YYYY-MM-DD HH:mm'
|
||||||
)
|
)
|
||||||
: '',
|
: '',
|
||||||
|
meta: o.meta ? JSON.parse(o.meta) : null,
|
||||||
label: o.title,
|
label: o.title,
|
||||||
expanded: false
|
expanded: false
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ const PSBT_BASE64_PREFIX = 'cHNidP8'
|
||||||
const COMMAND_PING = '/ping'
|
const COMMAND_PING = '/ping'
|
||||||
const COMMAND_PASSWORD = '/password'
|
const COMMAND_PASSWORD = '/password'
|
||||||
const COMMAND_PASSWORD_CLEAR = '/password-clear'
|
const COMMAND_PASSWORD_CLEAR = '/password-clear'
|
||||||
|
const COMMAND_ADDRESS = '/address'
|
||||||
const COMMAND_SEND_PSBT = '/psbt'
|
const COMMAND_SEND_PSBT = '/psbt'
|
||||||
const COMMAND_SIGN_PSBT = '/sign'
|
const COMMAND_SIGN_PSBT = '/sign'
|
||||||
const COMMAND_HELP = '/help'
|
const COMMAND_HELP = '/help'
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,36 @@
|
||||||
<p>
|
<p>
|
||||||
Onchain Wallet (watch-only) extension uses mempool.space<br />
|
Onchain Wallet (watch-only) extension uses mempool.space<br />
|
||||||
For use with "account Extended Public Key"
|
For use with "account Extended Public Key"
|
||||||
<a href="https://iancoleman.io/bip39/">https://iancoleman.io/bip39/</a>
|
<a
|
||||||
|
href="https://iancoleman.io/bip39/"
|
||||||
|
target="_blank"
|
||||||
|
style="color: unset"
|
||||||
|
>https://iancoleman.io/bip39/</a
|
||||||
|
>
|
||||||
|
<br />
|
||||||
|
Flash binaries
|
||||||
|
<a
|
||||||
|
href="https://lnbits.github.io/hardware-wallet"
|
||||||
|
target="_blank"
|
||||||
|
style="color: unset"
|
||||||
|
>directly from browser</a
|
||||||
|
>
|
||||||
<small>
|
<small>
|
||||||
<br />Created by,
|
<br />Created by,
|
||||||
<a target="_blank" class="text-white" href="https://github.com/arcbtc"
|
<a target="_blank" style="color: unset" href="https://github.com/arcbtc"
|
||||||
>Ben Arc</a
|
>Ben Arc</a
|
||||||
>
|
>
|
||||||
(using,
|
(using,
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="text-white"
|
style="color: unset"
|
||||||
href="https://github.com/diybitcoinhardware/embit"
|
href="https://github.com/diybitcoinhardware/embit"
|
||||||
>Embit</a
|
>Embit</a
|
||||||
></small
|
></small
|
||||||
>)
|
>)
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<a target="_blank" href="/docs#/watchonly" class="text-white"
|
<a target="_blank" href="/docs#/watchonly" style="color: unset"
|
||||||
>Swagger REST API Documentation</a
|
>Swagger REST API Documentation</a
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
:addresses="addresses"
|
:addresses="addresses"
|
||||||
:serial-signer-ref="$refs.serialSigner"
|
:serial-signer-ref="$refs.serialSigner"
|
||||||
@accounts-update="updateAccounts"
|
@accounts-update="updateAccounts"
|
||||||
@new-receive-address="showAddressDetails"
|
@new-receive-address="showAddressDetailsWithConfirmation"
|
||||||
>
|
>
|
||||||
</wallet-list>
|
</wallet-list>
|
||||||
|
|
||||||
|
|
@ -149,6 +149,7 @@
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<h6 class="text-subtitle1 q-my-none">
|
<h6 class="text-subtitle1 q-my-none">
|
||||||
{{SITE_TITLE}} Onchain Wallet (watch-only) Extension
|
{{SITE_TITLE}} Onchain Wallet (watch-only) Extension
|
||||||
|
<small>(v0.2)</small>
|
||||||
</h6>
|
</h6>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
|
|
@ -238,6 +239,8 @@
|
||||||
<script src="{{ url_for('watchonly_static', path='js/tables.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='js/tables.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='js/map.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='js/map.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='js/utils.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='js/utils.js') }}"></script>
|
||||||
|
<script src="{{ url_for('watchonly_static', path='js/bip39-word-list.js') }}"></script>
|
||||||
|
|
||||||
<script src="{{ url_for('watchonly_static', path='components/my-checkbox/my-checkbox.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/my-checkbox/my-checkbox.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/wallet-config/wallet-config.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/wallet-config/wallet-config.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/wallet-list/wallet-list.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/wallet-list/wallet-list.js') }}"></script>
|
||||||
|
|
@ -245,10 +248,12 @@
|
||||||
<script src="{{ url_for('watchonly_static', path='components/history/history.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/history/history.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/utxo-list/utxo-list.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/utxo-list/utxo-list.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/fee-rate/fee-rate.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/fee-rate/fee-rate.js') }}"></script>
|
||||||
|
<script src="{{ url_for('watchonly_static', path='components/seed-input/seed-input.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/send-to/send-to.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/send-to/send-to.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/payment/payment.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/payment/payment.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/serial-signer/serial-signer.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/serial-signer/serial-signer.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='components/serial-port-config/serial-port-config.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='components/serial-port-config/serial-port-config.js') }}"></script>
|
||||||
|
|
||||||
<script src="{{ url_for('watchonly_static', path='js/crypto/noble-secp256k1.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='js/crypto/noble-secp256k1.js') }}"></script>
|
||||||
<script src="{{ url_for('watchonly_static', path='js/crypto/aes.js') }}"></script>
|
<script src="{{ url_for('watchonly_static', path='js/crypto/aes.js') }}"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ async def api_wallet_create_or_update(
|
||||||
address_no=-1, # so fresh address on empty wallet can get address with index 0
|
address_no=-1, # so fresh address on empty wallet can get address with index 0
|
||||||
balance=0,
|
balance=0,
|
||||||
network=network["name"],
|
network=network["name"],
|
||||||
|
meta=data.meta,
|
||||||
)
|
)
|
||||||
|
|
||||||
wallets = await get_watch_wallets(w.wallet.user, network["name"])
|
wallets = await get_watch_wallets(w.wallet.user, network["name"])
|
||||||
|
|
@ -137,7 +138,7 @@ async def api_wallet_delete(wallet_id, w: WalletTypeInfo = Depends(require_admin
|
||||||
await delete_watch_wallet(wallet_id)
|
await delete_watch_wallet(wallet_id)
|
||||||
await delete_addresses_for_wallet(wallet_id)
|
await delete_addresses_for_wallet(wallet_id)
|
||||||
|
|
||||||
raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
return "", HTTPStatus.NO_CONTENT
|
||||||
|
|
||||||
|
|
||||||
#############################ADDRESSES##########################
|
#############################ADDRESSES##########################
|
||||||
|
|
@ -268,7 +269,6 @@ async def api_psbt_create(
|
||||||
for i, inp in enumerate(inputs_extra):
|
for i, inp in enumerate(inputs_extra):
|
||||||
psbt.inputs[i].bip32_derivations = inp["bip32_derivations"]
|
psbt.inputs[i].bip32_derivations = inp["bip32_derivations"]
|
||||||
psbt.inputs[i].non_witness_utxo = inp.get("non_witness_utxo", None)
|
psbt.inputs[i].non_witness_utxo = inp.get("non_witness_utxo", None)
|
||||||
print("### ", inp.get("non_witness_utxo", None))
|
|
||||||
|
|
||||||
outputs_extra = []
|
outputs_extra = []
|
||||||
bip32_derivations = {}
|
bip32_derivations = {}
|
||||||
|
|
@ -343,11 +343,8 @@ async def api_tx_broadcast(
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
r = await client.post(endpoint + "/api/tx", data=data.tx_hex)
|
r = await client.post(endpoint + "/api/tx", data=data.tx_hex)
|
||||||
tx_id = r.text
|
tx_id = r.text
|
||||||
print("### broadcast tx_id: ", tx_id)
|
|
||||||
return tx_id
|
return tx_id
|
||||||
# return "0f0f0f0f0f0f0f0f0f0f0f00f0f0f0f0f0f0f0f0f0f00f0f0f0f0f0f0.mock.transaction.id"
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("### broadcast error: ", str(e))
|
|
||||||
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail=str(e))
|
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue