Channel Restore

Channel Restore
pull/209/head
Shahana Farooqui 5 years ago
parent fdafe00c8b
commit 6e763281a3

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -9,5 +9,5 @@
<link rel="stylesheet" href="styles.6dc77cb683437fd2a879.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.f8adc32abf38a237412d.js"></script><script src="polyfills-es5.763f4f23e8aee5ec234d.js" nomodule></script><script src="polyfills.e59b6f9dc696bd89cf7f.js"></script><script src="main.a864964130872eb407fa.js"></script></body>
<script src="runtime.236d175ca3afc66ac73b.js"></script><script src="polyfills-es5.763f4f23e8aee5ec234d.js" nomodule></script><script src="polyfills.e59b6f9dc696bd89cf7f.js"></script><script src="main.bafd7ef59102001c3bc1.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

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,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:"d7ae515c07ced9330b77",7:"7d4ecad9df6179608c88"}[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++)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:"5af2985da59dce5e7dd1",7:"04ee362a2ccd18143c5e"}[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()}([]);

@ -98,3 +98,53 @@ exports.postBackupVerify = (req, res, next) => {
});
}
};
exports.postRestore = (req, res, next) => {
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/channels/backup/restore';
let channel_restore_file = '';
let message = '';
let restore_backup = '';
if (req.params.channelPoint === 'ALL') {
message = 'All Channels Restore Successful!';
channel_restore_file = common.selectedNode.channel_backup_path + common.path_separator + 'channel-all.bak';
let exists = fs.existsSync(channel_restore_file);
if (exists) {
restore_backup = fs.readFileSync(channel_restore_file, 'utf-8');
if (restore_backup !== '') {
restore_backup = JSON.parse(restore_backup);
// options.form = JSON.stringify({chan_backups: restore_backup.single_chan_backups});
options.form = JSON.stringify({multi_chan_backup: restore_backup.multi_chan_backup.multi_chan_backup});
} else {
res.status(404).json({ message: 'Channels backup to restore does not Exist!' });
}
} else {
restore_backup = '';
res.status(404).json({ message: 'Channels backup to restore does not Exist!' });
}
} else {
message = 'Channel ' + req.params.channelPoint + ' Restore Successful!';
channel_restore_file = common.selectedNode.channel_backup_path + common.path_separator + 'channel-' + req.params.channelPoint.replace(':', '-') + '.bak';
let exists = fs.existsSync(channel_restore_file);
if (exists) {
restore_backup = fs.readFileSync(channel_restore_file, 'utf-8');
options.form = JSON.stringify({ chan_backups: { chan_backups: [JSON.parse(restore_backup)] } });
} else {
restore_backup = '';
res.status(404).json({ message: 'Channel backup to restore does not Exist!' });
}
}
if (restore_backup !== '') {
request.post(options).then(function (body) {
logger.info({fileName: 'Channels Backup Restore', msg: 'Channel Backup Restore: ' + JSON.stringify(body)});
res.status(201).json({ message: message });
})
.catch(function (err) {
logger.error({fileName: 'Channels Backup Restore', lineNum: 143, msg: 'Channel Backup Restore: ' + JSON.stringify(err)});
return res.status(404).json({
message: 'Channel restore failed!',
error: err.error
});
});
}
};

@ -5,5 +5,6 @@ const authCheck = require("../authCheck");
router.get("/:channelPoint", authCheck, ChannelsBackupController.getBackup);
router.post("/verify/:channelPoint", authCheck, ChannelsBackupController.postBackupVerify);
router.post("/restore/:channelPoint", authCheck, ChannelsBackupController.postRestore);
module.exports = router;

@ -9,8 +9,9 @@
<mat-card-content>
<div fxLayout="column" fxLayout.gt-sm="row wrap" fxFlex="100" fxLayoutAlign="space-between start">
<h4 fxFlex="100">Backup folder location: {{selNode.channelBackupPath}}</h4>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1" (click)="onBackupChannels({})">Backup</button>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="2" (click)="onVerifyChannels({})">Verify Backup</button>
<button fxFlex="33" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1" (click)="onBackupChannels({})">Backup</button>
<button fxFlex="33" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="2" (click)="onVerifyChannels({})">Verify Backup</button>
<button fxFlex="33" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="3" (click)="onRestoreChannels({})">Restore</button>
</div>
</mat-card-content>
</mat-card>
@ -36,7 +37,11 @@
</ng-container>
<ng-container matColumnDef="verify">
<th mat-header-cell *matHeaderCellDef>Verify</th>
<td mat-cell *matCellDef="let channel"><mat-icon color="accent" (click)="onVerifyChannels(channel)">verified_user</mat-icon></td>
<td mat-cell *matCellDef="let channel"><mat-icon color="primary" (click)="onVerifyChannels(channel)">verified_user</mat-icon></td>
</ng-container>
<ng-container matColumnDef="restore">
<th mat-header-cell *matHeaderCellDef>Restore</th>
<td mat-cell *matCellDef="let channel"><mat-icon color="accent" (click)="onRestoreChannels(channel)">restore</mat-icon></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>

