Bitcoin Forum
February 29, 2020, 08:03:13 AM *
News: Latest Bitcoin Core release: 0.19.0.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to Create Bitcoin Transactions from a Server  (Read 123 times)
vicknick
Newbie
*
Offline Offline

Activity: 16
Merit: 10


View Profile
January 26, 2020, 02:35:53 PM
 #1

I am exploring ways to create a bitcoin transaction on a website server. When a user has typed in his bitcoin address and the amount to be sent, how do you create a bitcoin transaction to send the specified amount to his/her address on a server? I tried searching online but so far I can only find minimal info about this.

Some says you can install bitcoin core on the server, but the storage needed to hold the blockchain exceeds my capacity. Electrum seems to be a good option since it doesn't download the entire blockchain, but there is no info on how to make a transaction from the server code (I am writing in JavaScript).

Any recommendations are highly appreciated.
100% First Deposit Bonus Instant Withdrawals Best Odds 10+ Sports Since 2014 No KYC Asked Play Now
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1582963393
Hero Member
*
Offline Offline

Posts: 1582963393

View Profile Personal Message (Offline)

Ignore
1582963393
Reply with quote  #2

1582963393
Report to moderator
1582963393
Hero Member
*
Offline Offline

Posts: 1582963393

View Profile Personal Message (Offline)

Ignore
1582963393
Reply with quote  #2

1582963393
Report to moderator
1582963393
Hero Member
*
Offline Offline

Posts: 1582963393

View Profile Personal Message (Offline)

Ignore
1582963393
Reply with quote  #2

1582963393
Report to moderator
DaveF
Legendary
*
Offline Offline

Activity: 1946
Merit: 1067


DAVID CHAUM's xx coin SALE IS NOW LIVE!


View Profile WWW
January 26, 2020, 02:43:18 PM
 #2

I think you are just looking to create the raw transaction and send that?
If so:
https://en.bitcoin.it/wiki/Raw_Transactions

If you are looking to do something else you are going to have to define what you are looking to do a bit more.
Also, if the server you are working on can't hold the blockchain it's probably time to get a new one.

-Dave



███████                   
                      ██████████                        ██       
                       ████████████                  ███       
                                ██████████           █████       
                                        ███████      ██████         
██████                  ███████     ████
████████                ██████     ██   
██████████        ████████           
███████████    █████████           
████████    ████████
   
      ███████    ████████       
              ██████    █████████████ 
          █████████      ███████████ 
      ███████████          █████████ 
██████████████                       
████████████████                       
███████      ████████████           
██████        ████████████           
████                ██████████           

xx-coin.io

█▀▀▀











█▄▄▄

▀▀▀█











▄▄▄█

█▀▀▀











█▄▄▄
 
████
██████
█████████
█████████████
████████████████
████████████████████
████████████████████████
███████████████████████
████████████g█████████
██████████g███████
████████g██████
██████g██████
██████████
██████
███


                 ████
                ████
                ▀▀
     ,▄▄▄▄▄▄      ▄▄▄▄▄▄
   o████████▄██▄████████
  ████████████████████
 d███████████████████
,███████████████████
`███████████████████
 ████████████████████
 █████████████████████
  ████████████████████████
   ██████████████████████
    ████████████████████
     `████▀▀  ▀▀██████

▀▀▀█











▄▄▄█
ranochigo
Legendary
*
Offline Offline

Activity: 1932
Merit: 1271

Back online:)


View Profile WWW
January 26, 2020, 02:43:24 PM
Merited by BrewMaster (1)
 #3

You don't have to keep the entire blockchain on your computer for the whole time. You can delete the older blocks as you go with pruning and keep it from exceeding a certain size.

That being said, Electrum offers JSONRPC and you can easily integrate that with your code. There's some examples here[1].


[1] https://electrum.readthedocs.io/en/latest/merchant.html

vicknick
Newbie
*
Offline Offline

Activity: 16
Merit: 10


View Profile
January 26, 2020, 02:48:52 PM
 #4

Quote
That being said, Electrum offers JSONRPC and you can easily integrate that with your code. There's some examples here[1].

That's accepting bitcoin, however what I want is to send bitcoin to users.
vicknick
Newbie
*
Offline Offline

Activity: 16
Merit: 10


View Profile
January 26, 2020, 02:58:04 PM
 #5

I think you are just looking to create the raw transaction and send that?
If so:
https://en.bitcoin.it/wiki/Raw_Transactions

If you are looking to do something else you are going to have to define what you are looking to do a bit more.
Also, if the server you are working on can't hold the blockchain it's probably time to get a new one.

-Dave

Does it require bitcoin core to be installed? Is there other ways to send bitcoin from server without installing bitcoin core wallet?
ranochigo
Legendary
*
Offline Offline

