How big is the input of a P2PKH transaction?

How many bytes does a P2PKH input have? I’m finding a few different numbers:

  • Why does the default miner implementation use pay-to-pubkey? states:

    push + sig + push + key = 1 + 72 + 1 + 61 = 139

  • Princeton Bitcoin Book states [p.123]:

    The approximate size of a transaction is 148 bytes for each input[…]

  • A knowledgeable Bitcoin developer calculated from the top of the mind for me over coffee:

    PREVOUT + SCRIPTSIG = 36 + (1 + 1 + 33 + 1 + (71 or 72)) = 143 or 144

I couldn’t find further information in the Bitcoin Developer Guide or the wiki.

Bonus-question: How come there are different numbers? Did the size change over time?

How do I reclaim misplaced bitcoins?

I was given an address to send bitcoins to & it appears the address change but now the deposit did not occur at the address intended & my Source Bitcoin wallet company states there’s nothing they can do. The destination company shows no record of the transaction. This all happened when the Destination website was implementing a new program & having issues with taking deposits.

Can I get the lost Bitcoins if I know the Send from, Send to Addresses, the Block & Hash numbers?

Thanks,

I can’t connect to RPC from python. JSONRPCException: -342

Tryed to run this code :

from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
import json

logging.basicConfig()
logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG)

rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:18332"%('user', 'password'))
print(rpc_connection.getinfo())

with my pass and my username but I have this error:

DEBUG:BitcoinRPC:-1-> getinfo []
Traceback (most recent call last):
File "/home/conio/Scrivania/conioclass/conio/components/provaRPC.py", line 9, in <module>
print(rpc_connection.getinfo())
File "/home/conio/Scrivania/conioclass/conio/components/bitcoinrpc/authproxy.py", line 139, in __call__
response = self._get_response()
File "/home/conio/Scrivania/conioclass/conio/components/bitcoinrpc/authproxy.py", line 187, in _get_response
'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)})
bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server

Can you help me?

Would quantum computing be able to deanonymize CoinJoin transactions?

Using the worst case scenario of this question, namely:

Bitcoin ECDSA algorithm would be broken. Because quantum computers can easily decrypt the private key using the public key, anyone with a quantum computer can extract Bitcoins using the corresponding public key.

Given that quantum computers would be able to obtain private keys, would they be able to deanonymize CoinJoin transactions that are already present in the blockchain?

C# BC, successfully creating and signing raw transaction

First time on stackexchange to ask for help, sorry if i make mistakes (english is not my native language).

I try to create a valid raw transaction on C# with bouncycastle and i seems stuck, not able to find where is my mistake.
I test on the testnet network and have used many sources to help myself, mainly this one.
For start, i have the next address and private key

Address: mjhcWg5SvS96kk85R8G1wp7mru55UCNGY5
Public Key Hex: 0482052EF9560585ED62F046EE45C1B5F85448BCF1BD5CE36A7D35EB00C8A146C14BF99223907F9A8688E6F84B54FD747A637BB82F02E296203E735E7A6B40059F
Wif: 93U5P1qHPXAhXhiw1T15z3f1cBqFw9fWrd3Yzz1nDk8b2aRbrrM 
Private Key Hex: F7DBD21285F621F1C7A47AE7F63D06C276FE49839F4842DDEF805477936812A5

i want to use the 6.49689241 btc from the previous (testnet) transaction

912a2c3d84c8572b39c173b2bcde950cfe4ae07756bac189ace98f198d5ccb7d

and send (as test) some back to the faucet mwCwTceJvYV27KXBc3NJZys6CjsgsoeHmf

First, to build the unsigned raw transaction, i add these bytes:

01000000 (version number)
01 (number of inputs)
7dcb5c8d198fe9ac89c1ba5677e04afe0c95debcb273c1392b57c8843d2c2a91 (reversed previous tx hash)
01000000 (output index)
1976a9142de490b09ef14673af2bb4998fcb9f6b8446a84e88ac (previous tx script with its length at start) 
ffffffff (sequence)
02 (number of outputs)
496ff50200000000 (first output little endian amount. The faucet)
1976a914ac19d3fd17710e6b9a331022fe92c693fdf6659588ac (first output script with its length at start)
0046c32300000000 (second output little endian amount. My address, for change)
1976a9142de490b09ef14673af2bb4998fcb9f6b8446a84e88ac  (second script with its length at start)
00000000 (locktime)
01000000 (hash code type)

The result is

01000000017dcb5c8d198fe9ac89c1ba5677e04afe0c95debcb273c1392b57c8843d2c2a91010000001976a9142de490b09ef14673af2bb4998fcb9f6b8446a84e88acffffffff02496ff502000000001976a914ac19d3fd17710e6b9a331022fe92c693fdf6659588ac0046c323000000001976a9142de490b09ef14673af2bb4998fcb9f6b8446a84e88ac0000000001000000

I then retrieve the transaction hash by pushing the raw transaction in a double SHA256 function that return me

f64b6480a2888596636d4995153e990ce95582a1308c9c568d2698e6dc1f7893

Then, i sign with the private key hex (prvkeyHex) the transaction hash (txHash) with this function:

