feat: add keysend payment method in webln.js and update button action in web-l-n.blade.php

This commit is contained in:
fsociety
2024-09-10 21:51:17 +02:00
parent 1682d2ac48
commit 3d76c3d021
2 changed files with 20 additions and 1 deletions

View File

@@ -19,6 +19,25 @@ export default (livewireComponent) => ({
});
},
async keySendMethod() {
// keysend(args: KeysendArgs): Promise<SendPaymentResponse>;
// Send a keysend payment to the specified node.
await webln.keysend({
destination: '0363662a4ae8b8b7a73d9f4e459a9b25d4786f4ecc7315b5401934f3a2ef609750', amount: 1,
})
.then(response => {
console.log('Payment response:', response);
this.$wire.call('logThis', 'Payment response: ' + JSON.stringify(response));
this.$wire.call('reloadMe');
})
.catch(error => {
console.error('Payment failed:', error);
this.$wire.call('logThis', 'Payment failed: ' + error);
this.$wire.call('reloadMe');
});
},
async init() {
console.log('WebLN initialized');

View File

@@ -6,7 +6,7 @@
<div class="text-xs sm:text-base break-words">payment_request: {{ $invoice['payment_request'] }}</div>
<div class="mt-6">
<div class="flex justify-center">
<button x-on:click="pay" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Pay Invoice</button>
<button x-on:click="keySendMethod" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Pay Invoice</button>
</div>
</div>
</div>