Bitcoin Forum
December 05, 2016, 08:45:16 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: « 1 [2] 3 »  All
  Print  
Author Topic: Bitcoin SCI [PHP]: process transactions yourself! (addresses gen, IPN, QR Codes)  (Read 13783 times)
MasterX
Member
**
Offline Offline

Activity: 88



View Profile
May 05, 2013, 04:18:29 PM
 #21

Anyone has a clue why i'm always gettin "*** Invalid Ciphertext ***" on the "http://127.0.0.1/sci/admin.php?page=keys#" page?
Tought it was sommething with $sec_str but im not shure as i have tried what ever i could think of.

| Donations: 1MegaXG1bd6mTEQCdAMjVzGexcYrF5LJKv |
1480927516
Hero Member
*
Offline Offline

Posts: 1480927516

View Profile Personal Message (Offline)

Ignore
1480927516
Reply with quote  #2

1480927516
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480927516
Hero Member
*
Offline Offline

Posts: 1480927516

View Profile Personal Message (Offline)

Ignore
1480927516
Reply with quote  #2

1480927516
Report to moderator
1480927516
Hero Member
*
Offline Offline

Posts: 1480927516

View Profile Personal Message (Offline)

Ignore
1480927516
Reply with quote  #2

1480927516
Report to moderator
MasterX
Member
**
Offline Offline

Activity: 88



View Profile
May 05, 2013, 05:25:30 PM
 #22

Anyone has a clue why i'm always gettin "*** Invalid Ciphertext ***" on the "http://127.0.0.1/sci/admin.php?page=keys#" page?
Tought it was sommething with $sec_str but im not shure as i have tried what ever i could think of.
Never mind, forgot to remove old wif keys.

| Donations: 1MegaXG1bd6mTEQCdAMjVzGexcYrF5LJKv |
Eric Muyser
Full Member
***
Offline Offline

Activity: 126


You can't kill math.


View Profile WWW
June 08, 2013, 05:20:29 AM
 #23

If you have problems with __autoload already declared, then open bitcoin.lib.php and remove the autoload include and include the ecc-lib files manually.

Replace this:

Code:
<?php
/**
* Bitcoin utility functions class (extended for sci lib)
*
* @author theymos (functionality)
* @author Mike Gogulski (http://www.gogulski.com/)
* @author Jacob Bruce (private/public/mini key generation)
* (encapsulation, string abstraction, PHPDoc)
*/
require_once(dirname(__FILE__).'/ecc-lib/auto_load.php');
define("BITCOIN_ADDRESS_VERSION""00");// this is a hex byte

