Bitcoin Forum
January 21, 2019, 02:26:59 AM *
News: Latest Bitcoin Core release: 0.17.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Blocktrail/btc.com SDK Fees estimation  (Read 44 times)
new-bie 75
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
July 28, 2018, 01:13:05 PM
Last edit: July 29, 2018, 06:54:17 AM by new-bie 75
 #1

First of all hi and thanks for your support and your time.

I want to calculate the fees of a blocktrail transaction with blocktrail SDK, before making the transaction, in order to let the recipient pay fees.

Here is what I tried:

Code:
$FEES = $wallet->coinSelection(\Blocktrail\SDK\Wallet::normalizeOutputsStruct(['66f4dec6ab29cd056ce1814c6fdfee05e1524b36' =>'100000']),false,false,\Blocktrail\SDK\Wallet::FEE_STRATEGY_LOW_PRIORITY['fee'];
echo "$FEES";

But this don't work, error says this:
Code:
Fatal error: Uncaught Blocktrail\SDK\Exceptions\BlocktrailSDKException: Address not recognized
how can I fix it?Any other ideas to make this "action"?

I have also another question, how should I process payments on my site and why? Is more correct to process a payment when user request it, so with only 1 input or to process all payments togheter with a cronjob?

Thanks for read, hope that you'll have a nice day Smiley
1548037619
Hero Member
*
Offline Offline

Posts: 1548037619

View Profile Personal Message (Offline)

Ignore
1548037619
Reply with quote  #2

1548037619
Report to moderator
1548037619
Hero Member
*
Offline Offline

Posts: 1548037619

View Profile Personal Message (Offline)

Ignore
1548037619
Reply with quote  #2

1548037619
Report to moderator
1548037619
Hero Member
*
Offline Offline

Posts: 1548037619

View Profile Personal Message (Offline)

Ignore
1548037619
Reply with quote  #2

1548037619
Report to moderator
PLAY NOW
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1548037619
Hero Member
*
Offline Offline

Posts: 1548037619

View Profile Personal Message (Offline)

Ignore
1548037619
Reply with quote  #2

1548037619
Report to moderator
btj
Member
**
Offline Offline

Activity: 106
Merit: 14


View Profile
July 29, 2018, 11:08:50 PM
Last edit: July 29, 2018, 11:35:33 PM by btj
 #2

Here is how to do it:

Code:
<?php
use Blocktrail\SDK\BlocktrailSDK;
use 
Blocktrail\SDK\Wallet;

// BEGIN - CHANGE REQUIRED INFOS
require_once __DIR__ "BLOCKTRAIL_SDK";

define("blocktrail_api"""); 
define("blocktrail_secret""");
define("blocktrail_wallet""");
define("blocktrail_password""");

$address ""// your address
$satoshi 100000// your amount in satoshi

// END - CHANGE REQUIRED INFOS

$client = new BlocktrailSDK(blocktrail_apiblocktrail_secret"BTC"false);
$wallet $client->initWallet(blocktrail_walletblocktrail_password);

$feeStrategy = \Blocktrail\SDK\Wallet::FEE_STRATEGY_LOW_PRIORITY// your fee type

$coinselect $wallet->coinSelection(
\
Blocktrail\SDK\Wallet::normalizeOutputsStruct([$address => $satoshi]),
falsefalse,
$feeStrategy
);

$fees $coinselect["fee"];

// Logs
var_dump($coinselect);
echo 
"\n Fees for this transaction will be: ".$fees;
?>

Change some informations like: BLOCKTRAIL_SDK path, blocktrail api, address where you want to send the amount, and the amount it self in ($satoshi string).

I notice the bitcoin address you are trying to send BTC to:
Code:
66f4dec6ab29cd056ce1814c6fdfee05e1524b36
are not in correct format, a Bitcoin address start with number '1' or '3',  contains 26 to 33 characters (a-z, A-Z, 0-9), excluding 'O', 'I' and 'l', to prevent visual ambiguity. And your address do not follow all this conditions ... i think you put a random MD5 string.

If it's a testnet address, please switch to testnet on Blocktrail, but i don't know if Fees estimation is supported or not for testnet, change this line:
Code:
$client = new BlocktrailSDK(blocktrail_api, blocktrail_secret, "BTC", false);
to

Code:
$client = new BlocktrailSDK(blocktrail_api, blocktrail_secret, "BTC", true);

I suggest to process payments semi-automatically ... when user submit new withdraw request, from admin panel you can process it with one button click.

I used Blocktrail API in the past, but personnaly i didn't liked it ... support is late or never answer to customers tickets/emails, and the fees for transactions are very high (I don't know if this changed from that time - Around one year ago).
Pages: [1]
  Print  
 
Jump to:  

Bitcointalk.org is not available or authorized for sale. Do not believe any fake listings.
Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!