Перейти к содержимому



Купить ссылку здесь
Фотография
- - - - -

Создание кошельков Blockchain Wallet API

Форум ZiSMO.biz
2
Сообщений в теме: 2

OFFLINE Отправлено

Елизавета Шевченко
группа пользователя

    Новичок

  • Cообщений: 69
  • Поинты: 1
  • Предупреждений: 0
  • Онлайн:4ч 54м
0
 

Создание кошельков для ваших пользователей путем программирования с возможностью внесения и обналичивания средств.

 

Simple API for Blockchain Wallet users to send and receive bitcoin payments.

The Blockchain Wallet API provides a simple interface Merchants can use to programmatically interact with their wallet.

Existing users, beginning January 1st 2016 you will need to complete a brief installation of a local service in order to continue using this API. Please follow the installation instructions below.

Installation

To use this API, you will need to run small local service which be responsible for managing your Blockchain Wallet. Your application interacts with this service locally via HTTP API calls. Click here for complete setup instructions.

Create Wallet API Create blockchain wallets programmatically

The create_wallet method can be used to create a new blockchain.info bitcoin wallet. It can be created containing a pre-generated private key or will otherwise generate a new private key. Please note, if a POST request is sent without "Content-Type: application/x-www-form-urlencoded" header, some endpoints may not work correctly.

URL: http://localhost:3000/api/v2/create
Method: POST or GET

  • $password The password for the new wallet. Must be at least 10 characters in length.
  • $api_code An API code with create wallets permission.
  • $priv A private key to add to the wallet (Wallet import format preferred). (Optional)
  • $label A label to set for the first address in the wallet. Alphanumeric only. (Optional)
  • $email An email to associate with the new wallet i.e. the email address of the user you are creating this wallet on behalf of. (Optional)

Please create an API code here including permissions to "Create Wallets".

RESPONSE: 200 OK, APPLICATION/JSON {
"guid": "4b8cd8e9-9480-44cc-b7f2-527e98ee3287",
"address": "12AaMuRnzw6vW6s2KPRAGeX53meTf8JbZS",
"label": "Main address"
}
Making Outgoing Payments

Send bitcoin from your wallet to another bitcoin address. All transactions include a 0.0001 BTC miners fee.

All bitcoin values are in Satoshi i.e. divide by 100000000 to get the amount in BTC. The Base URL for all requests: https://blockchain.i...merchant/$guid/$guid should be replaced with your Blockchain Wallet identifier (found on the login page).

http://localhost:300...$fee&note=$note

  • $main_password Your Main Blockchain Wallet password
  • $second_password Your second Blockchain Wallet password if double encryption is enabled.
  • $to Recipient Bitcoin Address.
  • $amount Amount to send in satoshi.
  • $from Send from a specific Bitcoin Address (Optional)
  • $fee Transaction fee value in satoshi (Must be greater than default fee) (Optional)
  • $note A public note to include with the transaction -- can only be attached when outputs are greater than 0.005 BTC. (Optional)
RESPONSE: { "message" : "Response Message" , "tx_hash": "Transaction Hash", "notice" : "Additional Message" }{ "message" : "Sent 0.1 BTC to 1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq" , "tx_hash" : "f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c" , "notice" : "Some funds are pending confirmation and cannot be spent yet (Value 0.001 BTC)" }
Send Many Transactions

Send a transaction to multiple recipients in the same transaction.

