Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: bitcoinfuck on December 23, 2018, 04:43:01 PM



Title: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 23, 2018, 04:43:01 PM
hey i want to try a new approach to my project


What i want to do ?
Send BTC from private key to a address

USING PHP or any simple small script

Electrum like solution to send


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: Initscri on December 24, 2018, 03:31:49 AM
If you want to use PHP, you're either going to have to run a Bitcoind server, or leverage an existing API (for example, Blockchain.info's)

Bitcoind

Using PHP-bitcoinrpc class (https://github.com/denpamusic/php-bitcoinrpc)

Code:
<?php
$bitcoind 
= new BitcoinClient('http://rpcuser:rpcpassword@localhost:8332/');

//add the private key (label, key)
$import bitcoind->importprivkey("SOME_PRIVATE_KEY");

$result $bitcoind->sendToAddress('YOUR_ADDRESS'0.1); // 0.1=amount
$txid $result->get();
?>

Note: I haven't tested this code, so please test

Using an API (Blockchain.com)

Code:
<?php

$Blockchain 
= new \Blockchain\Blockchain($api_code);
$Blockchain->setServiceUrl("http://localhost:3000"); // Set to service URL (for example: https://blockchain.info/merchant/$guid/)
$wallet $Blockchain->Create->createWithKey($password$privKey$email=null$label=null);

// Example: Send 0.005 BTC to YOUR_ADDRESS (replace), with a 0.0001 BTC fee
$response $wallet->send("YOUR_ADDRESS""0.005"null"0.0001");


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 24, 2018, 12:04:11 PM
If you want to use PHP, you're either going to have to run a Bitcoind server, or leverage an existing API (for example, Blockchain.info's)

Bitcoind

