if (sumUTXO < totalAmountToSpend) { // Not enough money thrownewError('Insufficient Balance'); //exception }
for (let i = 0; i < txIns.length; i++) { // verify the input by signature // TODO: check if utxos[i].txOut.address is correct or not const checker = Signature.verify(utxos[i].txOut.address, txIns[i].signature, txIns[i].msgHash());
if (!checker) { thrownewError('Invalid txIns'); //exception } }
//Create out put to receiver by PP2K txOuts.push(newTxOut(receiverPubKey, receiveAmount)); //return change to the sender const change = sumUTXO - receiveAmount - fee; txOuts.push(newTxOut(senderPubKey, change));
publicasyncgetAllUTXO(): Promise<UTXO[]> { constouts: UTXO[] = []; // loop all the blocks for (let i = 0; i < this.blockService.getBlockHeight(); i++) { const currentBlockHash = this.blockService.getBlockHash(i); const currentBlock = awaitthis.blockService.getBlock(currentBlockHash); const currentTx = currentBlock.data.transactions; // need to convert to list of Transaction
// loop all the transaction currentTx.forEach((currentTx) => { const txID = currentTx.id; const txOuts = currentTx.txOuts; const txIns = currentTx.txIns;
// Create UTXO object for each TxOutPut, push to UTXO txOuts.forEach((txOut, i) => { outs.push(newUTXO(txID, txOut, i)); // create UTXO obj that store tx, txid and index });
Avoid single person could be responsible for diverse and critical functions. Otherwise, error or misappropriation could occur and not be detected in a timely manner and in normal course of business processes.
Incident handling
identify when where whole
Shadow IT: IT users at an organisation electing to use tools and services that have not been officially sanctioned by said organisation.
Converage - insurance?
Action - what to do?
Evidence
Tasks to do during recovery
Management of removable media and system documentation
Monitoring
audit logging
Clock Synchronize
Logical Controls
Concurrent Sign-on Session
can be very useful, but also a control weaknesses
Suggestion:
No or only few user can have concurrent
No more than two
Logged and reviewed
Remote access Control
Deducated leased liveness
VPN
Identification process (username?)
Authentication process (password?)
Permitted/denied
Input Control
source document design - arrange fields for ease of use.
In this phase, auditor review controls such as General Controls and application controls. After that, plan tests of controls and substantive testing procedures.
Phase 2 - Test of Control
Perform tests of control -> Evaluate Test result -> Determine degree of reliance on controls.
Phase 3 - Substantive Testing Phase
Perform Substantive Tests -> Evaluate Result -> issue audit report
I have been coding in JavaScript for a while now, but I realized that I didn’t have a solid understanding of how the language works. This was a surprising realization, considering how much time I spend working with it. So, to improve my skills, I decided to do some research and dive deeper into the workings of JavaScript.
JavaScript is a programming language designed to run on client-side browsers. In this context, everything related to the internet is unpredictable. For example, if an image is too large, the browser can get stuck, and that’s where callback functions come in.
A callback function is a function that’s passed as an argument to another function. It’s used to execute code asynchronously, which means that the program doesn’t stop until the function is executed entirely. The concept of a callback is that we put the functions that need time to run into a “Callback Queue” and continue running the following code. This allows us to avoid blocking the program while it waits for the function to finish running.
Another useful feature of JavaScript is the Promise object. A promise is an object that includes a resolve and reject function. The resolve function is called when the code runs successfully, while the reject function is called when the code throws an error. We use try-catch blocks to handle errors in promises.
Async/Await is another feature of JavaScript that’s used for clean code. The await keyword is used in the async function to pause the function until the Promise is resolved or rejected. We can use this feature to write asynchronous code that looks like synchronous code, which makes the code easier to read and understand.
In summary, JavaScript is a powerful language that’s essential for web development. Understanding its features, including callback functions, Promises, and Async/Await, is crucial for writing efficient and clean code.
Callback
The concept of callback is that, we put the functions that needs time to run into a “Callback Queue”, and continue run the following code.
Promise
Promise is object that include resolve and reject, for example,
1 2 3 4 5 6 7 8 9 10 11 12 13
let p = newPromise(function(resolve, reject) { if(){ resolve(); }else{ reject; } })
p.then(function(){ // resolve }).catch(function() { // return a exception, and catch the error })
var app = newVue({ el: '#app', data: { message: 'Hello Vue', //for placing data //method can place in data, but we normally don't do that }, methods: { handleClick: function(){ alert("Clicked"); } } })
v-on
v-on can replace by @, for example v-on:click="functionName" === @click="functionName" Used in <div>, for example:
v-bind is used when attribute in vue instance is needed, When we try to: <a href={{website}}>some website<a> It won’t work we need to use v-bind: <a v-bind:href={{website}}>some website<a> v-bind can be replaced by : <a :href={{website}}>some website<a>
v-if, v-else
Just another if-else statement, but there are a notice able use case:
1 2 3 4
<button @click="function"> <spanv-if="bool">bool is true</span> <spanv-else>bool is false</span> </button>
v-for
To show an array of data, we need to use v-for
1 2 3 4 5
books:[ {title: 'name of the wind', author: 'abc'}, {title: 'name of the fire', author: 'onfire'}, {title: 'name of the water', author: 'bewater'}, ]
1 2 3 4 5 6
<ul> <liv-for="book in books"> <h3>{{book.title}} - {{book.author}}</h3> </li> </ul>