feat: show hardware device Xpub option
This commit is contained in:
parent
a50fc2d4ae
commit
ae479ee0d0
4 changed files with 118 additions and 7 deletions
|
|
@ -3,9 +3,32 @@
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
<div class="row items-center no-wrap q-mb-md">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<q-btn unelevated color="primary" @click="formDialog.show = true"
|
<q-btn-dropdown
|
||||||
>Add Wallet Account
|
split
|
||||||
</q-btn>
|
unelevated
|
||||||
|
label="Add Wallet Account"
|
||||||
|
color="primary"
|
||||||
|
@click="showAddAccountDialog"
|
||||||
|
>
|
||||||
|
<q-list>
|
||||||
|
<q-item @click="showAddAccountDialog" clickable v-close-popup>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>New Account</q-item-label>
|
||||||
|
<q-item-label caption
|
||||||
|
>Enter account Xpub or Descriptor</q-item-label
|
||||||
|
>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item @click="getXpubFromDevice" clickable v-close-popup>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>From Hardware Device</q-item-label>
|
||||||
|
<q-item-label caption>
|
||||||
|
Get Xpub from a Hardware Device</q-item-label
|
||||||
|
>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-btn-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-auto q-pr-lg"></div>
|
<div class="col-auto q-pr-lg"></div>
|
||||||
|
|
@ -158,8 +181,8 @@
|
||||||
type="text"
|
type="text"
|
||||||
label="Title"
|
label="Title"
|
||||||
></q-input>
|
></q-input>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
v-if="!formDialog.useSerialPort"
|
||||||
filled
|
filled
|
||||||
type="textarea"
|
type="textarea"
|
||||||
v-model="formDialog.data.masterpub"
|
v-model="formDialog.data.masterpub"
|
||||||
|
|
@ -167,13 +190,33 @@
|
||||||
autogrow
|
autogrow
|
||||||
label="Account Extended Public Key; xpub, ypub, zpub; Bitcoin Descriptor"
|
label="Account Extended Public Key; xpub, ypub, zpub; Bitcoin Descriptor"
|
||||||
></q-input>
|
></q-input>
|
||||||
|
<q-select
|
||||||
|
v-if="formDialog.useSerialPort"
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
emit-value
|
||||||
|
v-model="formDialog.addressType"
|
||||||
|
:options="addressTypeOptions"
|
||||||
|
label="Address Type"
|
||||||
|
@input="handleAddressTypeChanged"
|
||||||
|
></q-select>
|
||||||
|
|
||||||
|
<q-input
|
||||||
|
v-if="formDialog.useSerialPort"
|
||||||
|
filled
|
||||||
|
type="text"
|
||||||
|
v-model="formDialog.data.accountPath"
|
||||||
|
height="50px"
|
||||||
|
autogrow
|
||||||
|
label="Account Path"
|
||||||
|
></q-input>
|
||||||
|
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
color="primary"
|
color="primary"
|
||||||
:disable="
|
:disable="
|
||||||
formDialog.data.masterpub == null ||
|
(formDialog.data.masterpub == null && formDialog.data.accountPath == null)||
|
||||||
formDialog.data.title == null"
|
formDialog.data.title == null"
|
||||||
type="submit"
|
type="submit"
|
||||||
>Add Watch-Only Account</q-btn
|
>Add Watch-Only Account</q-btn
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,51 @@ async function walletList(path) {
|
||||||
name: 'wallet-list',
|
name: 'wallet-list',
|
||||||
template,
|
template,
|
||||||
|
|
||||||
props: ['adminkey', 'inkey', 'sats-denominated', 'addresses', 'network'],
|
props: [
|
||||||
|
'adminkey',
|
||||||
|
'inkey',
|
||||||
|
'sats-denominated',
|
||||||
|
'addresses',
|
||||||
|
'network',
|
||||||
|
'serial-signer-ref'
|
||||||
|
],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
walletAccounts: [],
|
walletAccounts: [],
|
||||||
address: {},
|
address: {},
|
||||||
formDialog: {
|
formDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
|
addressType: {
|
||||||
|
label: 'Pay-to-witness-pubkey-hash scripts (P2WPKH)',
|
||||||
|
value: 'wpkh'
|
||||||
|
},
|
||||||
|
useSerialPort: false,
|
||||||
data: {}
|
data: {}
|
||||||
},
|
},
|
||||||
filter: '',
|
filter: '',
|
||||||
|
addressTypeOptions: [
|
||||||
|
{
|
||||||
|
label: 'Pay-to-pubkey-hash scripts (P2PKH)',
|
||||||
|
value: 'pkh',
|
||||||
|
path: "m/44'/0'/0'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Pay-to-witness-pubkey-hash scripts (P2WPKH)',
|
||||||
|
value: 'wpkh',
|
||||||
|
path: "m/84'/0'/0'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Pay-to-script-hash scripts (P2SH-P2WPKH)',
|
||||||
|
value: 'sh',
|
||||||
|
path: "m/49'/0'/0'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Pay-to-taproot outputs (P2TR)',
|
||||||
|
value: 'tr',
|
||||||
|
path: "m/86'/0'/0'"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
walletsTable: {
|
walletsTable: {
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
|
|
@ -173,6 +208,38 @@ async function walletList(path) {
|
||||||
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)
|
||||||
|
},
|
||||||
|
showAddAccountDialog: function() {
|
||||||
|
this.formDialog.show = true
|
||||||
|
this.formDialog.useSerialPort = false
|
||||||
|
},
|
||||||
|
getXpubFromDevice: async function () {
|
||||||
|
this.handleAddressTypeChanged('wpkh')
|
||||||
|
try {
|
||||||
|
if (!this.serialSignerRef.isConnected()) {
|
||||||
|
const portOpen = await this.serialSignerRef.openSerialPort()
|
||||||
|
if (!portOpen) return
|
||||||
|
}
|
||||||
|
if (!this.serialSignerRef.isAuthenticated()) {
|
||||||
|
await this.serialSignerRef.hwwShowPasswordDialog()
|
||||||
|
const authenticated = await this.serialSignerRef.isAuthenticating()
|
||||||
|
if (!authenticated) return
|
||||||
|
}
|
||||||
|
this.formDialog.show = true
|
||||||
|
this.formDialog.useSerialPort = true
|
||||||
|
} catch (error) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Cannot fetch Xpub!',
|
||||||
|
caption: `${error}`,
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleAddressTypeChanged: function (value) {
|
||||||
|
const addressType =
|
||||||
|
this.addressTypeOptions.find(t => t.value === value) || {}
|
||||||
|
this.formDialog.data.accountPath = addressType.path
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
created: async function () {
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ const watchOnly = async () => {
|
||||||
hostname: this.mempoolHostname
|
hostname: this.mempoolHostname
|
||||||
})
|
})
|
||||||
const fn = async () => {
|
const fn = async () => {
|
||||||
if (!accounts.find(w => (w.id === addrData.wallet))) return []
|
if (!accounts.find(w => w.id === addrData.wallet)) return []
|
||||||
return addressesAPI.getAddressTxs({
|
return addressesAPI.getAddressTxs({
|
||||||
address: addrData.address
|
address: addrData.address
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
:sats-denominated="config.sats_denominated"
|
:sats-denominated="config.sats_denominated"
|
||||||
:network="config.network"
|
:network="config.network"
|
||||||
:addresses="addresses"
|
:addresses="addresses"
|
||||||
|
:serial-signer-ref="$refs.serialSigner"
|
||||||
@accounts-update="updateAccounts"
|
@accounts-update="updateAccounts"
|
||||||
@new-receive-address="showAddressDetails"
|
@new-receive-address="showAddressDetails"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue