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

accounts: Check if 'to' address is reserved #1

Merged
merged 2 commits into from Jan 20, 2023

Conversation

matevz
Copy link
Member

@matevz matevz commented Dec 16, 2022

Fixes #7.

This PR checks, if the to address for Transfers, Withdrawals and Deposits is a known unspendable address:

  • rewards pool address
  • common pool address
  • fee accumulator address
  • governance deposit address
  • native ParaTime address

User can override the check by passing --force switch.

Example:

$ oasis accounts transfer 10 pool:rewards
Error: address 'oasis1qp7x0q9qahahhjas0xde8w0v04ctp4pqzu5mhjav' is rewards pool address
Use --force to ignore this check
$ oasis accounts deposit 10 paratime:emerald
Error: did you mean --paratime emerald? Address 'oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run' is native address of paratime:emerald on testnet and should not be transferred to directly
Use --force to ignore this check
$ oasis accounts deposit 10 oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run
Error: did you mean --paratime emerald? Address 'oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run' is native address of paratime:emerald on testnet and should not be transferred to directly
Use --force to ignore this check
$ oasis accounts deposit 10 paratime:emerald -f
Warning: did you mean --paratime emerald? Address 'oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run' is native address of paratime:emerald on testnet and should not be transferred to directly
Proceeding by force as requested
You are about to sign the following transaction:
{
  "v": 1,
  "call": {
    "method": "consensus.Deposit",
    "body": "omJ0b1UA9KKZ60FRuiSXy1EC/dTN4tOTDZxmYW1vdW50gkUCVAvkAEA="
  },
  "ai": {
    "si": [
      {
        "address_spec": {
          "signature": {
            "ed25519": "MJ2XCjkj132C9YWpDUSQFjkCTI8bSw8bi0w9EwwE1Bg="
          }
        },
        "nonce": 3
      }
    ],
    "fee": {
      "amount": {
        "Amount": "2001535",
        "Denomination": ""
      },
      "gas": 400307,
      "consensus_messages": 1
    }
  }
}

Account:  test:alice
Network:  testnet
Paratime: cipher
? Sign this transaction? (y/N)

Copy link
Member

@kostko kostko left a comment

Choose a reason for hiding this comment

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

Instead of just denying, there should be a flag (like --force) that would still allow you to do it. For the reward pool address this is even required as otherwise it would be hard to actually fund the pool.

@matevz matevz requested a review from kostko December 22, 2022 11:00
@matevz
Copy link
Member Author

matevz commented Dec 22, 2022

Instead of just denying, there should be a flag (like --force) that would still allow you to do it. For the reward pool address this is even required as otherwise it would be hard to actually fund the pool.

Added.

@matevz matevz force-pushed the matevz/feature/check-nonspendable-addresses branch from c304226 to 49a9792 Compare December 22, 2022 11:08
@matevz matevz changed the base branch from master to tjanez/independent-repo December 22, 2022 11:16
@matevz matevz force-pushed the matevz/feature/check-nonspendable-addresses branch from 49a9792 to e4aaa7b Compare December 22, 2022 11:22
@matevz matevz force-pushed the matevz/feature/check-nonspendable-addresses branch from e4aaa7b to 621bb68 Compare January 10, 2023 12:08
@matevz matevz changed the base branch from tjanez/independent-repo to master January 10, 2023 12:13
@matevz matevz force-pushed the matevz/feature/check-nonspendable-addresses branch 2 times, most recently from 1472762 to 1d3add0 Compare January 17, 2023 09:18
cmd/common/helpers.go Outdated Show resolved Hide resolved
@matevz matevz force-pushed the matevz/feature/check-nonspendable-addresses branch from 1d3add0 to 6301f1f Compare January 19, 2023 15:42
@matevz matevz requested a review from kostko January 19, 2023 15:42
@matevz matevz merged commit 367fe7a into master Jan 20, 2023
@matevz matevz deleted the matevz/feature/check-nonspendable-addresses branch January 20, 2023 10:12
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.

Add withdrawal/deposit/transfer check if destination is ParaTime or other non-withdrawable address
2 participants