M
M
MasterCopipaster2021-11-23 08:48:08
PHP
MasterCopipaster, 2021-11-23 08:48:08

Is there a PHP wrapper for working with a bitcoin wallet?

Hello, I'm wondering if there is a convenient API layer for php for managing a physical Bitcoin wallet?
Right now, I’ll clarify, I’m interested in managing the wallet that is installed on my PC, and not on some third-party site.
The features that the API should provide
1) View incoming transactions (including the addresses to which they come)
2) Read the comments of incoming transactions, if any
3) Get the balance of the wallet
4) Send transactions

I googled, of course, and found something similar to the truth Blockchain API library (PHP, v1) but gosh, I didn’t read their readme and couldn’t figure out if this is what I need, or is it a package for working with the REST API for blockchain.info.

Can anyone recommend a package that meets my requirements?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-11-23
@MasterCopipaster

yes, this is a cloud platform library
for working with bitcoin, an official wallet is enough (and if the tasks are a merchant, i.e. wallets whose balance you need to look at the newly created ones), then you can use the -prune=512 key, then the blockchain on the disk will take a few gigabytes ( now 5 seems), exactly the size of the UTXO base.
use the official https://developer.bitcoin.org/reference/rpc/
to quickly receive notifications of new blocks and transactions notify the keys of the bitcoin or zeromq daemon (most likely this is only necessary if you analyze the entire blockchain)
libraries are not required for this at all, maximum one curl send function like this:

spoiler
function wallet($method,$params=array(),$json=true)
{
  if(!is_array($params)) $params=array($params);
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'http://'.BITCOIN_USER.':'.BITCOIN_PASS.'@'.BITCOIN_IP.':BITCOIN_PORT');
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('jsonrpc'=>'1.0','id'=>'1','method'=>$method,'params'=>$params)));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
  $txs_str=curl_exec($ch);
  curl_close($ch);
  $result=$json?json_decode($txs_str):$txs_str;
  if(is_null($result))
  {
    die('FATAL: Invalid ip, login or password of bitcoin wallet?'.nl);
  }
  return $result;
}

подправь обработку ошибок и тебе больше ничего не понадобится

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question