Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM 1. For the following exercise, use the incremental development methodology described in Chapter 3 to implement the program. In other words, identify the program

PROBLEM 1. For the following exercise, use the incremental development methodology described in Chapter 3 to implement the program. In other words, identify the program tasks, create a design document with class descriptions, and draw the program diagram. Map out the development steps at the start. State any assumptions you must make about the input. Present any design alternatives and justify your selection. Be sure to perform adequate testing at the end of each development step.

TASK: To implement a simplified version of a cryptocurrency called ITUCoin. A cryptocurrency is a digital payment system that allows people to exchange values through the internet. In other words, "virtual money". Cryptocurrency transactions are securely stored in a blockchain. A blockchain is a digital, decentralized ledger used, for example, to record fund transfers of a crypto-currency. A virtual wallet is an interface that allows users to check their balance, add funds, and transfer cryptocurrency to another user.

REQUIREMENTS: 1. General behavior:

1.1. You must implement a file based, single instance blockchain that records transfers of ITUCoins.

1.2. A number of users must be able to create wallets, log in to their wallets (one at a time), add, withdraw, and transfer funds to another user (one at a time).

1.3. An admin account must be created for general inspection of the blockchain.

2. Wallet:

2.1. A wallet is the command line interface where users access the blockchain system. It is basically how your program should create and manipulate users and values in the blockchain.

2.2. When started, the wallet should allow users to sign up for a new wallet or log in to their existent one.

2.3. A user name is enough to create or log in to wallets.

2.4. Each new created wallet must receive a 3-digit long sequential number as identifier (e.g., 001, 002, etc).

2.5. The user with administrative credentials is "admin". It is created by default.

2.6. Admin cannot add funds or transfer funds from wallet. Admin can only inspect the blockchain by looking at (i) number of wallets created, (ii) total balance, (iii) totals balance per wallet, and (iv) content of a specific block in the blockchain (see Blockchain session below for more details).

2.7. Admin cannot cancel, delete or alter the blockchain. Nobody can (i.e., the blockchain is immutable).

3. Transactions:

3.1. A transaction is a record on a block of the blockchain.

3.2. A transaction must contain the following 4 fields: transaction number (i.e., 1 to 5), sending wallet id, receiving wallet id, and transferred amount.

3.3. There are 3 types of transactions: add-funds, subtract-funds, and transfer-funds.

3.3.1. add-funds are transfers from the "real world" to the blockchain so they do not have a recorded sending wallet id.

3.3.2. subtract-funds are transfers from the blockchain to the "real world" so they do not have a recorded receiving wallet id.

3.3.3. transfer-funds are transfers inside the blockchain so they must have both a sending and receiving wallet id.

3.4. transactions are stored/persisted in a block of the blockchain (see below).

3.5. transaction must be only initiated by the sending wallet (admin and receiving wallets cannot initiate a transaction).

4. Blocks:

4.1. A block of the ITUCoin blockchain holds an identifier, records for up to 5 transactions, plus the identifier of the previous block.

4.2. Block identifiers are 5-character long, random alphanumeric sequences (e.g., XHBCA, OCUKC,etc).

4.3. A block must be permanently stored (i.e., persisted to file) at the blockchain after 5 valid transactions or when a user logs out of their wallet.

5. Block"chain"

5.1. The blockchain is a chain of blocks that together work as an incremental ledger for ITUCoin transactions.

5.2. Current balances are calculated by traversing the blockchain from the latest block to the oldest block, adding all addition and receiving of funds and subtracting all sending and subtraction of funds (i.e., all values in minus all values out of wallet).

5.3. Admin inspection of individual blocks in the blockchain must be specified by block positional index (not alphanumeric identifier). A block positional index is the relative position of the block in the chain. 0 must refer to the first block, 1 to the second block, etc. Reversely, -1 must refer to the last (i.e., latest) block, -2 to the one before the last, etc. If the Admin chooses an invalid positional index, an error should let the admin know the length of the current block chain.

POSSIBLE SCENARIOS:

1. Mark loads program and signs up to new wallet with username mark. Program creates wallet id 001 for mark. Mark adds 100 ITUCoins to wallet 001, which shows as Mark's new balance. Marks logs out. Jane loads program and signs up to new wallet with username jane. Program creates wallet id 002 for jane. Jane sees balance 0 and logs out. Mark logs in again and transfers 30 ITUCoins to wallet 002. Mark sees balance 70 and logs out. Jane logs in again and sees her new balance 30. Jane logs out.

 

2. Mark and Jane create wallets and add funds, as described above. Jack creates a wallet with username jack and, subsequently, receives wallet id 003. Jack adds 50 ITUCoins to wallet. Jack immediately transfers 20 ITUCoins to wallet 002. Jack sees balance go down to 30 and logs out. Jane logs in and see balance 50. Jane withdraws 40 ITUCoins. Jane sees balance 10 and logs out. Admin logs in and sees 3 total number of wallets, the total number of ITUCoins in the blockchain, and a breakdown of ITUCoins per wallet: -- Blockchain Stats -- Total number of wallets : 3 Total number of ITUCoins: 110 -- ITUCoin Breakdown -- wallet 001: 70 wallet 002: 10 wallet 003: 30 Admin logs out.

-- Blockchain Stats -- Total number of wallets : 3 Total number of ITUCoins: 110 -- ITUCoin Breakdown -- wallet 001: 70 wallet 002: 10 wallet 003: 30

3. Mark, Jane, and Jack add, transfer, and subtract funds as described above. Jane logs back in and sees balance 10. Jane tries to transfer 20 ITUCoins to Jack. Program blocks transaction as Jane does not have enough funds. Jane adds 30 ITUCoins to wallet, seeing balance 40. Jane then transfers 20 ITUCoins to Mark and 20 ITUCoins to Jack. Jane sees balance 0 and logs out. Admin logs in and sees all updated totals. Admin queries for the latest block (i.e., -1) and sees 3 transactions in it: num sender receiver amount 1 --- 002 30 2 002 001 20 3 002 003 20 4 5 Admin logs out.

num sender receiver amount 1 --- 002 30 2 002 001 20 3 002 003 20 4 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books