Bitcoin Forum
November 21, 2019, 09:40:04 PM *
News: Help collect the most notable posts made over the last 10 years.
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do I create raw Tx using PHP ?  (Read 1053 times)
CounterEntropy
Full Member
***
Offline Offline

Activity: 174
Merit: 180


View Profile
September 01, 2015, 11:56:57 PM
 #1

I have the following data in MySQL table...

Address1 - PrivKey1 - Amount1
Address2 - PrivKey2 - Amount2
Address3 - PrivKey3 - Amount3

I can get the list of unspent outputs from blockchain.info API - https://blockchain.info/unspent?active=Address1|Address2|Address3

Now, I want a php script which will generate the raw Tx to spend all UTXO to an offline destination address, say dAddress, including the calculation of proper Tx fee, i.e. size of the raw Tx needs to be dynamically calculated. Can someone please help me out ?
1574372404
Hero Member
*
Offline Offline

Posts: 1574372404

View Profile Personal Message (Offline)

Ignore
1574372404
Reply with quote  #2

1574372404
Report to moderator
The Bitcoin Forum is turning 10 years old! Join the community in sharing and exploring the notable posts made over the years.
1574372404
Hero Member
*
Offline Offline

Posts: 1574372404

View Profile Personal Message (Offline)

Ignore
1574372404
Reply with quote  #2

1574372404
Report to moderator
1574372404
Hero Member
*
Offline Offline

Posts: 1574372404

View Profile Personal Message (Offline)

Ignore
1574372404
Reply with quote  #2

1574372404
Report to moderator
ca333
Hero Member
*****
Offline Offline

Activity: 516
Merit: 506


Developer - EthicHacker - BTC enthusiast


View Profile
September 02, 2015, 06:59:37 AM
Last edit: September 02, 2015, 07:18:37 AM by ca333
Merited by xandry (3)
 #2

I have the following data in MySQL table...

Address1 - PrivKey1 - Amount1
Address2 - PrivKey2 - Amount2
Address3 - PrivKey3 - Amount3

I can get the list of unspent outputs from blockchain.info API - https://blockchain.info/unspent?active=Address1|Address2|Address3

Now, I want a php script which will generate the raw Tx to spend all UTXO to an offline destination address, say dAddress, including the calculation of proper Tx fee, i.e. size of the raw Tx needs to be dynamically calculated. Can someone please help me out ?

If this is for production enviroment I strongly recommend to get unspent outputs from
local blockchain (from your btc-node).


For your question: (simple solution)

https://github.com/Bit-Wasp/bitcoin-lib-php
is the library for BTC in php. all key functions are implemented there.

for your raw-tx look in this:
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/RawTransaction.php

thank you,
ca333


#EDIT: you can also connect to btcdaemon with json rpc and then use bitcoin
functions on daemon. For your purpose you will need: listunspent, createrawtransaction, signrawtransaction, sendrawtransaction

usefull material:
https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP
https://en.bitcoin.it/wiki/Raw_Transactions
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

this space is available (free) for humanitarian nonprofit organizations - please contact me
Pages: [1]
  Print  
 
Jump to:  

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!