mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-28 09:40:59 +02:00
feat: allow external signed PSBT
This commit is contained in:
parent
3ad0463dfe
commit
8b0c004883
@ -272,15 +272,35 @@ async function payment(path) {
|
|||||||
this.showChecking = false
|
this.showChecking = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fetchUtxoHexForPsbt: async function (psbtBase64) {
|
||||||
|
if (this.tx?.inputs && this.tx?.inputs.length) return this.tx.inputs
|
||||||
|
|
||||||
|
const {data: psbtUtxos} = await LNbits.api.request(
|
||||||
|
'PUT',
|
||||||
|
'/watchonly/api/v1/psbt/utxos',
|
||||||
|
this.adminkey,
|
||||||
|
{psbtBase64}
|
||||||
|
)
|
||||||
|
|
||||||
|
const inputs = []
|
||||||
|
for (const utxo of psbtUtxos) {
|
||||||
|
const txHex = await this.fetchTxHex(utxo.tx_id)
|
||||||
|
inputs.push({tx_hex: txHex})
|
||||||
|
}
|
||||||
|
return inputs
|
||||||
|
},
|
||||||
extractTxFromPsbt: async function (psbtBase64) {
|
extractTxFromPsbt: async function (psbtBase64) {
|
||||||
try {
|
try {
|
||||||
|
const inputs = await this.fetchUtxoHexForPsbt(psbtBase64)
|
||||||
|
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'PUT',
|
'PUT',
|
||||||
'/watchonly/api/v1/psbt/extract',
|
'/watchonly/api/v1/psbt/extract',
|
||||||
this.adminkey,
|
this.adminkey,
|
||||||
{
|
{
|
||||||
psbtBase64,
|
psbtBase64,
|
||||||
inputs: this.tx.inputs,
|
inputs,
|
||||||
network: this.network
|
network: this.network
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -54,7 +54,10 @@ const watchOnly = async () => {
|
|||||||
showPayment: false,
|
showPayment: false,
|
||||||
fetchedUtxos: false,
|
fetchedUtxos: false,
|
||||||
utxosFilter: '',
|
utxosFilter: '',
|
||||||
network: null
|
network: null,
|
||||||
|
|
||||||
|
showEnterSignedPsbt: false,
|
||||||
|
signedBase64Psbt: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -173,6 +176,15 @@ const watchOnly = async () => {
|
|||||||
this.$refs.paymentRef.updateSignedPsbt(psbtBase64)
|
this.$refs.paymentRef.updateSignedPsbt(psbtBase64)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showEnterSignedPsbtDialog: function () {
|
||||||
|
this.showEnterSignedPsbt = true
|
||||||
|
},
|
||||||
|
|
||||||
|
checkPsbt: function () {
|
||||||
|
console.log('### checkPsbt', this.signedBase64Psbt)
|
||||||
|
this.$refs.paymentRef.updateSignedPsbt(this.signedBase64Psbt)
|
||||||
|
},
|
||||||
|
|
||||||
//################### UTXOs ###################
|
//################### UTXOs ###################
|
||||||
scanAllAddresses: async function () {
|
scanAllAddresses: async function () {
|
||||||
await this.refreshAddresses()
|
await this.refreshAddresses()
|
||||||
|
@ -52,14 +52,37 @@
|
|||||||
></q-spinner>
|
></q-spinner>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-sm-5 q-pr-md">
|
<div class="col-md-3 col-sm-5 q-pr-md">
|
||||||
<q-btn
|
<q-btn-dropdown
|
||||||
v-if="!showPayment"
|
split
|
||||||
unelevated
|
unelevated
|
||||||
|
label="New Payment"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
class="btn-full"
|
class="btn-full"
|
||||||
@click="goToPaymentView"
|
@click="goToPaymentView"
|
||||||
>New Payment</q-btn
|
|
||||||
>
|
>
|
||||||
|
<q-list>
|
||||||
|
<q-item @click="goToPaymentView" clickable v-close-popup>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>New Payment</q-item-label>
|
||||||
|
<q-item-label caption
|
||||||
|
>Create a new payment by selecting Inputs and
|
||||||
|
Outputs</q-item-label
|
||||||
|
>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item
|
||||||
|
@click="showEnterSignedPsbtDialog"
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
>
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>From Signed PSBT</q-item-label>
|
||||||
|
<q-item-label caption> Paste a signed PSBT</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-btn-dropdown>
|
||||||
|
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="showPayment"
|
v-if="showPayment"
|
||||||
outline
|
outline
|
||||||
@ -226,6 +249,36 @@
|
|||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="showEnterSignedPsbt" position="top">
|
||||||
|
<q-card class="q-pa-lg lnbits__dialog-card">
|
||||||
|
<h5 class="text-subtitle1 q-my-none">Enter the Signed PSBT</h5>
|
||||||
|
<q-separator></q-separator><br />
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.trim="signedBase64Psbt"
|
||||||
|
type="textarea"
|
||||||
|
label="Signed PSBT"
|
||||||
|
></q-input>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="row q-mt-lg q-gutter-sm">
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
v-close-popup
|
||||||
|
color="grey"
|
||||||
|
@click="checkPsbt"
|
||||||
|
class="q-ml-sm"
|
||||||
|
>Check PSBT</q-btn
|
||||||
|
>
|
||||||
|
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
||||||
|
</div>
|
||||||
|
<div class="row q-mt-lg q-gutter-sm"></div>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user