Activity: 1932
Merit: 1271

Back online:)


View Profile WWW
January 26, 2020, 03:06:40 PM
 #6

Does it require bitcoin core to be installed? Is there other ways to send bitcoin from server without installing bitcoin core wallet?
Would pruning not work for you? It's possible for you to use a code to script your own raw transaction and then directly broadcast the raw transaction to the other nodes. But that would require you to be able to obtain the information about your UTXO in the first place and it would preferably be from your Bitcoin node.

BrewMaster
Hero Member
*****
Offline Offline

Activity: 1470
Merit: 975


There is trouble abrewing


View Profile
January 26, 2020, 03:34:10 PM
 #7

Quote
That being said, Electrum offers JSONRPC and you can easily integrate that with your code. There's some examples here[1].

That's accepting bitcoin, however what I want is to send bitcoin to users.

you can do both with Electrum JSONRPC. the commands support both creation and signing of transactions from your keys with commands such as "signtransaction()" and then you can broadcast them using "broadcast(tx)".

vicknick
Newbie
*
Offline Offline

Activity: 16
Merit: 10


View Profile
January 26, 2020, 04:00:45 PM
 #8

Would pruning not work for you? It's possible for you to use a code to script your own raw transaction and then directly broadcast the raw transaction to the other nodes. But that would require you to be able to obtain the information about your UTXO in the first place and it would preferably be from your Bitcoin node.
However when users deposit bitcoin to the website, each of them have different addresses, which are generated in deterministic manner. The reason I prefer to use a wallet is because when the server send bitcoin to external address given by the user, the wallet is able to send bitcoin by combining from different addresses. I think writing own script to implement this feature would be harder?
vicknick
Newbie
*
Offline Offline

Activity: 16
Merit: 10


View Profile
January 26, 2020, 04:15:10 PM
 #9

Quote
That being said, Electrum offers JSONRPC and you can easily integrate that with your code. There's some examples here[1].

That's accepting bitcoin, however what I want is to send bitcoin to users.

you can do both with Electrum JSONRPC. the commands support both creation and signing of transactions from your keys with commands such as "signtransaction()" and then you can broadcast them using "broadcast(tx)".
Is there any examples/documentations for this? Electrum's documentation doesn't seem to have the info.
BrewMaster
Hero Member
*****
Offline Offline

Activity: 1470
Merit: 975


There is trouble abrewing


View Profile
January 26, 2020, 04:29:53 PM
 #10

{snip}
Is there any examples/documentations for this? Electrum's documentation doesn't seem to have the info.

there is the electrum docs here: https://electrum.readthedocs.io/en/latest/merchant.html that contain the needed information to start accepting bitcoin as a merchant using Electrum. it mainly explains accepting payment but the principle is the same for sending payments too.
there are also some articles on the internet that you can find in google search for keyword "bitcoin" + "electrum" + "merchants". i haven't used any of them so i can't recommend any.

PrimeNumber7
Copper Member
Sr. Member
****
Offline Offline

Activity: 378
Merit: 515


Free markets, free people


View Profile
January 27, 2020, 06:44:52 AM
 #11

Quote
That being said, Electrum offers JSONRPC and you can easily integrate that with your code. There's some examples here[1].

That's accepting bitcoin, however what I want is to send bitcoin to users.

you can do both with Electrum JSONRPC. the commands support both creation and signing of transactions from your keys with commands such as "signtransaction()" and then you can broadcast them using "broadcast(tx)".
Is there any examples/documentations for this? Electrum's documentation doesn't seem to have the info.
You would need to use a series of RPC commands, such as listunspent and signtransaction. You would also need to craft a transaction outside of electrum if you were automating sending transactions.

If you absolutely do not wish to use a full node, you can also use the blockchain.com wallet API. Blockchain.com/info does have a history of screwups that has resulted in the loss of customer money, but I believe this to be less common in recent years.

I do believe running a full node and using the sendtoaddress RPC command would probably be your best solution. The cost to run a fully validating full node is not extraordinary. 


[ Mix coins ]
 
Your BITCOIN Transaction
made Truly ANONYMOUS
 

███████
█████████████████
████████████████████████
█████████████████████████████
██████████                    ██████████
█████████                          █████████
███████                                    ████████
          ███████                                        ███████        ██
          █████████████████████████████████████      ███
          █████████████████████████████████████  █████
          ████████████████████████████████████  ██████
        ██████████████████████████████████████████
  █████████████████████████████████████████
█████                                        ████████████
                                  ██████████████
██                          █████████████████████          ██       
█████              ███████████████████████          ████       
█████████████████████████████            █████████       
██████████████████                      ████████████         
██████████████████████████████████████       
████████████████████████  ███████   
    ██████████              █████
                      ████████
      ████████████████    █
        ██████████████████
                  █████      ███
                      █████
                    ████

