aceat64 / easybitcoin-php Goto Github PK
View Code? Open in Web Editor NEWA simple class for making calls to Bitcoin's API using PHP. This is an old library, I suggest instead using https://github.com/denpamusic/php-bitcoinrpc
License: MIT License
A simple class for making calls to Bitcoin's API using PHP. This is an old library, I suggest instead using https://github.com/denpamusic/php-bitcoinrpc
License: MIT License
I'm using library for PHP https://github.com/aceat64/EasyBitcoin-PHP
I'm trying to unlock wallet using
`<?php
require 'func/ezbtc.php';
$bitcoin = new Bitcoin('admin','admin', 'localhost', '7788');
$bitcoin->walletpassphrase('PASSWORD', '30');
?>`
Instead of PASSWORD there is real password for wallet.
But when I try to send some bitcoins to another wallet it just not working.
No errors, nothing.
What's wrong?
EasyBitcoin-PHP should enable CURLOPT_FOLLOWLOCATION
only if ini_get( 'open_basedir' )
returns FALSE or an empty string.
Hi there,
Since Bitcoin 0.13.1 (segwit), the getblocktemplate()
method no longer returns anything.
I think this is due to the fact that you now need to specify a rule when calling getblocktemplate
. For example, if you call:
bitcoin-cli getblocktemplate
You get this error:
error code: -8
error message:
Support for 'segwit' rule requires explicit client support
To get it working, you have to pass a rule like this as an extra argument, like so:
bitcoin-cli getblocktemplate '{"rules":["segwit"]}'
Is there any way to pass this argument to the $bitcoin->getblocktemplate()
method to get it working again?
Hello this is my code
require_once('templates/easybitcoin.php');
$bitcoin = new Bitcoin('user','pw','localhost','8332');
$adress = $bitcoin->getnewaddress("myname");
But the $adress is null.
It wont create the adress but why?
And how can i create a adress and store it into a string?
Nvm
is it php 7 compatible?
Hi
To make this connection ====>
$bitcoin = new Bitcoin('username','password');
From where i get this username and password..Please guide me
// The ID should be unique for each call
$this->id++;
why do you need this?
if id is always 0, and not unique for each call, what will happen?
when I checked with some commands, it seemed fine.
sorry for my english.
Hi ..
i try want to build website with API service provider like
block.io
so i compile bitcoin-cli daemon in 1 vps. and created 1 vps more for backend using php
and i connected with your library
now i have a 25k address in my bitcoin wallet.dat .
and now i feel the proccess is slow .
what the best technical for this case ??
any help ?
sory for oot
$bitcoin->status returns me everytime a empty string "", but all rpc call work perfect!
What is the problem? How can i detect when I can't connect to RPC?
trying to get block 502284
$bitcoin->getblockhash('502284')
getting
(
[result] =>
[error] => Array
(
[code] => -1
[message] => JSON value is not an integer as expected
)
[id] => 1
Is possibile to know if connection is Ok without send a comand before?
hello dear i m trying to use easybitcoin to connect my bitcoind daemon to get wallet info and etc etc.
i m using bitcoin.conf file
server=1
daemon=1
rpcallowip=connecting server ip/0
rpcuser=username of mine
rpcpassword=password
rpcport=8333
listen=1
keypool=10000
prune=600
maxuploadtarget=20
maxconnections=16
walletnotify=/var/www/html/cron/receive.sh %s
and in easy bitcoin i m connecting like this
"; $info = $bitcoin->getinfo(); print_r($info); echo "it give me output
Empty server reply
what is wrong in my code please any one help me????
As stated here, this class does not supports scanobjects
https://bitcointalk.org/index.php?topic=5314073.20
https://bitcoincore.org/en/doc/0.18.0/rpc/blockchain/scantxoutset/
I'm running bitcoind with multiple wallets since they just added the support for it in their last release. However, I don't see any way to specify the .dat file for the wallet here. Is this possible? If so, how would I do this?
What do i need to install in my windows computer to use this script?
i want my website users to have their wallet on my website. So they can send and receive bitcoins into the wallet
Looking at the code here ...
What site are you calling the username/password for ? What is this connected too.
thanks, great work too!
How can i use named parameters instead of positional parameters? or do i need to rewrite something to make it happen ?
I know this isn't an issue but I wanted to find a contact but couldn't find one so I left a message here. Thank you for creating this. I created a website that uses a different type of cryptocurrency but works just as well. This made things so much easier and https still works as of 2019! Thanks again and it's so simple and elegant!
Cheers~
patrikpatrik
To solve that error
{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":1}
it's required to comment out line 120:
CURLOPT_FOLLOWLOCATION => true,
[Posted the below in stackoverflow as well]
Link: Here
I am creating a php script to use the sendmany() call to bitcoind. After some database calisthenics involving hitting three tables for permissions, checking user privileges and ensuring the send amounts are correct and there are enough bitcoins on the server, I wind up with the following array to send bitcoins to:
Array
(
[0] => Array
(
[coinadd] => mteCLqiEK7v5d3YbDQtxj8oKcdhtHRtXcw
[amount] => 0.21445033
)
[1] => Array
(
[coinadd] => 2N5aa9FBxGf5xmeLiDz1yJVNYdsfK9GUWWe
[amount] => 0.02588679
)
[2] => Array
(
[coinadd] => 2Muf4WEzFqNviURTdvkGSswHyrgMzR8optK
[amount] => 0.02601681
)
)
$max = count($paynow);
$b=1;
$amount = 0;
$emit = '{"';
foreach($paynow as $key => $val){
foreach($val as $k => $v){
$emit .= "$v";
if($b <= $max){
if($k == 'coinadd'){
$emit .= '":';
} elseif($k == 'amount') {
$amnt = $amount += $v;
if($b !== $max){
$emit .= ', "';
}
}
}
}
$b++;
}
$emit .= "}";
The above foreach takes the $paytoo array and generates the following json string:
{
"mteCLqiEK7v5d3YbDQtxj8oKcdhtHRtXcw":0.21445033, "2N5aa9FBxGf5xmeLiDz1yJVNYdsfK9GUWWe":0.02588679, "2Muf4WEzFqNviURTdvkGSswHyrgMzR8optK":0.02601681
}
This string passes the JSON lint test on jsonlint.com
I then decode the string to create an array.
$send = json_decode($emit,true);
Array
(
[mteCLqiEK7v5d3YbDQtxj8oKcdhtHRtXcw] => 0.21445033
[2N5aa9FBxGf5xmeLiDz1yJVNYdsfK9GUWWe] => 0.02588679
[2Muf4WEzFqNviURTdvkGSswHyrgMzR8optK] => 0.02601681
)
So far so good.
Now on to the RPC call
$sent = $bitcoin->sendmany( "", $send, 1, "", "", 1, 1, "CONSERVATIVE" );
$err = $bitcoin->error;
Aaaand Kablooie! I get the following error from Bitcoind:
"JSON value is not an array as expected"
If I turn the JSON string into an object, then the error switches to
"JSON value is not an object as expected".
From a comment in Github Here
This snippet of code is from the library's __call method in easybitcoin.php
// If no parameters are passed, this will be an empty array
$params = array_values($params);
// Build the request, it's ok that params might have any empty array
$request = json_encode(array(
'method' => $method,
'params' => $params,
'id' => $this->id
));So depending on the parameters of the RPC command the general format will be the following.
$myVar->nameofRPCcommand(...);
For example a command that takes two strings will be
$myVar->nameofRPCcommand($myStr1, $myStr2);
Or with a string followed by an array
$myVar->nameofRPCcommand($myStr, $myArr);
Other than slitting my wrists and offering my blood to the programming gods, I've done everything I can think of. Can anyone spot what I am doing wrong here?
I have been trying for days, and I cannot seem to understand why the EasyBitcoin.php will not accept my parameters for locking unspent transactions using the rpc calls. Here is the code I am using;
$tx = $bitcoin->masternode('outputs');
$txid = array_keys($tx);
$tx_array = [];
foreach($txid as $locktx) {
$tx_array = [
'txid' => $locktx,
'vout' => (int)$tx[$locktx],
];
$lock = "false";
$lock_mn = $bitcoin->lockunspent($lock, $tx_array);
}
And no matter how I spin it, I keep getting errors like this:
Expected type bool, got string
Has anyone had any success with this rpc command?
python main.py -c ../.bitcoin/
Traceback (most recent call last):
File "main.py", line 11, in
from gevent import monkey
ImportError: No module named gevent
On ubuntu server, I've tried a few different ways, and every time I get the following:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I can do a getinfo from command line successfully.
Any ideas?
Hello,
your library is very useful for me. I need some suggestion:
How can I pass parameters ?
I'm using this:
$params = array("I" => "SI");
$bitcoin->method($params);
Is that correct?
I realize this isn't an issue, but I thought I might be able to get the best advice here.
I've written a script that makes RPC calls using EasyBitcoin-PHP. When I run this script directly everything works fine.
However, I'd like to run this script as a daemon using systemd. When I start the daemon using systemctl start myscript
, I see the following error:
error: Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (/.bitc...
I think this may be because the script is being executed as root, and so it can't find the location of ~/bitcoin/bitcoin.conf correctly.
What would be the best way to get around this?
possible to not use an array for params so it send params: {} instead of params:[]
i tried to run a command that has the following structure bitcode-cli getaddressdeltas '{"addresses": ["Bh22SsBJyeAJY3vmc8EEd12HWMtM85c7C0"]}'
using the EasyBitcoin-PHP script but it returns NULL. How can i modify the code to accept the command?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.