http://localhost:300...pients&fee=$fee

  • $main_password Your Main Blockchain wallet password
  • $second_password Your second Blockchain Wallet password if double encryption is enabled.
  • $recipients Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
  • $from Send from a specific Bitcoin Address (Optional)
  • $fee Transaction fee value in satoshi (Must be greater than default fee) (Optional)
  • $note A public note to include with the transaction -- can only be attached to transactions where all outputs are greater than 0.005 BTC.(Optional)
{
"1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
"12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
"1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}

The above example would send 1 BTC to 1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh, 15 BTC to 12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT and 2 BTC to 1dice6YgEVBf88erBFra9BHf6ZMoyvG88 in the same transaction.

RESPONSE: { "message" : "Response Message" , "tx_hash": "Transaction Hash" }{ "message" : "Sent To Multiple Recipients" , "tx_hash" : "f322d01ad784e5deeb25464a5781c3b20971c1863679ca506e702e3e33c18e9c" }
PHP Example

<?

$guid="GUID_HERE";
$firstpassword="PASSWORD_HERE";
$secondpassword="PASSWORD_HERE";
$amounta = "10000000";
$amountb = "400000";
$addressa = "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq";
$addressb = "1ExD2je6UNxL5oSu6iPUhn9Ta7UrN8bjBy";
$recipients = urlencode('{
"'
.$addressa.'": '.$amounta.',
"'
.$addressb.'": '.$amountb.'
}'
);

$json_url = "http://localhost:300...ts=$recipients";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed->message;
$txid = $json_feed->tx_hash;

?>

Fetching the wallet balance

Fetch the balance of a wallet. This should be used as an estimate only and will include unconfirmed transactions and possibly double spends.

http://localhost:300...=$main_password

RESPONSE: { "balance": Wallet Balance in Satoshi }{ "balance": 1000}
Listing Addresses

List all active addresses in a wallet. Also includes a 0 confirmation balance which should be used as an estimate only and will include unconfirmed transactions and possibly double spends.

http://localhost:300...=$main_password

  • $confirmations The minimum number of confirmations transactions must have before being included in balance of addresses (Optional)
RESPONSE: {
"addresses": [
{
"balance": 1400938800,
"address": "1Q1AtvCyKhtveGm3187mgNRh5YcukUWjQC",
"label": "SMS Deposits",
"total_received": 5954572400
},
{
"balance": 79434360,
"address": "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq",
"label": "My Wallet",
"total_received": 453300048335
},
{
"balance": 0,
"address": "17p49XUC2fw4Fn53WjZqYAm4APKqhNPEkY",
"total_received": 0
}
]
}
Getting the balance of an address

Retrieve the balance of a bitcoin address. Querying the balance of an address by label is depreciated.

http://localhost:300...=$confirmations

  • $main_password Your Main Blockchain wallet password
  • $address The bitcoin address to lookup
  • $confirmations Minimum number of confirmations required. 0 for unconfirmed.
RESPONSE: {"balance" : Balance in Satoshi ,"address": "Bitcoin Address", "total_received" : Total Satoshi Received}{"balance" : 50000000, "address" : "19r7jAbPDtfTKQ9VJpvDzFFxCjUJFKesVZ", "total_received" : 100000000}
Generating a new address

http://localhost:300...rd&label=$label

  • $main_password Your Main Blockchain wallet password
  • $second_password Your second Blockchain Wallet password if double encryption is enabled.
  • $label An optional label to attach to this address. It is recommended this is a human readable string e.g. "Order No : 1234". You May use this as a reference to check balance of an order (documented later)
RESPONSE: { "address" : "The Bitcoin Address Generated" , "label" : "The Address Label"}{ "address" : "18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy" , "label": "Order No : 1234" }
Http Callbacks Processing the callback sent from blockchain.info
HTTP callbacks are enabled in the notifications section of [Account Settings] in the web interface.

When a payment is received blockchain.info will notify the http URL specified in [Account Settings]. The parameters will be supplied in a http GET request. The callback url is limited to 255 characters in length.

Parameters
  • value The value of the payment received in satoshi (not including fees). Divide by 100000000 to get the value in BTC.
  • transaction_hash The transaction hash.
  • input_address The bitcoin address that received the transaction.
  • confirmations The number of confirmations of this transaction.
  • {Custom Parameters} Any parameters included in the callback URL will be past back to the callback URL in the notification.
Expected Response

