Skip to content

Commit

Permalink
channels: Replace hard-coded fee with global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jianli committed May 17, 2017
1 parent 6b86081 commit e9dd155
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion two1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
TWO1_LOGGER_SERVER = os.environ.get('TWO1_LOGGER_SERVER', 'https://logger.21.co')
TWO1_POOL_URL = os.environ.get('TWO1_POOL_URL', 'swirl+tcp://grid.21.co:21006')
TWO1_DEVICE_ID = os.environ.get('TWO1_DEVICE_ID')
TWO1_CHANNELS_MIN_DURATION = os.environ.get('TWO1_CHANNELS_MIN_DURATION', 4 * 24 * 3600)
TWO1_CHANNELS_MIN_DURATION = int(os.environ.get('TWO1_CHANNELS_MIN_DURATION', 4 * 24 * 3600))
TWO1_CHANNELS_FEE = int(os.environ.get('TWO1_CHANNELS_FEE', 30000))
3 changes: 2 additions & 1 deletion two1/bitserv/payment_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import threading
import time

from two1 import TWO1_CHANNELS_FEE
from two1 import TWO1_CHANNELS_MIN_DURATION
from two1.bitcoin import Hash
from two1.bitcoin import PublicKey
Expand Down Expand Up @@ -82,7 +83,7 @@ class PaymentServer:
"TWO1_PROVIDER_HOST", "https://blockchain.21.co") + "/blockchain/testnet3"
"""Default testnet blockchain URL."""

MIN_TX_FEE = 30000
MIN_TX_FEE = TWO1_CHANNELS_FEE
"""Minimum transaction fee for payment channel deposit/payment."""

DUST_LIMIT = 3000
Expand Down
3 changes: 2 additions & 1 deletion two1/channels/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os

import two1
from two1 import TWO1_CHANNELS_FEE
from two1.wallet import Wallet, Two1Wallet

from . import PaymentChannelClient
Expand Down Expand Up @@ -142,7 +143,7 @@ def cli_list(ctx):
@click.argument('url', type=click.STRING)
@click.argument('deposit', type=click.INT)
@click.argument('expiration', type=click.INT)
@click.option('--fee', default=30000, help="Fee amount in satoshis.")
@click.option('--fee', default=TWO1_CHANNELS_FEE, help="Fee amount in satoshis.")
@click.option('--zeroconf', default=False, is_flag=True,
help="Use payment channel without deposit confirmation. This preference " +
"will be overriden by server configuration if applicable.")
Expand Down
3 changes: 2 additions & 1 deletion two1/channels/paymentchannelclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from . import database
from . import blockchain
from . import paymentchannel
from two1 import TWO1_CHANNELS_FEE


logger = logging.getLogger('channels')
Expand Down Expand Up @@ -105,7 +106,7 @@ def _update_channels(self):
self._channels[url] = paymentchannel.PaymentChannel(
url, self._database, self._wallet, self._blockchain)

def open(self, url, deposit, expiration, fee=30000, zeroconf=False, use_unconfirmed=False):
def open(self, url, deposit, expiration, fee=TWO1_CHANNELS_FEE, zeroconf=False, use_unconfirmed=False):
"""Open a payment channel at the specified URL.
Args:
Expand Down

0 comments on commit e9dd155

Please sign in to comment.