Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cooganb committed May 4, 2018
2 parents 8177811 + 2f8ab76 commit 2f9bb83
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion wallet/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,59 @@ function addAccount(privKey,pubKey) {

async function spend(fromAccount,toAccount,amountToSpend) {
// TODO
var trData = {
inputs: [],
outputs: [],
};

// pick inputs to use from fromAccount's outputs (i.e. previous txns, see line 22), sorted descending
// var sortedInputs =

// for (let input of sortedInputs) {
// // remove input from output-list


// // do we have enough inputs to cover the spent amount?



// }



// if (inputAmounts < amountToSpend) {

// throw `Don't have enough to spend ${amountToSpend}!`;
// }

// sign and record inputs


// record output


// is "change" output needed?


// create transaction and add it to blockchain
var tr = Blockchain.createTransaction(trData);
Blockchain.insertBlock(
// TODO .createBlock method

);

// record outputs in our wallet (if needed)

}

function accountBalance(account) {
// TODO
var balance = 0;

// if (account in wallet.accounts) {

// }


// return balance;

}

0 comments on commit 2f9bb83

Please sign in to comment.