Skip to content
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

Request: Method to give existing channel funds to arbitrary account. #192

Open
junderw opened this issue May 7, 2021 · 13 comments
Open

Comments

@junderw
Copy link

junderw commented May 7, 2021

Explanation:

  1. On LND, I have X channels open with local balances of A, B, C.
  2. I install LNDHub, create a wallet.
  3. My wallet balance is 0 and the only way I can get balance on it is by "charging it" via BlueWallet on-chain, or receiving an LN payment.
  4. LND won't let me pay an invoice created by itself, so the only method is on-chain "charging" which is a waste, since I already have A + B + C total LN balance available to me.

Request:

  1. On first boot of LNDHub from fresh slate, create a default user with a balance of 100% of all channels local balance at the time of first boot.
  2. This user's backup can be shown for users to "load" the account into their BlueWallet.
  3. The default user ID and the default user initial balance are persisted, and used to calculate the "true" balance of the default user moving forward. (so calculateBalance would add an if statement for if U.isDefaultUser() to add the instance's default user initial balance.)

Some issues that might pop up:

How to keep the backup of that user secure? I would guess showing it only once is fine but tbh if you have access to the box with lndhub you can mess with redis and also probably swipe the admin macaroon anyways... but for umbrel if you just put it on the landing page anyone with port access to the umbrel (anyone on my local network) can see the backup if you put it on the landing page... so it'll be difficult...

Maybe the first time the default user actually loads the backup, it changes things up so that the second person who tried to load that default user backup will always fail, and the first person is given a new backup for the default user. (rotate creds on first load?)

@Overtorment
Copy link
Member

i talked to umbrel guys, and the simplest solution might be:
adding "admin" account credentials straight to config.js during install.

the balance would not be awarded to it, instead, balance for this account would be simply current channelBalance, so admin user could spend all his channel coins anytime he wants.

what do you think?

@junderw
Copy link
Author

junderw commented May 15, 2021

As long as the admin credentials are randomly generated on install that sounds fine.
If it's the same credentials for everyone, then all I need is your onion URL to access your admin account.

@pinheadmz
Copy link

Joining this issue, I also am interested in this feature. I may just modify lndhub /getbalance to return lnd channelbalance since I am the only user of this hub (created my wallet then disabled /create)

@lndhub-admin
Copy link
Contributor

maybe the new Admin Extension could have a component that makes a Admin wallet or where Admin can fund any account wallet.

the "LND won't let me pay an invoice created by itself," is to make a payinvoice --allow_self_payment call to LND that the Admin Extension component could do.

se :

#196

#239

@lndhub-admin
Copy link
Contributor

Screenshot 2021-06-28 at 10 57 16

@lndhub-admin
Copy link
Contributor

@xraid
Copy link
Contributor

xraid commented Jul 6, 2021

I am contemplating creating a GRANT component using the LndHub-Admin toolbox.

A component screen-card where accounts in system is showing in a table and where one can specify amount units and send.

The send is from LndHub operator = admins LND wallet funds.

When chosen a account(user) and specify amount click send after filling in the adminPin, the component will create a invoice from account(user) credentials and then that amount gets Granted to account(user) in the LndHub Ledger.

Would the above suffice as functionality for case mentioned in this Request issue ?

@lndhub-admin
Copy link
Contributor

lndhub-admin commented Jul 6, 2021

aha ... this triggered a associating problem of accounts being unnamed on the LndHub side
I now know howto get accounts named from a BlueWallet connected to a LndHub Admin enabled LND.
This without touching BlueWallet repo as a start and proof of concept, whereby later if find tasty there could be a formalized add in BlueWallet also enabling and securing a sync of wallet account card "named" and its representation in LndHub ...

@junderw
Copy link
Author

junderw commented Oct 11, 2021

Any progress on this?

@xraid
Copy link
Contributor

xraid commented Oct 13, 2021

i started some work on it but left it for more prioritized projects :

  • one need get a list of all accounts and balances for each
  • then identify what account to GRANT funds to
  • generate a invoice for that account
  • flag invoice as paid in DB

this way DB would be correctly intact and new balance would show up in account invoice was created for.

or meanwhile unless somebody wants a UI for the functionality use a payment over network as hinted here :
#295 (comment)

@xraid
Copy link
Contributor

xraid commented Oct 13, 2021

if interested in hints coding it, further discussions can be had here :
https://t.me/joinchat/L31KXn9TlDNmMTY0

@jblachly
Copy link

jblachly commented Jan 16, 2022

Very much interested in this.

Use case / user story:

I have an LND node with, say, 1M sats. My child wants to be paid an allowance in sats, so I agree to transfer 10,000 sats monthly. Because we want to remain non-custodial, Bluewallet thru LNDHub makes sense. (Wallet of Satoshi, custodial; Phoenix and Muun non-custodial, but require new channels that will eat up huge fees).

LNDHub itself handles accounting just fine when the to/from are on the same node.

However, I have no way -- other than using on-chain activity or transfer out to a different Lightning Wallet then back in -- to fund an initial BlueWallet balance for myself.

What would be ideal is a command line admin tool to "instantiate" a balance, not greater than the sum of all un-allocated (in LNDHub's view) local channel funds, in an arbitrary LNDHub account.

I looked directly at the Redis keyspace to see if this were possible, but it appears not: Balance is computed directly from past lightning transactions.

Question 1: Is it possible to "synthesize" transactions to make this happen?

Question 2: The LNDHub schema documentation [1] describes a key, balance_for_{userid} = {int} but this does not appear in my Redis keyspace. Does this refer to on-chain balance? (I haven't made any on-chain transactions)
(Found in the code -- this key is deprecated and balance is computed directly:

LndHub/class/User.js

Lines 134 to 136 in 7f9463b

/**
* LndHub no longer relies on redis balance as source of truth, this is
* more a cache now. See `this.getCalculatedBalance()` to get correct balance.
)

[1] https://github.com/BlueWallet/LndHub/blob/master/doc/schema.md

@xraid
Copy link
Contributor

xraid commented Jan 16, 2022

one can imagine a script that help in paying a invoice generated on account holders behalf or for edutainment let account holder create invoice in wallet, script would payout to invoice ...

same would go for case where one make invoice in wallet and pay oneself from LND and then pay invoice to other account

what script would do is either just pay a invoice from LND or generate invoice and pay in one swoop ...


easiest for Your case is create a account in BlueWallet and then a invoice

in terminal at node

lncli sendpayment --pay_req "invoice" --allow_self_payment

from this account distribute further ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants