keysend initial (#427)

keysend initial
pull/431/head
ShahanaFarooqui 4 years ago committed by GitHub
parent 65882678ca
commit 8586b18a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -15,5 +15,5 @@
<link rel="stylesheet" href="styles.7f0a84d9b012559f3600.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.52afa68c0b2839cf85a5.js" defer></script><script src="polyfills-es5.2ac0d98b22574ae745b1.js" nomodule defer></script><script src="polyfills.5ae721a6ae5ab597a53d.js" defer></script><script src="main.63add4e662e0f112964c.js" defer></script></body>
<script src="runtime.fc43c4a60d249539e7ff.js" defer></script><script src="polyfills-es5.2ac0d98b22574ae745b1.js" nomodule defer></script><script src="polyfills.5ae721a6ae5ab597a53d.js" defer></script><script src="main.000a76bc1ed847617608.js" defer></script></body>
</html>

File diff suppressed because one or more lines are too long

@ -1 +1 @@
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],f=r[2],p=0,d=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&d.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);d.length;)d.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"9bb271dd8dffd2d994a5",6:"dfeb7be4d1d55ba1bfb2",7:"4a00e92294df28ac9ca1",8:"98795e7ab86361a07d2b"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(f);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var f=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var l=c;t()}([]);
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],f=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"9bb271dd8dffd2d994a5",6:"cc720e644b6f96f3d71b",7:"4a00e92294df28ac9ca1",8:"98795e7ab86361a07d2b"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(f);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var f=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var l=c;t()}([]);

