update allow new swap

cln-peer-swap
ShahanaFarooqui 10 months ago
parent 9c4929d31b
commit 556b8dd51f

@ -1012,7 +1012,7 @@ export class CLNEffects implements OnDestroy {
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchPSPolicy', status: APICallStatusEnum.COMPLETED } }));
return {
type: CLNActions.SET_PS_POLICY_CLN,
payload: res || {}
payload: res || { min_swap_amount_msat: 100000000 }
};
}), catchError((err: any) => {
this.handleErrorWithoutAlert('FetchPSPolicy', UI_MESSAGES.NO_SPINNER, 'Fetching Peerswap Policy Failed.', err);

@ -15,25 +15,22 @@
</div>
<div *ngIf="enablePeerswap && errorMessage === ''" class="padding-gap-large bordered-box">
<div fxLayout="row">
<div fxFlex="50">
<h4 fxLayoutAlign="start" class="font-bold-500">Allow New Swaps</h4>
<span class="foreground-secondary-text">{{psPolicy?.allow_new_swaps ? 'Yes' : 'No'}}</span>
</div>
<div fxFlex="50">
<h4 fxLayoutAlign="start" class="font-bold-500">Accept All Peers</h4>
<span class="foreground-secondary-text">{{psPolicy?.accept_all_peers ? 'Yes' : 'No'}}</span>
</div>
<mat-slide-toggle fxLayoutAlign="start center" tabindex="2" color="primary" name="allownew" [(ngModel)]="allowNewSwaps" (change)="updateAllowNewSwaps()">Allow New Swaps</mat-slide-toggle>
</div>
<mat-divider class="my-1" [inset]="true"></mat-divider>
<div fxLayout="row">
<div fxFlex="50">
<h4 fxLayoutAlign="start" class="font-bold-500">Onchain Reserve (Sats)</h4>
<span class="foreground-secondary-text">{{psPolicy?.reserve_onchain_msat / 1000 | number}}</span>
<div fxFlex="33">
<h4 fxLayoutAlign="start" class="font-bold-500">Accept All Peers</h4>
<span class="foreground-secondary-text">{{psPolicy?.accept_all_peers ? 'Yes' : 'No'}}</span>
</div>
<div fxFlex="50">
<div fxFlex="33">
<h4 fxLayoutAlign="start" class="font-bold-500">Min Swap Amount (Sats)</h4>
<span class="foreground-secondary-text">{{psPolicy?.min_swap_amount_msat / 1000 | number}}</span>
</div>
<div fxFlex="34">
<h4 fxLayoutAlign="start" class="font-bold-500">Onchain Reserve (Sats)</h4>
<span class="foreground-secondary-text">{{psPolicy?.reserve_onchain_msat / 1000 | number}}</span>
</div>
</div>
<mat-divider class="my-1" [inset]="true"></mat-divider>
<div fxLayout="row">

@ -11,7 +11,7 @@ import { faInfoCircle, faExclamationTriangle } from '@fortawesome/free-solid-svg
import { updateServiceSettings } from '../../../../../store/rtl.actions';
import { RTLState } from '../../../../../store/rtl.state';
import { setChildNodeSettingsLND } from '../../../../../lnd/store/lnd.actions';
import { fetchPSPolicy, setChildNodeSettingsCL } from '../../../../../cln/store/cln.actions';
import { fetchPSPolicy, setChildNodeSettingsCL, setPSPolicy } from '../../../../../cln/store/cln.actions';
import { setChildNodeSettingsECL } from '../../../../../eclair/store/ecl.actions';
import { rootSelectedNode } from '../../../../../store/rtl.selector';
import { PeerswapPolicy } from '../../../../models/peerswapModels';
@ -30,7 +30,7 @@ export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy {
public faExclamationTriangle = faExclamationTriangle;
public selNode: ConfigSettingsNode | any;
public enablePeerswap = false;
public allowSwapRequests = false;
public allowNewSwaps = false;
public psPolicy: PeerswapPolicy = { min_swap_amount_msat: 100000000 };
public peerswapPeersLists = PeerswapPeersLists;
public errorMessage = '';
@ -60,6 +60,7 @@ export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy {
this.errorMessage = 'ERROR: ' + (!this.apiCallStatus.message ? '' : (typeof (this.apiCallStatus.message) === 'object') ? JSON.stringify(this.apiCallStatus.message) : this.apiCallStatus.message);
}
this.psPolicy = policySeletor.policy;
this.allowNewSwaps = policySeletor.policy.allow_new_swaps;
this.logger.info(policySeletor);
});
}
@ -95,7 +96,7 @@ export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy {
this.dataService.addPeerToPeerswap(ngModelVar, list).pipe(takeUntil(this.unSubs[2])).
subscribe({
next: (res: PeerswapPolicy) => {
this.psPolicy = res || { min_swap_amount_msat: 100000000 };
this.store.dispatch(setPSPolicy({ payload: (res || { min_swap_amount_msat: 100000000 }) }));
if (list !== PeerswapPeersLists.ALLOWED) {
this.dataForSuspiciousList.ngModelVar = '';
} else {
@ -127,7 +128,7 @@ export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy {
this.dataService.removePeerFromPeerswap(peerNodeId, list).pipe(takeUntil(this.unSubs[3])).
subscribe({
next: (res: PeerswapPolicy) => {
this.psPolicy = res || { min_swap_amount_msat: 100000000 };
this.store.dispatch(setPSPolicy({ payload: (res || { min_swap_amount_msat: 100000000 }) }));
}, error: (err) => {
if (list !== PeerswapPeersLists.ALLOWED) {
this.dataForSuspiciousList.addRemoveError = 'ERROR: ' + err;
@ -145,6 +146,15 @@ export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy {
});
}
updateAllowNewSwaps() {
this.dataService.allowPeerswapRequests(this.allowNewSwaps).pipe(takeUntil(this.unSubs[4])).
subscribe({
next: (res: PeerswapPolicy) => {
this.store.dispatch(setPSPolicy({ payload: (res || { min_swap_amount_msat: 100000000 }) }));
}
});
}
ngOnDestroy() {
this.unSubs.forEach((unsub) => {
unsub.next();

@ -41,23 +41,23 @@ export interface SwapData {
coop_close_message?: string;
cancel_message_obj?: any;
cancel_message?: string;
peer_nod_id?: string;
peer_node_id?: string;
initiator_node_id?: string;
created_at?: number;
role?: number;
fsm_state?: string;
PrivkeyBytes?: string;
private_key?: string;
fee_preimage?: string;
opening_tx_fee?: number;
'opening_tx-hex'?: string;
opening_tx_hex?: string;
opening_block_height?: string;
claim_tx_id?: string;
claim_payment_hash?: string;
claim_preimage?: string;
blinding_key?: string;
last_message?: string;
NextMessage?: string;
NextMessageType?: number;
next_message?: string;
next_message_type?: number;
}
export interface ActiveSwap {

Loading…
Cancel
Save