X9ECParameters curve = SecNamedCurves.GetByName("secp256k1");
ECDomainParameters dom = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H)
ECKeyParameters params = new ECPrivateKeyParameters(new BigInteger(1, prvkeyHex), dom);
ECDsaSigner signer = new ECDsaSigner();
signer.Init(true, params);
BigInteger[] sig = signer.GenerateSignature(txHash);
MemoryStream ms = new MemoryStream(72);
DerSequenceGenerator seq = new DerSequenceGenerator(ms);
seq.AddObject(new DerInteger(sig[0]));
seq.AddObject(new DerInteger(sig[1]));
seq.Close();
byte[] signature = ms.ToArray();

Which return me a byte array of max 72 bytes length starting by 30. In my last test:

3045022100abceff62d3192b686c405d10516ff0e6f9ff221c00284d766200a6abb42361be02202972970369d6b9308467e15ebafd3f6b9faf111886071e3c429b34e9407e8d23

I then construct my final scriptSig with the public key hex and their lengths who result as

483045022100abceff62d3192b686c405d10516ff0e6f9ff221c00284d766200a6abb42361be02202972970369d6b9308467e15ebafd3f6b9faf111886071e3c429b34e9407e8d2301410482052ef9560585ed62f046ee45c1b5f85448bcf1bd5ce36a7d35eb00c8a146c14bf99223907f9a8688e6f84b54fd747a637bb82f02e296203e735e7a6b40059f

I finally built my signed raw transaction:

01000000 (version number)
01 (number of inputs)
7dcb5c8d198fe9ac89c1ba5677e04afe0c95debcb273c1392b57c8843d2c2a91 (reversed previous tx hash)
01000000 (output index)
8b (scriptSig length)
483045022100abceff62d3192b686c405d10516ff0e6f9ff221c00284d766200a6abb42361be02202972970369d6b9308467e15ebafd3f6b9faf111886071e3c429b34e9407e8d2301410482052ef9560585ed62f046ee45c1b5f85448bcf1bd5ce36a7d35eb00c8a146c14bf99223907f9a8688e6f84b54fd747a637bb82f02e296203e735e7a6b40059f (scriptSig)
ffffffff (sequence)
02 (number of outputs)
496ff50200000000 (first output little endian amount. The faucet)
1976a914ac19d3fd17710e6b9a331022fe92c693fdf6659588ac (first output script with its length at start)
0046c32300000000 (second output little endian amount. My address, for change)
1976a9142de490b09ef14673af2bb4998fcb9f6b8446a84e88ac  (second script with its length at start)
00000000 (locktime)

The final result give me that signed raw transaction

01000000017dcb5c8d198fe9ac89c1ba5677e04afe0c95debcb273c1392b57c8843d2c2a91010000008b483045022100abceff62d3192b686c405d10516ff0e6f9ff221c00284d766200a6abb42361be02202972970369d6b9308467e15ebafd3f6b9faf111886071e3c429b34e9407e8d2301410482052ef9560585ed62f046ee45c1b5f85448bcf1bd5ce36a7d35eb00c8a146c14bf99223907f9a8688e6f84b54fd747a637bb82f02e296203e735e7a6b40059fffffffff02496ff502000000001976a914ac19d3fd17710e6b9a331022fe92c693fdf6659588ac0046c323000000001976a9142de490b09ef14673af2bb4998fcb9f6b8446a84e88ac00000000

But now, when i try to send that signed raw transaction on the testnet network by a web service, everytime i get an error.
sandbox.smartbit.com.au/txs/pushtx return me

"PUSH TRANSACTION ERROR: 16: MANDATORY-SCRIPT-VERIFY-FLAG-FAILED (SCRIPT EVALUATED WITHOUT ERROR BUT FINISHED WITH A FALSE/EMPTY TOP STACK ELEMENT)"

live.blockcypher.com/btc-testnet/pushtx/ return me

"Error sending transaction: Error running script for input 0 referencing 912a2c3d84c8572b39c173b2bcde950cfe4ae07756bac189ace98f198d5ccb7d at 1: Script was NOT verified successfully.."

same with tbtc.blockr.io/tx/push

I’m far from mastering bitcoin or c#, i am learning (and want to learn how that work). Is anyone see where is my mistake ?
Thanks

How come some addresses show up in search results while others don’t?

Some Bitcoin wallet addresses can be found by google, but some others shows no result. For example, this wallet is visible on many Bitcoin websites and google has a lot of results 1ENFY4h7ntGZbqwcwpQtXVFJrPnfXRHQLe and we can see its transactions. But this other address 126kUxBmdLTk4M7w1uaQ2pjAhm9KbZ6dxp (a ransom-ware wallet!) has no result. How it is possible? How can people do this?

Format of mkey field in encrypted wallet.dat file

I am writing a C++ application to scour large files (typically disk images) for wallet.dat files, with the intention of recovering the private keys.

At the moment I am struggling the data contained in the ‘mkey’ (Master Key) section of an encrypted wallet.dat file.

From Googling and pouring over the source code for Bitcoin and various other utilities that do what I want to do (such as pywallet) I have deduced the that data layout of mkey data is:

  • mkey – a size prefixed string denoting the start of the master key data.
  • nID – an integer whose purpose I have been unable to determine.
  • encrypted_key – a size prefixed buffer containing the encrypted master key.
  • salt – a size prefixed buffer containing the salt data used when encrypting the key.
  • derivation_method – an integer containing either 0 or 1 for the method used to encrypt the master key using the wallet password.
  • derivation_rounds – an integer containing the number of rounds used to encrypt the master key.
  • other_derivation_parameters

However, having examined my wallet.dat file with a hex editor (screenshot attached) I cannot seem to get the data it contains to correlate with the above.

enter image description here

Can someone point me in the right direction or tell me what I have missed.