Blender
 
The ULTIMATE BITCOIN Mixer
with an ADVANCED TECHNOLOGY
 

███████████     
███████████████████████     
████████████████████████████       
██████████████████████████████       
██████████████████████████████     
 

                                          █████████████
                                          ███████████
██████
                                          ███████████
██████
                                          ███████████
        ██
                                        ████████████
        ██
    ██                              █████████████
        ██
    ████                      ███████████████
        ██
    ██████              █████████████████
        ██
    █████████████████████████████
          ██   
      ███████████████████████████
          ███
      ██████  ████████████████████
        ████
      ██████████████████████████
  ██████
      ██████████████████████████
███████
  █████      ████████████████████
███
████          ████████████████
████ 
████          ████████████████         
████████████████████████


   
█████████████████████████         
███████████████████████████         
█████████    ██    ███    ██████████       
███████████    ██    ███     ██████████         
███████████    ██    ███     ███████████       
██████████████████████████████████       
██████████████████████████████████       
MrFreeDragon
Full Member
***
Offline Offline

Activity: 196
Merit: 109


View Profile
January 29, 2020, 12:52:32 PM
 #12

Have a look at this service:

https://github.com/OutCast3k/coinbin/
https://coinb.in/

This tool helps to create transactions online and broadcast them. If you go to the source code on github, you can find the useful information for you and use it on your web server.

Actually there are 2 steps: (1) create raw transaction, (2) broadcast the transaction. Both steps are realized in the tool.

EDIT: The tool uses JavaScript (as you asked in the OP)
Theb
Hero Member
*****
Offline Offline

Activity: 1218
Merit: 513



View Profile
January 29, 2020, 07:55:50 PM
 #13

there is the electrum docs here: https://electrum.readthedocs.io/en/latest/merchant.html that contain the needed information to start accepting bitcoin as a merchant using Electrum. it mainly explains accepting payment but the principle is the same for sending payments too.
there are also some articles on the internet that you can find in google search for keyword "bitcoin" + "electrum" + "merchants". i haven't used any of them so i can't recommend any.

Like what the OP stated in his other post he would also like to send crypto payments automatically om his side. Electrum's merchant function in their document only accept payments as a business and doesn't have any documentation for them sending the payments. @OP on this part I think it will be harder to find a sample script on what you are asking since even e-commerce crypto payment processors like Bitpay and Coinbase commerce only has a function to receive payments for your business. You would need to consider the balance your wallet have, the fees you will be handling, and also the conversion of the prices in USD all of which if it will go wrong your funds will be instantly flushed.

      ▄ ▄█▄ ▄█ ▄
     ▄▐██▀▀▀▀▀▀
      ▀▄▄████▄ █▄
   ▄ ██▄█▀▀   ▀▀ ▀
  ▄██▄██▄ ▀██▄▀ ▀█▄
 ▀███████▄▄▄▄▄█▄▄▄██
▐███████████▀▀  ▀█▀ █
█▀███████████  ▄▄█▄ ██
 ▐█████████████▀   ███
  ████▀██████████▄███
  ▐█▀  ████████████ ▀
   ▀  ▐███████████
     ▄██████▀▀ █▀
.
JACKMATE'S
MAJESTIC

  ███████████████████
 ███████████████████
███████████████████
         █████████
        █████████
       █████████
      █████████
     █████████
    █████████
   █████████
  █████████
 █████████
████████
██
██
██
██
██
██
██
██
██
██
██
████████
██████████████████████████████████████████████████████████████████████████████████████████████     ███
.
WIN 1 BITCOIN ON EVERY PREMIER LEAGUE MATCHDAY
.
███     ██████████████████████████████████████████████████████████████████████████████████████████████
████████
██
██
██
██
██
██
██
██
██
██
██
████████
████████████████████████████████
████████████▀█▀ ▀█▀█▀███████████
███████████▄ ▄▄▄▄▄▄▄████████████
███████████▀▀▄▄▄▄▄▄▄▄███████████
█████████▀▄ ██▀▄▄▄ ▀ ▄▀█████████
███████▀ ▀█████▄▄▄█▄▄▄██████████
███████▀▄████████▀  ▀█ █▐███████
███████ ▀█████████▄█▀▀██ ███████
████████ ███▀██████ ▄ ██ ███████
████████▌▐▀▄ ██████████ ▄███████
█████████▄██▌▐█████▀██ █████████
████████████▄▀▀▀▀▀▄ ▀▄██████████
████████████████████████████████
██████
██
██
██
██
██
██
██
██
██
██
██
██████
.
JOIN US - IT'S FREE!
██████
██
██
██
██
██
██
██
██
██
██
██
██████
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!