feat: ui/ux improvements
This commit is contained in:
parent
9c343acf86
commit
7f32139bcd
3 changed files with 87 additions and 43 deletions
|
|
@ -48,7 +48,8 @@ new Vue({
|
||||||
password: null,
|
password: null,
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
showPasswordDialog: false,
|
showPasswordDialog: false,
|
||||||
showConsole: false
|
showConsole: false,
|
||||||
|
psbtSent: false
|
||||||
},
|
},
|
||||||
|
|
||||||
formDialog: {
|
formDialog: {
|
||||||
|
|
@ -564,6 +565,7 @@ new Vue({
|
||||||
wallet.adminkey,
|
wallet.adminkey,
|
||||||
{tx_hex: this.payment.signedTxHex}
|
{tx_hex: this.payment.signedTxHex}
|
||||||
)
|
)
|
||||||
|
this.payment.sentTxId = data
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
message: 'Transaction broadcasted!',
|
message: 'Transaction broadcasted!',
|
||||||
|
|
@ -571,6 +573,7 @@ new Vue({
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.payment.sentTxId = null
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Failed to broadcast!',
|
message: 'Failed to broadcast!',
|
||||||
|
|
@ -695,6 +698,7 @@ new Vue({
|
||||||
else if (msg[0] == COMMAND_PASSWORD) this.handleLoginResponse(msg[1])
|
else if (msg[0] == COMMAND_PASSWORD) this.handleLoginResponse(msg[1])
|
||||||
else if (msg[0] == COMMAND_PASSWORD_CLEAR)
|
else if (msg[0] == COMMAND_PASSWORD_CLEAR)
|
||||||
this.handleLogoutResponse(msg[1])
|
this.handleLogoutResponse(msg[1])
|
||||||
|
else if (msg[0] == COMMAND_SEND_PSBT) this.handleSendPsbtResponse(msg[1])
|
||||||
else console.log('### handleSerialPortResponse', value)
|
else console.log('### handleSerialPortResponse', value)
|
||||||
},
|
},
|
||||||
updateSerialPortConsole: function (value) {
|
updateSerialPortConsole: function (value) {
|
||||||
|
|
@ -708,6 +712,19 @@ new Vue({
|
||||||
console.log('### sharePsbtWithAnimatedQRCode')
|
console.log('### sharePsbtWithAnimatedQRCode')
|
||||||
},
|
},
|
||||||
//################### HARDWARE WALLET ###################
|
//################### HARDWARE WALLET ###################
|
||||||
|
hwwShowPasswordDialog: async function () {
|
||||||
|
try {
|
||||||
|
this.hww.showPasswordDialog = true
|
||||||
|
await this.serial.writer.write(COMMAND_PASSWORD + '\n')
|
||||||
|
} catch (error) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Failed to connect to Hardware Wallet!',
|
||||||
|
caption: `${error}`,
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
hwwLogin: async function () {
|
hwwLogin: async function () {
|
||||||
try {
|
try {
|
||||||
await this.serial.writer.write(
|
await this.serial.writer.write(
|
||||||
|
|
@ -716,7 +733,7 @@ new Vue({
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Failed to send password to hardware wallet!',
|
message: 'Failed to send password to Hardware Wallet!',
|
||||||
caption: `${error}`,
|
caption: `${error}`,
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
|
|
@ -767,7 +784,7 @@ new Vue({
|
||||||
if (this.hww.authenticated) {
|
if (this.hww.authenticated) {
|
||||||
this.hwwLogout()
|
this.hwwLogout()
|
||||||
} else {
|
} else {
|
||||||
this.hww.showPasswordDialog = true
|
this.hwwShowPasswordDialog()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hwwSendPsbt: async function () {
|
hwwSendPsbt: async function () {
|
||||||
|
|
@ -789,6 +806,9 @@ new Vue({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleSendPsbtResponse: function (res = '') {
|
||||||
|
this.hww.psbtSent = true
|
||||||
|
},
|
||||||
hwwSignPsbt: async function () {
|
hwwSignPsbt: async function () {
|
||||||
try {
|
try {
|
||||||
await this.serial.writer.write(COMMAND_SIGN_PSBT + '\n')
|
await this.serial.writer.write(COMMAND_SIGN_PSBT + '\n')
|
||||||
|
|
|
||||||
|
|
@ -1128,12 +1128,13 @@
|
||||||
v-if="!hww.authenticated"
|
v-if="!hww.authenticated"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
@click="hww.showPasswordDialog = true"
|
@click="hwwShowPasswordDialog()"
|
||||||
>
|
>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label>Login</q-item-label>
|
<q-item-label>Login</q-item-label>
|
||||||
<q-item-label caption
|
<q-item-label caption
|
||||||
>Enter password for HWW.</q-item-label
|
>Enter password for Hardware
|
||||||
|
Wallet.</q-item-label
|
||||||
>
|
>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
|
|
@ -1155,14 +1156,8 @@
|
||||||
:disabled="!hww.authenticated"
|
:disabled="!hww.authenticated"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
@click="hww.showPasswordDialog = true"
|
@click="hwwShowPasswordDialog()"
|
||||||
>
|
>
|
||||||
<q-item-section>
|
|
||||||
<q-item-label>Sign</q-item-label>
|
|
||||||
<q-item-label caption
|
|
||||||
>Sign PSBT on Hardware Wallet.</q-item-label
|
|
||||||
>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable v-close-popup>
|
<q-item clickable v-close-popup>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
|
|
@ -1234,25 +1229,62 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<q-badge color="blue"
|
<q-badge
|
||||||
|
v-if="hww.psbtSent"
|
||||||
|
color="yellow"
|
||||||
|
text-color="black"
|
||||||
|
class="text-subtitle1"
|
||||||
>Please check transaction data on the Hardware Wallet
|
>Please check transaction data on the Hardware Wallet
|
||||||
Display</q-badge
|
display</q-badge
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<q-btn
|
<q-btn
|
||||||
|
v-if="hww.psbtSent"
|
||||||
@click="hwwSignPsbt()"
|
@click="hwwSignPsbt()"
|
||||||
unelevated
|
unelevated
|
||||||
color="green"
|
color="green"
|
||||||
class="float-right text-subtitle1"
|
class="float-right"
|
||||||
>Confirm</q-btn
|
>Confirm</q-btn
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="payment.psbtBase64Signed"
|
||||||
|
class="row items-center no-wrap q-mb-md"
|
||||||
|
>
|
||||||
|
<div class="col-3 q-pr-lg"></div>
|
||||||
|
|
||||||
|
<div class="col-9">
|
||||||
|
<q-input
|
||||||
|
v-model="payment.psbtBase64Signed"
|
||||||
|
filled
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<q-separator
|
<q-separator
|
||||||
v-if="payment.signedTx"
|
v-if="payment.signedTx"
|
||||||
class="q-mb-md"
|
class="q-mb-md"
|
||||||
></q-separator>
|
></q-separator>
|
||||||
|
<div
|
||||||
|
v-if="payment.psbtBase64Signed"
|
||||||
|
class="row items-center no-wrap q-mb-md"
|
||||||
|
>
|
||||||
|
<div class="col-3 q-pr-lg">
|
||||||
|
<q-btn
|
||||||
|
v-if="payment.signedTx"
|
||||||
|
@click="broadcastTransaction()"
|
||||||
|
unelevated
|
||||||
|
color="secondary"
|
||||||
|
>Send Payment</q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="col-9">
|
||||||
|
<span class="text-subtitle2">Transaction Details</span>
|
||||||
|
<q-separator></q-separator>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="payment.signedTx"
|
v-if="payment.signedTx"
|
||||||
class="row items-center no-wrap q-mb-md"
|
class="row items-center no-wrap q-mb-md"
|
||||||
|
|
@ -1276,6 +1308,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-separator class="q-mb-lg"></q-separator>
|
<q-separator class="q-mb-lg"></q-separator>
|
||||||
|
<span class="text-subtitle2">Outputs</span>
|
||||||
|
<q-separator class="q-mb-lg"></q-separator>
|
||||||
<div
|
<div
|
||||||
v-for="out in payment.signedTx.outputs"
|
v-for="out in payment.signedTx.outputs"
|
||||||
class="row items-center no-wrap q-mb-sm"
|
class="row items-center no-wrap q-mb-sm"
|
||||||
|
|
@ -1292,28 +1326,18 @@
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<q-separator
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="payment.psbtBase64Signed"
|
|
||||||
class="row items-center no-wrap q-mb-md"
|
|
||||||
>
|
|
||||||
<div class="col-3 q-pr-lg">
|
|
||||||
<q-btn
|
|
||||||
v-if="payment.signedTx"
|
|
||||||
@click="broadcastTransaction()"
|
|
||||||
unelevated
|
|
||||||
color="secondary"
|
|
||||||
>Send Payment</q-btn
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="col-9">
|
|
||||||
<q-input
|
|
||||||
v-if="payment.sentTxId"
|
v-if="payment.sentTxId"
|
||||||
v-model="payment.sentTxId"
|
class="q-mb-lg"
|
||||||
filled
|
></q-separator>
|
||||||
readonly
|
<div
|
||||||
/>
|
v-if="payment.sentTxId"
|
||||||
|
class="row items-center no-wrap q-mb-sm"
|
||||||
|
>
|
||||||
|
<div class="col-12">
|
||||||
|
<q-input v-model="payment.sentTxId" filled readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
||||||
|
|
@ -311,10 +311,9 @@ async def api_psbt_extract_tx(
|
||||||
|
|
||||||
|
|
||||||
@watchonly_ext.post("/api/v1/tx")
|
@watchonly_ext.post("/api/v1/tx")
|
||||||
async def api_psbt_extract_tx(
|
async def api_tx_broadcast(
|
||||||
data: BroadcastTransaction, w: WalletTypeInfo = Depends(require_admin_key)
|
data: BroadcastTransaction, w: WalletTypeInfo = Depends(require_admin_key)
|
||||||
):
|
):
|
||||||
print("### data", data)
|
|
||||||
try:
|
try:
|
||||||
config = await get_config(w.wallet.user)
|
config = await get_config(w.wallet.user)
|
||||||
if not config:
|
if not config:
|
||||||
|
|
@ -322,11 +321,12 @@ async def api_psbt_extract_tx(
|
||||||
"Cannot broadcast transaction. Mempool endpoint not defined!"
|
"Cannot broadcast transaction. Mempool endpoint not defined!"
|
||||||
)
|
)
|
||||||
x = bytes.fromhex(data.tx_hex)
|
x = bytes.fromhex(data.tx_hex)
|
||||||
print("### x", x)
|
|
||||||
async with httpx.AsyncClient() as client:
|
# async with httpx.AsyncClient() as client:
|
||||||
r = await client.post(config.mempool_endpoint + "/api/tx", data=data.tx_hex)
|
# r = await client.post(config.mempool_endpoint + "/api/tx", data=data.tx_hex)
|
||||||
tx_id = r.text
|
# tx_id = r.text
|
||||||
return tx_id
|
# return tx_id
|
||||||
|
return "0f0f0f0f0f0f0f0f0f0f0f00f0f0f0f0f0f0f0f0f0f00f0f0f0f0f0f0.mock.transaction.id"
|
||||||
except Exception as e:
|
except Exception as 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