Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Updating Electrum library and added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitwasp committed Feb 6, 2014
1 parent 6d7586c commit 6e3cf4f
Show file tree
Hide file tree
Showing 15 changed files with 669 additions and 252 deletions.
File renamed without changes.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,39 @@ This is experimental software, and has only been successfully tested using bitco
I feel there should be a simple utility which signs multisignature transactions using the information users are shown on the Sign Transaction page. This would ideally just require the 3 public keys (to generate the multisig address and redeemscript), raw transaction hex, and the inputs for the spending transaction in JSON, along with the private key. It could be a simple GUI application, or even a CLI app, since users are reduced to dealing with the console in the clients anyway..
Please let me know what clients this works with!

Libraries
===

BIP32 implementation library
Electrum implementation library
Bitcoin key processing library
Raw transaction crafting library for CodeIgniter


Licence
===
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>

Empty file modified application/controllers/index.html
100755 → 100644
Empty file.
17 changes: 3 additions & 14 deletions application/controllers/multisig2of2.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public function __construct()
*/
public function index()
{
$this->load->library('bitcoin/BitcoinLib'); // Load general bitcoin functions
$this->load->library('BitcoinLib'); // Load general bitcoin functions

// Do Form Validation
if($this->form_validation->run('submit_2public_keys') == TRUE){
if($this->form_validation->run('submit_2public_keys') == TRUE)
{
// Load the public key from POST
$data['pubkeys']['public_key1'] = $this->input->post('public_key1');
$data['pubkeys']['public_key2'] = $this->input->post('public_key2');
Expand Down Expand Up @@ -55,7 +56,6 @@ public function index()

public function pay2address()
{
$this->load->library('form_validation');
$data['address'] = $this->session->userdata('address');
if($data['address'] == NULL)
redirect('/');
Expand All @@ -67,12 +67,6 @@ public function pay2address()
$rawtransaction = $this->bitcoin->getrawtransaction($transaction_id);
$data['rawtransaction'] = $this->bitcoin->decoderawtransaction($rawtransaction);

// Load the script pubkey
foreach($data['rawtransaction']['vout'] as $vout => $output)
{
$value = $output['value'];
break;
}
// Generate the transaction
$extras = array('redeemScript' => $this->session->userdata('redeemScript'));
$this->transaction->add_input($transaction_id, $vout, $extras);
Expand All @@ -83,11 +77,6 @@ public function pay2address()
// Create, decode, and sign the new transaction
$data['newrawtransaction'] = $this->bitcoin->createrawtransaction($generated);
$data['decodenewtransaction'] = $this->bitcoin->decoderawtransaction($data['newrawtransaction']);
echo json_encode(array('scriptPubKey' => $data['decodenewtransaction']['vout'][0]['scriptPubKey']['hex'],
'redeemScript' => $this->session->userdata('redeemScript'),
'KeyID' => '0',
'address' => '15ZL6i899dDBXm8NoXwn7oup4J5yQJi1NH',
'signatures' => ''));
$data['json_input'] = json_encode($generated['inputs']);
$private_key = $this->session->userdata('privKey');
$data['signedtransaction'] = $this->bitcoin->signrawtransaction($data['newrawtransaction'], $generated['inputs'], array($private_key));
Expand Down
10 changes: 1 addition & 9 deletions application/controllers/multisig2of3.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()
*/
public function index()
{
$this->load->library('bitcoin/BitcoinLib'); // Load general bitcoin functions
$this->load->library('BitcoinLib'); // Load general bitcoin functions

// Do Form Validation
if($this->form_validation->run('submit_3public_keys') == TRUE)
Expand Down Expand Up @@ -57,7 +57,6 @@ public function index()

public function pay3address()
{
$this->load->library('form_validation');
$data['address'] = $this->session->userdata('address');
if($data['address'] == NULL)
redirect('/');
Expand All @@ -69,13 +68,6 @@ public function pay3address()
$rawtransaction = $this->bitcoin->getrawtransaction($transaction_id);
$data['rawtransaction'] = $this->bitcoin->decoderawtransaction($rawtransaction);

// Load the script pubkey
foreach($data['rawtransaction']['vout'] as $vout => $output)
{
$value = $output['value'];
break;
}

// Generate the transaction
$extras = array('redeemScript' => $this->session->userdata('redeemScript'));
$this->transaction->add_input($transaction_id, $vout, $extras);
Expand Down
21 changes: 0 additions & 21 deletions application/controllers/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,4 @@ public function index($address = NULL)
$this->load->view('welcome');
}

public function mpk(){
$this->load->library('bitcoin/BitcoinLib.php');
$this->load->library('electrum', array('magic_byte' => '00'));
$mpk[0] = '';
$mpk[1] = '';
$mpk[2] = '';
$iteration = 0;

$address = array();
foreach($mpk as $key => $mpk_hex){
$public_key = $this->electrum->public_key_from_mpk($mpk_hex,$iteration);
echo $public_key." ".BitcoinLib::public_key_to_address($public_key, '00')."<br />";
}
echo '<br />';
/*
for($i = 0; $i < 6; $i++){
$pubkey = $this->electrum->public_key_from_mpk($mpk[0],$i);
echo $pubkey."<Br />";
echo BitcoinLib::public_key_to_address($pubkey,'00').'<br /><br />';
}*/
}
};
Loading

0 comments on commit 6e3cf4f

Please sign in to comment.