public function testsave_keys() { $network = "Testnet"; // mock the client library to return key array copy numbers from tool $private = $this->getMock('Bitpay\\PrivateKey'); $private->expects($this->any())->method('__toString')->will($this->returnValue('3a1cb093db55fc9cc6f2e1efc3938e4e498d8b2557a975249a49e2aec70ad471')); $public = $this->getMock('Bitpay\\PublicKey'); $public->expects($this->any())->method('__toString')->will($this->returnValue('03bb80b4391db1a7ba344fbe5421d87952a4b8934ca0865ae70591d1614e0f6fc8')); $sin = $this->getMock('Bitpay\\SinKey'); $sin->expects($this->any())->method('__toString')->will($this->returnValue('TfLG7rjKVMa9AFBaBKrS6ti8XM62yJA4D4c')); $token = $this->getMock('Bitpay\\TokenInterface'); $token->expects($this->any())->method('getFacade')->will($this->returnValue('pos')); save_keys($token, $network, $private, $public, $sin); }
function pair_and_get_token($pairing_code, $network) { try { list($private, $public, $sin) = generate_keys(); $client = create_client($network, $public, $private); $token = pairing($pairing_code, $client, $sin); save_keys($token, $network, $private, $public, $sin); } catch (\Exception $e) { debuglog('[Error] In Bitpay plugin, pair_and_get_token() function on line ' . $e->getLine() . ', with the error "' . $e->getMessage() . '" .'); throw $e; } }