class bitcoin {

With this:

Code:
<?php
/**
* Bitcoin utility functions class (extended for sci lib)
*
* @author theymos (functionality)
* @author Mike Gogulski (http://www.gogulski.com/)
* @author Jacob Bruce (private/public/mini key generation)
* (encapsulation, string abstraction, PHPDoc)
*/

set_time_limit(7200);

if(
extension_loaded('gmp') && !defined('USE_EXT')){
    
define ('USE_EXT''GMP');
}else if(
extension_loaded('bcmath') && !defined('USE_EXT')){
    
define ('USE_EXT''BCMATH');
}

require_once(
dirname(__FILE__).'/ecc-lib/classes/interface/PointInterface.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/interface/PrivateKeyInterface.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/interface/PublicKeyInterface.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/interface/SignatureInterface.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/interface/CurveFpInterface.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/NumberTheory.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/CurveFp.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/SECcurve.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/Point.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/PrivateKey.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/PublicKey.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/Signature.php');
require_once(
dirname(__FILE__).'/ecc-lib/classes/util/bcmath_Utils.php');

define("BITCOIN_ADDRESS_VERSION""00");// this is a hex byte

class bitcoin {

@EricMuyser | Coinlancer.com | EricMuyser.com | OTC - "Defeat is a state of mind; no one is ever defeated until defeat has been accepted as a reality" - Bruce Lee
colinistheman
Legendary
*
Offline Offline

Activity: 938



View Profile
September 15, 2013, 12:40:03 PM
 #24

Hi Bitfreak,

I would like to try using your PHP Bitcoin Shopping Cart Interface so that I can accept Bitcoin payments without a middleman.

The links didn't work. Does your interface work? If so, can you put it up again or send me a copy?

Thank you,
Colin
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
September 15, 2013, 02:20:47 PM
 #25

I'm having some issues with my web host at the moment but my website should be back online within a day or two. Sorry for the inconvenience.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
September 17, 2013, 05:20:40 AM
 #26

Bitfreak website is now back online.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
colinistheman
Legendary
*
Offline Offline

Activity: 938



View Profile
September 17, 2013, 12:54:32 PM
 #27

Thanks.

I need to be able to send BTC payments too. Is this possible with your code? If not, do you have a recommended way I could go about this easily with PHP?
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
September 17, 2013, 01:21:34 PM
 #28

I need to be able to send BTC payments too. Is this possible with your code?
No it's not with this script. In order to send payments to another address using PHP you will probably need to have bitcoind installed on your server. I don't really think there is any easier way but I could be wrong.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
colinistheman
Legendary
*
Offline Offline

Activity: 938



View Profile
September 17, 2013, 10:33:33 PM
 #29

I need to be able to send BTC payments too. Is this possible with your code?
No it's not because with this script. In order to send payments to another address using PHP you will probably need to have bitcoind installed on your server. I don't really think this is any easier way but I could be wrong.
Ok thanks
fbueller
Sr. Member
****
Offline Offline

Activity: 412


View Profile
October 17, 2013, 11:26:53 AM
 #30

I've written some code based on Bitcoin SCI, to back up live wallets once the balances exceed a certain amount. So far my work has only really touched the testnet. I've found the PHPECC class returns a keypair which allows valid bitcoin addresses to be derived (bitcoind's validateaddress function confirms this is OK), and have been successful in sending funds to one of these addresses.. However I can't import the private key?

Output from backup script:
Code:
Main Wallet Backup
------ 16 October 2013 10pm
Balance: BTC 0.0003
Bitcoin Address: mm5SSxdLbMV6yN59koD5kGUezgbaQbBEGE
Transaction ID: c507000c4ead8397337fdd93979b98df6759f938550e09bc0d4985e1e2cb4599
Private Key: 0017DDEEC21A492AD5D22046C890327C95ACFB290587F065BBDC19A35D128EDD
WIF Format: 4imfxryzuMUsrB4T7p48fBcBHhyiv624qkXdJBRUaLz5N3hg227

Testing:
Code:
~/bitcoin-0.8.5-linux/bin$ ./bitcoind importprivkey 0017DDEEC21A492AD5D22046C890327C95ACFB290587F065BBDC19A35D128EDD
error: {"code":-5,"message":"Invalid private key"}

~/bitcoin-0.8.5-linux/bin$ ./bitcoind importprivkey 4imfxryzuMUsrB4T7p48fBcBHhyiv624qkXdJBRUaLz5N3hg227
error: {"code":-5,"message":"Invalid private key"}

~/bitcoin-0.8.5-linux/bin$ ./bitcoind validateaddress mm5SSxdLbMV6yN59koD5kGUezgbaQbBEGE
{
    "isvalid" : true,
    "address" : "mm5SSxdLbMV6yN59koD5kGUezgbaQbBEGE",
    "ismine" : false
}

Bitwasp Developer.
qrs
Jr. Member
*
Offline Offline

Activity: 48


gather BTC for a trip around the world


View Profile
February 23, 2014, 06:00:27 PM
 #31

this script is great, I love it, when I will be rich I will donate you every day, bitfreak!

one question, I have working script on my site and now have few keys in wif-keys.csv file - what now? how to get BTC to my own wallet?


let's begin at the beginning => 1BuQuHX3xC4MxjcrRX6eCzzrmFvyHD4uaQ
thonglor
Newbie
*
Offline Offline

Activity: 24


View Profile
March 06, 2014, 06:07:52 PM
 #32

I asked the same question. Here the reply:

Quote
-clicking on the "(decrypt)" besides Private Key: what needs to be entered in the upcoming dialogue? If I enter the private key generated in the beginning I get "*** Invalid Ciphertext ***"?
Many people seem to have this problem and every single time it turns out to be that they didn't copy the private RSA key properly when they generated it. Try generating a new RSA key set and make sure you copy the full private RSA key properly and also make sure you save the full public RSAkey into the sci/config.php file. Watch the installation tutorial video if you need more help figuring it out. If you sent any money to those addresses then I'm afraid you may have lost it unless you can get your existing RSA keys to work.

Quote
-and now there is the Bitcoin address for each transaction. How to get this BTC transferred somewhere? Importing the private key generated in the beginning into an Armory wallet does not work.
The private RSA key is simply used for encryption, it's not a private key for Bitcoin. When you solve the invalid ciphertext problem you'll get the private keys you need.

For importing your keys into a blockchain.info wallet:

1. Login to admin area
2. Got to Orders
3. Select MANAGE KEYS
4. Select EXPORT KEYS
5. Input private RSA key when prompted
6. Scroll down and copy text from "Blockchain.info Format" box
7. Log into Blockchain.info wallet
8. Select "Import / Export" from top menu
9. Select "Import Wallet" from side menu
10. Paste text from step 6 into box and select "Import Wallet"
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
March 06, 2014, 08:11:14 PM
 #33

@thonglor: sorry I thought you were using the BitShop script. Those instructions only apply to the BitShop script. But your problem will be the same thing; you didn't copy the RSA keys properly. With this SCI script you'll have to decrypt each key separately, I don't think I included a function to decrypt them all at once. Ideally you should be saving the keys into a database and then building your own admin area based on the simple admin area I included with this script. It really isn't intended to be used as it is, it's supposed to be integrated with your projects and you should have a good knowledge of PHP to edit it.

As for how to import the decrypted private keys into your bitcoin wallet, see this page:
https://en.bitcoin.it/wiki/How_to_import_private_keys_v7%2B

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
thonglor
Newbie
*
Offline Offline

Activity: 24


View Profile
March 06, 2014, 09:22:43 PM
 #34

Hello bitfreak!,

OK, understand, thanks.

Then another aspect of the usage: I really want to use this script for a donation purpose. For this purpose I would not need new adresses for any transaction, just one receiveing address for all. So could I "hardcode" this one adress somewhere in the code and then disable the address generation?

BTW: I found the version number in the config.php file at the bottom...
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
March 06, 2014, 09:32:03 PM
 #35

No a new address must be generated each time because they need to start with an empty balance in order to detect payments. It's difficult, if not impossible, to determine who has paid what when you're using a single address to receive all payments.

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
thonglor
Newbie
*
Offline Offline

Activity: 24


View Profile
March 08, 2014, 08:40:16 PM
 #36

Quote
Try generating a new RSA key set and make sure you copy the full private RSA key properly and also make sure you save the full public RSAkey into the sci/config.php file.

The private RSA key is simply used for encryption, it's not a private key for Bitcoin. When you solve the invalid ciphertext problem you'll get the private keys you need.

Hi bitfreak!,

you're right with your analysis above. After repeating the mentioned steps I can now properly generate the private key for Bitcoin. Great!
bitvestor
Full Member
***
Offline Offline

Activity: 182


View Profile
March 09, 2014, 03:25:12 PM
 #37

    This is a little project I've been working on for the last few days. I first came up with this idea here: PHP script to create private key & public address. It was hard to find a decent Elliptic Curve library for PHP but eventually I came across this on a blog: Elliptic Curve PHP-OOP DSA and Diffie-Hellman. The library only came with a set of NIST curves so I had to create a set of SEC curves using the parameters supplied in sec2_final.pdf.

Then to convert the keys into bitcoin addresses I basically followed the instructions on this page: Technical background of version 1 Bitcoin addresses. I found that many of these steps had already been coded in PHP: bitcoin-php - Bitcoin utility functions. I did a lot of testing with it and it seems to generate valid bitcoin addresses each time, I even sent coins to one of the addresses generated in PHP and it worked fine. However, I am far from an expert on cryptography so please check the code and let me know if you see any problems.

If you have time, take a look at the bitcoin.lib.php file and check the following functions for problems. The mini key functions aren't really used for anything at this point, I just coded them because it seemed like a good idea at the time.

getNewPrivKey()
getNewKeyPair()
getNewKeySet()
privKeyToAddress($privKey)
privKeyToWIF($privKey)
checkMiniKey($miniKey)
getNewMiniKey()
miniKeyToWIF($miniKey)
miniKeyToAddress($miniKey)

The other part of this script is the Bitcoin Payment Gateway. Instead of passing the transaction through to a 3rd party for processing, payments are verified simply by using blockexplorer to monitor the status of a payment to a specified address. There's no need to install bitcoind on your server, everything is done in pure PHP. This script essentially enables you to have your own Payment Notification System without the need for a middleman (except blockchain.info/blockexplorer.com), very safe imo, and another amazing feature of bitcoin. This is the description from my website:

Quote
The Bitcoin Shopping Cart Interface package is a set of libraries and tools that enable you to process bitcoin transactions with only PHP. You can have your own Instant Payment Notification system without the need for a middleman. If you've been wondering how to handle customer payment since MyBitcoin went down, look no further, because this is the safest solution.

An elliptic curve library written in PHP is used to achieve server side generation of FRESH bitcoin addresses for each customer. The script monitors the status of a payment by making use of the data supplied by blockexplorer.com. As such, there is no need to install a heavy duty service such as bitcoind on your server. The only limitation with this PHP package is that you can't make outgoing payments.

The SCI package comes with a simple example to give you an idea about how to generate new keys and initiate a new payment through the Bitcoin Payment Gateway. This is NOT full shopping cart software, you would typically use this script to offer Bitcoins as one method of payment. Some of the Bitcoin SCI scripts (in the 'sci' folder) need to be modified to work properly on your website.

Info: Bitcoin SCI: process bitcoin transactions with PHP

Download: Bitcoin SCI

Demo: BitShop Integration

I am testing this out now, this is great, smart move you made here, will fork around with it some more..
btcdrak
Legendary
*
Offline Offline

Activity: 1064


View Profile
September 26, 2014, 04:32:27 PM
 #38

    This is a little project I've been working on for the last few days. I first came up with this idea here: PHP script to create private key & public address. It was hard to find a decent Elliptic Curve library for PHP but eventually I came across this on a blog: Elliptic Curve PHP-OOP DSA and Diffie-Hellman. The library only came with a set of NIST curves so I had to create a set of SEC curves using the parameters supplied in sec2_final.pdf.

Then to convert the keys into bitcoin addresses I basically followed the instructions on this page: Technical background of version 1 Bitcoin addresses. I found that many of these steps had already been coded in PHP: bitcoin-php - Bitcoin utility functions. I did a lot of testing with it and it seems to generate valid bitcoin addresses each time, I even sent coins to one of the addresses generated in PHP and it worked fine. However, I am far from an expert on cryptography so please check the code and let me know if you see any problems.

If you have time, take a look at the bitcoin.lib.php file and check the following functions for problems. The mini key functions aren't really used for anything at this point, I just coded them because it seemed like a good idea at the time.

getNewPrivKey()
getNewKeyPair()
getNewKeySet()
privKeyToAddress($privKey)
privKeyToWIF($privKey)
checkMiniKey($miniKey)
getNewMiniKey()
miniKeyToWIF($miniKey)
miniKeyToAddress($miniKey)

The other part of this script is the Bitcoin Payment Gateway. Instead of passing the transaction through to a 3rd party for processing, payments are verified simply by using blockexplorer to monitor the status of a payment to a specified address. There's no need to install bitcoind on your server, everything is done in pure PHP. This script essentially enables you to have your own Payment Notification System without the need for a middleman (except blockchain.info/blockexplorer.com), very safe imo, and another amazing feature of bitcoin. This is the description from my website:

Quote
The Bitcoin Shopping Cart Interface package is a set of libraries and tools that enable you to process bitcoin transactions with only PHP. You can have your own Instant Payment Notification system without the need for a middleman. If you've been wondering how to handle customer payment since MyBitcoin went down, look no further, because this is the safest solution.

An elliptic curve library written in PHP is used to achieve server side generation of FRESH bitcoin addresses for each customer. The script monitors the status of a payment by making use of the data supplied by blockexplorer.com. As such, there is no need to install a heavy duty service such as bitcoind on your server. The only limitation with this PHP package is that you can't make outgoing payments.

The SCI package comes with a simple example to give you an idea about how to generate new keys and initiate a new payment through the Bitcoin Payment Gateway. This is NOT full shopping cart software, you would typically use this script to offer Bitcoins as one method of payment. Some of the Bitcoin SCI scripts (in the 'sci' folder) need to be modified to work properly on your website.

Info: Bitcoin SCI: process bitcoin transactions with PHP

Download: Bitcoin SCI

Demo: BitShop Integration

Is there any chance you could relicense the code as LGPL? As a library it should be LGPL rather than GPL or it reduces what can use it a lot.
TXWA
Full Member
***
Offline Offline

Activity: 168


View Profile
January 11, 2015, 03:33:58 PM
 #39

I always receive the error "*** Invalid Ciphertext ***" if I am trying to decrypt my private keys. This even happens when I am resetting the wif-keys file. Can you please tell me how to fix this?

Thanks!
btcdrak
Legendary
*
Offline Offline

Activity: 1064


View Profile
January 11, 2015, 06:58:43 PM
 #40

There is a pretty good PHP bitcoin library project here https://github.com/Bit-Wasp/bitcoin-lib-php/ which relies on https://github.com/mdanter/phpecc

The projects are also well maintained.
Pages: « 1 [2] 3 »  All
  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!