Using PHP-bitcoinrpc class (https://github.com/denpamusic/php-bitcoinrpc)

Code:
<?php
$bitcoind 
= new BitcoinClient('http://rpcuser:rpcpassword@localhost:8332/');

//add the private key (label, key)
$import bitcoind->importprivkey("SOME_PRIVATE_KEY");

$result $bitcoind->sendToAddress('YOUR_ADDRESS'0.1); // 0.1=amount
$txid $result->get();
?>

Note: I haven't tested this code, so please test

Using an API (Blockchain.com)

Code:
<?php

$Blockchain 
= new \Blockchain\Blockchain($api_code);
$Blockchain->setServiceUrl("http://localhost:3000"); // Set to service URL (for example: https://blockchain.info/merchant/$guid/)
$wallet $Blockchain->Create->createWithKey($password$privKey$email=null$label=null);

// Example: Send 0.005 BTC to YOUR_ADDRESS (replace), with a 0.0001 BTC fee
$response $wallet->send("YOUR_ADDRESS""0.005"null"0.0001");

p.s: you should probably move this to development & technical (https://bitcointalk.org/index.php?board=6.0), you'd get more programming related responses/assistance there.

thanks for reply, but Blockchain.com api is not good small Payout as they take 0.001 from every payout


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: Initscri on December 24, 2018, 12:11:25 PM
If you want to use PHP, you're either going to have to run a Bitcoind server, or leverage an existing API (for example, Blockchain.info's)

Bitcoind

Using PHP-bitcoinrpc class (https://github.com/denpamusic/php-bitcoinrpc)

Code:
<?php
$bitcoind 
= new BitcoinClient('http://rpcuser:rpcpassword@localhost:8332/');

//add the private key (label, key)
$import bitcoind->importprivkey("SOME_PRIVATE_KEY");

$result $bitcoind->sendToAddress('YOUR_ADDRESS'0.1); // 0.1=amount
$txid $result->get();
?>

Note: I haven't tested this code, so please test

Using an API (Blockchain.com)

Code:
<?php

$Blockchain 
= new \Blockchain\Blockchain($api_code);
$Blockchain->setServiceUrl("http://localhost:3000"); // Set to service URL (for example: https://blockchain.info/merchant/$guid/)
$wallet $Blockchain->Create->createWithKey($password$privKey$email=null$label=null);

// Example: Send 0.005 BTC to YOUR_ADDRESS (replace), with a 0.0001 BTC fee
$response $wallet->send("YOUR_ADDRESS""0.005"null"0.0001");

p.s: you should probably move this to development & technical (https://bitcointalk.org/index.php?board=6.0), you'd get more programming related responses/assistance there.

thanks for reply, but Blockchain.com api is not good small Payout as they take 0.001 from every payout

You can change the fee by switching the last parameter in $wallet->send. That was just for an example.


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: darosior on December 24, 2018, 12:16:54 PM
Quote
Send BTC from private key to a address
You don't have to use only RPC, you can also make transactions and send them to the network thanks to a library (https://github.com/search?l=PHP&q=bitcoin+transaction&type=Repositories) .


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: LoyceV on December 24, 2018, 01:29:17 PM
simple small script

Electrum like solution to send
I haven't tested it, but have you lookd at Electrum command line options? I was amazed with this feature (https://bitcointalk.org/index.php?topic=3866008.msg37535758#msg37535758) a while ago. It may be worth checking if it can do what you need.


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 25, 2018, 01:49:33 PM
Quote
Send BTC from private key to a address
You don't have to use only RPC, you can also make transactions and send them to the network thanks to a library (https://github.com/search?l=PHP&q=bitcoin+transaction&type=Repositories) .


can you link me to a single webapge, its full search and none of them offer solution i am trying to get


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 25, 2018, 01:51:13 PM
If you want to use PHP, you're either going to have to run a Bitcoind server, or leverage an existing API (for example, Blockchain.info's)

Bitcoind

Using PHP-bitcoinrpc class (https://github.com/denpamusic/php-bitcoinrpc)

Code:
<?php
$bitcoind 
= new BitcoinClient('http://rpcuser:rpcpassword@localhost:8332/');

//add the private key (label, key)
$import bitcoind->importprivkey("SOME_PRIVATE_KEY");

$result $bitcoind->sendToAddress('YOUR_ADDRESS'0.1); // 0.1=amount
$txid $result->get();
?>

Note: I haven't tested this code, so please test

Using an API (Blockchain.com)

Code:
<?php

$Blockchain 
= new \Blockchain\Blockchain($api_code);
$Blockchain->setServiceUrl("http://localhost:3000"); // Set to service URL (for example: https://blockchain.info/merchant/$guid/)
$wallet $Blockchain->Create->createWithKey($password$privKey$email=null$label=null);

// Example: Send 0.005 BTC to YOUR_ADDRESS (replace), with a 0.0001 BTC fee
$response $wallet->send("YOUR_ADDRESS""0.005"null"0.0001");

p.s: you should probably move this to development & technical (https://bitcointalk.org/index.php?board=6.0), you'd get more programming related responses/assistance there.

thanks for reply, but Blockchain.com api is not good small Payout as they take 0.001 from every payout

You can change the fee by switching the last parameter in $wallet->send. That was just for an example.

this is what i am trying to say

https://i.ibb.co/mGTCc40/Capture.png (https://ibb.co/XbLZCtD)

https://www.blockchain.com/api/blockchain_wallet_api


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: darosior on December 25, 2018, 07:58:55 PM
Quote
can you link me to a single webapge, its full search and none of them offer solution i am trying to get
You could search by yourself instead of asking and waiting for the ready answer, it was just an example. However, the first result of the search points to a PHP Bitcoin library (https://github.com/Bit-Wasp/bitcoin-php) providing a transaction builder (https://github.com/Bit-Wasp/bitcoin-php/blob/master/doc/documentation/Transaction.md).


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: Initscri on December 26, 2018, 03:26:26 AM
~
this is what i am trying to say

https://i.ibb.co/mGTCc40/Capture.png (https://ibb.co/XbLZCtD)

https://www.blockchain.com/api/blockchain_wallet_api

Ah ok, I see, I missed that.

If you're not up for RPC, you can use PHP along with LoyveV's reco. Or, you can try another API


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 26, 2018, 06:04:45 AM
Quote
can you link me to a single webapge, its full search and none of them offer solution i am trying to get
You could search by yourself instead of asking and waiting for the ready answer, it was just an example. However, the first result of the search points to a PHP Bitcoin library (https://github.com/Bit-Wasp/bitcoin-php) providing a transaction builder (https://github.com/Bit-Wasp/bitcoin-php/blob/master/doc/documentation/Transaction.md).

i practicly looked to all repo, none of them seems to work as i intended

+ who told i am waiting here ? i am already working on project why would i keep my hopes on you guys, i am just here for suggestion.


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: Initscri on December 26, 2018, 07:13:41 PM
You could use the Block.IO Api; they have an example for sweeping here: https://github.com/BlockIo/block_io-php/blob/master/examples/sweeper.php

There's more information on their API page here as well (although, I couldn't find anything regarding sweeping):
https://block.io/api/


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 27, 2018, 07:54:19 AM
You could use the Block.IO Api; they have an example for sweeping here: https://github.com/BlockIo/block_io-php/blob/master/examples/sweeper.php

There's more information on their API page here as well (although, I couldn't find anything regarding sweeping):
https://block.io/api/

block io api is known for cold techniques stealing and manipluating funds, i would advise everyone to be carefull


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: Initscri on December 28, 2018, 01:22:05 AM
You could use the Block.IO Api; they have an example for sweeping here: https://github.com/BlockIo/block_io-php/blob/master/examples/sweeper.php

There's more information on their API page here as well (although, I couldn't find anything regarding sweeping):
https://block.io/api/

block io api is known for cold techniques stealing and manipluating funds, i would advise everyone to be carefull

Do you have links/references for this? I'd like to take a look.

Cheers,


Title: Re: Best Way to send bitcoin using Privatekey [PHP or SHELL]
Post by: bitcoinfuck on December 28, 2018, 04:18:26 PM
for anyone looking for updates to this thread the best i found for general public is dev.btc.com

it has fees adjustments, fast and realiable