particle4dev / dicoapp-e

SPV lightweight GUI wallet with barterDEX swap capabilities
MIT License
1 stars 11 forks source link

implement wallet page #6

Closed particle4dev closed 6 years ago

particle4dev commented 6 years ago

Title: [Persona name] should (not) be able to [overarching action]

Business/User Value: As [persona] I want to [action by user] so that [value or need met]

Acceptance Criteria GIVEN [necessary context and preconditions for story] WHEN [action] THEN [reaction]

DEV NOTES

DESIGN Notes

screen shot 2018-08-18 at 07 04 01

---other items that you may add to a story---

NEEDS PM None

NEEDS DESIGN None

/label ~"story"

particle4dev commented 6 years ago

withdraw

const sendparams = {
  'userpass': (await this.Userdata.findOne({
    key: "userpass"
  })).userpass,
  'method': 'withdraw',
  'coin': coin,
  'outputs': JSON.parse(outputs)
};

https://github.com/chainmakers/dicoapp/blob/glxt/.desktop/modules/marketmaker/index.js#L852 https://docs.komodoplatform.com/barterDEX/barterDEX-API.html#withdraw

particle4dev commented 6 years ago

https://docs.komodoplatform.com/barterDEX/barterDEX-API.html#sendrawtransaction

particle4dev commented 6 years ago

twitter redux state

particle4dev commented 6 years ago

listTransactions

async listTransactions(coin) {
  if (await this.Userdata.count() > 1) {
    const listparams = {
      'userpass': (await this.Userdata.findOne({
        key: "userpass"
      })).userpass,
      'method': 'listtransactions',
      'coin': coin,
      'address': (await this.Userdata.findOne({
        coin: coin
      })).smartaddress.toString(),
      'count': 10
    };

    try {
      const result = await this.fetch(listparams);

      const transactions = await result.json();
      for (let i = 0; i < transactions.length; i++) {

        var transaction = transactions[i];

        if (!(await this.Transactions.findOne({
            txid: transaction.tx_hash
          }))) {
          var height = transaction.height;
          if (height === 0) {
            height = "unconfirmed";
          }
          await this.Transactions.insert({
            coin: coin,
            txid: transaction.tx_hash,
            height: height,
            createdAt: new Date()
          });
        } else {
          if (await this.Transactions.findOne({
              txid: transaction.tx_hash
            }).height != transaction.height) {
            if (transaction.height != 0) {
              await this.Transactions.update({
                txid: transaction.tx_hash
              }, {
                $set: {
                  height: transaction.height
                }
              });
            }
          }
        }
      }
    } catch (e) {
      throw e;
    }
  }

  while (await this.Transactions.count({
      coin: coin
    }) > 10) {
    await this.Transactions.remove((await this.Transactions.findOne({}, {
      sort: {
        height: 1
      }
    }))._id);
  }
}
setInterval(async () => {
  // try{
  //   console.log(Userdata.find().count());
  //   Userdata.remove();
  //   console.log("removed");
  // }catch(e){
  //   console.log(e);
  // }
  console.log('list transactions');

  if (await Userdata.count() > 6) {
    await this.modules['marketmaker'].listTransactions("KMD");
    await this.modules['marketmaker'].listTransactions("BTC");
    await this.modules['marketmaker'].listTransactions("LTC");
    await this.modules['marketmaker'].listTransactions(tokenconfig.dICOtoken.shortcode);
    //await this.modules['marketmaker'].listTransactions("LTC");
  }

}, 90000);
particle4dev commented 6 years ago

https://docs.komodoplatform.com/barterDEX/barterDEX-API.html#withdraw

To withdraw, you just need to specify the array of outputs and the coin. It returns the rawtx, the signed transaction in hex the txid and if it was complete or not. All inputs are assumed to be standard pay to pubkeyhash, having other non-standard utxo will make it create invalid rawtx. Withdrawing ETH/ERC20 tokens works using different parameters (please see eth_withdraw,).

Sample File Contents:

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"KMD\",\"outputs\":[{\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.001}, {\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.002}],\"broadcast\":1}"

https://docs.komodoplatform.com/barterDEX/barterDEX-API.html#sendrawtransaction sendrawtransaction This method will broadcast a raw transaction over the network. Uses tx-hex from ./withdraw API output.

Sample File Contents:

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sendrawtransaction\",\"coin\":\"KMD\",\"signedtx\":\"$1\"}"