Remodel usergen form. Add fee limit hparams.

This commit is contained in:
Reckless_Satoshi 2022-01-30 05:18:32 -08:00
parent c21e230c76
commit 64115a8bb5
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
8 changed files with 48 additions and 34 deletions

View File

@ -43,5 +43,10 @@ INVOICE_AND_ESCROW_DURATION = 30
# Time to confim chat and confirm fiat (time to Fiat Sent confirmation) HOURS
FIAT_EXCHANGE_DURATION = 4
# Proportional routing fee limit (fraction of total payout: % / 100)
PROPORTIONAL_ROUTING_FEE_LIMIT = 0.0002
# Base flat limit fee for routing in Sats (used only when proportional is lower than this)
MIN_FLAT_ROUTING_FEE_LIMIT = 10
# Username for HTLCs escrows
ESCROW_USERNAME = 'admin'

View File

@ -186,7 +186,7 @@ class LNNode():
def pay_invoice(cls, invoice, num_satoshis):
'''Sends sats to buyer'''
fee_limit_sat = int(max(num_satoshis * 0.0002, 10)) # 200 ppm or 10 sats
fee_limit_sat = int(max(num_satoshis * float(config('PROPORTIONAL_ROUTING_FEE_LIMIT')), float(config('MIN_FLAT_ROUTING_FEE_LIMIT')))) # 200 ppm or 10 sats
request = routerrpc.SendPaymentRequest(
payment_request=invoice,
fee_limit_sat=fee_limit_sat,

View File

@ -24,8 +24,7 @@ export default class BookPage extends Component {
getOrderDetails(type, currency) {
fetch('/api/book' + '?currency=' + currency + "&type=" + type)
.then((response) => response.json())
.then((data) => console.log(data) &
this.setState({
.then((data) => this.setState({
orders: data,
not_found: data.not_found,
loading: false,
@ -33,7 +32,6 @@ export default class BookPage extends Component {
}
handleRowClick=(e)=>{
console.log(e)
this.props.history.push('/order/' + e);
}

View File

@ -210,7 +210,9 @@ export default class BottomBar extends Component {
// TODO Link to router and do this.props.history.push
<ListItemButton component="a" href={window.location.origin +'/order/'+this.state.active_order_id}>
<ListItemIcon>
<NumbersIcon color="primary"/>
<Badge badgeContent="" color="primary">
<NumbersIcon color="primary"/>
</Badge>
</ListItemIcon>
<ListItemText primary={'One active order #'+this.state.active_order_id} secondary="Your current order"/>
</ListItemButton>
@ -255,7 +257,7 @@ bottomBarDesktop =()=>{
<Grid item xs={2}>
<ListItemButton onClick={this.handleClickOpenProfile} >
<ListItemAvatar sx={{ width: 30, height: 30 }} >
<Badge badgeContent={(this.state.active_order_id > 0 & !this.state.profileShown) ? "1": null} color="primary">
<Badge badgeContent={(this.state.active_order_id > 0 & !this.state.profileShown) ? "": null} color="primary">
<Avatar className='rotatedAvatar' sx={{margin: 0, top: -13}}
alt={this.props.nickname}
src={this.props.nickname ? window.location.origin +'/static/assets/avatars/' + this.props.nickname + '.png' : null}

View File

@ -103,7 +103,6 @@ export default class MakerPage extends Component {
handleCreateOfferButtonPressed=()=>{
this.state.amount == null ? this.setState({amount: 0}) : null;
console.log(this.state)
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken')},

View File

@ -184,7 +184,6 @@ export default class OrderPage extends Component {
}
handleClickTakeOrderButton=()=>{
console.log(this.state)
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
@ -216,7 +215,6 @@ export default class OrderPage extends Component {
}
handleClickConfirmCancelButton=()=>{
console.log(this.state)
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
@ -226,7 +224,7 @@ export default class OrderPage extends Component {
};
fetch('/api/order/' + '?order_id=' + this.orderId, requestOptions)
.then((response) => response.json())
.then((data) => (console.log(data) & this.getOrderDetails(data.id)));
.then((data) => this.getOrderDetails(data.id));
this.handleClickCloseConfirmCancelDialog();
}
@ -262,7 +260,6 @@ export default class OrderPage extends Component {
}
handleClickConfirmCollaborativeCancelButton=()=>{
console.log(this.state)
const requestOptions = {
method: 'POST',
headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
@ -272,7 +269,7 @@ export default class OrderPage extends Component {
};
fetch('/api/order/' + '?order_id=' + this.orderId, requestOptions)
.then((response) => response.json())
.then((data) => (console.log(data) & this.getOrderDetails(data.id)));
.then((data) => this.getOrderDetails(data.id));
this.handleClickCloseCollaborativeCancelDialog();
}

View File

@ -412,7 +412,6 @@ export default class TradeBox extends Component {
// Asks the user for a dispute statement.
showInDisputeStatement=()=>{
console.log(this.props.data.statement_submitted)
if(this.props.data.statement_submitted){
return (
<Grid container spacing={1}>

View File

@ -3,7 +3,8 @@ import { Button , Dialog, Grid, Typography, TextField, ButtonGroup, CircularProg
import { Link } from 'react-router-dom'
import Image from 'material-ui-image'
import InfoDialog from './InfoDialog'
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import PublishIcon from '@mui/icons-material/Publish';
import CasinoIcon from '@mui/icons-material/Casino';
import ContentCopy from "@mui/icons-material/ContentCopy";
function getCookie(name) {
@ -29,7 +30,8 @@ export default class UserGenPage extends Component {
this.state = {
token: this.genBase62Token(34),
openInfo: false,
showRobosat: true,
loadingRobot: true,
tokenHasChanged: false,
};
this.getGeneratedUser(this.state.token);
}
@ -56,7 +58,7 @@ export default class UserGenPage extends Component {
shannon_entropy: data.token_shannon_entropy,
bad_request: data.bad_request,
found: data.found,
showRobosat:true,
loadingRobot:false,
})
&
// Add nick and token to App state (token only if not a bad request)
@ -81,23 +83,24 @@ export default class UserGenPage extends Component {
.then((data) => console.log(data));
}
handleAnotherButtonPressed=(e)=>{
this.delGeneratedUser()
// this.setState({
// showRobosat: false,
// token: this.genBase62Token(34),
// });
// this.getGeneratedUser(this.state.token);
window.location.reload();
handleClickNewRandomToken=()=>{
this.setState({
token: this.genBase62Token(34),
tokenHasChanged: true,
});
}
handleChangeToken=(e)=>{
this.delGeneratedUser()
this.setState({
token: e.target.value,
tokenHasChanged: true,
})
this.getGeneratedUser(e.target.value);
this.setState({showRobosat: false})
}
handleClickSubmitToken=()=>{
this.delGeneratedUser()
this.getGeneratedUser(this.state.token);
this.setState({loadingRobot: true, tokenHasChanged: false})
}
handleClickOpenInfo = () => {
@ -125,8 +128,8 @@ export default class UserGenPage extends Component {
render() {
return (
<Grid container spacing={1}>
<Grid item xs={12} align="center" sx={{width:370}}>
{this.state.showRobosat ?
<Grid item xs={12} align="center" sx={{width:370, height:260}}>
{!this.state.loadingRobot ?
<div>
<Grid item xs={12} align="center">
<Typography component="h5" variant="h5">
@ -144,7 +147,7 @@ export default class UserGenPage extends Component {
</div><br/>
</Grid>
</div>
: <CircularProgress />}
: <CircularProgress sx={{position: 'relative', top: 100, }}/>}
</Grid>
{
this.state.found ?
@ -158,8 +161,8 @@ export default class UserGenPage extends Component {
}
<Grid container align="center">
<Grid item xs={12} align="center">
<IconButton onClick= {()=>navigator.clipboard.writeText(this.state.token)}>
<ContentCopy/>
<IconButton sx={{top:6}} onClick= {()=>navigator.clipboard.writeText(this.state.token)}>
<ContentCopy sx={{width:18, height:18}} />
</IconButton>
<TextField
//sx={{ input: { color: 'purple' } }}
@ -175,15 +178,26 @@ export default class UserGenPage extends Component {
size='small'
// multiline = {true}
onChange={this.handleChangeToken}
onKeyPress={(e) => {
if (e.key === 'Enter') {
this.handleClickSubmitToken();
}
}}
/>
<IconButton sx={{top:8}} onClick={this.handleClickNewRandomToken}>
<CasinoIcon />
</IconButton>
</Grid>
</Grid>
<Grid item xs={12} align="center">
<Button size='small' onClick={this.handleAnotherButtonPressed}>Generate Another Robosat</Button>
<Button disabled={!this.state.tokenHasChanged} type="submit" size='small' onClick= {this.handleClickSubmitToken}>
<PublishIcon />
<span> Generate Robot</span>
</Button>
</Grid>
<Grid item xs={12} align="center">
<ButtonGroup variant="contained" aria-label="outlined primary button group">
<Button color='primary' to='/make/' component={Link}>Make Order</Button>
<Button disabled={this.state.loadingRobot} color='primary' to='/make/' component={Link}>Make Order</Button>
<Button color='inherit' onClick={this.handleClickOpenInfo}>Info</Button>
<this.InfoDialog/>
<Button color='secondary' to='/book/' component={Link}>View Book</Button>