-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wallet servers requesting a daily fee will automatically get paid by client #2707
Conversation
4be45c6
to
32614d2
Compare
4a51d05
to
7da1f42
Compare
7da1f42
to
7d47d5c
Compare
7d47d5c
to
ee4b14b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the intention to drop support for sending donations and only allow required payments? Personally I think it's reasonable to leave the existing donation feature and just add the required payment feature next to it.
lbry/wallet/manager.py
Outdated
@@ -79,11 +81,14 @@ def accounts(self): | |||
await asyncio.gather(*( | |||
l.start() for l in self.ledgers.values() | |||
)) | |||
self.usage_payment_service = WalletServerPayer(self.ledger, self.default_wallet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be instantiated in __init__
then you won't need to add Optional
to the type?
LEDGER = lbry.wallet | ||
|
||
def setUp(self) -> None: | ||
WalletServerPayer.PAYMENT_PERIOD = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be a configurable thing in the WalletServerPayer (eg. an argument to WalletServerPayer.init which then uses the PAYMENT_PERIOD constant as a default)?
|
||
|
||
class TestUsagePayment(CommandTestCase): | ||
LEDGER = lbry.wallet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer necessary.
lbry/wallet/usage_payment.py
Outdated
tx = await Transaction.create([], | ||
[Output.pay_pubkey_hash(amount, self.ledger.address_to_hash160(address))], | ||
self.wallet.get_accounts_or_all(None), | ||
self.wallet.get_account_or_default(None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting is strange, needs indentation fix
lbry/wallet/usage_payment.py
Outdated
self.wallet.get_account_or_default(None)) | ||
|
||
await self.ledger.broadcast(tx) | ||
# await self.analytics_manager.send_credits_sent() fixme: handle that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this difficult to handle?
lbry/wallet/usage_payment.py
Outdated
if not self.ledger.is_valid_address(address): | ||
raise Exception(f"Invalid address: {address}") | ||
if self.wallet.is_locked: | ||
raise Exception("Cannot spend funds with locked wallet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will kill the pay service, even after the wallet is unlocked no payment will be sent. Perhaps just print a message and continue running?
b9e0c48
to
b261df0
Compare
b261df0
to
5695b18
Compare
dbd72ec
to
9e040d2
Compare
9e040d2
to
f0e1db3
Compare
continuation of #2683
Changes in this PR:
New SDK component:
WALLET_SERVER_PAYMENTS_COMPONENT
New configuration key:
max_wallet_server_fee
(defaults to 1.0)Wallet server config options:
PAYMENT_ADDRESS
andDAILY_FEE
During SDK startup, if its not set to skip, the component for payments starts by reading
max_wallet_server_fee
then sleeping for 24 hours.On the wallet server, operators can set the configurations for a daily fee and the address for it, however there isn't any enforcement yet.
After 24 hours, the component wakes up, pays to the current "master" server and goes back to sleep. This only happens if there is a valid address and fee set on the main server and that fee is below the configured threshold.
It also sends analytics when after it pays