bit-wasp / bitcoin-lib-php Goto Github PK
View Code? Open in Web Editor NEWPHP libraries implementing bitcoin key functions, as well as BIP32 and electrum.
License: The Unlicense
PHP libraries implementing bitcoin key functions, as well as BIP32 and electrum.
License: The Unlicense
I know it was because of a fix for a side channel attack or something like that and that that's something important but the difference is kinda big ...
below isn't a proper benchmark, but just to compare a simple test that does some signing and verifying.
is there anything we can do to optimize this?
or is the only way for that to move away from a pure PHP implementation?
1.0 branch
$ phpunit tests/SignVerifyMessageTest.php
Time: 5.76 seconds, Memory: 4.25Mb
$ hhvmunit tests/SignVerifyMessageTest.php
Time: 4.72 seconds, Memory 7.50Mb
master
$ phpunit tests/SignVerifyMessageTest.php
Time: 30.29 seconds, Memory: 4.25Mb
$ hhvmunit tests/SignVerifyMessageTest.php
Time: 15.61 seconds, Memory 7.59Mb
PS. hhvm different on 1.0 branch is relatively small because it has more bootstrap time than PHP
The PHPECC project has been abandoned for years, despite numerous attempts to fix security issues in the code. Paragon Initiative Enterprises has opted to fork PHPECC in order to provide a more secure implementation of ECDH and ECDSA for PHP projects.
Please refer to the Release Notes for our fork, which contains the specifics about the security issues we fixed and how to ensure your code is safe.
Fatal error: Call to undefined method BitWasp\BitcoinLib\BitcoinLib::dhash_string() in bitwasp/bitcoin-lib/src/BitcoinLib.php on line 372
What is this supposed to be?
I wonder if this lib can support it as well. If you already support it, please give me an example, thanks !
https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/RawTransaction.php#L1285
This hardcoded OP_PUSHDATA1 will cause problems with BIP62, which addresses malleability in a number of ways, including checking if the length of the datadata's could be represented in fewer bytes.
For example, 2-of-3 is only about 0x69 bytes, hence does not require any special PUSHDATA opcodes. The scripts produced are valid, but are relying on the same behavior that actually causes malleability, and may soon be invalidated.
We have some time on this one as BIP62 is delayed, I'll have a look at this soon.
Hi,
I'm trying to create a PoC with your library, but I struggled for few days.
Well, I want to create multisig address derived from BIP32, so I use scripts you showed in examples/ folder :
You can check the full code there https://gist.github.com/dizda/15c3672d0df4b0d30f88
I wasn't sure about the way to transform private keys to WIF format ( https://gist.github.com/dizda/15c3672d0df4b0d30f88#file-bip32-php-L66 )
I've tested a lot of stuff, so am I miss something, or maybe there is a bug when we try to use BIP32 + multisig ?
FYI, the script return:
I appreciate any help,
Cheers
How i can get the message that sign the transaction? to verify it.
Hi,
is it possible to create other coins address with seed with bip39 in this library
like trx and eth
How i can list unspent transaction for any private key of address.
is there any idea.
In block
} else if ($code <= 78) {
// In this range, 2^($code-76) is the number of bytes to take for the *next* number onto the stack.
$szsz = 2 ^ ($code - 76); // decimal number of bytes.
$sz = hexdec(substr($script, $pos, ($szsz * 2))); // decimal number of bytes to load and push.
$pos += $szsz;
$push = substr($script, $pos, ($pos + $sz * 2)); // Load the data starting from the new position.
$pos += $sz * 2;
}
$szsz = 2 ^ ($code - 76); ^ is not function as pow, this is binary operation, nead use function pow
write code
$szsz = pow(2, ($code - 76));
and
$pos += $szsz; wrong set new position
nead
$pos += $szsz *2;
Would you mind if I refactor the code to autoloading standards (PSR-4) so it becomes compatible with most modern PHP libraries? It can then get added to Composer/Packagist and be available for wide deployment. manually including/requiring files is pretty outdated.
refs:
http://www.php-fig.org/psr/psr-4/
https://getcomposer.org/
https://packagist.org/
I have my private key and public key.
how i can use this library to create transaction and push it with my nodes..
Regards,
Parse error: syntax error, unexpected '[', expecting ')' in /..../mpk/tests/BIP32Test.php on line 39
how to use electrum using that liabrary is not clear.how to run this laibrary.Descrie usage of that liabrary anyone for electrum
Is there any way to know this errore
I test the first transaction it works, then i create another one based in the last previous transaction hash.
it not works and get this error.
Can any one help in that?
Hello,
I've been experimenting with getting the WIF encoding of a BIP32 extended private key, so I can import it into the bitcoind wallet using the "importprivkey" command (while using the Bitcoin testnet).
I simplified the existing test_bip32.php script, and had it emit the address and WIF of the master private key using BitcoinLib::private_key_to_WIF():
<?php
require_once(dirname(__FILE__).'/../BitcoinLib.php');
require_once(dirname(__FILE__).'/..//BIP32.php');
$master = BIP32::master_key('fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542', 'bitcoin', true);
echo "Chain m\n";
echo " ext priv:\n ".$master[0]."\n";
$public = BIP32::extended_private_to_public($master);
echo " ext pub:\n ".$public[0]."\n";
echo " address (priv):\n ".BIP32::key_to_address($master[0])."\n";
echo " address (pub):\n ".BIP32::key_to_address($public[0])."\n";
echo " ext wif:\n ".BitcoinLib::private_key_to_WIF(BIP32::import($master[0])['key'], '6f')."\n";
Running the script prints:
Chain m
ext priv:
tprv8ZgxMBicQKsPdqC56nGKYsarqYsgrSm33vCswnuMLFCk3gP7DFW5nPFExzSe7FGAzkbAFrxtXoQEe8vaX471tU3dsUUC7PNpYLGuzb2agmj
ext pub:
tpubD6NzVbkrYhZ4XJDrzRvuxHEyQaPd1mwwdDofEJwekX18tAdsqeKfxss79AJzg1431FybXg5rfpTrJF4iAhyR7RubberdzEQXiRmXGADH2eA
address (priv):
mxkmFi1a9MhPPcKGWqHnY6A8NayFMKSKvr
address (pub):
mxkmFi1a9MhPPcKGWqHnY6A8NayFMKSKvr
ext wif:
929xKZ1UYiiw7iHXQeWL9PVA6YDRkesRnMjaMxL3FkMR4M7Lr3h
I then tried importing the private key using bitcoind's "importprivkey" command:
$ bitcoind -testnet importprivkey 929xKZ1UYiiw7iHXQeWL9PVA6YDRkesRnMjaMxL3FkMR4M7Lr3h 20140512 true
It appeared to complete okay, with somewhat of a delay due to the rescan.
Then I tried to dump that imported key using the "dumpprivkey" command, but it gave an error like below:
$ bitcoind -testnet dumpprivkey mxkmFi1a9MhPPcKGWqHnY6A8NayFMKSKvr
error: {"code":-4,"message":"Private key for address mxkmFi1a9MhPPcKGWqHnY6A8NayFMKSKvr is not known"}
I'm new to Bitcoin and this library, so I'm not sure if this is a bug, or if it's just me generating the address or WIF incorrectly.
If this isn't a bug, would it be possible to provide some sample code showing how to get the address and WIF properly?
This was with commit 9eab00f, under OS X 10.9.2, with bitcoind v0.9.99.0-b733288-beta (built from source).
Thanks!
Dear All,
Anyone can do this job, I can hire him.
I need this library working to my Altcoin,
I can give you my source code,
I am willing to pay 1 BTC, when that works,
Regards,
this project is vulnerable to this problem?
https://bitcointalk.org/index.php?topic=977070.0
$hex = "0100000001552eed137888e6a6c2c69ded505d9e573c3d78ab0f478ecbdaf74b99b40f350d010000006b483045022100d958e320b5bbc700e7862b7832fc86d18f50be7a272399c38b35a6aecd471d68022014a02f0387a0971c4e06cac086d662615a3e07a0323e1f138d96c54c7f6aaead012102af6034f808ee5989a7ea0304cc7d464edb22a86d362739aeb4e52e759436b7f5ffffffff0240480801000000001976a91415df9c5643a3ef61ee05a92a7703f47a4ffbbcdb88ac8b0361695e0000001976a91490967f997eda3a1c0bd4358b3cd19824e46538b688ac00000000";
RawTransaction::decode($hex, '6f', 'c4');
decoding works fine if i comment out the throw
The RawTransaction::decode
function works for almost every transaction, but it doesn't seem to be read the vout
for this transaction.
TXID:
54bbfc96996328578a1617fe7642d2a4d64a3cb373fa9af086e5242fab5a145e
Raw Transaction Data:
010000002517f6a08b306e052502c0a368f8e922bb26695ce1f60732d3cffa4e0def032160000000006b4830450221008330651d4af55b632adad4be63f45228eb68447252046ceceacd40aa41f459800220696467edc565a7779ea4f5f9def585bdcdc8e1d9f7e88de5d35f26274e2c38fb0121039f9d13867a2071f3d90d00b1385cc192764d0c30965e5e48576b9589901ac070ffffffff3bdb51fb949e3ea4dd394db8b1e2413e24a3d4b03d348e961c385330a597155c010000006b483045022037c53fe3d0b39769a358910cd8fbc14ccd5a32ff0c1b297b78803ea405803e3e022100afedb753906df597a63d29db8bb050e8eeef668b4cb1b3452baab47042f06c55012102fcffafac2cb3494565f15841036757b0f857abeb8b1363e345779e037ad86146ffffffff1d1a19198da4c3adacf86938b452e9f2d6390418960e086e27768be50cd6937d000000008a4730440220128ba33e187194306fe5df48166401a43696d8386400a7afb2a80b3a4aec09fb02206d97b598cc729bfc58b2e98ad60b16da1ff436570a45fda50de4cc1080d1c24a01410451de83274ce471f83a70de99688700b9d5ab0af61444d2c6721a76a03e255e254b4d31baac418aa87ed3c5a98e5962bf79512eea35186715ad8f468407143b09ffffffffa3c4806c28bda643ba4ac313d4be0f9d2c4a866bee4eeac98df3a276eb13d8a2000000006c493046022100d64662a938c69155b3d7fc8f0c4aee3236d5cbbfad9fadb66e2ca9f7b49a54e9022100a312c83c2ee8c0183f111af3e45300ec6abc3dc411f3bc51113f6a0bf33ac8aa01210354a3a83a884e90c214cb4b9529ff4d0d0829d751b6ca8446beda1a7d0b16731effffffff1a50052257406d00737bc0001455dad29de1180a4b4788de5348988edb6ad9bf000000006c493046022100f439846181579c226a528c129d152562f746f2c4620dccbf13309924b8891a1c022100c30ba3428dc7da613c022c021a76ba864aabae9e6a890019856a4396667740ab012103120061a53f20e412d9a56efd353e99e33ba7d646004496afa54996c7d402406affffffff683befea423a6d32c9c7da7b7ece84c7aaaa5eb8f7e797a752a2e81e4c4390fd010000008a4730440220569457e5897a4d9f3473f277f821b04b0508b703895003edd45f4b45e445d64a0220379423a8a0845a2a6eb4b2aaaa5956c7224363cd108cb07319ab911d7f5a7e8501410446217dd51e03af8791ec5dba4d2906f43840d00d01b9946de2546c1a6afaadcbc514879661ae0a0f3fd0cb831de0c27425a4a8b7f49710d01dbabd2ea661f8a9ffffffff3af8cb8239126deeb0a70ec9c89930940f6e1db09593e859f8fea480fc21a7c0010000006b483045022100d82a8ed5b7a5adf152a85cecc76051d26b73da19ac8ad5c54ff77b546843a5ae022071a2edff3b80597de15ce4ad4e673eb2827f6af5dc498ebfa52debb96ed0028f012102395dccfbd1f7fad6998538ce808a3fc80cb9fc2d6f86b254ebbc2af8c3189079ffffffffd6d05cac22487ddc63fa361c998fff5e48f6fe54504f39db3f650092ef8bb9fc000000006a4730440220262823164a9855317ec291323ef672a59210f26e1c6543dcc6faa51e89be2a750220019c243d5ecfea9950b2550079b2dc73d92c237c9d4e2af541e704715132fa96012102f047bb510c212c6542f3a413a6065e1e734fc376f88555cd674ea21a802bc094ffffffff21a4f0dc066745a1f77ff3e0156e99e63c18875000df926d91c32b933b21f237000000008a47304402206fa058beca6b5b59abe2646b7710a2a25b0287ae205068add7c6a93d1d43f0280220663707ccfbfc8873f904b376106e6b24cbafb742a927a2855ecfa275b9b799ab01410430a2e01923be91dac058e4baceea06a5ba96c601fa52ecb2d7c5d089a36d99b403104701e3dc22e620c9563f4455326d8e8b7b62bf7dc8aa775512a522f7e90affffffff8397db5ff8e6973c6d08b0c8bac1013614b48199d1aa1016cb57ce68019b252b000000008b483045022026a703bbc446e0bfaad33dda82bd0ace5190adbbb79e317ba62f2f71139d8bca022100f3fab4480ab83de0c229f8403549035a399735c91dee0be4fb04922bdaeb3bea01410407bdde4dc34aff3daca7a3e7e98551fb64ff443355941990219f01ece841214b73dda16055a30986c9edfca17da7546bbce2b63219516c01dc1f25f61bd9df36ffffffff0e4e074728236acf1f3c0e6174143d60c09252dedb5fecb0e87734dd152bcf70000000006b48304502207afaa77d29fb51642a9d72ac8aa681917699612f0a3185d14ae382998a563b3c022100907509951ed1ae3fd5fba0e398ef7cc933ad5e11d516fe835cad98793d2359f0012103ed079150248f74210f43359a424c28aba617e96ef950fe24f522e0e9e3349618ffffffffe30ac821b47bd95f641d476dd38b8a372a9e6f37ac78cf8ebdff4d1f5aff0916000000006a47304402201b2e4c7a9c8e6bfd3b2f2cb1b4995f3dabca1e91faec1c171940570eb4ba364102206f94dff28ab31ec65aadabca7d7c710d6f0d6d4ad325a69547386a76a02a6363012102dd0ae2b35804c72ed0f6e1244eb81d4982f5f946ae6c058d72edfc67b0410f30ffffffffd2bc614391d79861cd36c150db96b3d63fabcfb025e76eacf396acf9e505c16f000000006a473044022044d59e4199a12ddb0423517e5b546b1ba7c87baaa9fd1799a9c01f74476cda4702207bec9e5c64dc40193c7fd71f62008f3e500bde7d830701aff310e7bb157b288c0121037cfe7724bc1ab30061b2624e3618aab8bff1fc70a02880526057fc74d6fc49b6ffffffff4372f4eb4c67da16dbaadaf1076ed68a2277b1cc4086e388e5628545860d41b9000000006b483045022100e1268ffcb6c8a29510262b3f814a3b4ad6e2bff2d636a86ebee46de7aa6bfc4002203900b77eef0bd00ac28e96b4908e80d00a38d887e9a4453d9558fed1e70b8d6c012103694b201eae72e12290ddcf19c034d634bf6d8564d5fabbd0a691982cd90490c6ffffffff56c9d5696a21b05d7986d69e0c84dfa3ec375b52a0d7ef64b019cddd66b24996000000006c4930460221008c5159a8faeb58db2c923552f212e661313263a5c46ea50a265f89a9a522bf820221008a6b4b48a99acca0dc4e94eecb9bc1a6e6f9311938d935f9433d1d5445565f9c0121030252aa037db753e45ee71e9369f9a788cf2eae054e5c75416895dc9957bd815fffffffff0f3e0d1b4fe0630ba01feba46a9a5ae6d6d8e8b57bf870802e42df169413646c010000006a47304402207aae319cf9e18668a016300b6e90645a30b34fd8a879eedaa9a32b43e44db5d402202966d1334d9e85ded13a625f84ebf9d37ce9980c2d06875426acfa1e6c5ea9d901210373578c49c3945d8b687937af189f6058183ac99ecc6f70316b2bd4d30b9a3f96fffffffff07c7ebb7052b6c1c4abf5eabdda56b48c172ab82d73fc7a0babf7ed3519c70e010000006c493046022100a060739cb9da5f7fefdfc6c570f6b22952faf72b45ba00ca6998d711543478d9022100dff478b7d76085e166b44ea72a1c8cd2db4415c19d40d2133464ade1a629af7e012103743e5a8a8b3388c1a11165a7c28e5243bdaebfa380b893a44faaee3c0bb3c56affffffff00ad7c9a03472a62a21cd8a341cb3d3c0daea71806ec64733c4248b1178ba445000000006b48304502207dec28c2148b70e9ec807281a23c5dcae25a1b6989fe84b0e714e11248d99165022100d6ebe6a00508868913f1f2758495bda4b77bf7ca7f7eb1fd8d079f4f61d273b0012102d0e38e4847dc3cfd76b5205e2a361f1493ad21219b617e7114ae6db0cd7b6525ffffffff6bbe809162565056f85776763b9bda0d7b28c1e6c2c64702b68196331743a243000000006b4830450220675d8b3920aa8045a7c75c8a29334c3b70bada5aa3ca98eb6cc2bb97eccfa030022100df365ede37f208c663bb0b818aa93ab348556fd143b8c35fe0ba698db8b2ca96012103e75a15fcbbacb79d0705654a14b787168ec5d3f5ddd1f007c2108dbc582a8144ffffffff252778f0c2befa0ce65fc703656237a995d992b82529a017e2118360d6ac3abd010000006b48304502202bb9a871578b80aa6eea606f2d0f306dc400300662df61792c02927e9409e5d4022100b5c009c79dea1c1f162d6e9ba0f913c9c447f497eddc6367d931d866c1993ed701210360088e7df0fe9744fa708cf631dadb51616054a886d75d0893e10175adf5cb35ffffffff83a35f5de7f1d3894786e13c57e0cee3e52e00c6d0384bb67a8cfa434534bc90000000006b483045022100abca773d0e60243f2388f6ac48a2b0830ec842af56030726bc6f11045e791c42022010743b718e2172e45b0ac83cbd7c8c3c268fbbbd7f5d9ba17be6c577e5b0a6b0012102d58135da77e54604bbfd01729e60e5405a0070cbed6b979435ba164940d0ffc1ffffffffd999794b56b61029e4a4b9033ccf11424dfbee3467baae57f6f48e4e551e92cd010000008b483045022100dfec4c450067e907e4d6c0f29479e13b07eeca40176ee811c3e7aebaa4cbea78022051d458bf7d8699508a9f35c1f538c8fe5264ca255485dc9e5644b6affba90f7301410458fa61860e956860468f4353d2b2a9d9944b651986da2b1e207715595d567a60520e524ec8f384b659c524aa4a5247a703d5ac27c1c3b7f1a1392058f7ae435effffffff0af87fb4576870138c746e17f5c5ab71a443c54d730ec1f3d84caa69d2e1135c000000006b483045022100c41f6535f99935fbfa9495209907a90bcba8baedeb04b62276ea65d3df7aa572022052c153c8e5762fb7d9ff0f8c639b7d7c5e05be31dccbfdb3f23f27e73603307d012103026443604b26a3e6118f0eacdcbf9b783c6b35955aa1c4436bdcf51905cb58b5ffffffffef2a308999f8f0f871b0e5b84af5e3155365c48dbe26b5638ad1498615f6a6a5010000006a4730440220758eef701004d265a78963eb32eaba5d56f504feccda5b3b9ba7e6389144a87a02206c40dbe8f8f53c4f1bca24a62f015ce6d0afddb3b33da4a569c00e60c4accfba012103457f47babe657b9512661a8685051eb8524c08aa4a86a583483b80c06628a26dfffffffff0eb14ef95a2fe4a980687da94b635d689be2c620e3585fc7cf05235ba7c82df010000006c4930460221008315fa79f15c8c3f597a663261baf469003636cb6ca77f52c77f2f6d4e62c5dc022100d55dcfdd97ba20d9ed5280b47361f5ef089f97ec76999f186651a6d057adc0bf012103f94800cdc3a143e15d9e61aef7bb0053a82ccd3e8b78a76e79634a90cf6707e0ffffffffdac89205ab608955825312319554580fb15ad66558a121fce3bb4d27fa405165010000006b483045022027ca3e04869357ba075db07e8e6d400817683be0acc2d8a0278f5ecf609da86e022100e41299c046b9315b8bee9f070110d070fbfefc439ba0f7ad3766f68b0b8922b3012103483c0e962c743e8eb89b252a0af03b31162115d56a9e8010ca5e0465eda83958fffffffffc70e9016a059463b262a43310033e891900e809afd994d82e9e618080ce201f010000006a47304402202c5e2badf3c890c16a43852c0840afe54c55f61706fcfaacdfbc920a4762cafb0220757f50eb80cfb0f928aca360a3a876832f87aec028b0559f29669780f59110f7012102a2f029560433a73cbe6a0614edb7a4d9cd42ff252e7c621425c57d2dc6cedf19ffffffff739c76d2cfd5d542da93b897fc9e85b04156e0d06eff2c5092c75eccdd607ffe000000006b483045022014c20b0394c76e36b95b3ff10de57c8ba90de8ae073782202ecdb73d281cdb7f022100fb3cc6285dd2e4cf299fae22c3740e3f9829e69429ce92848200133c988381a901210244cb96c6878c6c617ebca08e7bdcb5507ca7e83f8f64bfa4e8542c02e5828afaffffffff106ad19eefa49ec472c8ceebe960e4c04e3579ceaf5113b9d49e0694dac65c0c010000006a4730440220367f63d41fc29c0d806aa86df4f74dab161db356cf118787dd404bf91d08317b02203ecdacf7f0cc17c1256a42fd3ec82e572c487298b7d6ce557d15201519d2147c0121024d5adc05c1b5fbcf962e16085906fded83f069579ebf33ae96d34bde55ba9bd1ffffffffb1d5c8ccc27d8ccb1eb32dec38dff486db58d55e0dab5154e44ac4099834d9b6000000006b48304502202b7adbf7798df05707197b2aedb2200d62c4bb252b2696bea213edc78d2de9a7022100f27e4d8de0854b155a61845a4b9d4b3f398c553bd91f9394d12710386df3076c01210240d59ce2e53ae4bd9de3082e51cfe24342aaa5976ab8710b4a7d8b3ca737251cffffffff476b2fe3e8bbec292e5d0f98d591ea6a777523f4e6dfa1c1cf22cada8deae122010000006b483045022066a71161089c96d75fed907cdf75cce4ca98c50b2ebe6c56e54d8b4bbcd0267f0221009efb58d4b04472bc10975a6f60bbf3d8d503e14f6dcff5192b17f24d981ea463012102321fb21f34f1e1ad333d28f6cfb1e0f630e0e716f6edb2669f4ee445468b6439ffffffff3c54e0b0ca84757bc8c6a3a2325ae6bc0d36c6641e67f272b5c4a684d14def08000000008b483045022026dd833ba1dca09b2bfd250684e62b4a8a2bcd87ddf0d7f72784976baeb657b0022100cb58f298ecfb46318aaa865de091f25d23c62106478b5d62f2e88b661ec64678014104d31fc3a7137d961775fea0d69d10a5f19ce705839092c77c2e96e704918dfe496d2d02507f2e3d3f2e63badb95b3a82f07290f764a0d891290e7ade9d906f08fffffffff5f5f1ba68cb174bde44e9a980c1853152ed4796036b2e285710479ccb42edc51010000008c4930460221009df2af2dc9e804ee3d9165e67fd02b6c18a0561ea461f8542f71ae2ead2ed2ed022100c0bc24f2e88ef93cd6a271f3a6493dc86cd75ad098fcc9475369f7ee177887b10141047c8a2a881f7be338b0f0f232ca645b6bb7bf9944727d95ce72048d2370aa742465cceffbe86101c195c8364967885c6f603d11a0eaa972864ac0773ff2b10825ffffffff023cd4ab7e9c7aebae09abac93565cce40bf6b34d03ef878256d46cec772afc5010000006b483045022024f715b0f538a743238fae0db383311ab308b605ff967909dc0dc7581b628f99022100e05354d8295e5353baf42e7a4c0e4b339ecc1c88b9624d7b3c9be889f8def1b80121027892ec4eb9c8ddfa7465f244a8cd5f31b6f9cf7730d061f06926f6c733a58e8effffffff56e2e7b06316a5c8755ae09573c66363b4c2634241d93de3cf321c1c08c46789010000006a4730440220607171bdf81a7b59a04511ab95cfe51a1672d927f83e8c37ff1012891c8c9a990220768a54057e0ee64c6ae95769d41e861c49ce9b3aebf38ba4582f627a415c5886012103a2a6e3770e8b8035bc09e0ef611e1bb41e0fa54403d88ea25308d3f8ac499daaffffffff86ae2246b8f8f3b33dcb9d8dc2b0a9b5e084473e94b4d01d9bc58a9c9cbe7d23000000006b48304502205397f969bdb9fc0ea57e9a53620cadf36543bbf6beafcb4185579d77a0362cb60221008f271266fafa4206935c360f66e7e3a2ad6c130d0afb71e72f1dcde82d4c0d720121026a39d80b09e32b55e921845b90a15ed48165a14bdde39ed7f5953b0c134ef838ffffffffe0256c13fcb7c09de05a2b48677643a9f10e6174b094c2f2c7d65763d38dd32c000000008a473044022028908ed5a30971d34f04694faebe9f6bccf4bf3fdfc472605a8498dda3a4e6590220227c9af82f663b804cd7f2107ba3670766ae90ef3adb66cb766dc6901c51a2c0014104c2ca92f5ef8d25d8e0f673b754153b206d67e7f0017691ef256b3140171cc2dd92b4e535299b74aa7cf69c9deccdd470a22332867dfd9f8dc67e1437974b9483ffffffff01405652066b0000001976a914724ca9d8cf7c2cae27e6e6ba159e0af6183780dc88ac00000000
The results of bitcoin-cli decoderawtransaction
are able to pick up the vout:
I can't figure out why it's failing. The transaction data doesn't seem unusual.
EDIT:
More examples:
TXID: 44d9919f4ec5579351073de20ac5117cda9989f31a6556c9d0ec8eb61c0a45c5
TXID: 4a56c1161f3ae25c90e0e6adef4a514c3e532fd71bd99e74717058a7394e0649
I realize that this is an outdated script, but I just wanted to leave a note to mention that RawTransaction::decode will fail if you try and decode a transaction that has a version number that is not equal to "0" or "1".
This is useful when creating and verifying your own transactions. However, on the off chance that you are parsing the entire blockchain, you should be aware that the script will not decode the following transactions:
637dd1a3418386a418ceeac7bb58633a904dbf127fa47bbea9cc8f86fef7413f (version: 2187681472)
c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369 (version: 2591798512)
a7b0fd34c953aeabe93b984bc0e3690ea0165eacab450a5af453cc0ec3307c44 (version: 2)
In that case you will want to remove the check here: https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/RawTransaction.php#L599
I get this error when using verifyMessage on 1.1.0. Looks like the namespacing has changed.
Argument 5 passed to BitWasp\BitcoinLib\BitcoinLib::recoverPubKey() must be an instance of Mdanter\Ecc\GeneratorPoint, instance of Mdanter\Ecc\Primitives\GeneratorPoint given, called in /home/forge/bitcorns.com/releases/20181003123600/vendor/bitwasp/bitcoin-lib/src/BitcoinLib.php on line 1005
I would like to generate change address from public key
that's my code:
$masterPriv = 'xprv9s21ZrQH143K2p33tm4NEgsJwb2sc2WQ6VHauuaMXqSnYfcQ66Q1WUTg8543XpSKZA3pKkfT9XrWT9yTCipj7rurAEkAKLrDnv2rQ4P7jic';
$masterPub = 'xpub661MyMwAqRbcFJ7WznbNbpp3VcsN1VEFTiDBiHyy6AymRTwYddiG4Gn9yLoTFunHYrwwAEh4jA8XTeyVCwiWwkE4aNJzU8A5QvujoEy1bpN';
$masterkey2 = HierarchicalKeyFactory::fromExtended($masterPriv);
$public = $masterkey2->derivePath("m/44'/0'/0'")->toExtendedPublicKey();
$test = HierarchicalKeyFactory::fromExtended($public);
$address2 = $test->derivePath("m/0/0")->getPublicKey()->getAddress()->getAddress();
is changing 0 to 1 in the last line will return me "change address"?
The following function needs to be updated: BitcoinLib::get_random()
In PHP 7.2 mcrypt was deprecated, as a result we need to substitute mcrytp functions, with openssl.
The original code:
mcrypt_create_iv(32, \MCRYPT_DEV_URANDOM);
The requested change:
return openssl_random_pseudo_bytes(32);
As a safe guard it might be worthwhile to add an exception:
$crypto_strong = \OPENSSL_DEV_URANDOM;
$value = openssl_random_pseudo_bytes(32,$crypto_strong);
if(!$crypto_strong) throw new \Exception('"Algorithm used to generate random value is NOT cryptographically strong");
return $value;
In addition to this class, mcrypt functions are used throughout this repo, that would need replacing.
can you explain this?
and how i can generate this:
'scriptPubKey' => '76a914'.'7e3f939e8ded8c0d93695310d6d481ae5da39616'.'88ac')
Hi, I've written a tool (https://github.com/dan-da/bitprices) that generates a historic transaction report including USD price/value/balance at the time of each transaction. The tool works with any bitcoin address. I'm also working on a website frontend (http://mybitprices.info/) that calls the tool, where people can enter their wallet addresses and easily generate a report.
Now that HD wallets are becoming popular, I would like to add the capability to input a single master public key/address and derive all the wallet addresses ever used from that.
SInce my tool is written in PHP, I'd like to find a PHP library that facilitates this.
In reviewing the Bip32.php in this project, I didn't see any way to derive addresses from a master public key. but maybe I missed it? If so, an example would be much appreciated.
The other piece I need besides derivation is checking if the address has ever been used. bip44 defines a gap of 20 unused addresses as indicating the end of a wallet.
What I would really love to see is a simple to use API like:
::derive_used_wallet_addresses_from_pubkey();
I've no idea how hard that would be to implement. ;-)
In general this capability should be useful to anyone writing an app for auditing purposes where private keys are not needed/desired.
See Vitalik's article which mentions that usage:
https://bitcoinmagazine.com/8396/deterministic-wallets-advantages-flaw/
Some classes puts the adapter from the last to the first
when i take 00010966776006953D5567439E5E39F86A0D273BEED61967F6 as param of base58_encode, the result is 1, i debug step by step and find that
$hex = "00010966776006953D5567439E5E39F86A0D273BEED61967F6"
$num = gmp_strval(gmp_init($hex, 16), 58);
where the value of num is false
so strange
i find another way to get the encode
public static function base58_encode($hex) {
if(strlen($hex) % 2 != 0)
{
die("encodeBase58: uneven number of hex characters");
}
$orighex = $hex;
$chars = self::$base58chars;
$hex = self::hex_decode($hex);
$return = "";
while (bccomp($hex, 0) == 1)
{
$dv = (string)bcdiv($hex, "58", 0);
$rem = (integer)bcmod($hex, "58");
$hex = $dv;
$return = $return . $chars[$rem];
}
$return = strrev($return);
//leading zeros
for($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == "00"; $i += 2)
{
$return = "1".$return;
}
return $return;
}
this function return the right result:16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
We need sooner rather than later to implement BIP173 (native SegWit addresses) as well as support for SegWit transactions (native and nested in P2SH). Does bitcoin-php or secpk256k1 php need changes for these purposes also?
It seems the format for an electrum xpub has changed.
In your electrumtest.php file the MPK format is 819519e966729f31e1855eb75133d9e7f0c31abaadd8f184870d62771c62c2e759406ace1dee933095d15e4c719617e252f32dc0465393055f867aee9357cd52
The format Electrum gives now is xpub661MyMwAqRbcFuGfayWGmjEAGo3uUjcDnhDgcCz5DMSEYy7KDsoKJZvoYZhWgP784ehgkctHKXZ47kHgUKqEpDw1xrUa8WBqQg3YKnSUzS5
This is cool, any decent way to go from bits to difficulty in PHP?
def calculate_target(nBits):
# cf. CBigNum::SetCompact in bignum.h
shift = 8 * (((nBits >> 24) & 0xff) - 3)
print shift
bits = nBits & 0x7fffff
print bits
sign = -1 if (nBits & 0x800000) else 1
print sign
r = sign * (bits << shift if shift >= 0 else bits >> -shift)
how i can create multi btc address
A few things warrant bumping the version number as there will be a BC break. The break is mostly in the ordering of P2SH keys which is currently incorrect, and that amounts will be handled in Satoshis and not BTC units.
A small few other changes immediately come to mind, if anything else pops up @rubensayshi @btcdrak note them here
Hi there,
I see the bitcoin-lib-php is works perfect with Bitcoin.
can any you show me what and where the parameters to change in the code to be work perfect wirth Litecoin.
I mean the address prefix , private key prefix and any other required parameters.
regards,
/src/BitcoinLib.php [1011]
public static function toBTC($satoshi)
{
return bcdiv((int)(string)$satoshi, 100000000, 8);
}
Looks like it will silently fail on type overflow with 32-bit integer.
bcdiv works with strings. So omiting that cast looks apropriate:
bcdiv((string)$satoshi, 100000000, 8);
Class 'Mdanter\Ecc\ModuleConfig' not found in /var/app/current/lib/vendor/bitwasp/bitcoin-lib/src/BIP32.php on line 12"
Looks like you have a reference to a class that doesn't exist anymore.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for mdanter/ecc dev-master#89640a0873e212a723212e7f374f973b7d1fe6f6 -> satisfiable by mdanter/ecc[dev-master].
- mdanter/ecc dev-master requires phpunit/phpunit ~4.1 -> no matching package found.
Ignore this, I'm an idiot and using an old version.
base on https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/examples/electrum.php
I change the magic_byte ='00' to '41' for templecoin
and come up with as follow:
https://templecoin.com/api/electrum/private.php
put the seed as follow (without qutation)
"smart shut inside pride milk linger pretty happen stupid lung warmth zone"
look at the #5
QWTbEwMvmw4aKtao2taKDGM4y41Le7cgGcjPQWGyDsBHQ9mMXH
It is invalid, others are the same as electrum, I can't figure out how to solve this problem.
The source for the private WIF:
$magic_byte = '41';
$string = trim($seed);
$seed = Electrum::decode_mnemonic($string);
for($i = $startidx; $i < $startidx+10; $i++) {
$privkey = Electrum::generate_private_key($seed, $i,0);
$wif=BitcoinLib::private_key_to_WIF($privkey, FALSE, $magic_byte);
echo "$i ::
";
}
I need help on this.
UPDATE: I change the magic_byte='0' will have the same problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.