mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2025-02-22 14:22:48 +01:00
Payment, channel and onchain Post calls
Payment, channel and onchain Post calls
This commit is contained in:
parent
f517357702
commit
46afc9cb24
26 changed files with 331 additions and 303 deletions
File diff suppressed because one or more lines are too long
1
angular/6.37386727f9bc3e6eed2a.js
Normal file
1
angular/6.37386727f9bc3e6eed2a.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -6,8 +6,8 @@
|
|||
<base href="/rtl/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
|
||||
<link rel="stylesheet" href="styles.13a9674cdbdfd014a4cf.css"></head>
|
||||
<link rel="stylesheet" href="styles.ab2352d6f1061166b369.css"></head>
|
||||
<body>
|
||||
<rtl-app></rtl-app>
|
||||
<script src="runtime.6d7f4fc1b563aa79d526.js"></script><script src="polyfills-es5.763f4f23e8aee5ec234d.js" nomodule></script><script src="polyfills.e59b6f9dc696bd89cf7f.js"></script><script src="main.59fa2b3afa7a6b0831a3.js"></script></body>
|
||||
<script src="runtime.bf8e641e92f245cd461d.js"></script><script src="polyfills-es5.763f4f23e8aee5ec234d.js" nomodule></script><script src="polyfills.e59b6f9dc696bd89cf7f.js"></script><script src="main.f95cf4f11f52307d09ec.js"></script></body>
|
||||
</html>
|
||||
|
|
File diff suppressed because one or more lines are too long
1
angular/main.f95cf4f11f52307d09ec.js
Normal file
1
angular/main.f95cf4f11f52307d09ec.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
!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++)o[a=i[p]]&&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:"5d20dbfb50eaa379bb80",6:"12388ed64e707cd157b5",7:"a5c863be17d1f63652ca"}[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()}([]);
|
1
angular/runtime.bf8e641e92f245cd461d.js
Normal file
1
angular/runtime.bf8e641e92f245cd461d.js
Normal file
|
@ -0,0 +1 @@
|
|||
!function(e){function r(r){for(var n,i,a=r[0],f=r[1],c=r[2],p=0,s=[];p<a.length;p++)o[i=a[p]]&&s.push(o[i][0]),o[i]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,c||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++)0!==o[t[a]]&&(n=!1);n&&(u.splice(r--,1),e=i(i.s=t[0]))}return e}var n={},o={0:0},u=[];function i(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,i),t.l=!0,t.exports}i.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,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+""+({}[e]||e)+"."+{1:"5d20dbfb50eaa379bb80",6:"37386727f9bc3e6eed2a",7:"e3fc04f04ff1b847504d"}[e]+".js"}(e);var f=new Error;u=function(r){a.onerror=a.onload=null,clearTimeout(c);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;f.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",f.name="ChunkLoadError",f.type=n,f.request=u,t[1](f)}o[e]=void 0}};var c=setTimeout(function(){u({type:"timeout",target:a})},12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(r)},i.m=e,i.c=n,i.d=function(e,r,t){i.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,r){if(1&r&&(e=i(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)i.d(t,n,(function(r){return e[r]}).bind(null,n));return t},i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,"a",r),r},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.p="",i.oe=function(e){throw console.error(e),e};var a=window.webpackJsonp=window.webpackJsonp||[],f=a.push.bind(a);a.push=r,a=a.slice();for(var c=0;c<a.length;c++)r(a[c]);var l=f;t()}([]);
|
File diff suppressed because one or more lines are too long
1
angular/styles.ab2352d6f1061166b369.css
Normal file
1
angular/styles.ab2352d6f1061166b369.css
Normal file
File diff suppressed because one or more lines are too long
|
@ -19,7 +19,30 @@ exports.listChannels = (req, res, next) => {
|
|||
});
|
||||
}
|
||||
|
||||
exports.openChannel = (req, res, next) => {}
|
||||
exports.openChannel = (req, res, next) => {
|
||||
options = common.getOptions();
|
||||
options.url = common.getSelLNServerUrl() + '/channel/openChannel';
|
||||
options.body = req.body;
|
||||
logger.info({fileName: 'Channels', msg: 'Open Channel Options: ' + JSON.stringify(options)});
|
||||
request.post(options).then((body) => {
|
||||
logger.info({fileName: 'Channels', msg: 'Open Channel Response: ' + JSON.stringify(body)});
|
||||
if(undefined === body || body.error) {
|
||||
res.status(500).json({
|
||||
message: 'Open Channel Failed!',
|
||||
error: (undefined === body) ? 'Error From Server!' : body.error
|
||||
});
|
||||
} else {
|
||||
res.status(201).json(body);
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
logger.error({fileName: 'Channels', lineNum: 39, msg: 'Open Channel Failed: ' + JSON.stringify(err)});
|
||||
return res.status(500).json({
|
||||
message: 'Open Channel Failed!',
|
||||
error: err.error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.setChannelFee = (req, res, next) => {
|
||||
options = common.getOptions();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var request = require('request-promise');
|
||||
var common = require('../../common');
|
||||
var logger = require('../logger');
|
||||
var options = {};
|
||||
|
||||
exports.getNewAddress = (req, res, next) => {
|
||||
|
@ -15,3 +16,28 @@ exports.getNewAddress = (req, res, next) => {
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.onChainWithdraw = (req, res, next) => {
|
||||
options = common.getOptions();
|
||||
options.url = common.getSelLNServerUrl() + '/withdraw';
|
||||
options.body = req.body;
|
||||
logger.info({fileName: 'OnChain', msg: 'OnChain Withdraw Options: ' + JSON.stringify(options)});
|
||||
request.post(options).then((body) => {
|
||||
logger.info({fileName: 'OnChain', msg: 'OnChain Withdraw Response: ' + JSON.stringify(body)});
|
||||
if(undefined === body || body.error) {
|
||||
res.status(500).json({
|
||||
message: 'OnChain Withdraw Failed!',
|
||||
error: (undefined === body) ? 'Error From Server!' : body.error
|
||||
});
|
||||
} else {
|
||||
res.status(201).json(body);
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
logger.error({fileName: 'OnChain', lineNum: 211, msg: 'OnChain Withdraw Response: ' + JSON.stringify(err)});
|
||||
return res.status(500).json({
|
||||
message: 'OnChain Withdraw Failed!',
|
||||
error: err.error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ exports.decodePayment = (req, res, next) => {
|
|||
error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error
|
||||
});
|
||||
} else {
|
||||
// body.btc_num_satoshis = (undefined === body.num_satoshis) ? 0 : common.convertToBTC(body.num_satoshis);
|
||||
// body.timestamp_str = (undefined === body.timestamp) ? '' : common.convertTimestampToDate(body.timestamp);
|
||||
body.created_at_str = (undefined === body.created_at) ? '' : common.convertTimestampToDate(body.created_at);
|
||||
body.expire_at_str = (undefined === body.created_at || undefined === body.expiry) ? '' : common.convertTimestampToDate(body.created_at + body.expiry);
|
||||
res.status(200).json(body);
|
||||
}
|
||||
})
|
||||
|
@ -59,21 +59,11 @@ exports.postPayment = (req, res, next) => {
|
|||
options = common.getOptions();
|
||||
options.url = common.getSelLNServerUrl() + '/pay';
|
||||
options.body = req.body;
|
||||
// options.body = {
|
||||
// amount: req.body.amount,
|
||||
// addr: req.body.address,
|
||||
// sat_per_byte: req.body.fees,
|
||||
// target_conf: req.body.blocks
|
||||
// };
|
||||
// if (req.body.sendAll) {
|
||||
// options.form.send_all = req.body.sendAll;
|
||||
// }
|
||||
// options.form = JSON.stringify(options.form);
|
||||
request.post(options).then((body) => {
|
||||
logger.info({fileName: 'Payments', msg: 'Payment Post Response: ' + JSON.stringify(body)});
|
||||
if(undefined === body || body.error) {
|
||||
res.status(500).json({
|
||||
message: "Payment post failed!",
|
||||
message: "Payment Post Failed!",
|
||||
error: (undefined === body) ? 'Error From Server!' : body.error
|
||||
});
|
||||
} else {
|
||||
|
@ -82,7 +72,7 @@ exports.postPayment = (req, res, next) => {
|
|||
})
|
||||
.catch(function (err) {
|
||||
return res.status(500).json({
|
||||
message: "Payment post failed!",
|
||||
message: "Payment Post Failed!",
|
||||
error: err.error
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,5 +4,6 @@ const router = express.Router();
|
|||
const authCheck = require("../authCheck");
|
||||
|
||||
router.get("/", authCheck, OnChainController.getNewAddress);
|
||||
router.post("/", authCheck, OnChainController.onChainWithdraw);
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
<mat-form-field fxFlex="40" fxLayoutAlign="start end">
|
||||
<mat-select [(ngModel)]="selectedPeer" placeholder="Alias" name="peer_alias" tabindex="1" required
|
||||
name="selPeer" #selPeer="ngModel">
|
||||
<mat-option *ngFor="let peer of peers" [value]="peer.pub_key">
|
||||
<mat-option *ngFor="let peer of peers" [value]="peer.id">
|
||||
{{peer.alias}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="25" fxLayoutAlign="start end">
|
||||
<input matInput [(ngModel)]="fundingAmount" placeholder="Amount ({{information?.smaller_currency_unit}})"
|
||||
type="number" step="1000" min="1" tabindex="2" required name="amount" #amount="ngModel">
|
||||
<input matInput [(ngModel)]="fundingAmount" placeholder="Amount (mSats)" type="number" step="1000" min="1"
|
||||
tabindex="2" required name="amount" #amount="ngModel">
|
||||
<mat-hint>(Wallet Bal: {{totalBalance}}, Remaining Bal:
|
||||
{{totalBalance - ((fundingAmount) ? fundingAmount : 0)}})</mat-hint>
|
||||
</mat-form-field>
|
||||
|
@ -28,35 +28,26 @@
|
|||
</mat-checkbox>
|
||||
</div>
|
||||
<span *ngIf="moreOptions" fxLayout="column" fxLayout.gt-sm="row wrap" fxFlex="80"
|
||||
fxLayoutAlign.gt-sm="space-between center">
|
||||
fxLayoutAlign.gt-sm="start center">
|
||||
<mat-form-field fxFlex="25" fxLayoutAlign="start end">
|
||||
<mat-select tabindex="4" [(value)]="selTransType">
|
||||
<mat-option *ngFor="let transType of transTypes" [value]="transType.id">
|
||||
{{transType.name}}
|
||||
<mat-select tabindex="4" placeholder="Fee Rate" [(value)]="selFeeRate">
|
||||
<mat-option *ngFor="let feeRateType of feeRateTypes" [value]="feeRateType.feeRateId">
|
||||
{{feeRateType.feeRateType}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="25" *ngIf="selTransType=='0'">
|
||||
<input matInput placeholder="Channel Opening Priority" disabled>
|
||||
<mat-checkbox fxFlex="25" fxFlex.lt-lg="35" tabindex="5" [(ngModel)]="flgMinConf" name="flgMinConf">
|
||||
<mat-form-field fxFlex="100">
|
||||
<input matInput [(ngModel)]="minConfValue" placeholder="Min Confirmation Blocks" type="number"
|
||||
name="blocks" step="1" min="0" tabindex="6" #blocks="ngModel" [required]="flgMinConf"
|
||||
[disabled]="!flgMinConf">
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="25" *ngIf="selTransType=='1'">
|
||||
<input matInput [(ngModel)]="transTypeValue.blocks" placeholder="Target Confirmation Blocks" type="number"
|
||||
name="blocks" step="1" min="0" required tabindex="5" #blocks="ngModel">
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="25" *ngIf="selTransType=='2'">
|
||||
<input matInput [(ngModel)]="transTypeValue.fees"
|
||||
placeholder="Fee ({{information?.smaller_currency_unit}}/Byte)" type="number" name="fees" step="1"
|
||||
min="0" required tabindex="6" #fees="ngModel">
|
||||
</mat-form-field>
|
||||
<mat-checkbox fxFlex="25" fxFlex.lt-lg="35" tabindex="7" [(ngModel)]="spendUnconfirmed"
|
||||
name="spendUnconfirmed">Spend Unconfirmed Output</mat-checkbox>
|
||||
<mat-checkbox fxFlex="20" fxFlex.lt-lg="15" tabindex="8" [(ngModel)]="isPrivate" name="isPrivate">Private
|
||||
</mat-checkbox>
|
||||
</span>
|
||||
<div fxFlex="10" fxLayoutAlign="end start">
|
||||
<button fxFlex="90" fxLayoutAlign="center center" mat-raised-button color="primary"
|
||||
[disabled]="selectedPeer === '' || fundingAmount == null || (totalBalance - ((fundingAmount) ? fundingAmount : 0) < 0)"
|
||||
type="submit" tabindex="8">
|
||||
[disabled]="selectedPeer === '' || fundingAmount == null || (totalBalance - ((fundingAmount) ? fundingAmount : 0) < 0) || !openChannelForm.valid"
|
||||
type="submit" tabindex="7">
|
||||
<p
|
||||
*ngIf="(selectedPeer === '' || fundingAmount == null) && (selPeer.touched || selPeer.dirty) && (amount.touched || amount.dirty); else openText">
|
||||
Invalid Values</p>
|
||||
|
@ -92,7 +83,9 @@
|
|||
</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="update">
|
||||
<th mat-header-cell *matHeaderCellDef><mat-icon color="accent" (click)="onChannelUpdate('all')">edit</mat-icon></th>
|
||||
<th mat-header-cell *matHeaderCellDef>
|
||||
<mat-icon color="accent" (click)="onChannelUpdate('all')">edit</mat-icon>
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let channel">
|
||||
<mat-icon color="accent" (click)="onChannelUpdate(channel)">edit</mat-icon>
|
||||
</td>
|
||||
|
@ -133,7 +126,8 @@
|
|||
{{channel?.spendable_msatoshi | number}} </span></td>
|
||||
</ng-container>
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="onChannelClick(row, $event)"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="onChannelClick(row, $event)"
|
||||
[ngClass]="{'row-disabled': row.state === 'ONCHAIN'}"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
|
|
@ -33,11 +33,11 @@ export class CLChannelsComponent implements OnInit, OnDestroy {
|
|||
public selectedFilter = '';
|
||||
public myChanPolicy: any = {};
|
||||
public selFilter = '';
|
||||
public transTypes = [{id: '0', name: 'Default Priority'}, {id: '1', name: 'Target Confirmation Blocks'}, {id: '2', name: 'Fee'}];
|
||||
public selTransType = '0';
|
||||
public transTypeValue = {blocks: '', fees: ''};
|
||||
public spendUnconfirmed = false;
|
||||
public feeRateTypes = [];
|
||||
public selFeeRate = '';
|
||||
public isPrivate = false;
|
||||
public flgMinConf = false;
|
||||
public minConfValue = null;
|
||||
public moreOptions = false;
|
||||
public flgSticky = false;
|
||||
public redirectedWithPeer = false;
|
||||
|
@ -82,6 +82,7 @@ export class CLChannelsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
});
|
||||
this.information = rtlStore.information;
|
||||
this.feeRateTypes = rtlStore.feeRateTypes;
|
||||
this.peers = rtlStore.peers;
|
||||
this.peers.forEach(peer => {
|
||||
if (undefined === peer.alias || peer.alias === '') {
|
||||
|
@ -105,20 +106,16 @@ export class CLChannelsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
onOpenChannel(form: any) {
|
||||
// this.store.dispatch(new RTLActions.OpenSpinner('Opening Channel...'));
|
||||
// let transTypeValue = '0';
|
||||
// if (this.selTransType === '1') {
|
||||
// transTypeValue = this.transTypeValue.blocks;
|
||||
// } else if (this.selTransType === '2') {
|
||||
// transTypeValue = this.transTypeValue.fees;
|
||||
// }
|
||||
// this.store.dispatch(new RTLActions.SaveNewChannel({
|
||||
// selectedPeerPubkey: this.selectedPeer, fundingAmount: this.fundingAmount, private: this.isPrivate,
|
||||
// transType: this.selTransType, transTypeValue: transTypeValue, spendUnconfirmed: this.spendUnconfirmed
|
||||
// }));
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Opening Channel...'));
|
||||
this.store.dispatch(new RTLActions.SaveNewChannelCL({
|
||||
peerId: this.selectedPeer, satoshis: this.fundingAmount, announce: !this.isPrivate, feeRate: this.selFeeRate, minconf: this.flgMinConf ? this.minConfValue : null
|
||||
}));
|
||||
}
|
||||
|
||||
onChannelUpdate(channelToUpdate: ChannelCL | 'all') {
|
||||
if(channelToUpdate !== 'all' && channelToUpdate.state === 'ONCHAIN') {
|
||||
return;
|
||||
}
|
||||
if (channelToUpdate === 'all') {
|
||||
const titleMsg = 'Updated Values for ALL Channels';
|
||||
const confirmationMsg = {};
|
||||
|
@ -179,10 +176,13 @@ export class CLChannelsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
onChannelClose(channelToClose: ChannelCL) {
|
||||
if (channelToClose.state === 'AWAITING_UNILATERAL' || channelToClose.state === 'ONCHAIN') {
|
||||
if(channelToClose.state === 'ONCHAIN') {
|
||||
return;
|
||||
}
|
||||
if (channelToClose.state === 'AWAITING_UNILATERAL') {
|
||||
this.store.dispatch(new RTLActions.OpenAlert({ width: '75%', data: {
|
||||
type: 'WARN',
|
||||
titleMessage: 'Channel can not be closed when it is in AWAITING UNILATERAL/ONCHAIN state.'
|
||||
titleMessage: 'Channel can not be closed when it is in AWAITING UNILATERAL state.'
|
||||
}}));
|
||||
} else {
|
||||
this.store.dispatch(new RTLActions.OpenConfirmation({
|
||||
|
@ -246,20 +246,20 @@ export class CLChannelsComponent implements OnInit, OnDestroy {
|
|||
this.selectedPeer = '';
|
||||
this.fundingAmount = 0;
|
||||
this.moreOptions = false;
|
||||
this.spendUnconfirmed = false;
|
||||
this.flgMinConf = false;
|
||||
this.isPrivate = false;
|
||||
this.selTransType = '0';
|
||||
this.transTypeValue = {blocks: '', fees: ''};
|
||||
this.selFeeRate = '';
|
||||
this.minConfValue = null;
|
||||
this.redirectedWithPeer = false;
|
||||
}
|
||||
|
||||
onMoreOptionsChange(event: any) {
|
||||
// if (!event.checked) {
|
||||
// this.spendUnconfirmed = false;
|
||||
// this.isPrivate = false;
|
||||
// this.selTransType = '0';
|
||||
// this.transTypeValue = {blocks: '', fees: ''};
|
||||
// }
|
||||
if (!event.checked) {
|
||||
this.flgMinConf = false;
|
||||
this.isPrivate = false;
|
||||
this.selFeeRate = '';
|
||||
this.minConfValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
|
@ -35,6 +35,7 @@ export class CLRootComponent implements OnInit, OnDestroy {
|
|||
this.store.dispatch(new RTLActions.FetchLocalRemoteBalanceCL());
|
||||
this.store.dispatch(new RTLActions.FetchFeeRatesCL('perkw'));
|
||||
this.store.dispatch(new RTLActions.FetchFeeRatesCL('perkb'));
|
||||
this.store.dispatch(new RTLActions.FetchPeersCL());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
|
@ -13,12 +13,16 @@
|
|||
<mat-card-content fxLayout="column" fxLayoutAlign="center center">
|
||||
<mat-card-content class="mt-1">
|
||||
<svg style="width:70px;height:70px" viewBox="0 0 24 24">
|
||||
<path fill="currentColor" d="M10,2H14A2,2 0 0,1 16,4V6H20A2,2 0 0,1 22,8V19A2,2 0 0,1 20,21H4C2.89,21 2,20.1 2,19V8C2,6.89 2.89,6 4,6H8V4C8,2.89 8.89,2 10,2M14,6V4H10V6H14Z" />
|
||||
<path fill="currentColor"
|
||||
d="M10,2H14A2,2 0 0,1 16,4V6H20A2,2 0 0,1 22,8V19A2,2 0 0,1 20,21H4C2.89,21 2,20.1 2,19V8C2,6.89 2.89,6 4,6H8V4C8,2.89 8.89,2 10,2M14,6V4H10V6H14Z" />
|
||||
</svg>
|
||||
</mat-card-content>
|
||||
<span *ngIf="information?.currency_unit; else withoutData">
|
||||
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit1">{{balance?.btc_totalBalance | number}} {{information?.currency_unit}}</h3>
|
||||
<ng-template #smallerUnit1><h3>{{balance?.totalBalance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
|
||||
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit1">{{balance?.btc_totalBalance | number}}
|
||||
{{information?.currency_unit}}</h3>
|
||||
<ng-template #smallerUnit1>
|
||||
<h3>{{balance?.totalBalance | number}} {{information?.smaller_currency_unit}}</h3>
|
||||
</ng-template>
|
||||
</span>
|
||||
</mat-card-content>
|
||||
<mat-progress-bar class="mt-minus-5" *ngIf="flgLoadingWallet===true" mode="indeterminate"></mat-progress-bar>
|
||||
|
@ -36,12 +40,16 @@
|
|||
<mat-card-content fxLayout="column" fxLayoutAlign="center center">
|
||||
<mat-card-content class="mt-1">
|
||||
<svg style="width:70px;height:70px" viewBox="0 0 24 24">
|
||||
<path fill="currentColor" d="M10,2H14A2,2 0 0,1 16,4V6H20A2,2 0 0,1 22,8V19A2,2 0 0,1 20,21H4A2,2 0 0,1 2,19V8A2,2 0 0,1 4,6H8V4A2,2 0 0,1 10,2M14,6V4H10V6H14M10.5,17.5L17.09,10.91L15.68,9.5L10.5,14.67L8.41,12.59L7,14L10.5,17.5Z" />
|
||||
<path fill="currentColor"
|
||||
d="M10,2H14A2,2 0 0,1 16,4V6H20A2,2 0 0,1 22,8V19A2,2 0 0,1 20,21H4A2,2 0 0,1 2,19V8A2,2 0 0,1 4,6H8V4A2,2 0 0,1 10,2M14,6V4H10V6H14M10.5,17.5L17.09,10.91L15.68,9.5L10.5,14.67L8.41,12.59L7,14L10.5,17.5Z" />
|
||||
</svg>
|
||||
</mat-card-content>
|
||||
<span *ngIf="information?.currency_unit; else withoutData">
|
||||
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit2">{{balance?.btc_confBalance | number}} {{information?.currency_unit}}</h3>
|
||||
<ng-template #smallerUnit2><h3>{{balance?.confBalance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
|
||||
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit2">{{balance?.btc_confBalance | number}}
|
||||
{{information?.currency_unit}}</h3>
|
||||
<ng-template #smallerUnit2>
|
||||
<h3>{{balance?.confBalance | number}} {{information?.smaller_currency_unit}}</h3>
|
||||
</ng-template>
|
||||
</span>
|
||||
</mat-card-content>
|
||||
<mat-progress-bar class="mt-minus-5" *ngIf="flgLoadingWallet===true" mode="indeterminate"></mat-progress-bar>
|
||||
|
@ -59,12 +67,16 @@
|
|||
<mat-card-content fxLayout="column" fxLayoutAlign="center center">
|
||||
<mat-card-content class="mt-1">
|
||||
<svg style="width:70px;height:70px" viewBox="0 0 24 24">
|
||||
<path fill="currentColor" d="M14,2A2,2 0 0,1 16,4V6H20A2,2 0 0,1 22,8L10.85,19C10.85,20.1 10.85,19.5 10.85,21H4C2.89,21 2,20.1 2,19V8C2,6.89 2.89,6 4,6H8V4C8,2.89 8.89,2 10,2H14M14,6V4H10V6H14M21.04,12.13C20.9,12.13 20.76,12.19 20.65,12.3L19.65,13.3L21.7,15.35L22.7,14.35C22.92,14.14 22.92,13.79 22.7,13.58L21.42,12.3C21.31,12.19 21.18,12.13 21.04,12.13M19.07,13.88L13,19.94V22H15.06L21.12,15.93L19.07,13.88Z" />
|
||||
<path fill="currentColor"
|
||||
d="M14,2A2,2 0 0,1 16,4V6H20A2,2 0 0,1 22,8L10.85,19C10.85,20.1 10.85,19.5 10.85,21H4C2.89,21 2,20.1 2,19V8C2,6.89 2.89,6 4,6H8V4C8,2.89 8.89,2 10,2H14M14,6V4H10V6H14M21.04,12.13C20.9,12.13 20.76,12.19 20.65,12.3L19.65,13.3L21.7,15.35L22.7,14.35C22.92,14.14 22.92,13.79 22.7,13.58L21.42,12.3C21.31,12.19 21.18,12.13 21.04,12.13M19.07,13.88L13,19.94V22H15.06L21.12,15.93L19.07,13.88Z" />
|
||||
</svg>
|
||||
</mat-card-content>
|
||||
<span *ngIf="information?.currency_unit; else withoutData">
|
||||
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit3">{{balance?.btc_unconfBalance | number}} {{information?.currency_unit}}</h3>
|
||||
<ng-template #smallerUnit3><h3>{{balance?.unconfBalance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
|
||||
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit3">{{balance?.btc_unconfBalance | number}}
|
||||
{{information?.currency_unit}}</h3>
|
||||
<ng-template #smallerUnit3>
|
||||
<h3>{{balance?.unconfBalance | number}} {{information?.smaller_currency_unit}}</h3>
|
||||
</ng-template>
|
||||
</span>
|
||||
</mat-card-content>
|
||||
<mat-progress-bar class="mt-minus-5" *ngIf="flgLoadingWallet===true" mode="indeterminate"></mat-progress-bar>
|
||||
|
@ -92,10 +104,13 @@
|
|||
</div>
|
||||
<div fxFlex="25" fxLayoutAlign="space-between end">
|
||||
<div fxFlex.gt-md="65" fxFlex.lt-lg="49" fxLayoutAlign="start end">
|
||||
<button fxLayoutAlign="center center" mat-raised-button color="primary" [disabled]="undefined === selectedAddress.addressId" (click)="onGenerateAddress()" tabindex="2" class="top-minus-15px">Generate Address</button>
|
||||
<button fxLayoutAlign="center center" mat-raised-button color="primary"
|
||||
[disabled]="undefined === selectedAddress.addressId" (click)="onGenerateAddress()" tabindex="2"
|
||||
class="top-minus-15px">Generate Address</button>
|
||||
</div>
|
||||
<div fxFlex.gt-md="30" fxFlex.lt-lg="49" fxLayoutAlign="start end">
|
||||
<button fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="3" (click)="resetReceiveData()" class="top-minus-15px">Clear</button>
|
||||
<button fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="3"
|
||||
(click)="resetReceiveData()" class="top-minus-15px">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
<div fxFlex="42" fxLayoutAlign="start end">
|
||||
|
@ -104,7 +119,9 @@
|
|||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex.lt-lg="40" fxFlex.gt-md="14" fxLayoutAlign="center center">
|
||||
<qrcode [qrdata]="newAddress" [size]="120" [level]="'L'" [allowEmptyString]="true" [ngStyle]="{'visibility': (newAddress === '') ? 'hidden' : 'visible'}" class="top-minus-5px qr-border"></qrcode>
|
||||
<qrcode [qrdata]="newAddress" [size]="120" [level]="'L'" [allowEmptyString]="true"
|
||||
[ngStyle]="{'visibility': (newAddress === '') ? 'hidden' : 'visible'}" class="top-minus-5px qr-border">
|
||||
</qrcode>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -119,49 +136,50 @@
|
|||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div fxLayout="column" fxLayout.gt-sm="row wrap">
|
||||
<div fxFlex="62" fxLayoutAlign="start end">
|
||||
<mat-form-field fxFlex="99">
|
||||
<input matInput [(ngModel)]="transaction.address" placeholder="{{information?.currency_unit}} Address" tabindex="4" name="address" #address="ngModel">
|
||||
<form fxLayout="column" fxLayout.gt-sm="row wrap" fxLayoutAlign="space-between start"
|
||||
(ngSubmit)="sendFundForm.form.valid && onSendFunds()" #sendFundForm="ngForm">
|
||||
<mat-form-field fxFlex="35" fxLayoutAlign="start end">
|
||||
<input matInput [(ngModel)]="transaction.address" placeholder="Address" name="address" tabindex="4" required
|
||||
name="address" #address="ngModel">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="38" fxLayoutAlign="start end">
|
||||
<mat-radio-group fxFlex="100" fxLayoutAlign="space-between center" (change)="onOptionChange($event)" [(ngModel)]="flgCustomAmount">
|
||||
<mat-radio-button fxFlex="35" value="0">Sweep All</mat-radio-button>
|
||||
<mat-radio-button fxFlex="60" value="1">
|
||||
<mat-form-field fxFlex="70"><input matInput [(ngModel)]="transaction.amount" (click)="onCustomClicked()" placeholder="Amount ({{information?.smaller_currency_unit}})" name="amount" type="number" step="100" min="0" tabindex="5" #amount="ngModel"></mat-form-field>
|
||||
</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
<div fxLayout="column" fxLayout.gt-sm="row wrap">
|
||||
<div fxFlex="30" fxLayoutAlign="start start">
|
||||
<mat-form-field fxFlex="99">
|
||||
<mat-select [(value)]="selTransType">
|
||||
<mat-option *ngFor="let transType of transTypes" [value]="transType.id">
|
||||
{{transType.name}}
|
||||
<mat-form-field fxFlex="10" fxLayoutAlign="start end">
|
||||
<input matInput [(ngModel)]="transaction.satoshis" placeholder="Amount (mSats)" type="number" step="1000" min="1"
|
||||
tabindex="5" required name="amount" #amount="ngModel">
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="10" fxLayoutAlign="start end">
|
||||
<mat-select tabindex="6" placeholder="Fee Rate" [(value)]="transaction.feeRate">
|
||||
<mat-option *ngFor="let feeRateType of feeRateTypes" [value]="feeRateType.feeRateId">
|
||||
{{feeRateType.feeRateType}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="30" fxLayoutAlign="start start">
|
||||
<mat-form-field fxFlex="99" *ngIf="selTransType=='1'">
|
||||
<input matInput [(ngModel)]="transaction.blocks" placeholder="Target Confirmation Blocks" type="number" name="blocks" step="1" min="0" required tabindex="6" #blocks="ngModel">
|
||||
<mat-checkbox fxFlex="20" fxFlex.lt-lg="35" tabindex="7" [(ngModel)]="flgMinConf" name="flgMinConf">
|
||||
<mat-form-field fxFlex="100">
|
||||
<input matInput [(ngModel)]="transaction.minconf" placeholder="Min Confirmation Blocks" type="number"
|
||||
name="blocks" step="1" min="0" tabindex="8" #blocks="ngModel" [required]="flgMinConf"
|
||||
[disabled]="!flgMinConf">
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="99" *ngIf="selTransType=='2'">
|
||||
<input matInput [(ngModel)]="transaction.fees" placeholder="Fee ({{information?.smaller_currency_unit}}/Byte)" type="number" name="fees" step="1" min="0" required tabindex="7" #fees="ngModel">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxFlex="40" fxLayoutAlign="space-between start">
|
||||
<button fxFlex="48" fxLayoutAlign="center center" mat-raised-button color="primary" [disabled]="invalidValues" type="submit" tabindex="8" (click)="onSendFunds()">
|
||||
</mat-checkbox>
|
||||
<div fxFlex="10" fxLayoutAlign="end start">
|
||||
<button fxFlex="90" fxLayoutAlign="center center" mat-raised-button color="primary" [disabled]="invalidValues" type="submit" tabindex="8">
|
||||
<p *ngIf="invalidValues && (address.touched || address.dirty) && (amount.touched || amount.dirty); else sendText">Invalid Values</p>
|
||||
<ng-template #sendText><p>Send</p></ng-template>
|
||||
</button>
|
||||
<button fxFlex="48" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="9" type="reset" (click)="resetData()">Clear</button>
|
||||
</div>
|
||||
<div fxFlex="10" fxLayoutAlign="end start">
|
||||
<button fxFlex="90" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="9" type="reset"
|
||||
(click)="resetData()">Clear</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template #withoutData><h3>Sats</h3></ng-template>
|
||||
<ng-template #withoutData>
|
||||
<h3>Sats</h3>
|
||||
</ng-template>
|
|
@ -29,9 +29,8 @@ export class CLOnChainComponent implements OnInit, OnDestroy {
|
|||
public information: GetInfoCL = {};
|
||||
public newAddress = '';
|
||||
public transaction: OnChainCL = {};
|
||||
public transTypes = [{id: '1', name: 'Target Confirmation Blocks'}, {id: '2', name: 'Fee'}];
|
||||
public selTransType = '1';
|
||||
public flgCustomAmount = '1';
|
||||
public feeRateTypes = [];
|
||||
public flgMinConf = false;
|
||||
private unsub: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private clEffects: CLEffects) {}
|
||||
|
@ -45,7 +44,7 @@ export class CLOnChainComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
|
||||
this.store.select('cl')
|
||||
.pipe(takeUntil(this.unsub[0]))
|
||||
.pipe(takeUntil(this.unsub[1]))
|
||||
.subscribe((rtlStore) => {
|
||||
rtlStore.effectErrorsCl.forEach(effectsErr => {
|
||||
if (effectsErr.action === 'FetchBalanceCL') {
|
||||
|
@ -54,6 +53,7 @@ export class CLOnChainComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
this.selNode = rtlStore.nodeSettings;
|
||||
this.information = rtlStore.information;
|
||||
this.feeRateTypes = rtlStore.feeRateTypes;
|
||||
this.addressTypes = rtlStore.addressTypes;
|
||||
|
||||
this.balance = rtlStore.balance;
|
||||
|
@ -79,94 +79,36 @@ export class CLOnChainComponent implements OnInit, OnDestroy {
|
|||
this.store.dispatch(new RTLActions.OpenSpinner('Getting New Address...'));
|
||||
this.store.dispatch(new RTLActions.GetNewAddressCL(this.selectedAddress));
|
||||
this.clEffects.setNewAddressCL
|
||||
.pipe(takeUntil(this.unsub[1]))
|
||||
.pipe(takeUntil(this.unsub[2]))
|
||||
.subscribe(newAddress => {
|
||||
this.newAddress = newAddress;
|
||||
});
|
||||
}
|
||||
|
||||
onSendFunds() {
|
||||
// const confirmationMsg = {
|
||||
// 'BTC Address': this.transaction.address,
|
||||
// };
|
||||
// if (!+this.flgCustomAmount) {
|
||||
// confirmationMsg['Sweep All'] = 'True';
|
||||
// this.transaction.sendAll = true;
|
||||
// } else {
|
||||
// confirmationMsg['Amount (' + this.information.smaller_currency_unit + ')'] = this.transaction.amount;
|
||||
// this.transaction.sendAll = false;
|
||||
// }
|
||||
// if (this.selTransType === '1') {
|
||||
// delete this.transaction.fees;
|
||||
// confirmationMsg['Target Confirmation Blocks'] = this.transaction.blocks;
|
||||
// } else {
|
||||
// delete this.transaction.blocks;
|
||||
// confirmationMsg['Fee (' + this.information.smaller_currency_unit + '/Byte)'] = this.transaction.fees;
|
||||
// }
|
||||
// this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data:
|
||||
// {type: 'CONFIRM', message: JSON.stringify(confirmationMsg), noBtnText: 'Cancel', yesBtnText: 'Send'}
|
||||
// }));
|
||||
|
||||
// this.rtlEffects.closeConfirm
|
||||
// .pipe(takeUntil(this.unsub[2]))
|
||||
// .subscribe(confirmRes => {
|
||||
// if (confirmRes) {
|
||||
// if (this.transaction.sendAll && !+this.appConfig.sso.rtlSSO) {
|
||||
// this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data:
|
||||
// {type: 'CONFIRM', titleMessage: 'Enter Login Password', noBtnText: 'Cancel', yesBtnText: 'Authorize', flgShowInput: true, getInputs: [
|
||||
// {placeholder: 'Enter Login Password', inputType: 'password', inputValue: ''}
|
||||
// ]}
|
||||
// }));
|
||||
// this.rtlEffects.closeConfirm
|
||||
// .pipe(takeUntil(this.unsub[3]))
|
||||
// .subscribe(pwdConfirmRes => {
|
||||
// if (pwdConfirmRes) {
|
||||
// const pwd = pwdConfirmRes[0].inputValue;
|
||||
// this.store.dispatch(new RTLActions.IsAuthorized(sha256(pwd)));
|
||||
// this.rtlEffects.isAuthorizedRes
|
||||
// .pipe(take(1))
|
||||
// .subscribe(authRes => {
|
||||
// if (authRes !== 'ERROR') {
|
||||
// this.dispatchToSendFunds();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// this.dispatchToSendFunds();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data:
|
||||
{type: 'CONFIRM', message: JSON.stringify(this.transaction), noBtnText: 'Cancel', yesBtnText: 'Send'}
|
||||
}));
|
||||
this.rtlEffects.closeConfirm
|
||||
.pipe(takeUntil(this.unsub[3]))
|
||||
.subscribe(confirmRes => {
|
||||
if (confirmRes) {
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Sending Funds...'));
|
||||
this.store.dispatch(new RTLActions.SetChannelTransactionCL(this.transaction));
|
||||
this.transaction = {};
|
||||
}
|
||||
|
||||
dispatchToSendFunds() {
|
||||
// this.store.dispatch(new RTLActions.OpenSpinner('Sending Funds...'));
|
||||
// this.store.dispatch(new RTLActions.SetChannelTransaction(this.transaction));
|
||||
// this.transaction = {address: '', amount: 0, blocks: 0, fees: 0};
|
||||
});
|
||||
}
|
||||
|
||||
get invalidValues(): boolean {
|
||||
return (undefined === this.transaction.address || this.transaction.address === '')
|
||||
|| (+this.flgCustomAmount && (undefined === this.transaction.amount || this.transaction.amount <= 0))
|
||||
|| (this.selTransType === '1' && (undefined === this.transaction.blocks || this.transaction.blocks <= 0))
|
||||
|| (this.selTransType === '2' && (undefined === this.transaction.fees || this.transaction.fees <= 0));
|
||||
}
|
||||
|
||||
onCustomClicked() {
|
||||
this.flgCustomAmount = '1';
|
||||
}
|
||||
|
||||
onOptionChange(event) {
|
||||
if (!+this.flgCustomAmount) {
|
||||
delete this.transaction.amount;
|
||||
}
|
||||
|| ((undefined === this.transaction.satoshis || this.transaction.satoshis <= 0))
|
||||
|| (this.flgMinConf && (undefined === this.transaction.minconf || this.transaction.minconf <= 0));
|
||||
}
|
||||
|
||||
resetData() {
|
||||
this.transaction.address = '';
|
||||
this.transaction.amount = 0;
|
||||
this.transaction.blocks = 0;
|
||||
this.transaction.fees = 0;
|
||||
this.transaction = {};
|
||||
this.flgMinConf = false;
|
||||
}
|
||||
|
||||
resetReceiveData() {
|
||||
|
|
|
@ -85,65 +85,66 @@ export class CLPaymentsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
onSendPayment() {
|
||||
// if (undefined !== this.paymentDecoded.timestamp_str) {
|
||||
// this.sendPayment();
|
||||
// } else {
|
||||
// this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
|
||||
// this.store.dispatch(new RTLActions.DecodePayment(this.paymentRequest));
|
||||
// this.clEffects.setDecodedPayment
|
||||
// .pipe(take(1))
|
||||
// .subscribe(decodedPayment => {
|
||||
// this.paymentDecoded = decodedPayment;
|
||||
// if (undefined !== this.paymentDecoded.timestamp_str) {
|
||||
// this.paymentDecoded.timestamp_str = (this.paymentDecoded.timestamp_str === '') ? '' :
|
||||
// formatDate(this.paymentDecoded.timestamp_str, 'MMM/dd/yy HH:mm:ss', 'en-US');
|
||||
// if (undefined === this.paymentDecoded.num_satoshis) {
|
||||
// this.paymentDecoded.num_satoshis = '0';
|
||||
// }
|
||||
// this.sendPayment();
|
||||
// } else {
|
||||
// this.resetData();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
if (undefined !== this.paymentDecoded.created_at_str) {
|
||||
this.sendPayment();
|
||||
} else {
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
|
||||
this.store.dispatch(new RTLActions.DecodePaymentCL(this.paymentRequest));
|
||||
this.clEffects.setDecodedPaymentCL
|
||||
.pipe(take(1))
|
||||
.subscribe(decodedPayment => {
|
||||
this.paymentDecoded = decodedPayment;
|
||||
if (undefined !== this.paymentDecoded.created_at_str) {
|
||||
this.paymentDecoded.created_at_str = (this.paymentDecoded.created_at_str === '') ? '' :
|
||||
formatDate(this.paymentDecoded.created_at_str, 'MMM/dd/yy HH:mm:ss', 'en-US');
|
||||
this.paymentDecoded.expire_at_str = (this.paymentDecoded.expire_at_str === '') ? '' :
|
||||
formatDate(this.paymentDecoded.expire_at_str, 'MMM/dd/yy HH:mm:ss', 'en-US');
|
||||
if (undefined === this.paymentDecoded.msatoshi) {
|
||||
this.paymentDecoded.msatoshi = 0;
|
||||
}
|
||||
this.sendPayment();
|
||||
} else {
|
||||
this.resetData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// sendPayment() {
|
||||
// this.flgAnimate = true;
|
||||
// this.newlyAddedPayment = this.paymentDecoded.payment_hash;
|
||||
// if (undefined === this.paymentDecoded.num_satoshis || this.paymentDecoded.num_satoshis === '' || this.paymentDecoded.num_satoshis === '0') {
|
||||
// const titleMsg = 'This is an empty invoice. Enter the amount (Sats) to pay.';
|
||||
// this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data: {
|
||||
// type: 'CONFIRM', titleMessage: titleMsg, message: JSON.stringify(this.paymentDecoded), noBtnText: 'Cancel', yesBtnText: 'Send', flgShowInput: true, getInputs: [
|
||||
// {placeholder: 'Amount (Sats)', inputType: 'number', inputValue: ''}
|
||||
// ]
|
||||
// }}));
|
||||
// this.rtlEffects.closeConfirm
|
||||
// .pipe(take(1))
|
||||
// .subscribe(confirmRes => {
|
||||
// if (confirmRes) {
|
||||
// this.paymentDecoded.num_satoshis = confirmRes[0].inputValue;
|
||||
// this.store.dispatch(new RTLActions.OpenSpinner('Sending Payment...'));
|
||||
// this.store.dispatch(new RTLActions.SendPayment([this.paymentRequest, this.paymentDecoded, true]));
|
||||
// this.resetData();
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data: {
|
||||
// type: 'CONFIRM', titleMessage: 'Send Payment', noBtnText: 'Cancel', yesBtnText: 'Send', message: JSON.stringify(this.paymentDecoded)
|
||||
// }}));
|
||||
// this.rtlEffects.closeConfirm
|
||||
// .pipe(take(1))
|
||||
// .subscribe(confirmRes => {
|
||||
// if (confirmRes) {
|
||||
// this.store.dispatch(new RTLActions.OpenSpinner('Sending Payment...'));
|
||||
// this.store.dispatch(new RTLActions.SendPayment([this.paymentRequest, this.paymentDecoded, false]));
|
||||
// this.resetData();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
sendPayment() {
|
||||
this.flgAnimate = true;
|
||||
this.newlyAddedPayment = this.paymentDecoded.payment_hash;
|
||||
if (undefined === this.paymentDecoded.msatoshi || this.paymentDecoded.msatoshi === 0) {
|
||||
const titleMsg = 'This is an empty invoice. Enter the amount (Sats) to pay.';
|
||||
this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data: {
|
||||
type: 'CONFIRM', titleMessage: titleMsg, message: JSON.stringify(this.paymentDecoded), noBtnText: 'Cancel', yesBtnText: 'Send', flgShowInput: true, getInputs: [
|
||||
{placeholder: 'Amount (mSats)', inputType: 'number', inputValue: ''}
|
||||
]
|
||||
}}));
|
||||
this.rtlEffects.closeConfirm
|
||||
.pipe(take(1))
|
||||
.subscribe(confirmRes => {
|
||||
if (confirmRes) {
|
||||
this.paymentDecoded.msatoshi = confirmRes[0].inputValue;
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Sending Payment...'));
|
||||
this.store.dispatch(new RTLActions.SendPaymentCL({invoice: this.paymentRequest, amount: confirmRes[0].inputValue}));
|
||||
this.resetData();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data: {
|
||||
type: 'CONFIRM', titleMessage: 'Send Payment', noBtnText: 'Cancel', yesBtnText: 'Send', message: JSON.stringify(this.paymentDecoded)
|
||||
}}));
|
||||
this.rtlEffects.closeConfirm
|
||||
.pipe(take(1))
|
||||
.subscribe(confirmRes => {
|
||||
if (confirmRes) {
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Sending Payment...'));
|
||||
this.store.dispatch(new RTLActions.SendPaymentCL({invoice: this.paymentRequest}));
|
||||
this.resetData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// onVerifyPayment() {
|
||||
// this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
|
||||
|
|
|
@ -57,7 +57,6 @@ export class CLPeersComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.store.dispatch(new RTLActions.FetchPeersCL());
|
||||
this.store.select('cl')
|
||||
.pipe(takeUntil(this.unSubs[0]))
|
||||
.subscribe((rtlStore) => {
|
||||
|
|
|
@ -267,7 +267,7 @@ export class CLEffects implements OnDestroy {
|
|||
ofType(RTLActions.SAVE_NEW_CHANNEL_CL),
|
||||
mergeMap((action: RTLActions.SaveNewChannelCL) => {
|
||||
return this.httpClient.post(this.CHILD_API_URL + environment.CHANNELS_API, {
|
||||
channelId: action.payload.channelId, satoshis: action.payload.satoshis, feeRate: action.payload.feeRate, private: action.payload.private, minconf: (action.payload.minconf) ? action.payload.minconf : ''
|
||||
id: action.payload.peerId, satoshis: action.payload.satoshis, feeRate: action.payload.feeRate, announce: action.payload.announce, minconf: (action.payload.minconf) ? action.payload.minconf : null
|
||||
})
|
||||
.pipe(
|
||||
map((postRes: any) => {
|
||||
|
@ -383,31 +383,19 @@ export class CLEffects implements OnDestroy {
|
|||
ofType(RTLActions.SEND_PAYMENT_CL),
|
||||
withLatestFrom(this.store.select('root')),
|
||||
mergeMap(([action, store]: [RTLActions.SendPaymentCL, any]) => {
|
||||
let queryHeaders = {};
|
||||
if (action.payload[2]) {
|
||||
queryHeaders = { paymentDecoded: action.payload[1] };
|
||||
} else {
|
||||
queryHeaders = { paymentReq: action.payload[0] };
|
||||
}
|
||||
return this.httpClient.post(this.CHILD_API_URL + environment.PAYMENTS_API, queryHeaders)
|
||||
return this.httpClient.post(this.CHILD_API_URL + environment.PAYMENTS_API, action.payload)
|
||||
.pipe(
|
||||
map((sendRes: any) => {
|
||||
this.logger.info(sendRes);
|
||||
if (sendRes.payment_error) {
|
||||
return this.handleErrorWithAlert('ERROR', 'Send Payment Failed', this.CHILD_API_URL + environment.PAYMENTS_API, { status: sendRes.payment_error.status, error: sendRes.payment_error.error.message });
|
||||
this.store.dispatch(new RTLActions.CloseSpinner());
|
||||
if (sendRes.error) {
|
||||
return this.handleErrorWithAlert('ERROR', 'Send Payment Failed', this.CHILD_API_URL + environment.PAYMENTS_API, { status: sendRes.status, error: sendRes.error.message });
|
||||
} else {
|
||||
const confirmationMsg = { 'Destination': action.payload[1].destination, 'Timestamp': action.payload[1].timestamp_str, 'Expiry': action.payload[1].expiry };
|
||||
confirmationMsg['Amount (' + ((undefined === store.information.smaller_currency_unit) ?
|
||||
'Sats' : store.information.smaller_currency_unit) + ')'] = action.payload[1].num_satoshis;
|
||||
const msg = {};
|
||||
msg['Total Fee (' + ((undefined === store.information.smaller_currency_unit) ? 'Sats' : store.information.smaller_currency_unit) + ')'] =
|
||||
(sendRes.payment_route.total_fees_msat / 1000);
|
||||
Object.assign(msg, confirmationMsg);
|
||||
this.store.dispatch(new RTLActions.OpenAlert({
|
||||
width: '70%',
|
||||
data: { type: 'SUCCESS', titleMessage: 'Payment Sent Successfully!', message: JSON.stringify(msg) }
|
||||
data: { type: 'SUCCESS', titleMessage: 'Payment Sent Successfully!', message: JSON.stringify(sendRes) }
|
||||
}));
|
||||
// this.store.dispatch(new RTLActions.FetchChannelsCL({ routeParam: 'all' }));
|
||||
this.store.dispatch(new RTLActions.FetchChannelsCL());
|
||||
this.store.dispatch(new RTLActions.FetchBalanceCL());
|
||||
this.store.dispatch(new RTLActions.FetchPaymentsCL());
|
||||
return {
|
||||
|
@ -637,6 +625,29 @@ export class CLEffects implements OnDestroy {
|
|||
));
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
SetChannelTransactionCL = this.actions$.pipe(
|
||||
ofType(RTLActions.SET_CHANNEL_TRANSACTION_CL),
|
||||
mergeMap((action: RTLActions.SetChannelTransactionCL) => {
|
||||
this.store.dispatch(new RTLActions.ClearEffectErrorCl('SetChannelTransactionCL'));
|
||||
return this.httpClient.post(this.CHILD_API_URL + environment.ON_CHAIN_API, action.payload)
|
||||
.pipe(
|
||||
map((postRes: any) => {
|
||||
this.logger.info(postRes);
|
||||
this.store.dispatch(new RTLActions.CloseSpinner());
|
||||
this.store.dispatch(new RTLActions.FetchBalanceCL());
|
||||
return {
|
||||
type: RTLActions.OPEN_ALERT,
|
||||
payload: { data: { type: 'SUCCESS', titleMessage: 'Fund Sent Successfully!' } }
|
||||
};
|
||||
}),
|
||||
catchError((err: any) => {
|
||||
this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'SetChannelTransactionCL', code: err.status, message: err.error.error }));
|
||||
return this.handleErrorWithAlert('ERROR', 'Sending Fund Failed', this.CHILD_API_URL + environment.ON_CHAIN_API, err);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
handleErrorWithoutAlert(actionName: string, err: { status: number, error: any }) {
|
||||
this.logger.error(err);
|
||||
if (err.status === 401) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { SelNodeChild } from '../../shared/models/RTLconfig';
|
||||
import { GetInfoCL, FeesCL, BalanceCL, LocalRemoteBalanceCL, AddressTypeCL, PeerCL, PaymentCL, ChannelCL, FeeRatesCL, ForwardingHistoryResCL, ListInvoicesCL } from '../../shared/models/clModels';
|
||||
import { GetInfoCL, FeesCL, BalanceCL, LocalRemoteBalanceCL, AddressTypeCL, PeerCL, PaymentCL, ChannelCL, FeeRatesCL, ForwardingHistoryResCL, ListInvoicesCL, FeeRateTypeCL } from '../../shared/models/clModels';
|
||||
import { ErrorPayload } from '../../shared/models/errorPayload';
|
||||
import * as RTLActions from '../../store/rtl.actions';
|
||||
|
||||
|
@ -19,6 +19,7 @@ export interface CLState {
|
|||
invoices: ListInvoicesCL;
|
||||
totalInvoices: number;
|
||||
addressTypes: AddressTypeCL[];
|
||||
feeRateTypes: FeeRateTypeCL[];
|
||||
}
|
||||
|
||||
export const initCLState: CLState = {
|
||||
|
@ -39,6 +40,11 @@ export const initCLState: CLState = {
|
|||
addressTypes: [
|
||||
{ addressId: '0', addressTp: 'bech32', addressDetails: 'bech32' },
|
||||
{ addressId: '1', addressTp: 'p2sh-segwit', addressDetails: 'p2sh-segwit (default)' }
|
||||
],
|
||||
feeRateTypes: [
|
||||
{ feeRateId: 'urgent', feeRateType: 'Urgent'},
|
||||
{ feeRateId: 'normal', feeRateType: 'Normal'},
|
||||
{ feeRateId: 'slow', feeRateType: 'Slow'},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -83,10 +83,9 @@ export interface ListInvoicesCL {
|
|||
|
||||
export interface OnChainCL {
|
||||
address?: string;
|
||||
amount?: number;
|
||||
sendAll?: boolean;
|
||||
blocks?: number;
|
||||
fees?: number;
|
||||
satoshis?: number;
|
||||
feeRate?: string;
|
||||
minconf?: number;
|
||||
}
|
||||
|
||||
export interface AddressTypeCL {
|
||||
|
@ -95,6 +94,11 @@ export interface AddressTypeCL {
|
|||
addressDetails?: string;
|
||||
}
|
||||
|
||||
export interface FeeRateTypeCL {
|
||||
feeRateId?: string;
|
||||
feeRateType?: string;
|
||||
}
|
||||
|
||||
export interface HopCL {
|
||||
hop_sequence?: number;
|
||||
pubkey_alias?: string;
|
||||
|
@ -124,18 +128,18 @@ export interface PaymentCL {
|
|||
}
|
||||
|
||||
export interface PayRequestCL {
|
||||
payment_hash?: string;
|
||||
route_hints?: any[];
|
||||
timestamp?: number;
|
||||
timestamp_str?: string;
|
||||
fallback_addr?: string;
|
||||
cltv_expiry?: number;
|
||||
description_hash?: string;
|
||||
destination?: string;
|
||||
currency?: string;
|
||||
created_at?: number;
|
||||
expiry?: number;
|
||||
payee?: string;
|
||||
msatoshi?: number;
|
||||
amount_msat?: string;
|
||||
description?: string;
|
||||
num_satoshis?: string;
|
||||
btc_num_satoshis?: string;
|
||||
min_final_cltv_expiry?: number;
|
||||
payment_hash?: string;
|
||||
signature?: string;
|
||||
created_at_str?: string;
|
||||
expire_at_str?: string;
|
||||
}
|
||||
|
||||
export interface ForwardingEventCL {
|
||||
|
|
|
@ -103,4 +103,10 @@
|
|||
padding: 0 4px 0 12px;
|
||||
}
|
||||
|
||||
.row-disabled {
|
||||
background-color: gray;
|
||||
.mat-icon {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Action } from '@ngrx/store';
|
|||
|
||||
import { ErrorPayload } from '../shared/models/errorPayload';
|
||||
import { RTLConfiguration, Settings, LightningNode, GetInfoRoot, SelNodeChild } from '../shared/models/RTLconfig';
|
||||
import { GetInfoCL, FeesCL, AddressTypeCL, PeerCL, PaymentCL, PayRequestCL, QueryRoutesCL, ChannelCL, FeeRatesCL, ForwardingHistoryResCL, InvoiceCL, ListInvoicesCL } from '../shared/models/clModels';
|
||||
import { GetInfoCL, FeesCL, AddressTypeCL, PeerCL, PaymentCL, PayRequestCL, QueryRoutesCL, ChannelCL, FeeRatesCL, ForwardingHistoryResCL, InvoiceCL, ListInvoicesCL, OnChainCL } from '../shared/models/clModels';
|
||||
import {
|
||||
GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, ListInvoices, Payment, GraphNode, AddressType,
|
||||
PayRequest, ChannelsTransaction, PendingChannels, ClosedChannel, Transaction, SwitchReq, SwitchRes, QueryRoutes
|
||||
|
@ -141,6 +141,7 @@ export const SET_TOTAL_INVOICES_CL = 'SET_TOTAL_INVOICES_CL';
|
|||
export const SAVE_NEW_INVOICE_CL = 'SAVE_NEW_INVOICE_CL';
|
||||
export const ADD_INVOICE_CL = 'ADD_INVOICE_CL';
|
||||
export const DELETE_EXPIRED_INVOICE_CL = 'DELETE_EXPIRED_INVOICE_CL';
|
||||
export const SET_CHANNEL_TRANSACTION_CL = 'SET_CHANNEL_TRANSACTION_CL';
|
||||
|
||||
export class VoidAction implements Action {
|
||||
readonly type = VOID;
|
||||
|
@ -662,7 +663,7 @@ export class SetDecodedPaymentCL implements Action {
|
|||
|
||||
export class SendPaymentCL implements Action {
|
||||
readonly type = SEND_PAYMENT_CL;
|
||||
constructor(public payload: [string, PayRequest, boolean]) {} // payload = [paymentReqStr, paymentDecoded, EmptyAmtInvoice]
|
||||
constructor(public payload: { invoice: string, amount?: number }) {}
|
||||
}
|
||||
|
||||
export class GetQueryRoutesCL implements Action {
|
||||
|
@ -691,7 +692,7 @@ export class UpdateChannelsCL implements Action {
|
|||
|
||||
export class SaveNewChannelCL implements Action {
|
||||
readonly type = SAVE_NEW_CHANNEL_CL;
|
||||
constructor(public payload: {channelId: string, satoshis: number, feeRate: string, private: boolean, minconf?: number}) {}
|
||||
constructor(public payload: {peerId: string, satoshis: number, feeRate: string, announce: boolean, minconf?: number}) {}
|
||||
}
|
||||
|
||||
export class CloseChannelCL implements Action {
|
||||
|
@ -764,6 +765,11 @@ export class DeleteExpiredInvoiceCL implements Action {
|
|||
constructor(public payload?: number) {} // maxexpiry
|
||||
}
|
||||
|
||||
export class SetChannelTransactionCL implements Action {
|
||||
readonly type = SET_CHANNEL_TRANSACTION_CL;
|
||||
constructor(public payload: OnChainCL) {}
|
||||
}
|
||||
|
||||
export type RTLActions =
|
||||
ClearEffectErrorRoot | EffectErrorRoot | ClearEffectErrorLnd | EffectErrorLnd | ClearEffectErrorCl | EffectErrorCl |
|
||||
VoidAction | OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings |
|
||||
|
@ -793,7 +799,7 @@ export type RTLActions =
|
|||
FetchPeersCL | SetPeersCL | AddPeerCL | DetachPeerCL | SaveNewPeerCL | RemovePeerCL |
|
||||
FetchChannelsCL | SetChannelsCL | UpdateChannelsCL | SaveNewChannelCL | CloseChannelCL | RemoveChannelCL |
|
||||
FetchPaymentsCL | SetPaymentsCL | SendPaymentCL | DecodePaymentCL | SetDecodedPaymentCL |
|
||||
GetQueryRoutesCL | SetQueryRoutesCL |
|
||||
GetQueryRoutesCL | SetQueryRoutesCL | SetChannelTransactionCL |
|
||||
PeerLookupCL | ChannelLookupCL | InvoiceLookupCL | SetLookupCL |
|
||||
GetForwardingHistoryCL | SetForwardingHistoryCL |
|
||||
FetchInvoicesCL | SetInvoicesCL | SetTotalInvoicesCL | SaveNewInvoiceCL | AddInvoiceCL | DeleteExpiredInvoiceCL;
|
||||
|
|
Loading…
Add table
Reference in a new issue