Skip to content

Commit abcd454

Browse files
committed
withdraw eos/btc
1 parent bea1ad2 commit abcd454

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

bitcoin-wallet-nodejs/bitcoin-wallet-nodejs.js

+68-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ const EXIN_BOT = "61103d28-3ac2-44a2-ae34-bd956070dab1";
1717
const BTC_ASSET_ID = "c6d0c728-2624-429b-8e0d-d9d19b6592fa";
1818
const EOS_ASSET_ID = "6cfe566e-4aad-470b-8c9a-2fd35b49c68d";
1919
const USDT_ASSET_ID = "815b0b1a-2764-3736-8faa-42d694fa620a";
20-
const BTC_WALLET_ADDR = "14T129GTbXXPGXXvZzVaNLRFPeHXD1C25C";
2120

21+
//change to your third exchange/cold btc wallet address
22+
const BTC_WALLET_ADDR = "14T129GTbXXPGXXvZzVaNLRFPeHXD1C25C";
23+
const EOS_WALLET_NAME = "huobideposit";
24+
const EOS_WALLET_TAG = "1872050";
2225
//change to your mixin messenger account 's uuid
2326
const MASTER_UUID = "0b4f49dc-8fb4-4539-9a89-fb3afc613747";
2427

@@ -90,6 +93,7 @@ if ( process.argv.length == 2 ) {
9093
{
9194
name: 'type',
9295
type: 'list',
96+
pageSize: 15,
9397
default: "Create Wallet",
9498
message: PromptMsg,
9599
choices: walletList,
@@ -185,15 +189,21 @@ if ( process.argv.length == 3 ) {
185189
const TYPE_TRANS_BTC_TO_MASTER = '6: Transfer BTC from Wallet to Master';
186190
const TYPE_TRANS_EOS_TO_MASTER = '7: Transfer EOS from Wallet to Master';
187191
const TYPE_VERIFY_PIN = '8: Verify Wallet PIN ';
192+
const TYPE_BTC_WITHDRAW = '9: BTC withdraw';
193+
const TYPE_EOS_WITHDRAW = '10: EOS withdraw';
194+
const TYPE_BTC_WITHDRAW_READ = '11: Fetch BTC withdrawal info';
195+
const TYPE_EOS_WITHDRAW_READ = '12: Fetch EOS withdrawal info';
188196
const prompts = [
189197
{
190198
name: 'type',
191199
type: 'list',
200+
pageSize: 15,
192201
default: TYPE_BITCOIN_INFO,
193202
message: PromptCmd,
194203
choices: [TYPE_BITCOIN_INFO, TYPE_USDT_INFO, TYPE_EOS_INFO, TYPE_TRANS_BTC_TO_WALLET,
195204
TYPE_TRANS_EOS_TO_WALLET, TYPE_TRANS_BTC_TO_MASTER, TYPE_TRANS_EOS_TO_MASTER,
196-
TYPE_VERIFY_PIN, "Exit"],
205+
TYPE_VERIFY_PIN, TYPE_BTC_WITHDRAW, TYPE_EOS_WITHDRAW, TYPE_BTC_WITHDRAW_READ,
206+
TYPE_EOS_WITHDRAW_READ, "Exit"],
197207
},
198208
];
199209
(async () => {
@@ -307,6 +317,62 @@ if ( process.argv.length == 3 ) {
307317
const verifyPin = await newUserClient.verifyPin(data[4]);
308318
// const updatePin = await client.updatePin({ oldPin: config.assetPin, newPin: '123456' }); // CAUTION
309319
console.log({ verifyPin });
320+
} else if (args.type === TYPE_BTC_WITHDRAW) {
321+
const withdrawAddress = await newUserClient.createWithdrawAddress({
322+
assetId: BTC_ASSET_ID,
323+
label: 'BTC withdraw',
324+
publicKey: BTC_WALLET_ADDR,
325+
});
326+
console.log(withdrawAddress);
327+
const prompts = [
328+
{
329+
name: 'amount',
330+
type: 'input',
331+
message: "Input you BTC amount: ",
332+
},
333+
];
334+
const answers = await inquirer.prompt(prompts);
335+
console.log(answers);
336+
const withdrawResult = await newUserClient.withdraw({
337+
addressId: withdrawAddress.address_id,
338+
assetId: BTC_ASSET_ID,
339+
amount: answers.amount,
340+
memo: 'withdraw by nodejs',
341+
});
342+
console.log(withdrawResult);
343+
} else if (args.type === TYPE_EOS_WITHDRAW) {
344+
const withdrawAddress = await newUserClient.createWithdrawAddress({
345+
assetId: EOS_ASSET_ID,
346+
label: 'EOS withdraw',
347+
publicKey: "do not need",
348+
accountName: EOS_WALLET_NAME,
349+
accountTag: EOS_WALLET_TAG,
350+
});
351+
console.log(withdrawAddress);
352+
// const addressList = await newUserClient.getWithdrawAddress(EOS_ASSET_ID);
353+
// console.log(addressList);
354+
const prompts = [
355+
{
356+
name: 'amount',
357+
type: 'input',
358+
message: "Input you BTC amount: ",
359+
},
360+
];
361+
const answers = await inquirer.prompt(prompts);
362+
console.log(answers);
363+
const withdrawResult = await newUserClient.withdraw({
364+
addressId: withdrawAddress.address_id,
365+
assetId: EOS_ASSET_ID,
366+
amount: answers.amount,
367+
memo: 'withdraw by nodejs',
368+
});
369+
console.log(withdrawResult);
370+
} else if (args.type === TYPE_EOS_WITHDRAW_READ) {
371+
const addressList = await newUserClient.getWithdrawAddress(EOS_ASSET_ID);
372+
console.log(addressList);
373+
} else if (args.type === TYPE_BTC_WITHDRAW_READ) {
374+
const addressList = await newUserClient.getWithdrawAddress(BTC_ASSET_ID);
375+
console.log(addressList);
310376
}
311377
runScript(scriptName, [process.argv[2]], function (err) {
312378
if (err) throw err;

0 commit comments

Comments
 (0)