feat: update tx size in real time

This commit is contained in:
Vlad Stan 2022-07-26 16:31:39 +03:00
parent cec44f4a99
commit 24d162f3fc
4 changed files with 34 additions and 14 deletions

View File

@ -15,6 +15,7 @@
:tx-size="txSizeNoChange" :tx-size="txSizeNoChange"
:selected-amount="selectedAmount" :selected-amount="selectedAmount"
:sats-denominated="sats_denominated" :sats-denominated="sats_denominated"
@update:outputs="handleOutputsChange"
></send-to> ></send-to>
<!-- <div class="row items-center no-wrap q-mb-md"> <!-- <div class="row items-center no-wrap q-mb-md">
<div class="col-12"> <div class="col-12">
@ -152,6 +153,7 @@
<div class="col-12"> <div class="col-12">
<q-separator class="q-mb-md"></q-separator> <q-separator class="q-mb-md"></q-separator>
<utxo-list <utxo-list
ref="utxoList"
:utxos="utxos" :utxos="utxos"
:selectable="true" :selectable="true"
:payed-amount="totalPayedAmount" :payed-amount="totalPayedAmount"

View File

@ -162,6 +162,9 @@ async function payment(path) {
} }
this.selectChangeAddress(this.changeWallet) this.selectChangeAddress(this.changeWallet)
}, },
handleOutputsChange: function () {
this.$refs.utxoList.applyUtxoSelectionMode()
},
getTotalPaymentAmount: function () { getTotalPaymentAmount: function () {
return this.sendToList.reduce((t, a) => t + (a.amount || 0), 0) return this.sendToList.reduce((t, a) => t + (a.amount || 0), 0)
} }

View File

@ -30,6 +30,7 @@
type="text" type="text"
label="Address" label="Address"
:rules="[val => !!val || 'Field is required']" :rules="[val => !!val || 'Field is required']"
@input="handleOutputsChange"
></q-input> ></q-input>
</div> </div>
<div class="col-3 q-pr-lg"> <div class="col-3 q-pr-lg">
@ -40,7 +41,8 @@
type="number" type="number"
step="1" step="1"
label="Amount (sats)" label="Amount (sats)"
:rules="[val => !!val || 'Field is required', val => +val > DUST_LIMIT || 'Amount to small (below dust limit)'] " :rules="[val => !!val || 'Field is required', val => +val > DUST_LIMIT || 'Amount to small (below dust limit)']"
@input="handleOutputsChange"
></q-input> ></q-input>
</div> </div>
<div class="col-1"> <div class="col-1">
@ -55,24 +57,31 @@
<q-tr> <q-tr>
<q-td colspan="100%"> <q-td colspan="100%">
<div class="row items-center no-wrap"> <div class="row items-center no-wrap">
<div class="col-3 q-pr-lg"> <div class="col-3 q-pr-lg"></div>
<q-btn outline color="grey" @click="addPaymentAddress"
>Add Send Address</q-btn
>
</div>
<div class="col-4 q-pr-lg"></div> <div class="col-4 q-pr-lg"></div>
<div class="col-5">
<div class="float-right">
<span class="text-weight-bold">Payed Amount: </span>
<q-badge class="text-subtitle2 q-ml-lg" color="blue">
{{satBtc(getTotalPaymentAmount())}}
</q-badge>
</div>
</div>
</div> </div>
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
</q-table> </q-table>
<div class="row items-center no-wrap">
<div class="col-3 q-pr-lg">
<q-btn
unelevated
color="secondary"
@click="addPaymentAddress"
class="btn-full"
>Add</q-btn
>
</div>
<div class="col-9">
<div class="float-right">
<span>Payed Amount: </span>
<span class="text-subtitle2 q-ml-lg">
{{satBtc(getTotalPaymentAmount())}}
</span>
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -48,12 +48,14 @@ async function sendTo(path) {
}, },
addPaymentAddress: function () { addPaymentAddress: function () {
this.dataLocal.push({address: '', amount: undefined}) this.dataLocal.push({address: '', amount: undefined})
this.handleOutputsChange()
}, },
deletePaymentAddress: function (v) { deletePaymentAddress: function (v) {
const index = this.dataLocal.indexOf(v) const index = this.dataLocal.indexOf(v)
if (index !== -1) { if (index !== -1) {
this.dataLocal.splice(index, 1) this.dataLocal.splice(index, 1)
} }
this.handleOutputsChange()
}, },
sendMaxToAddress: function (paymentAddress = {}) { sendMaxToAddress: function (paymentAddress = {}) {
@ -65,6 +67,10 @@ async function sendTo(path) {
0, 0,
inputAmount - payedAmount - feeValue inputAmount - payedAmount - feeValue
) )
this.handleOutputsChange()
},
handleOutputsChange: function () {
this.$emit('update:outputs')
}, },
getTotalPaymentAmount: function () { getTotalPaymentAmount: function () {
return this.dataLocal.reduce((t, a) => t + (a.amount || 0), 0) return this.dataLocal.reduce((t, a) => t + (a.amount || 0), 0)