@ -23,7 +23,7 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
export class ChannelBackupComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: true }) sort: MatSort;
public selNode: SelNodeChild = {};
public displayedColumns = ['chan_id', 'backup', 'verify'];
public displayedColumns = ['chan_id', 'backup', 'verify', 'restore'];
public selChannel: Channel;
public channels: any;
public flgLoading: Array<Boolean | 'error'> = [true]; // 0: channels
@ -82,6 +82,11 @@ export class ChannelBackupComponent implements OnInit, OnDestroy {
this.store.dispatch(new RTLActions.VerifyChannels({channelPoint: (selChannel.channel_point) ? selChannel.channel_point : 'ALL'}));
}
onRestoreChannels(selChannel: Channel) {
this.store.dispatch(new RTLActions.OpenSpinner('Restoring Channels...'));
this.store.dispatch(new RTLActions.RestoreChannels({channelPoint: (selChannel.channel_point) ? selChannel.channel_point : 'ALL'}));
}
onChannelClick(selRow: Channel, event: any) {
const flgButtonsClicked = event.target.className.includes('mat-icon')
|| event.target.className.includes('mat-column-backup')

@ -422,6 +422,42 @@ export class LNDEffects implements OnDestroy {
}
));
@Effect()
restoreChannels = this.actions$.pipe(
ofType(RTLActions.RESTORE_CHANNELS),
mergeMap((action: RTLActions.RestoreChannels) => {
this.store.dispatch(new RTLActions.ClearEffectErrorLnd('RestoreChannels'));
return this.httpClient.post(this.CHILD_API_URL + environment.CHANNELS_BACKUP_API + '/restore/' + action.payload.channelPoint, {})
.pipe(
map((postRes: any) => {
this.logger.info(postRes);
this.store.dispatch(new RTLActions.CloseSpinner());
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: { type: 'SUCCESS', titleMessage: postRes.message } }));
return {
type: RTLActions.RESTORE_CHANNELS_RES,
payload: postRes.message
};
}),
catchError((err: any) => {
this.store.dispatch(new RTLActions.CloseSpinner());
this.logger.error(err);
this.store.dispatch(new RTLActions.EffectErrorLnd({ action: 'RestoreChannels', code: err.status, message: err.error.error }));
return of(
{
type: RTLActions.OPEN_ALERT,
payload: {
width: '70%', data: {
type: 'ERROR', titleMessage: 'Unable to Restore Channel. Try again later.',
message: JSON.stringify({ code: err.status, Message: err.error.message })
}
}
}
);
})
);
}
));
@Effect()
fetchFees = this.actions$.pipe(
ofType(RTLActions.FETCH_FEES),

@ -60,6 +60,8 @@ export const BACKUP_CHANNELS = 'BACKUP_CHANNELS';
export const VERIFY_CHANNELS = 'VERIFY_CHANNELS';
export const BACKUP_CHANNELS_RES = 'BACKUP_CHANNELS_RES';
export const VERIFY_CHANNELS_RES = 'VERIFY_CHANNELS_RES';
export const RESTORE_CHANNELS = 'RESTORE_CHANNELS';
export const RESTORE_CHANNELS_RES = 'RESTORE_CHANNELS_RES';
export const FETCH_INVOICES = 'FETCH_INVOICES';
export const SET_INVOICES = 'SET_INVOICES';
export const SET_TOTAL_INVOICES = 'SET_TOTAL_INVOICES';
@ -392,6 +394,16 @@ export class VerifyChannelsRes implements Action {
constructor(public payload: string) {}
}
export class RestoreChannels implements Action {
readonly type = RESTORE_CHANNELS;
constructor(public payload: {channelPoint: string}) {}
}
export class RestoreChannelsRes implements Action {
readonly type = RESTORE_CHANNELS_RES;
constructor(public payload: string) {}
}
export class FetchInvoices implements Action {
readonly type = FETCH_INVOICES;
constructor(public payload: {num_max_invoices?: number, index_offset?: number, reversed?: boolean}) {}
@ -795,7 +807,7 @@ export type RTLActions =
FetchNetwork | SetNetwork |
FetchChannels | SetChannels | SetPendingChannels | SetClosedChannels | UpdateChannels |
SaveNewChannel | CloseChannel | RemoveChannel |
BackupChannels | VerifyChannels | BackupChannelsRes | VerifyChannelsRes |
BackupChannels | VerifyChannels | BackupChannelsRes | VerifyChannelsRes | RestoreChannels | RestoreChannelsRes |
FetchTransactions | SetTransactions |
FetchInvoices | SetInvoices | SetTotalInvoices |
FetchPayments | SetPayments | SendPayment |

Loading…
Cancel
Save