Recent

Author Topic: Bitcoin Programming in Lazarus Pascal  (Read 7853 times)

shonay

  • Full Member
  • ***
  • Posts: 169
Bitcoin Programming in Lazarus Pascal
« on: October 16, 2015, 10:09:04 am »
Morning everyone.

Bitcoin is open source.

I been looking around to creating my own Bitcoin Wallet in Pascal where someone can create Wallets there, fund the Bitcoin account and transfer to another customer. But maybe let's say I wanted to use blockchains.info's api.
But before I continue, I want to ask a question what's the possibility? Can it be done? What API do I have to use in this case to fund Addresses.. thats where I got stuck, I'm doing this in Pascal, kindly help.
When the power of love overcomes the love of power, the world would know Peace

- Jimi Hendrix.

edvard

  • Full Member
  • ***
  • Posts: 172
Re: Bitcoin Programming in Lazarus Pascal
« Reply #1 on: November 11, 2015, 10:15:17 am »
...
Can it be done?
Definitely
Quote
What API do I have to use in this case to fund Addresses.. thats where I got stuck, I'm doing this in Pascal, kindly help.

Looking around at Blockchain.info's API, most of the functions look easy to do without a whole lot of reading.  As far as funding, are you talking about making an initial deposit using native money?  That is probably best handled by an exchange service.  To fund your wallet with BTC, I don't see a direct method, but probably you would use the "Making Outgoing Payments" method, but sending from the other account to the new account instead.  In other words, make a payment from another wallet to your blockchain.info wallet.

If you haven't started already, you'll need to get familiar with making POST and GET requests to the Bitcoin.info site with FreePascal/Lazarus.  I've heard you can use http client functions from Synapse or Indy, but I've had good success using FPHttpClient from the standard FCL-Web package.  See the examples in your FPC installation:
 [your fpc source directory]/packages/fcl-web/examples/httpclient/httpclient.pas.

A few practical caveats:
1- Looks like all the examples at the blockchain.info site use the OpenSSL protocol (https://)
Read about using HTTPS at the FreePascal Wiki, or try Synapse or Indy, which both have methods for using SSL.
2- Looks like they want the POST to be URL-encoded as well.  See the example of a URL encoding function here: https://github.com/nandod/kitto/blob/master/Source/ThirdParty/ExtPascal/ExtPascalUtils.pas
and here:
http://castlesand.googlecode.com/svn/trunk/Common/URLUtils.pas
Search for "function URLEncode". 
The Delphi 'CharInSet' function call can either be emulated (as in the castlesand example), or just change
Code: [Select]
if CharInSet(Decoded[I], Allowed) thento
Code: [Select]
if Decoded[i] in Allowed thento work with FPC.

I'm not too familiar with Bitcoin, but I have wrangled with web requests using FPHttpClient, so hopefully this helps.
« Last Edit: November 11, 2015, 10:38:43 am by edvard »
All children left unattended will be given a mocha and a puppy.

Arch (though I may go back to Debian)| FreePascal 3.2.2 + Lazarus 2.2.4, GTK2+ and Qt.  Mostly Qt...

 

TinyPortal © 2005-2018