Closed particle4dev closed 6 years ago
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
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);
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\"}"
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
https://github.com/chainmakers/dicoapp/blob/glxt/.desktop/modules/marketmaker/index.js#L706
https://github.com/chainmakers/dicoapp/blob/glxt/imports/ui/components/wallet/wallet.js#L169
https://github.com/chainmakers/dicoapp/blob/glxt/.desktop/modules/marketmaker/index.js#L844
DESIGN Notes
---other items that you may add to a story---
NEEDS PM None
NEEDS DESIGN None
/label ~"story"