In order to acknowledge successful processing of the callback the server should respond with the text "*ok*". If the server responds with anything else the callback will be resent again every new block (approximately every 10 minutes) up to 1000 times (1 week).

A notification will never be sent for the same transaction twice once acknowledged with *ok*. It is a good idea to record the transaction hash even if not needed to detect duplicates for logging purposes.

PHP Example

If the callback url provided is https://mystore.com

$transaction_hash = $_GET['transaction_hash'];
$value_in_btc = $_GET['value'] / 100000000;
$address = $_GET['address'];

//Commented out to test, uncomment when live
if ($_GET['test'] == true) {
return;
}

echo $address . ' received a payment of ' . $value_in_btc . ' transaction hash ' . $transaction_hash;

 

 

Callback Security

A secret parameter should be included in the callback URL. When the callback is received the secret parameter should be checked for validity.

Test notifications sent using the "Call the API" tool will include the parameter "test" with a value of "true". Callback processing scripts should always check for this testing flag.

Address Management
Archiving an address

To improve wallet performance addresses which have not been used recently should be moved to an archived state. They will still be held in the wallet but will no longer be included in the "list" or "list-transactions" calls.

For example if an invoice is generated for a user once that invoice is paid the address should be archived.

Or if a unique bitcoin address is generated for each user, users who have not logged in recently (~30 days) their addresses should be archived.

http://localhost:300...ddress=$address

  • $main_password Your Main Blockchain wallet password
  • $second_password Your second Blockchain Wallet password if double encryption is enabled.
  • $address The bitcoin address to archive
RESPONSE: {"archived" : "18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy"}
Unarchive an address

Unarchive an address. Will also restore consolidated addresses (see below).

http://localhost:300...ddress=$address

  • $main_password Your Main Blockchain wallet password
  • $second_password Your second Blockchain Wallet password if double encryption is enabled.
  • $address The bitcoin address to unarchive
RESPONSE: {"active" : "18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy"}
Consolidating Addresses

Queries to wallets with over 10 thousand addresses will become sluggish especially in the web interface. The auto_consolidate command will remove some inactive archived addresses from the wallet and insert them as forwarding addresses (see receive payments API). You will still receive callback notifications for these addresses however they will no longer be part of the main wallet and will be stored server side.

If generating a lot of addresses it is a recommended to call this method at least every 48 hours. A good value for days is 60 i.e. addresses which have not received transactions in the last 60 days will be consolidated.

http://localhost:300...word&days=$days

  • $main_password Your Main Blockchain wallet password
  • $second_password Your second Blockchain Wallet password if double encryption is enabled.
  • $days Addresses which have not received any transactions in at least this many days will be consolidated.
RESPONSE: { "consolidated" : ["18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy"]}
Common Error Responses {"error":"Error Decrypting Wallet"}{"error":"Error decoding private key for address x"}{"error":"Second password incorrect"}{"error":"You must provide an address and amount"}{"error":"Wallet Checksum did not validate. Serious error: Restore a backup if necessary."}{"error":"Two factor authentication currently not enabled in the Merchant API"}{"error":"Label must be between 0 & 255 characters"}{"error":"Error saving wallet"}{"error":"Wallets are currently restricted to 5000 transactions"}{"error":"Wallet identifier not found"}{"error":"Uknown method"}

Источник





    • 0
  • Наверх
  • Ответить

OFFLINE Отправлено

leonkiss
группа пользователя

    Новичок

  • Cообщений: 3
  • Поинты: 12
  • Предупреждений: 0
  • Онлайн:27м
0


    • 0
  • Наверх
  • Ответить

OFFLINE Отправлено

Ольга Белова
группа пользователя

    Новичок

  • Cообщений: 21
  • Поинты: 4
  • Предупреждений: 0
  • Онлайн:5ч 28м
1

Спасибо за видео 


    • 0
  • Наверх
  • Ответить



Напишите свое сообщение