P2P lending of real money secured with Bitcoin collateral. How it works?

Getting access to collateral through the console

If the aforementioned method of obtaining collateral through Electrum purse is not available to you, you can use the console.

This manual is based on Ubuntu 16.04.

To begin, you must first have an installed and fully synchronized Bitcoin Core purse. Page where you can download an up-to-date version of Bitcoin Core: https://bitcoin.org/ru/download

Note: Bitcoin Core network sync speed depends on the size of the blockchain and the speed of your Internet connection. It may take more than four days.

After installation and full synchronization of Bitcoin Core you will need:

  • Redeem Script;
  • Your Private key;
  • Biterest's Private key.
Note: Public key is not needed because it is used to access the collateral through Electrum purse only.

Key derivation and transformation

Before performing the procedure to obtain a collateral, you should convert keys to WIF format, because Bitcoin Core (in bitcoin-cli console) does not support HD key signatures(in BIP32 format).

You will need to perform key derivation beforehand. For the derivation we recommend to use a Web service from Bitcore: https://bitcore.io/playground/#/hdkeys

You need to perform the procedure for your key and market's key as per the Bitcore screenshot below:

Designations:

  1. Choose to use the livenet network;
  2. Enter your HD Private key (starts with xprv);
  3. Specify the path for derivation (m/0/0);
  4. The standard Private key will appear to you. You will need it in the next step.

Next, on the same Web page through the console, you must convert the keys generated in the form (4) to the WIF-format. To do this, execute the following commands:

>> var priv = new bitcore.PrivateKey('your standard Private key')
>> priv.toWIF()

Transaction creation

After performing the derivation you will have two Private keys: in the WIF format and the redeem script from multisig address.

To start the transaction creation you need to find the ID of the input transaction (1). You need to go to the site http://blockchain.info and search the multisig address. The transaction ID can be found on the page with transaction information.

Enter the console command:

bitcoin-cli getrawtransaction Input_transaction_ID 1

where Input transaction ID is the ID you got previously.

To sign the transaction you need to get Script Pub Key. It is located in the transaction information (1).

Now you can create a transaction.

bitcoin-cli createrawtransaction '[{"txid":"Input transaction ID","vout":0}]'  '{"Out address":Out amount}'

where:

  • Input transaction ID: the ID you got previously;
  • Out address: the address to which you want to withdraw BTC;
  • Out amount: the transaction amount minus commission fees.

You need to copy the resulting "raw" transaction (1).

Signing the transaction with the first key.

>> bitcoin-cli signrawtransaction 'Raw transaction' '[{"txid":"Input transaction ID","vout":0,"scriptPubKey":"Script_Pub_key","redeemScript":"Redeem_Script"}]' '["Private Key"]'

where:

  • Raw transaction: the output of the previous command;
  • Input transaction ID: the ID you got previously;
  • Script Pub Key: the Pubkey script you got previously;
  • Redeem Script: provided by the market;
  • Private Key: the common private key (non-HD), for example yours. The resulting transaction needs to be copied (1).

Signing the transaction with the second key.

Where:

  • Raw transaction: the output of the previous command;-
  • Input transaction ID: the ID you got previously;
  • Script Pub Key: the Pubkey script you got previously;
  • Redeem Script: provided by the market;
  • Private Key: the common private key, for example yours.
>> bitcoin-cli signrawtransaction 'Raw transaction' '[{"txid":"Input transaction ID","vout":0,"scriptPubKey":"Script_Pub_key","redeemScript":"Redeem_Script"}]' '["Private Key"]'

ATTENTION! Raw transaction is the result of the first signature. The resulting transaction needs to be copied (1). With each signature raw transaction size increases.

Transaction unloading

>> bitcoin-cli sendrawtransaction Raw_transaction

You have successfully created the transaction and signed it with two keys. The only thing remains is to unload it to the network.

ATTENTION! Raw transaction is taken from the last command.

As a result, you get the output transaction ID (1), which can be checked at blockchain.

Do you have a problem or a question?

If you have a technical problem or other questions, please contact Support.

We are in social media