Anybody have any idea about how to do it?

  1. User send the bitcoins
  2. X% goes to fee wallet
  3. remaining funds goes to service wallet


I'm trying to use the "sendfrom" but it's not working because he only send the fee amount (or the first call), never the rest.

$sendingFee = $bitcoin->sendfrom($account, $addFee, $feeFormated, 0);
$sendingRest = $bitcoin->sendfrom($account, $addRest, $restMath, 0);

This is my code:

getbalance($account, 1);

#do a math to remove X%
$feeMath = fee($tax, $balance);

#I was receiving "invalid amount" error. Fixed with this, I was giving 9 instead of 8 after zero. See satoshis for more.
$feeFormated = number_format($feeMath, 8);

#remove the fee from current balance
$restMath = $balance - $feeFormated;

#send the fee to the address xxxx
$sendingFee = $bitcoin->sendfrom($account, $addFee, $feeFormated, 0);

#send the balance minus fee to the address yyy
$sendingRest = $bitcoin->sendfrom($account, $addRest, $restMath, 0);

$err = $bitcoin->error;

#Print message for control
print_r("Fee TXID = " . $sendingFee . " Amount sent = " . "" . $feeFormated . "

"); print_r("Rest TXID = " . $sendingRest . " Amount sent = " . "" . $restMath . "

"); print_r("It's not working because: " . $err); echo var_dump($sendingFee) . "

"; echo var_dump($sendingRest) . "

"; ?>

It's not perfect (far from this) but please understand, I'm not a php guy, even a programmer, I'm just working in a personal project as a hobby.

Maybe should I use "sendmany"? If so, how to use this with php? I saw some examples on internet but nothing showing how to use with php and variables.

Thanks in advance.


    Problem solved using "sendmany":

                    "2Mt7dkQiyExrNQTXu9D3qoCpWg3J5TJy9Up" => "0.00222" );
    $send = $bitcoin->sendmany($account, $arrayRec);

      Your Answer

      By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

      Not the answer you're looking for? Browse other questions tagged or ask your own question.