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

Restricted asset account #238

Draft
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

louisinger
Copy link
Collaborator

@louisinger louisinger commented Oct 25, 2021

This PR aims to let the user pair Marina with a cosigner and then "allow" to spend some funds via another injected provider.

New Domain: Account

  • An Account is an interface. The idea is to map serializable data stored in reducers to Accounts.
  • The wallet reducer now stores the account data. Each account is identified by an AccountID.
  • encrypted mnemonic and all the main data used to restore the Main Marina wallet represents the mainAccount.
  • this "mainAccount" is the single sig account used to own a "regular" asset.
  • the user data (utxos, txs etc...) is the mixed balances of all accounts set up in Marina Wallet, same for coin selection, blinding, and signing.

Restricted Asset account

  • The user can pair with a cosigner using Settings > Cosigner > Add Cosigner screen.
  • Pairing with a cosigner will add a new account to Marina wallet reducer: RestrictedAssetAccount.
  • This account is a 2of2 account working with the Cosigner interface.
  • the user can generates multisig addresses via "Receive" page (:warning: WIP: need to hardcode the assets (with logo and tickers) in select asset screen, now it's a "restricted asset" btn (useful for testing in regtest)).

"Allowance" provider

the coinos provider is injected via inject-script.ts. Its implementation is described in coinosBroker file. It let's to getCoins --> returns the utxos owned by the 2of2 Marina account and allowCoin --> create a SIGHASH_NONE tx and send it to Cosigner (via Cosigner.allow method).

mocked cosigner
This PR uses a mocked cosigner for testing purposes as a Cosigner interface.

TODO:
This PR is the first base block for the restricted assets but need some task to be fully complete:

  • "real" cosigner implementation.
  • handle the list of restricted assets.
  • Handle allowed coins in Marina ???
  • Only inject the coinos provider on specific hostnames ??

@tiero please review

Copy link
Member

@tiero tiero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the behavior and signature of allowCoin to something more high level such us approveSpend API, otherwise the web app must handle coin selection and utxos outpoint, which can be not that practical

Copy link
Member

@tiero tiero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should allow user to opt-in for a "Security Account powered by CoinOS" via a checkbox in the onboarding phase too, and users that have already onboarded before this change via settings.

@louisinger
Copy link
Collaborator Author

UPDATE: enrich CoinosProvider (implementing the first version of the interface proposed here<--)

@louisinger louisinger requested a review from tiero October 28, 2021 12:02
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

Successfully merging this pull request may close these issues.

2 participants