From 64115a8bb543a609f419a87700c70ed4e269e278 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 30 Jan 2022 05:18:32 -0800 Subject: [PATCH] Remodel usergen form. Add fee limit hparams. --- .env-sample | 5 +++ api/lightning/node.py | 2 +- frontend/src/components/BookPage.js | 4 +- frontend/src/components/BottomBar.js | 6 ++- frontend/src/components/MakerPage.js | 1 - frontend/src/components/OrderPage.js | 7 +--- frontend/src/components/TradeBox.js | 1 - frontend/src/components/UserGenPage.js | 56 ++++++++++++++++---------- 8 files changed, 48 insertions(+), 34 deletions(-) diff --git a/.env-sample b/.env-sample index d2045839..f6c56edf 100644 --- a/.env-sample +++ b/.env-sample @@ -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' \ No newline at end of file diff --git a/api/lightning/node.py b/api/lightning/node.py index 9f62dc97..e95b9668 100644 --- a/api/lightning/node.py +++ b/api/lightning/node.py @@ -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, diff --git a/frontend/src/components/BookPage.js b/frontend/src/components/BookPage.js index 8785ffd7..37b5b903 100644 --- a/frontend/src/components/BookPage.js +++ b/frontend/src/components/BookPage.js @@ -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); } diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js index 17775793..1cf718b5 100644 --- a/frontend/src/components/BottomBar.js +++ b/frontend/src/components/BottomBar.js @@ -210,7 +210,9 @@ export default class BottomBar extends Component { // TODO Link to router and do this.props.history.push - + + + @@ -255,7 +257,7 @@ bottomBarDesktop =()=>{ - 0 & !this.state.profileShown) ? "1": null} color="primary"> + 0 & !this.state.profileShown) ? "": null} color="primary"> { 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')}, diff --git a/frontend/src/components/OrderPage.js b/frontend/src/components/OrderPage.js index da923dc9..e8f20b5b 100644 --- a/frontend/src/components/OrderPage.js +++ b/frontend/src/components/OrderPage.js @@ -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(); } diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js index 0dc5ebfc..ddc5ddfd 100644 --- a/frontend/src/components/TradeBox.js +++ b/frontend/src/components/TradeBox.js @@ -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 ( diff --git a/frontend/src/components/UserGenPage.js b/frontend/src/components/UserGenPage.js index 7b3b15ce..5a82141a 100644 --- a/frontend/src/components/UserGenPage.js +++ b/frontend/src/components/UserGenPage.js @@ -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 ( - - {this.state.showRobosat ? + + {!this.state.loadingRobot ?
@@ -144,7 +147,7 @@ export default class UserGenPage extends Component {

- : } + : }
{ this.state.found ? @@ -158,8 +161,8 @@ export default class UserGenPage extends Component { } - navigator.clipboard.writeText(this.state.token)}> - + navigator.clipboard.writeText(this.state.token)}> + { + if (e.key === 'Enter') { + this.handleClickSubmitToken(); + } + }} /> + + + - + - +