@ -75,14 +75,18 @@ exports.decodePayment = (req, res, next) => {
exports.postPayment = (req, res, next) => {
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/pay';
if (req.params.type === 'keysend') {
options.url = common.getSelLNServerUrl() + '/pay/keysend';
} else {
options.url = common.getSelLNServerUrl() + '/pay';
}
options.body = req.body;
request.post(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Payment Post Response: ' + JSON.stringify(body)});
logger.info({fileName: 'Payments', msg: 'Send Payment Response: ' + JSON.stringify(body)});
if(!body || body.error) {
logger.error({fileName: 'Payments', lineNum: 81, msg: 'Payment Post Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.error({fileName: 'Payments', lineNum: 81, msg: 'Send Payment Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
res.status(500).json({
message: "Payment Post Failed!",
message: "Send Payment Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
@ -97,9 +101,9 @@ exports.postPayment = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Payments', lineNum: 97, msg: 'Payments Post Error: ' + JSON.stringify(err)});
logger.error({fileName: 'Payments', lineNum: 97, msg: 'Send Payments Error: ' + JSON.stringify(err)});
return res.status(500).json({
message: "Payment Post Failed!",
message: "Send Payment Failed!",
error: err.error
});
});

@ -5,6 +5,6 @@ const authCheck = require("../authCheck");
router.get("/", authCheck, PaymentsController.listPayments);
router.get("/:invoice", authCheck, PaymentsController.decodePayment);
router.post("/", authCheck, PaymentsController.postPayment);
router.post("/:type", authCheck, PaymentsController.postPayment);
module.exports = router;

@ -55,7 +55,7 @@
<mat-option *ngFor="let transaction of transactions" [value]="transaction">{{transaction.value | number}} Sats</mat-option>
</mat-select>
</mat-form-field>
<mat-slide-toggle fxFlex="60" tabindex="9" color="primary" [(ngModel)]="flgUseAllBalance" (change)="onUTXOAllBalanceChange()" name="flgUseAllBalance" matTooltip="Use selected UTXO balance as amount after subtracting fee" matTooltipPosition="above" [disabled]="selUTXOs.length < 1">
<mat-slide-toggle fxFlex="60" tabindex="9" color="primary" [(ngModel)]="flgUseAllBalance" (change)="onUTXOAllBalanceChange()" name="flgUseAllBalance" matTooltip="Use selected UTXOs balance as the amount to be sent. Final amount sent will be less the mining fee." matTooltipPosition="above" [disabled]="selUTXOs.length < 1">
Use selected UTXOs balance
</mat-slide-toggle>
</div>

@ -105,7 +105,7 @@
<mat-option *ngFor="let transaction of transactions" [value]="transaction">{{transaction.value | number}} Sats</mat-option>
</mat-select>
</mat-form-field>
<mat-slide-toggle fxFlex="48" tabindex="7" color="primary" [(ngModel)]="flgUseAllBalance" (change)="onUTXOAllBalanceChange()" name="flgUseAllBalance" matTooltip="Use selected UTXOs balance as amount after subtracting fee" matTooltipPosition="above" [disabled]="selUTXOs.length < 1">
<mat-slide-toggle fxFlex="48" tabindex="7" color="primary" [(ngModel)]="flgUseAllBalance" (change)="onUTXOAllBalanceChange()" name="flgUseAllBalance" matTooltip="Use selected UTXOs balance as the amount to be sent. Final amount sent will be less the mining fee." matTooltipPosition="above" [disabled]="selUTXOs.length < 1">
Use selected UTXOs balance
</mat-slide-toggle>
</div>

@ -192,7 +192,7 @@ export class SetDecodedPayment implements Action {
export class SendPayment implements Action {
readonly type = SEND_PAYMENT_CL;
constructor(public payload: { fromDialog: boolean, invoice: string, amount?: number }) {}
constructor(public payload: {fromDialog: boolean, invoice?: string, amount?: number, pubkey?: string}) {}
}
export class SendPaymentStatus implements Action {

@ -412,44 +412,43 @@ export class CLEffects implements OnDestroy {
ofType(CLActions.SEND_PAYMENT_CL),
withLatestFrom(this.store.select('root')),
mergeMap(([action, store]: [CLActions.SendPayment, any]) => {
this.store.dispatch(new CLActions.ClearEffectError('SendPayment'));
return this.httpClient.post(this.CHILD_API_URL + environment.PAYMENTS_API, action.payload)
.pipe(
map((sendRes: any) => {
this.logger.info(sendRes);
this.store.dispatch(new RTLActions.CloseSpinner());
if (sendRes.error) {
this.logger.error('Error: ' + sendRes.payment_error);
const myErr = {status: sendRes.payment_error.status, error: sendRes.payment_error.error && sendRes.payment_error.error.error && typeof(sendRes.payment_error.error.error) === 'object' ? sendRes.payment_error.error.error : {error: sendRes.payment_error.error && sendRes.payment_error.error.error ? sendRes.payment_error.error.error : 'Unknown Error'}};
if (action.payload.fromDialog) {
this.handleErrorWithoutAlert('SendPayment', 'Send Payment Failed.', myErr);
} else {
this.handleErrorWithAlert('ERROR', 'Send Payment Failed', this.CHILD_API_URL + environment.PAYMENTS_API, myErr);
}
return of({type: RTLActions.VOID});
} else {
this.store.dispatch(new RTLActions.OpenSnackBar('Payment Sent Successfully!'));
this.store.dispatch(new CLActions.FetchChannels());
this.store.dispatch(new CLActions.FetchBalance());
this.store.dispatch(new CLActions.FetchPayments());
this.store.dispatch(new CLActions.SetDecodedPayment({}));
return {
type: CLActions.SEND_PAYMENT_STATUS_CL,
payload: sendRes
};
}
}),
catchError((err: any) => {
this.logger.error('Error: ' + JSON.stringify(err));
const myErr = {status: err.status, error: err.error && err.error.error && typeof(err.error.error) === 'object' ? err.error.error : {error: err.error && err.error.error ? err.error.error : 'Unknown Error'}};
this.store.dispatch(new CLActions.ClearEffectError('SendPayment'));
let paymentUrl = (action.payload.pubkey && action.payload.pubkey !== '') ? this.CHILD_API_URL + environment.PAYMENTS_API + '/keysend' : this.CHILD_API_URL + environment.PAYMENTS_API + '/invoice';
return this.httpClient.post(paymentUrl, action.payload).pipe(
map((sendRes: any) => {
this.logger.info(sendRes);
this.store.dispatch(new RTLActions.CloseSpinner());
if (sendRes.error) {
this.logger.error('Error: ' + sendRes.payment_error);
const myErr = {status: sendRes.payment_error.status, error: sendRes.payment_error.error && sendRes.payment_error.error.error && typeof(sendRes.payment_error.error.error) === 'object' ? sendRes.payment_error.error.error : {error: sendRes.payment_error.error && sendRes.payment_error.error.error ? sendRes.payment_error.error.error : 'Unknown Error'}};
if (action.payload.fromDialog) {
this.handleErrorWithoutAlert('SendPayment', 'Send Payment Failed.', myErr);
} else {
this.handleErrorWithAlert('ERROR', 'Send Payment Failed', this.CHILD_API_URL + environment.PAYMENTS_API, myErr);
}
return of({type: RTLActions.VOID});
})
);
} else {
this.store.dispatch(new RTLActions.OpenSnackBar('Payment Sent Successfully!'));
this.store.dispatch(new CLActions.FetchChannels());
this.store.dispatch(new CLActions.FetchBalance());
this.store.dispatch(new CLActions.FetchPayments());
this.store.dispatch(new CLActions.SetDecodedPayment({}));
return {
type: CLActions.SEND_PAYMENT_STATUS_CL,
payload: sendRes
};
}
}),
catchError((err: any) => {
this.logger.error('Error: ' + JSON.stringify(err));
const myErr = {status: err.status, error: err.error && err.error.error && typeof(err.error.error) === 'object' ? err.error.error : {error: err.error && err.error.error ? err.error.error : 'Unknown Error'}};
if (action.payload.fromDialog) {
this.handleErrorWithoutAlert('SendPayment', 'Send Payment Failed.', myErr);
} else {
this.handleErrorWithAlert('ERROR', 'Send Payment Failed', this.CHILD_API_URL + environment.PAYMENTS_API, myErr);
}
return of({type: RTLActions.VOID});
}));
})
);

@ -4,30 +4,47 @@
<div fxFlex="95" fxLayoutAlign="start start">
<span class="page-title">Send Payment</span>
</div>
<button tabindex="8" fxFlex="5" fxLayoutAlign="center" class="btn-close-x p-0" [mat-dialog-close]="false" default mat-button>X</button>
<button tabindex="12" fxFlex="5" fxLayoutAlign="center" class="btn-close-x p-0" [mat-dialog-close]="false" default mat-button>X</button>
</mat-card-header>
<mat-card-content class="mt-5px">
<mat-card-content class="mt-5px" fxLayout="column" fxLayoutAlign="start stretch">
<mat-radio-group class="mb-2" color="primary" name="paymentType" [(ngModel)]="paymentType" (change)="onPaymentTypeChange()" fxFlex="100" fxLayoutAlign="start stretch">
<mat-radio-button fxFlex="25" tabindex="1" value="invoice" class="mr-2">Invoice Payment</mat-radio-button>
<mat-radio-button fxFlex="25" tabindex="2" value="keysend">Keysend Payment</mat-radio-button>
</mat-radio-group>
<form fxLayoutAlign="space-between stretch" fxLayout="column" #sendPaymentForm="ngForm">
<mat-form-field fxFlex="100">
<textarea autoFocus matInput placeholder="Payment Request" name="paymentRequest" tabindex="1" [ngModel]="paymentRequest" (ngModelChange)="onPaymentRequestEntry($event)" (matTextareaAutosize)="true" required #paymentReq="ngModel"></textarea>
<mat-hint *ngIf="paymentRequest && paymentDecodedHint !== ''">{{paymentDecodedHint}}</mat-hint>
<mat-error *ngIf="!paymentRequest">Payment request is required.</mat-error>
<mat-error *ngIf="paymentReq.errors?.decodeError">{{paymentDecodedHint}}</mat-error>
</mat-form-field>
<mat-form-field fxFlex="100" *ngIf="zeroAmtInvoice">
<input matInput placeholder="Amount (Sats)" name="amount" [(ngModel)]="paymentAmount" (change)="onAmountChange($event)" tabindex="2" required #paymentAmt="ngModel">
<mat-hint>It is a zero amount invoice, enter amount to be paid.</mat-hint>
<mat-error *ngIf="!paymentAmount">Payment amount is required.</mat-error>
</mat-form-field>
<ng-container *ngTemplateOutlet="paymentType === 'keysend' ? keysendBlock : invoiceBlock"></ng-container>
<div fxFlex="100" class="alert alert-danger mt-1" *ngIf="paymentError !== ''">
<fa-icon [icon]="faExclamationTriangle" class="mr-1 alert-icon"></fa-icon>
<span *ngIf="paymentError !== ''">{{paymentError}}</span>
</div>
<div class="mt-2" fxLayout="row" fxLayoutAlign="end center">
<button class="mr-1" mat-stroked-button color="primary" tabindex="2" type="reset" (click)="resetData()">Clear Fields</button>
<button mat-flat-button color="primary" (click)="onSendPayment();" tabindex="3">Send Payment</button>
<button class="mr-1" mat-stroked-button color="primary" tabindex="8" type="reset" (click)="resetData()">Clear Fields</button>
<button mat-flat-button color="primary" (click)="onSendPayment()" tabindex="7">Send Payment</button>
</div>
</form>
</mat-card-content>
</div>
</div>
<ng-template #invoiceBlock>
<mat-form-field fxFlex="100">
<textarea autoFocus matInput placeholder="Payment Request" name="paymentRequest" tabindex="3" [ngModel]="paymentRequest" (ngModelChange)="onPaymentRequestEntry($event)" (matTextareaAutosize)="true" required #paymentReq="ngModel"></textarea>
<mat-hint *ngIf="paymentRequest && paymentDecodedHint !== ''">{{paymentDecodedHint}}</mat-hint>
<mat-error *ngIf="!paymentRequest">Payment request is required.</mat-error>
<mat-error *ngIf="paymentReq.errors?.decodeError">{{paymentDecodedHint}}</mat-error>
</mat-form-field>
<mat-form-field fxFlex="100" *ngIf="zeroAmtInvoice">
<input matInput placeholder="Amount (Sats)" name="amount" [(ngModel)]="paymentAmount" (change)="onAmountChange($event)" tabindex="4" required #paymentAmt="ngModel">
<mat-hint>It is a zero amount invoice, enter amount to be paid.</mat-hint>
<mat-error *ngIf="!paymentAmount">Payment amount is required.</mat-error>
</mat-form-field>
</ng-template>
<ng-template #keysendBlock>
<mat-form-field fxFlex="100">
<input autoFocus matInput placeholder="Pubkey" [(ngModel)]="pubkey" name="pubkey" tabindex="5" required>
<mat-error *ngIf="!pubkey">Pubkey is required.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="100">
<input matInput placeholder="Amount (Sats)" name="keysendAmount" [(ngModel)]="keysendAmount" tabindex="6" required #keysendAmt="ngModel">
<mat-error *ngIf="!keysendAmount">Keysend amount is required.</mat-error>
</mat-form-field>
</ng-template>

@ -26,12 +26,16 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
styleUrls: ['./send-payment.component.scss'],
})
export class CLLightningSendPaymentsComponent implements OnInit, OnDestroy {
@ViewChild('paymentReq', { static: true }) paymentReq: NgModel;
private paymentReq: NgModel;
@ViewChild('paymentReq') set payReq(paymReq: NgModel) {if(paymReq) { this.paymentReq = paymReq; }}
public faExclamationTriangle = faExclamationTriangle;
public selNode: SelNodeChild = {};
public paymentDecoded: PayRequest = {};
public zeroAmtInvoice = false;
public paymentAmount = null;
public paymentType = 'invoice';
public pubkey = '';
public keysendAmount = null;
public paymentRequest = '';
public paymentDecodedHint = '';
public selActiveChannel: Channel = {};
@ -72,37 +76,45 @@ export class CLLightningSendPaymentsComponent implements OnInit, OnDestroy {
}
onSendPayment() {
if(!this.paymentRequest) { return true; }
if (this.paymentDecoded.created_at_str) {
this.sendPayment();
if ((this.paymentType === 'invoice' && !this.paymentRequest) || (this.paymentType === 'keysend' && (!this.pubkey || this.pubkey.trim() === '' || !this.keysendAmount || this.keysendAmount <= 0))) { return true; }
if (this.paymentType === 'keysend') {
this.keysendPayment();
} else {
this.paymentAmount = null;
this.paymentError = '';
this.paymentDecodedHint = '';
this.paymentReq.control.setErrors(null);
this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
this.store.dispatch(new CLActions.DecodePayment({routeParam: this.paymentRequest, fromDialog: true}));
this.clEffects.setDecodedPaymentCL.pipe(take(1)).subscribe(decodedPayment => {
this.paymentDecoded = decodedPayment;
if (this.paymentDecoded.created_at_str && !this.paymentDecoded.msatoshi) {
this.paymentDecoded.msatoshi = 0;
this.zeroAmtInvoice = true;
this.paymentDecodedHint = 'Zero Amount Invoice | Memo: ' + this.paymentDecoded.description;
} else {
this.zeroAmtInvoice = false;
this.commonService.convertCurrency(+this.paymentDecoded.msatoshi, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2], this.selNode.fiatConversion)
.pipe(takeUntil(this.unSubs[2]))
.subscribe(data => {
if(this.selNode.fiatConversion) {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats (' + data.symbol + this.decimalPipe.transform((data.OTHER ? data.OTHER : 0), CURRENCY_UNIT_FORMATS.OTHER) + ') | Memo: ' + this.paymentDecoded.description;
} else {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats | Memo: ' + this.paymentDecoded.description;
}
});
}
});
if (this.paymentDecoded.created_at_str) {
this.sendPayment();
} else {
this.paymentAmount = null;
this.paymentError = '';
this.paymentDecodedHint = '';
this.paymentReq.control.setErrors(null);
this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
this.store.dispatch(new CLActions.DecodePayment({routeParam: this.paymentRequest, fromDialog: true}));
this.clEffects.setDecodedPaymentCL.pipe(take(1)).subscribe(decodedPayment => {
this.paymentDecoded = decodedPayment;
if (this.paymentDecoded.created_at_str && !this.paymentDecoded.msatoshi) {
this.paymentDecoded.msatoshi = 0;
this.zeroAmtInvoice = true;
this.paymentDecodedHint = 'Zero Amount Invoice | Memo: ' + this.paymentDecoded.description;
} else {
this.zeroAmtInvoice = false;
this.commonService.convertCurrency(+this.paymentDecoded.msatoshi, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2], this.selNode.fiatConversion)
.pipe(takeUntil(this.unSubs[2]))
.subscribe(data => {
if(this.selNode.fiatConversion) {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats (' + data.symbol + this.decimalPipe.transform((data.OTHER ? data.OTHER : 0), CURRENCY_UNIT_FORMATS.OTHER) + ') | Memo: ' + this.paymentDecoded.description;
} else {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats | Memo: ' + this.paymentDecoded.description;
}
});
}
});
}
}
}
keysendPayment() {
this.store.dispatch(new RTLActions.OpenSpinner('Sending Keysend Payment...'));
this.store.dispatch(new CLActions.SendPayment({pubkey: this.pubkey, amount: this.keysendAmount*1000, fromDialog: true}));
}
sendPayment() {
@ -151,16 +163,26 @@ export class CLLightningSendPaymentsComponent implements OnInit, OnDestroy {
this.paymentDecoded.msatoshi = event;
}
onPaymentTypeChange() {
this.paymentError = '';
}
resetData() {
this.paymentDecoded = {};
this.paymentRequest = '';
this.selActiveChannel = null;
this.feeLimit = null;
this.selFeeLimitType = FEE_LIMIT_TYPES[0];
this.paymentReq.control.setErrors(null);
if (this.paymentType === 'keysend') {
this.pubkey = '';
this.keysendAmount = null;
} else {
this.paymentDecoded = {};
this.paymentRequest = '';
this.selActiveChannel = null;
this.feeLimit = null;
this.selFeeLimitType = FEE_LIMIT_TYPES[0];
this.paymentReq.control.setErrors(null);
this.paymentDecodedHint = '';
this.zeroAmtInvoice = false;
this.paymentAmount = null;
}
this.paymentError = '';
this.paymentDecodedHint = '';
this.zeroAmtInvoice = false;
}
ngOnDestroy() {

@ -1,4 +1,4 @@
.spinner-container {
position: absolute;
left: 50%;
left: 45%;
}

Loading…
Cancel
Save