text:
BlockChain.Info Incorrect Balance
Recently my Bitcoin-Qt client started crashing on start-up (running Mac OS X 10.7.4). I was able to stop the crashing by removing the blocks directory and letting it re-download the blockchain.
However, I don't really have time to re-download the forever bloating 13GB blockchain! So I tried importing my wallet.dat file into blockchain.info. Upon doing this, my total balance is now 1BTC short.
When I inspect the transactions, nowhere did I send 1BTC from that wallet. And when checking in Bitcoin-Qt, the coin is there and verified.  Unfortunately I can't dump the private key for this coin as I get an error in Bitcoin-Qt (I think due to my blockchain being out of date). As I was hoping to then import this key manually.
Is there anyway around this? Ideally I just want to get my balance into a wallet like Multibit, so I don't have to worry about the 13GB+ blockchain! Backup my wallet safely and know that my coin is secure and safe! In a crashing Bitcoin-Qt with a forever growing blockchain I don't feel too happy at the moment.
Currently available to me I just have my encrypted wallet, and it is currently imported to blockchain.info with the incorrect balance. Any suggestions? I feel like I tip toe around a lot with Bitcoin as I don't want to accidently delete anything I shouldn't!

As long as you keep your private/public keypair, you aren't in danger of actually losing the funds.
The problem is most likely due to "missing inputs" for your current wallet. In order to spend bitcoins, your wallet must reference the inputs that gave your wallet the funds in the first place. The function of the blockchain is to keep track of these inputs from creation to their current wallet. Without the full blockchain, qt will not be able to reference inputs for spending, and thus won't show such inputs as existing in your wallet.
Download the blockchain. If you can't/won't sweep you private key into a new wallet that has access to the full blockchain. This will also serve to reset the oldest input in your new wallet.

Thanks, I'll feedback to here as soon as I have finished reindexing my existing blockchain in Bitcoin-Qt, if that succeeds is it possible to dump the private/public key pair and move to a new wallet? Or is it best to just perform a transaction to a new wallet?

I tend to prefer sweeping into a new wallet. Most wallets do this via a transaction of all known inputs into a new wallet.

Sorry for the ignorance, what is sweeping? Btw, the reason why I am downloading the blockchain for qt, is that I can't seem to get my private keys out using the console, it throws up an error currently


text:
Where did the idea of blockchain come from? Git was already using it since 2005
With bitcoin's blockchain, each block's hash is computed with the previous block's hash. That makes all blocks an immutable chain.
This is not the first time people used a hash-chain. As far as I know, Git was already used it since 2005 for the commit-hash computing.
So, what is the earliest use of hash chains? Where did the idea of blockchain come from?

According to Bitcoin and Cryptocurrency Technologies (BaCT), the Princeton Bitcoin textbook, the block chain dates back to a "paper by Haber and Stornetta in 1991. Their proposal was a method for secure timestamping of digitaldocuments, rather than a digital money scheme." (BaCT p.15)
The chaining of Merkle trees instead of single documents was proposed in a later paper. (BaCT p.16)

Although the blockchain as it is used in Bitcoin is a new and novel concept, the idea of a chain of blocks in the field of cryptography goes back to symmetric block cipher modes of operation.  Specifically, the common practice of cipher block chaining.  This practice was first described in a standard from 1981, although it was almost certainly in use before then.
Although cipher block chaining is fundamentally different than the chain of blocks that Bitcoin uses, it is an example from cryptography where a change to an earlier block affects all subsequent blocks.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
How to get last transactions made to a non-wallet bitcoin address?
I know I can rebuild my block index by setting txindex=1 in my bitcoin.conf file and restart bitcoind with -reindex so that I can view non-wallet transactions using:
bitcoind getrawtransaction a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa 1

I'm currently in another situation however, in which I only have the recipient address. So my question is, can I list all transactions that have been received by a certain address, preferably including the confirmations that this transaction has gotten?
All tips are welcome!

There is a blockchain tool call Obelisk which works like bitcoind in effect, they do have public servers open to save you having to download the whole blockchain. You need to install obelisk and sx tools (same authors)..
Info:  http://libbitcoin.dyne.org/  also  http://sx.dyne.org/history.html
sx tools Git:  https://github.com/spesmilo/sx
Obelisk Git:  https://github.com/libbitcoin/obelisk/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Is Bitcoin a stack of cards which will collapse?
Is it possible, that once all the bicoins are minted, the code is designed in such a way, that the entire ledger or stack of cards, comes tubling down and all cryptos are deleted?

No, that's not possible. The people behind the code are invested in the success of bitcoin.
If they designed it to crash to nothing, even way off in the future (around 2140), their motives would be pulled in to question and deflate confidence in bitcoin today.
Also, remember the code is public and someone would have spotted such a deliberate undermining of the coin.


text:
Can I limit the back-up data in wallet.dat?
I want to know is it possible to back-up manually from wallet.dat. I am running Dogecoin daemon locally.
Scenario:

say user (user1) have some dogecoin balance in addr1
another user (user2) have dogecoin balance in addr2
I want to back-up only user2 not user1

Is there any way to limit the back-up data in wallet.dat file?

Sounds like you should be using separate wallet files.

No, this is not possible without custom software or a lot of extra work. The wallet.dat file contains all the private keys, and the reference client doesn't have a way to split it up.

I wrote a simple Python script that I believe does what you're looking for. I created it for Bitcoin Core, but since Dogecoin's CLI (dogecli) is based on the same technology, I think the commands should be quite similar. I'll leave the link here in case you're still interested.
https://canalqb.blogspot.com/2024/12/python-incluindo-banco-de-dados-de-wif.html

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How to implement and use BIP 70?
I have a server running bitcoind 9.x, how can I incorporate features such as return addresses to my customers using BIP 70? I have seen the GIT repo but is it something that I have to download or is it already implemented in the bitcoind daemon I'm running?
Thanks

It's neither part of the Bitcoin daemon nor something you can just download. It's code you are expected to write and integrate with your web commerce application. The code in the git repository is only a sample.
See my answer  https://bitcoin.stackexchange.com/a/24450/5757 for some further information.

thank you for your help, i have made some progress i think. so i downloaded the proto compiler and compiled this template https://github.com/bitcoin/bips/blob/master/bip-0070/paymentrequest.proto, created a django view and passed it an instantiation of the payment object but it isn't working just yet. Can you tell me where I'm going wrong?

I'm afraid I know very little about protobuf or django so I can't be of much help. You could ask a new question but without seeing more of your code or something more specific than "it isn't working" it will be hard for anyone to answer. If you can narrow it to a specific issue that will help too; general "please debug my code" questions are not encouraged here.

authors: อัครพร ทองคําสุข


text:
How to handle return address Output field using bitcoin bip 70?
More specifically, how do I derive the return address from the Output field in a protocol buffer Payment object?
I can convert the serialized byte string from the 'script' field of the Output into a 25 character scriptPubKey but I'm stuck as to where to go from here?
Any help greatly appreciated :)

I managed it with Petrer Todds python-bitcoinlib.
Link to payments_pb2 proto file here.
import bitcoin

## Uncomment for testnet
#bitcoin.SelectParams('testnet')

import payments_pb2

from bitcoin.wallet import CBitcoinAddress
from bitcoin.core.script import CScript

def protoresponse(httprequest):

    ## Object
    o = payments_pb2

    ## PaymentACK object
    pao = o.PaymentACK()
    pao.payment.ParseFromString(httprequest.body)

    refund_address = CBitcoinAddress.from_scriptPubKey(CScript(pao.payment.refund_to[0].script))

    return httpresponse


text:
Can I pass values over a bitcoin bip 70 URI?
is it possible to add arguments such as BTC amount to a bip 70 URI, something like:
bitcoin:?r=http://127.0.0.1:8000/paymentobject/?amount=10

I already tried with the backwards compatible URI:
bitcoin:?amount=10&r=http://127.0.0.1:8000/paymentobject/

But the client doesnt seem to register anything other than the 'r=' param.
Any help greatly appreciated :)

EDIT:
Added function from django views.py for extra explenation-
def protoresponse(request):
    xpo = payments_pb2.ParseFromString(request)

    returnaddress = xpo.Payment.refund_to
    transactions = xpo.transactions
    memo = xpo.Payment.memo

    xpa = payments_pb2.PaymentACK
    xpa.payment = xpo.SerializeToString()
    xpa.memo = u'success, i think'
    return HttpResponse(xpa.SerializeToString(), content_type="application/octet-stream")

Note, the function is defined as protoresponse because we have optional string payment_url = 6; in the payments.proto file.

Quoted from 'Nate Eldredge' in the comments above:

The whole point of BIP 70 is that all sensitive information, including
  the address, is only sent over HTTPS (so your URL needs to be https,
  not http, and you need an SSL-enabled webserver running on localhost).
  That way an man-in-the-middle attacker cannot, for example, alter the
  payment address so the payment goes to the attacker instead.

The purpose of the BIP70 is to provide a secondary URL, which, when visited by your client wallet, will provide all the details to make the transaction, and a whole lot more. It was designed to be linked to POS systems which would generate the information and produce a unique URL.
In the standard Bitcoin URI scheme, it is possible to pass the amount, but you also need to pass the pay-to address.

Thanks or the response. My problem is that I would like to be able to pass the payment amount via the bip 70 URI so that I can just have a fixed URI that supplies a standard bip template rather than having to create a new one for each customer with a different amount in it. I understand this is achievable by keeping the amount at 0 which will then prompt the customer to enter amount but this isn't functional in the current bitcoin client due to a bug so i was looking for a way around it.

You might find it useful to visit this page https://bitcoincore.org/~gavin/createpaymentrequest.php useful, to help you understand how to construct the full URI. I created one for you bitcoin:mfxg9RL47G3rManb7UcYHr95EJ1CtG3SKH?r=https%3A%2F%2Fbitcoincore.org%2F%7Egavin%2Ff.php%3Fh%3D60b13b2fe3c6fad30a7216aacd6e06cc&amount=10

Thank you. But the problem still persists I'm afraid because the user still has to declare the amount in advance where as I am trying to do it dynamically. The 'amount' at the end of the URI you generated for instance is irrelevant because even if I change it to something other than 10 I am still prompted to pay 10 because it's set in stone on the server side. I'm looking for a dynamic work around since it isn't possible to set the amount to zero and prompt the user because there is a bug in the bitcoin-qt 0.9 client that prevents this. I need a way to pass the value on the fly somehow :)

Can you give a practical example of what you are trying to do - a use case. I still don't understand what you are trying to achieve. Your original example would not work because it does not contain the pay-to address. So a bit more information would be useful.

I have tried it with a pay to address such as bitcoin:adDr3s5?amount=10&r=http://uri.com but reading the documentation it states that when a bip 70 compatible wallet sees the r= param then it doen't see anything else, no address, no amount. Use case - a customer clicks a button that generates a btc address and a corresponding qrcode, it also generates a link to fetch a payment request object but when the link is clicked how will it know what btc address to attach to the payment request if I can't pass the information over the URI?

Firstly customers do not ever generate anything on behalf of the merchant. I think this is where you are going wrong. Try re-thinking your use case and work it from the merchant's point of view. That's what BIP70 was intended to do. For the rest, I have no idea why a customer would determine where to send the funds, because these must be linked to another party's private key.

Thanks for the speedy response :) it's hard to explain but when you want to send crypto to an exchange you first must click a button and generate an address, this is what I am doing only i want to give customers the option to either scan a qr code or click a bip 70 link but these two methods will result in two different addresses since I can only figure out how to generate an address and perform operations on it after the URI is clicked. I'm trying to make my django instance available for live viewing so I could show you but my router's having none of it :(

"but these two methods will result in two different addresses" - no they should not! A QR Code is a URL. That same address can be used in either a standard Bitcoin URL or a BIP70 one.

also the address you generate on an exchange is not YOUR address, because the exchange holds the private keys.

lol, yes but how? if this is my bip 70 URI bitcoin:?r=http://127.0.0.1:8000/paymentobject/ then where does the address go? It doesn't seem to work if I put it before the ?, I will post a copy of the view in the original question in case that helps at all :)

@derrend: With BIP 70 the payment address doesn't go in the URL at all.  It's sent as part of the response when the user requests the URL, so your script paymentobject needs to generate it.  The whole point of BIP 70 is that all sensitive information, including the address, is only sent over HTTPS (so your URL needs to be https, not http, and you need an SSL-enabled webserver running on localhost).  That way an man-in-the-middle attacker cannot, for example, alter the payment address so the payment goes to the attacker instead.

@Nate: Thank you for the input, I'm beginning to understand it now :) If you copy and paste your comment as the answer I'll mark it as solved.


text:
How to receive and manipulate a bip 70 payment object in django python?
I'm trying to check to see if the variables are being set correctly by the client and being received correctly by me.
I'm new to proto buffs and django and my code below doesn't seem to be working.
I'm using bitcoin 0.9
I'm trying to capture a refund address.
In views:
from project import payments_pb2
def protoresponse(request):
    xpo = payments_pb2.Payment.ParseFromString(request)
    returnaddress = xpo.refund_to
    transactions = xpo.transactions
    memo = xpo.memo

    xpa = payments_pb2.PaymentACK
    xpa.payment = xpo.SerializeToString()
    xpa.memo = 'success'
    return HttpResponse(xpa.SerializeToString(), content_type="application/octet-stream")

Any pointers would be greatly appreciated :)

Any information how it doesn't work is necessary for answering the question.

Thank you for the response :) I receive a 'forbidden access' error once I attempt to send the payment after initially opening the URI, (where to send the payment object is different to the initial URI address). Do I need to do something special to the object like def protoresponse(request, content_type="application/octet-stream")? Are there any obvious mistakes with the above code?

Forbidden access is not related to the code above, but is most likely related to your web server. Please study how to setup a basic single web page through Django first, see it works and then try see that your protoresponse view gets called properly.

It is unlikely the error is any way related to the code or the question above, unless shown otherwise.

will the protobuffer object come through as a request that I must deserialize - edit - and reserialize before sending back? Please can you give me an example, I cannot find any documentation or forum posts specifically on this subject which is why I am posting here. Thanks :)

I asked this same question in a simpler way without mentioning bip 70 and got the answer here.
The initial problem was that Django doesn't like people posting to your server who arent authorised so I used from django.views.decorators.csrf import csrf_exempt and the corresponding decorator @csrf_exempt as a short term work around for further debugging.
More detailed info can be found by following the link to the simplified question.


text:
Is the denumerability of private keys a threat?
Since the set of all private keys is denumerable, it is at least possible to create a searcheable record of all keypairs. Which, when finished, is a killer for the whole idea. Am I right or do I miss some essential part?

You're meaning something like this?

@aland Clever! I think I just found the smallest vanity address: 19's compressed address starts with 1Amy

It's pretty hard to represent non-denumerable sets on a finite state digital computer.

OP - It's not denumerable, it's finite. "Denumerable" in standard mathematical terminology means countably infinite.

There's around 2^256 possible private keys. However, there's only 2^160 valid wallet addresses. To store each key-address pair we need 160+256 bits = 25 bytes, so the searchable record will take several million mass of solar system if stored on 4TiB harddrives.
But first we need to create this database. If we equip each PC on Earth (around 2 billion) with 4 GPUs (each generating around 20Mkey/s), we will need much more time than the age of the universe. By the way, we most likely will also hit the hard drive write performance limit if we write each pair to disk.

No, it is not a threat, because the number of possible private keys is about 2^256. Even if every atom on earth was a Petabyte hard drive, you would still not have nearly enough storage for a record of all keys.
(More interesting is the finite number of Bitcoin addresses, but that is still enormously large.)


text:
HD / Deterministic Wallets and public key
I understand the basic concept of generating an unlimited number of public key addresses from a master public key. What I won't understand is how to get the wallet balance. Do I have to query unspent outputs for every public key in the wallet that I have generated?
Is it possible to iterate through the addresses in the utxo and determine whether they are within the public set of addresses that could be generated by the wallet?
If I hand the server a public key and it generates more on my behalf, how do I know which addresses received coin? It seems like there must be a way to determine if an address is spendable by the master key pair.
Any ideas? Seems that you would have to check the entire utxo set somehow. Much appreciated.

Clients that use an HD wallet generate a fairly large number of the keys in advance (e.g. Armory does 100 by default). When it scans the blockchain for relevant transactions, it checks for transactions to all of the keys that it's generated so far.
Typically, you do transactions off the next address in the list (there's a certain order to it, and it's easier to just generate the next one than 100 next ones). Let's say your client has generated the first 100 keys, and someone sends money to the 150th address in your list. You'd have to wait for the client to decide to generate the 150th key (probably because you hit your 50th key used and it pregenerated out to 150), or tell your client to generate out to the 150th key, and then rescan the blockchain, in order to know that you received money there.

It seems like there must be a way to determine if an address is spendable by the master key pair.

Not necessarily: you can generate a very long series of addresses (2^32, if I'm reading BIP 0032 right) from a master key pair, but doing so would take a substantial amount of time. I'm not sure if there's a theoretical way to do what you're asking (without actually calculating all of them), but in practice it's clear that you just generate the set of addresses you think will be useful in the near future, and go from there.

So for example if you hand off an HD public key to a service and it generates public keys on your behalf for payments. You can pay from those public addresses, but how do you know which ones you control?

You and the service will generate the same series of public keys: that's what it means to be a deterministic wallet, instead of one like Bitcoin Core where each private key is random. You control all of them in the series, it's just a matter of knowing which have money in them (which is controlled by the 100 pregenerated keys in my example), so you know which you can try to spend with.

I was under the impression that the public key could be used to generate additional public keys. I.e you could hand off a branch of the hd wallet to a service provider without generating the sub keys. Is that incorrect?

In the BIP 0032 specification an HD wallet has both "normal" child keys, from which you can generate more public child keys with only the public key, and "hardened" child keys, from which you cannot generate more child keys. If a service used a normal child key to calculate a key that's far down the chain, I'd expect them to tell you just how far down the chain that is. But I see no reason why they would go beyond the last unused address unless you asked them to. If you hand them an address or a hardened child key, they cannot generate subkeys.

What I won't understand is how to get the wallet balance. Do I have to query unspent outputs for every public key in the wallet that I have generated?

Short answer: Yes. Sort of.
You need to find all the keys up to Gap limit (most wallets use 20).  See Bip32 and 44.  If you really want to, you could go further though.  Then you lookup utxo for these.
Or you could just use mybitprices.info which will find the used addresses for you, and can also print out a transaction report.   Source code is on github, you can find it at above link.


text:
Does GHashIO already have above 51% hashrate?
Right before writing this question I noticed the GHashIO showing 32% hashrate distribution using the following link.
Unknown has 26%. And the IP address of the most blocks reported from unknown is: 88.150.205.243. After doing some digging it seems that the IP address is owned by GhashIO according to totalhash.
Not sure how reliable the data from totalhash is but it seems that GHashIO has already achieved above 51% total hashrate. Can someone confirm this? If it's false then what would be the proper way to investigate this in the future?

When blockchain.info says that a block came from an IP address (for example, 88.150.205.243) it means that blockchain.info received this block from this IP address, but it can not determine which pool mined this block.
It also means that blockchain.info is connected with this peer node. There is a high probability that this node has many peers where blocks can come from.
It does not mean that this block was mined by this IP address.

The operator also said that if he gets close to 51%, he'll pull everyone mining on the Getwork protocol, which will reduce their rate by about 10%.

Have you a source for this?

And even if he says he'll do this, doesn't make it reliable and trustworthy. The first honest criminal should still be born imho.

I can't remember where I read that, it was a while back.


text:
Bitcoin payout based on real-life event
Just starting to learn bitcoin scripting. Can someone explain how to pay out based on some real-life event?
I currently test from the command line with bitcoind -regtest

Could you clarify what you mean by conditional? When I use a normal transaction script, it includes two conditional statements: OP_EQUALVERIFY and OP_CHECKSIG.

In most simplest form, if a condition is met by checking an outside "oracle", then pay out, if not then do not pay and continue to check until condition is met.

There isn't one - that's intentional. If it allowed an outside oracle, that oracle might tell one part of the network that the transaction is valid, and tell another that the transaction is invalid.

So how would one go about a conditional script which relies on a real life event to trigger a payout?

Have a trusted server monitor the real-life event, then make it send the payment when it happens.

@NickODell That seems to be a good start for an answer. :)

I am awaiting the Murphy answer like a school girl

You could use a service such as ifttt or tasker to tie in BitCoin API with a real-life event monitoring service.

Bitcoin can't directly check the outcome of real-life events. However, it is possible to make conditional transactions with the help of third parties. This can be achieved with multisignature addresses. A multisignature address is an address which is controlled by several different people. To spend the money from such address, signatures from specific number of those people is required. For example, to spend from a 2-of-3 multisignature address, at least two of the three owners must agree on a transaction.
How can this be used to make conditional payments? Well, there are three parties: the sender, the recipient and the party which determines the outcome of the event, which we will call the oracle. The oracle provides a public key which corresponds to the event which is the condition of the payment. If the event happens, the oracle would reveal the corresponding private key, so anyone would be able to use it to make signatures.
Now, suppose that the sender sends his money to a 2-of-3 multisignature address with the owners being himself, the recipient and the public key provided by the oracle. Until the oracle reveals his private key, the recipient can only spend the money with the assistance of the sender. Afterward, the recipient can use the key revealed by oracle to spend the money as he wishes.
This scheme, however, has a few problems. Firstly, if the event doesn't happen, the sender can only take his money back with the assistance of the recipient. Secondly, if the event does happen, the sender can take his money back if the recipient is not fast enough to move it first. The first problem can be solved by having the recipient sign a transaction returning money back to the sender before the sender broadcasts the first transaction. Here is an example of how this feature can be used. The second problem can be solved by using more complex script than 2-of-3. For example, it is possible to make a script which lets the money to be spent by sender+recipient and recipient+oracle, but not sender+oracle.
By the way, when doing research on this question, I found an actual website which offers to reveal private keys based on the outcome of real-life events.


text:
Which part of code (function) handles received transactions?
I was trying to understand the flow of control between functions (operations performed and their order) when a transaction is received.

When any transaction is recieved, or just when you recieve a transaction that pays to you?

In both case, which functions will be called ? and in what order?

Any transaction
main.cpp, AcceptToMemoryPool:
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
                        bool* pfMissingInputs, bool fRejectInsaneFee)

A transaction that pays to or from you
wallet.cpp, CWallet::AddToWallet:
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)

can you please explain the arguments passed ?

@somesh Could you explain why you want to know? I initially assumed that you wanted to instrument the code somehow.


text:
Bitcoin spend before received
When browsing the blockchain.info I came across this address. It seemed peculiar to me, that the amount of 0.6 BTCs has allegedly been spend before received.
Is it because the "receiving transaction" somehow occurred in a side-chain and has only afterwards been merged into the Blockchain? Or what other explanations might there be for this behavior?

That's an interesting find! The transaction that created the output was in block 274227. The transaction that spent the output was 6 blocks later, 274233. So it's perfectly valid on the bitcoin network even though blockchain.info seems to have a glitch in the times they are reporting.
If they are basing the received time of the transaction at all on the time of the block it was included in, then you should know that the time recorded in bitcoin blocks can be a little off sometimes. See Why don't the timestamps in the block chain always increase?. Although, this doesn't appear to be what they are doing since they report two separate times, one for when the transaction was received and one for the time of the block.
Blockchain.info's API, Wallets, and Block Explorer are not known for being the most robust. They have started a bug bounty program, though: https://www.crowdcurity.com/blockchain-info.

display bug on blockchain.info, they display the time that is in the block header, but since the time in the block header is allowed to be 2 hours off (and sometimes is because of performance tricks the pools do).
https://www.blocktrail.com/BTC/address/1BacceeNmQzGFm11QwKdqmXA1wvnoHvaAv/transactions shows them in the right order


text:
Who give initial value to Bitcoin?
I know how the process of changing BTC price occur, but I curious as to what gave the  initial value to BTC and whether the price of another cryptocurrency refers to the BTC?
How would I replicate this process using an API or any algorithm?

You're asking two things in a single question. Please try to split it into two separate questions, one asking about the initial price and the other one looking for APIs.

I (and another editor) condensed the two questions into one, and wonder if it can be reopened in its current form.

I am still not sure what this question is asking. It might be a duplicate to Where do bitcoins come from and what gives them their value?, yet on the other hand seems to be asking Where can I get historic data series of Bitcoin prices? as well, and something else entirely. So, there are three close reasons: Multiple questions, intelligibility, and being a duplicate. It would really help if the asker were to clarify what he actually wants, but as it is it should stay closed, actually better deleted.

If you feel it is worth the effort to expand the discussion of this question's worth, please create a post on [meta] and link it here.

How much would you pay for 1 BTC in 2009 before knowing all this? Probably some cents since u would not mind losing, that was how the first BTC price was defined.
Nowadays is pure especulation with some basis on the price of electricity cost to generate 1 BTC.
APIs u can search for on the major exchanges, such as Bitstamp,BTCchina,Huobi,OKcoin,BTCe and so on...

Whoops, seems I misunderstood completely

You didn't. The asker made 2 questions in one.

฿ price comes from whichever API you use. I prefer Coindesk because it does a weighted average, but Blockchain.info is another good option, as is Bitstamp or Coindesk.
From there you can use Bittrex API or Cryptsy or Poloniex.
There's also specialist API like gem.io or blockcypher.com

OK, now I perhaps see the author's reference to "API", but it's still very inaccurate. API is not where the price comes from. The price comes from the market, it's where the demand and supply meet. That's the "source" of what is referred to as Bitcoin price. Now, API here is just an convenient access to one exchange's historical data, and does not have anything to do with the price forming process; thus I think it does not really fit into the topic of this question.


text:
How are transactions broadcast to the rest of the network?
If a person sends a transaction to another person, and Bitcoin is a peer-to-peer application, how will the transaction get to the rest of the Bitcoin community? How does everyone have the same blockchain?
Does every system know about every other system in the network? If so, how?

Patrick, have you read this? https://bitcoin.org/bitcoin.pdf

This pdf is new to me. Thank you. This looks to be very informative.

The PDF does not talk about how the broadcast is realized though

If a person sends a transaction to another person, and Bitcoin is a peer-to-peer application, how will the transaction get to the rest of the Bitcoin community?

Think of it like how gossip would spread. There are a bunch of people (nodes), and when one of them knows something, they tell it to the few (8 or so) people they are near (connected with), and then those people tell a few more people the message that was told to them, and then... Eventually everyone knows about the original information (transaction).
So when we say bitcoin is peer-to-peer, we mean it's just nodes that have internet connections (on port 8333 usually) with other peers. Not even necessarily the one you're sending the coins to!

How does everyone have the same blockchain?

After peers exchange their information (and validate that all transactions and blocks follow the protocol rules), they store it. Since all of the bitcoin transactions from the beginning of the bitcoin block chain are needed to validate everything that has taken place, essentially all full nodes store the same data (about 27.5 GB of pure block chain data as of now).

Does every system know about every other system in the network? If so, how?

No need to know about every other system on the network, each node just knows about the 8 or so nodes that it is connected to!

Is it possible that the message loop happens? e.g., A->B->C->A.

No. What actually happens is when a node receives a transaction, they advertise the txid to their peers, and then their peer will only request the transaction if they haven't seen a transaction with that txid yet, so it prevents requesting duplicates.

According to https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery

DNS Addresses
Upon startup, if peer node discovery is needed, the client then issues DNS requests to learn about the addresses of other peer nodes. The client includes a list of host names for DNS services that are seeded. As of December, 2017 the list (from chainparams.cpp[1]) includes:
seed.bitcoin.sipa.be
dnsseed.bluematt.me
dnsseed.bitcoin.dashjr.org
seed.bitcoinstats.com
seed.bitcoin.jonasschnelli.ch
seed.btc.petertodd.org
A DNS reply can contain multiple IP addresses for a requested name.
Addresses discovered via DNS are initially given a zero timestamp, therefore they are not advertised in response to a "getaddr" request.

Hard Coded "Seed" Addresses
The client contains hard coded IP addresses that represent bitcoin nodes.
These addresses are only used as a last resort, if no other method has produced any addresses at all. When the loop in the connection handling thread ThreadOpenConnections2() sees an empty address map, it uses the "seed" IP addresses as backup.
There is code is move away from seed nodes when possible. The presumption is that this is to avoid overloading those nodes. Once the local node has enough addresses (presumably learned from the seed nodes), the connection thread will close seed node connections.
Seed Addresses are initially given a zero timestamp, therefore they are not advertised in response to a "getaddr" request.

Welcome to Bitcoin.SE! Your well-written answer is not complete, it does not address the original question but, it is a good beginning for a detailed answer.

Thanks, I shaded light to me on what addresses where used and how the client find out about the rest of the nodes!

The bitcoin daemon makes the transaction with the source address and the destination address then broadcasts the transaction to the network.
The Bitcoin miners confirm the transaction and include it in the next(s) blockchain blocks. The miners receive the transaction fee as the reward for this.
When the receiver downloads a new Bitcoin blockchain block and sees incoming transaction to his/her address, the receiver knows the payment was made.
So all Bitcoin nodes share the same blockchain data (approx. 27.5 GB at the moment). This blockchain as eventually consistent, append-only, database of all Bitcoin transactions.

how do they all have the same 20GB blockchain? How can the daemon broadcast the transaction to the network? Would you have to know all the systems on the network?

Each node communicates with neighbouring nodes and they communicate with neighbours and so on. Then the information propagades. For more details please refer to https://en.bitcoin.it/wiki/Network

If i just created a wallet after installing the software how would i know of any other nodes to connect to the network?

@PatrickW.McMahon http://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other

Transactions which are not double spends will be happily relayed by all nodes who receive them to all the people they connect to. This ensures that miners will hear about transactions.
Everyone who is fully synced will share the same blockchain. Bitcoin helps people achieve consensus, which simply means they all agree on the same list.
Generally bitcoin nodes will connect to at least 8 other (random) nodes. This is enough - You pick geographically separate nodes to get a true sense of the network's state. Nodes are responsible for relaying information about new transactions and blocks to their peers.

How the wallet know that is fully synced with others ?

There is a well explained article in harmony website you can read https://blog.harmony.one/peer-discovery-in-harmony-network/


text:
Address generator for Bitcoin wallet
As describe by Maxwell here in HD wallets assuming we have a key pair with private key SK.a and public key of PK.a and a seed s and a generator point G, we can generate a new key pair of (SK.b, PK.b) as follows:
PK.b = PK.a + sG
SK.b = SK.a + s

The advantage with this method is that a service provider can generate new public keys without knowing the clients private key.
My question is that, why don't we multiply the seed and private key rather than adding them?
PK.b = PK.a * s
SK.b = SK.a * s

Is there any problem with the later method that I suggested?

A previous draft of BIP0032 did this, actually. (Sorry about linking to the bitcoin wiki - that change was made before we switched over to git for BIP tracking.)
According to the changelog, it was done for speed reasons.

[30 Apr 2013] Switched from multiplication by IL to addition of IL (faster, easier implementation)

It's much faster when deriving a child private key from a parent private key. The new method requires only a normal addition (mod n) rather than an ECDSA point multiplication.
It's not faster when deriving a child public key from a parent public key. That still requires an ECDSA multiplication followed by an ECDSA addition. (In fact, it's about 2% slower.)
Using addition does not add any security issues. It's possible to get a parent private key from a child private key and an extended public key, but that would also be true if multiplication was used.

Thanks for the answer! As I also expected, it should be due to the performance and efficiency. However, doesn't multiplication makes it stronger in terms of security? In addition, finding the master public key based on children's public key would be easy for an attacker I suppose? He just needs to subtract a children's public key by different number (brute forcing seed size)

No, it does not add anything. There are no security properties that a multiplication gives that addition doesn't. The reasons for changing was that it 1) didn't improve anything 2) was faster 3) was easier to implement and 4) would not make people assume it has any properties it doesn't (people often assume that no inverse for EC multiplication exists, which is true, but only to solve for k in k*P = Q; solving for P is possible).

@PieterWuille can you elaborate a bit more on your last sentence? What do you mean by solving P is possible?

@abeikverdi This is getting out of scope of the original question, so I made a new question.


text:
HD wallets with an exposed child private key
HD wallets as described here are built based on a master seed and a master public key as follows:
PK.b = PK.a + sG
SK.b = SK.a + s

I just got a little confused about this. Is s the mnemonic seed that
user knows? which generates the private keys.
Secondly a service
provider only needs to know sG to calculate the user's next address.
Am I right?
And lastly more importantly I am just wondering whether it is possible to
calculate the master private key (seed) if an attacker or service provider gets one child's private key address?

The link you give doesn't define the notation PK.a and so on.

@NateEldredge precisely you can look at this link

@abeikverdi I don't see that notation on the first page of the thread you link, and I don't see it in a search of the forums.

@NickODell PK.a refers to the public key of a and SK.a refers to the private key of a. G is the generator point and s I suppose is the secret that is used to generate next keys. In HD wallets as you know we can generate new key pairs by adding the private key with a secret s. Anyone without knowing your private key by knowing a "master public key" can generate your next public key. Does this "master public key" refer to sG here?

@abeikverdi What you're saying doesn't describe BIP32. Are you asking about BIP32, or some other HD wallet system?

I was assuming that this is the description of BIP32 for HD wallets. Can you tell me at which part I'm wrong?

@NickODell Alright I found the reason for this confusion. The thing that I am referring to is currently called deterministic wallet type 2 which was proposed by Maxwell which eventually was used as the initial idea of BIP32 proposed by Pieter Wuille. It kinda makes more sense now to me.

I don't know where you found this formula, here is the code to derivate a childkey, the BIP is here, it does not look like your formula, but I'll try to respond to some of your questions.
I just got a little confused about this. Is s the mnemonic seed that user knows? which generates the private keys.

A mnemonic seed is just a sentence that permit you to get the master key with (optionally) a password. A master key is the real important piece of information, a mnemonic is only a way to generate one that can be write it down in words.
Secondly a service provider only needs to know sG to calculate the user's next address. Am I right?

Your formula does not look like what is in the BIP, so I can't really comment on that.
And lastly more importantly I am just wondering whether it is possible to calculate the master private key (seed) if an attacker or service provider gets one child's private key address?

Yes, if all the children in the path to the leaked private are non-hardened keys AND the root HD PubKey leaked. I explain that P 35 of my book.
A non-hardened key can “climb” the hierarchy.
Non-hardened key should only be used for categorizing accounts that belongs to a single control.

Thanks for your answer. I know what a mnemonic seed is. I'm not referring to the exact implementation of BIP32. Whats important for me here is that how we can generate the next public key without knowing the private key of the next public key. I am referring to this post"https://bitcointalk.org/index.php?topic=19137.msg239768#msg239768" by gmaxwell who proposed the idea of HD wallets. Thats what the formula says which I mentioned. Is that incorrect?

I've never heard about hardened keys. How can you harden it to stop people from climbing back to the root? I definitely love to read your book, but can you explain that to me in summary?

You can take a look at the implementation. The condition "(nChild >> 31) == 0" means "is non hardened".
You can see that when it is non hardened, the child key is derived from the public key, while if it hardened, it is derived from private key. This means that if it is not hardened, you can go back in the hierarchy if you know the parent public key. As I am doing here
The post on bitcointalk is outdated compared to the bip.

@NicolasDorier Actually, you didn't explain it in the book. You just stated the fact without any explanation. :-)


text:
Why does bitcoind not recognize the uncompressed version of my address?
I have an address representing a compressed public address, which bitcoind is recognizing as "ismine":
compressed_address = n2HCyN8GWPuc8CrwbiiBASCS7iWku3Ke8S
compressed_key     = 03c6debc01d8cf1c7eae826b8acb0ba6ff5d37b8d840b2bfc5244cdebab83a6781
> bitcoind  -testnet validateaddress n2HCyN8GWPuc8CrwbiiBASCS7iWku3Ke8S
{
    "isvalid" : true,
    "address" : "n2HCyN8GWPuc8CrwbiiBASCS7iWku3Ke8S",
    "ismine" : true,
    "isscript" : false,
    "pubkey" : "03c6debc01d8cf1c7eae826b8acb0ba6ff5d37b8d840b2bfc5244cdebab83a6781",
    "iscompressed" : true,
    "account" : ""
}

I extract the y value from the compressed public keys, and create an address from that (with the same function I wrote for compressed keys):
decompressed_key     = 04c6debc01d8cf1c7eae826b8acb0ba6ff5d37b8d840b2bfc5244cdebab83a6781a8b69757635c64ce32eed71115b68174d7241c716b1f76d317c6440635d8bc01
decompressed_address = mfjsW5m8CL5EazGBvjutZ4dgJwd6AjHM11

The address is valid since if satisfies the curve equation... x, y values are as follows:
x = 89951481645973345162937095289811840492311042685266238084455665220379660150657
y = 76311169247456070080081989221882104208438035444189442719121845261776897752065
y * y         = 107822876231389859288843816887520488062823501023166616425651229464214081607136
x * x * x - 7 = 107822876231389859288843816887520488062823501023166616425651229464214081607136

However, bitcoind does not recognize the decompressed address as "ismine".
> bitcoind  -testnet validateaddress mfjsW5m8CL5EazGBvjutZ4dgJwd6AjHM11
{
    "isvalid" : true,
    "address" : "mfjsW5m8CL5EazGBvjutZ4dgJwd6AjHM11",
    "ismine" : false
}

I don't understand... the only difference between the two is that one key is compressed to save 32 bytes... the private key should be the same!  Shouldn't they be interchangeable? Does this mean I won't be able to spend to spend coins send to the de/uncompressed address?

Compressed and uncompressed keys are treated completely separately. Funds sent to the compressed point address will not be available to a client that has the uncompressed key in their wallet.
That is to say, although mfjsW5m8CL5EazGBvjutZ4dgJwd6AjHM11 and n2HCyN8GWPuc8CrwbiiBASCS7iWku3Ke8S have the same private key, they are treated as completely separate to the Bitcoin network. Ideally they would be treated the same, but compressed ECDSA keys just weren't considered by Satoshi originally, it's only a more recent addition (sipa's, probably) to the client.


text:
Including transactions in a block - rules and time / technical aspect
I’ve a question regarding block and transactions included in the next block that is solved.
Let us assume theoretically that there is newly propagated solved block.
And now there are:
tx0 and tx1 – not included in propagated block with time of transaction earlier that solved block.
Tx2 – which was propagated 10 second after solving previous block
Tx3 -  which was propagated 60 second after solving previous block
Does the miners take only Tx0 and tx1, make hash and start to mine (already have hash of those) or (I presume this is not the case) are adding those tx2 and tx3 which was propagated in this “10 minute” window?
Presumably they would need to start all over again, but it would mean that when miner receive info about  new block that was solved by another miner stops working, puts all of transaction form block which he was solving, all transaction in pool (tx0 and tx1 in my example), check what transaction is already in solved block takes all reminding tx makes hash and start solving. Is that correct?
So basically my question is,  does the next block includes only those transactions that  were propagated BEFORE solving of current block and AFTER miners starting to find current block (so in this “10 minute window” or there are some other rules? I tried to find solution in docs but no success. (if anyone knows some source I would be grateful)
Best regards

There are no real rules, per se, just various optimizations.
ASICs are fast. They can burn through the entire 2^32 possible nonces for a given block in seconds, which requires miners to use the extra nonce field in the coinbase transaction to generate a new block header (since altering the coinbase transaction changes the merkle root) and try again.
This process can be done in parallel - a miner can prepare the N+1 block header by changing the extra nonce in the coinbase transaction while they are checking the Nth block header's 2^32 nonce values.
Similarly, transaction selection can also be done in parallel - a new block template can be created while a miner is operating on the previous one, and the new template's block header can simply be used when the miner swaps out the previous one after exhausting the nonce space (unless they find a valid block, in which case the template must be updated again).
This is what most mining pools do - the block template generate is done in parallel by the mining pool, and they continuously pass updated block templates to all of their miners. This allows them to quickly include high fee transactions in potential blocks while still ensuring that they are looking for a solution at all times.

There really isn't any "starting over" in mining, because mining is effectively progress free, like a lottery and unlike a race. Nothing is lost when updating the transaction list, other then the negligible amount of processing needed to make the new list and bandwidth to communicate it.
The miner will include the additional transactions whenever it gets around to it, usually within a couple seconds-- with the delay simply being batching to save bandwidth and cpu in sending out updated block data to their hardware.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How can I download the blockchain from own, trusted source?
I have two computers with two different bitcoin-qt wallets:

Very heavy-weight desktop with a great internet connection.
Less powerful laptop with relatively slow internet.

I would like to download AND validate the blockchain only on the desktop. I can trust that blockchain to contain only valid data because it actually validates the input and it is a source under my control. So I figure I don't need to do the same for the laptop. How can I syncronize the blockchain on the laptop? Could I rsync the chainstate, blocks, and database directories for instance? And then I rescan on my laptop and we should be good to go! Would this work?

I don't know, but it seems like it would be pretty easy to try. Back up your wallet.dat, of course.

You could probably have the laptop download the blockchain from the desktop (assuming you can have them on a LAN for a suitable period of time to do the transfer). I think addnode=x or connect=x are what you want, see https://en.bitcoin.it/wiki/Running_Bitcoin for commands to connect to an IP

@tim s.: But in that case the laptop will still verify and index the whole chain, which I think the asker wants to avoid.

If you copy the blocks/ and chainstate/ directory, you're good to go. Rescanning the wallet will happen automatically. The database/ directory only contains temporary data.
You should make sure to shut down the node on your desktop before copying though, or the copy may be inconsistent.

what about the /indexes folder?

Have you considered a bitcoin client that doesn't need to download the blockchain on your laptop?
https://electrum.org/
If the two computers resides on the same private network, have you tryied to use the addnode option to point to your PC private address? You could specify it via command line or via the bitcoin.conf file.
You need to try, i am not really sure if this helps, in my imagination the PC passes the already downloaded block to the laptop without downloading from the internet.

Yes, I have considered that and prefer to use bitcoin-qt.


text:
Capturing IP address of transactions submitted to Bitcoin
Dan Kaminsky has pointed out that it would be possible to build a service that tries to infer the source IP address of each Bitcoin transaction.  His idea, which he calls Blitcoin, works by maintaining connections to all nodes in the peer-to-peer network and noting the IP address of the first node to report the transaction.  This won't always be the IP address of the source of the transaction (for instance, there are a number of ways to hide one's IP address), but sometimes it might be.
Has anyone built such a service?  How often does it work, in practice?  Are there any commercially available services that have maintained past archives of this information?

So a node that creates a transaction needs to propagate it. It will connect to other nodes. Usually to some reasonable number like 8 nodes (please see getpeerinfo on your client).
As a mental exercise: If the 8 nodes (that I randomly selected from the network) belong to the same person, that person will have the possibility to capture 100% of my traffic. My IP address will be known, but also there could be a selective attack that prevents my transaction from being broadcasted (i.e. he/she decides to drop it based on my sending bitcoin address).
The more nodes the attacker has, the more chances to have all outgoing connections from the victims plus the possibility to do data analysis. Also more chances of dropping (selected or random) transactions.
I don't know the economics behind an attack of this nature. Buying 5000 VMs to run nodes could cost a lot.
Examples are out there that they ask for bitcoin to set up full nodes, like https://classic-cloud.net/ [1]. as 2016-04-01 they have 810 nodes running. So you can imagine that they could be able to track some transactions to IPaddress.
Edit: [1] as of 2019-05-17 this is not longer a page that has stats about nodes, but rather a blog.

This secure, private, untraceable C++ implementation of the I2P anonymous network being developed for Monero could eventually be of use for Bitcoin too. It will address the IP address issue you are asking about.
Metadata related privacy issues continue to be researched both by those who want to perform blockchain analysis and those who want to protect the privacy of users
https://github.com/monero-project/kovri
Why I2P over Tor?
https://www.reddit.com/r/Monero/comments/2ti53m/why_is_monero_aiming_to_integrate_i2p/

Thank you for your contribution, but this doesn't appear to answer the question that was asked.  The question was "Has anyone built such a service?"  It wasn't "Is there some other protocol that doesn't have this problem?".  Please reserve the answer box for material that answers the question that was asked.  We are a question-and-answer site, not a discussion forum, so we expect answers to answer the question, not to be merely discussion of related topics.  Thank you!


text:
Conditional based Crypto based on Smart Contracts
Is it possible to store an encrypted message in the blockchain that reveals itself only when a particular condition is met?
I think that the conditional disclosure can be done with Smart Contracts, but I don’t know if it would be securely encrypted until the condition to disclosure is met.

Yes, but with some very strict limitations.

You can store encrypted data in the block chain.  This is expensive, hard, and strongly discouraged, but it is possible to place the encrypted data in nulldata (OP_RETURN) transactions.  Each standard OP_RETURN output is limited to an 80 byte payload, so you'll probably need to use multiple outputs which will require multiple transactions unless you have the help of a miner.
A later transaction can publicly disclose the key to the encrypted data.  You can use a smart contract (specifically a hashlock) to pay someone to release the key.  A clever use of cryptography may be able to restrict them from releasing the keys except under certain circumstances; for example Peter Todd's timelocks can restrict the public release of the key by number of CPU hours spent generating the decryption key.

The essential piece of information here is that you can't make the key release mechanism part of a smart contract because the key would need to be public.  At best you can only use a smart contract to incentivize someone who already has a key (or the ability to regenerate a key) to publicly release that key when the incentives are worth it.
With that said, it's probably much better in most cases to put your encrypted data in a torrent file rather than the block chain, and at most use a Bitcoin hashlock to incentivize anyone with the decryption key to release it.  (It'd be nice if you also made the hashlock an anyone-can-spend after an expiration time so that it wouldn't bloat the UTXO set forever if the decryption key was permanently lost.)

No, you can't.
There is no secret information anywhere in a blockchain. It is exactly the log of all information the public has to verify correctness of the system.

authors: Олег Кропивницький


text:
Transaction input bigger than output
Yesterday I made a transaction from my one btc address to another by using pybitcointools library for blockchain api. I made a mistake by making input value 10x times higher than output value.
So I have a quesiton: Is that input minus output value treated as fee now, or can I restore it back in some way ?
Here is link transaction history ( only 1 transaction ) where you can see what's going on : https://blockchain.info/address/1Fno6XBjLbEq53oTG6MWw1X1vA2hbyaLPh?format=json
and here is transaction's blockchain link:
https://blockchain.info/tx/d80feae624c18067044e1bca0917bdb0c42f81ff1e7b9b2febacfced1ed7f691

Yes, the difference between the input and the output is the transaction fee, and there's no way for you to get it back once it has been mined (except for building a fork that results in a stronger chain---not likely unless you have >50% of network hash rate).
In the future, I highly recommend experimenting on testnet (bitcoind -testnet) or using regtest mode.  That way you don't lose any wealth when you make a mistake.

I believe some people have had their excessive txn fees refunded my mining pools on rare occasions


text:
Is there an easy way to consolidate Dust Microtransactions
I just found out today that all those websites I go to to earn like .0000087 for clicking around here and there have now in a way corrupted my wallet as yesterday I deposited 50$ into my wallet and when I try to transfer it to make a payment to another wallet, no matter what I get transaction fees. How can I clean my wallet of this dust. I know there is a program out there that claims to rid yourself of this dust, but there is no real directions on how to use it.
My question is three parts

Is there a client/wallet that allows you to transfer out of certain incoming transactions?
Is there an easy way to clean the wallet now that it has this dust?
If I transfer everything in the wallet will it clean the wallet? And if so does the wallet I transferred to now have the issue with the dust, does the dust transfer?

Let's take a step back and define dust: dust is an transaction output with a very low value.  When creating an input to a new transaction that spends that output, you have to use 36 bytes to reference it (the outpoint), about 72 bytes for the signature, either 65 or 33 bytes for the public key (depending on whether it was compressed, plus about 10 more bytes for other things.  Let's round it to 150 bytes.
Transaction fees are usually computed per kilobyte, so if you pay 0.0001 BTC per kB, dust is not worth spending if its worth less than 0.0000015 BTC.  Hopefully, defining all this will make the following answers a bit more clear.

Bitcoin Core's "raw" RPCs let you choose what outputs to spend.  You'll typically run listtransactions to get outputs available to your wallet, createrawtransaction to create a transaction spending specific outputs, signrawtransaction to sign the transaction, and sendrawtransaction to broadcast the transaction to the network.  If you do this, you want to be very careful---once a transaction has been broadcast, it's very difficult to change any mistakes in it.
As you alluded to in your question, Peter Todd's dust-b-gone will purge a Bitcoin Core wallet of dust transactions by giving them to someone else (Todd, I think, but it could go to 100% transaction fees---either way, nobody is getting rich off dust).  I haven't used it, but the instructions look simple.
Yes, if you transfer everything in the wallet, the dust will be gone.  That's because dust is an output from a previous transaction---once you use that output as an input in a new transaction, all that matters is the value of the output in that new transaction.

Although I've never used Bitcoin Core with dust, it's likely to be the smartest Bitcoin wallet about keeping dust-related transaction fees low---so if you want an easy graphical solution, I suggest just using Bitcoin-Qt.


text:
What programming language should I learn to create a new altcoin?
I've been wondering. What programming language is needed to develop and maintain an altcoin? Because I've been thinking to try creating my own altcoin.
I've seen a lot of services to develop an altcoin for certain amount of money. I could pay for it, but I prefer not to since it would be boring as hell to just do that and there's simply nothing that I can be proud of.
I've seen a step by step guide, forking from Litecoin. But I kinda want to do it blindly. (Meaning doing something that I don't understand at all).
I've learned Java and VB but I don't think it's even used a single bit in Cryptocurrency.

Never roll your own cryptography unless you have at least a PhD in math and computer science. When you try to develop your own cryptocurrency from scratch, you will likely build something which seems perfectly secure from your perspective but will quickly fall apart in the real world. Then you will have to deal with people who lost real-world money because of it. Are you prepared for that?

Some of us just want to make an altcoin to learn underlying principles better, at least thats my use case @Philipp. Can't speak for OP, but as for my case I just want to learn.

You can use any programming language you want, as long as it allows you to build applications which run on most computers, perform advanced mathematical operations, make network connections to any other IP address and build graphical user interfaces.
Which one you pick should depend on what languages you are proficient with.
Java or Visual Basic would not be my first choice for such a project, but I see no reason why it would not be possible to implement a cryptocurrency with either.

C, C++, Python, Java, QT, PHP, JS, and everything networking admin (apache, tomcat, node, whatever other server of your choice and network security/show stoppers for each)
Oh and SSL in whatever language variation of your choice.

Your answer doesn't make clear if one should know all of these technologies or one of these technologies. I also wonder why you are mixing web technologies with technologies for developing binary applications. Bitcoin started as a binary application and the core of it still is. The web-based ecosystem around it developed later.

And why SSL? SSL is based on certificate authorities. Cryptocurrencies are usually decentralized without central authorities. I think what you actually mean is SSH. Or rather a solid knowledge of public key cryptography in general.

Well, you can learn languages that can interface with your bitcoin/altcoin daemon or make a new server that latches onto the coin server.  And I mix the web technologies around because coins need apps, pools, charting tech, and all sorts of services that revolve around these network use cases.  SSH is cool, but I meant SSL.  SSL is used for the key creation/signature methods (or for straight SSL comm. for your web), & I know not all languages implement the same version of TLS and sometimes there are compatibility issues.  I bring up all these things so that programmers are cognizant of it all.

The most likely you followed this link to create an altcoin.
If you feel that C++ is a bit cumbersome, then I would try Python.


text:
How does ShapeShift operate on 0-1 confirmations
ShapeShift can exchange user's crypto currency almost instantly. They state that most transactions don't require any confirmations:

Small deposits are processed with zero confirmations. Larger deposits wait for at least 1 confirmation.

How can they do this and cover themselves from double-spending?

They're not saying that larger deposits will take 1 confirmation. They're saying that they will take at least 1 confirmation.

How can they do this and cover themselves from double-spending?

Sure, doing this increases the risks of double-spending. However, that might be an acceptable risk. They may have done the math and figured that the additional business they get is worth it.
They might be doing it to distinguish themselves from the bajillion other exchanges out there.
Also, they're charging a fee of 3.7%.
Edit: Clarification

With ShapeShift, what you see is what you get. The exchange rate shown is exactly what you'll receive, minus only the "miner fee."
There is no exchange fee, or service fee.

This is true, but the spread is noticeably higher than on other sites.
I arrived at 3.7% by taking the BTC -> LTC exchange rate and comparing it to the LTC -> BTC exchange rate.
1.00 BTC = 137.1636 LTC
1.00 LTC = 0.00685688 BTC

If you multiply 137.1636 and 0.00685688, you get 0.9405. This means that if you exchanged 1 Bitcoin for Litecoins and back, you would have 0.9405 Bitcoins left. (Ignoring transaction fees.) This is a change of 5.95%. Divide that by two, because you'd only exchange once.
This gets you 3.0%, which is different from my original calculation because the prices on ShapeShift have changed since then.
So there is a fee, but it's baked into the price they show you. On the other hand, if you're exchanging less than 0.33 BTC, the fee is lower than what BTC-E would charge you.

The important point is that there is no fixed fee. The difference between our price and a price at a different exchange is variable and based on the specifics of that transaction.

The answer above is correct, however, the 3.7% fee is incorrect. You can read about our fees on the site on our about section. Just scroll down to the bottom of the page. Let us know if you have any questions!

Saying "there is no exchange fee, or service fee" is highly misleading, borderline fraudulent. If there is a non-zero spread, there is a fee.

The important point is that there is no fixed fee. The difference between our price and a price at a different exchange is variable and based on the specifics of that transaction.

Please feel free to email us with any questions you have about the details of our fee system. The instant rate that people see at the top of the screen is exactly what they will get minus miner fee. To make sure there is no slippage, we do go down the spread in order to offer that one fee and we get a very small percentage from this. But the fee you see when you purchase is what you see is what you get. Email mail@shapeShift.io if you would like to discuss further or leave another comment here! We are happy to disclose!

You should report the spread up front so people aren't tricked into thinking this is some sort of "for the good of all" cryptocharity. 2. If I don't need my exchange until 1 or 2 conf's - then I'd like a reduced spread. (Get a better rate for longer wait times.)


text:
How do you determine 'magic byte' or version for alt coins?
I'm looking at creating a deterministic wallet for some of the less popular altcoins. Bitcoin has a magic byte of '0488b21e' and litecoin '019da462'. How are these determined or calculated? Also how would I generate these values for other altcoins?

Note that the 'version byte' is different from the private key prefix. https://en.bitcoin.it/wiki/List_of_address_prefixes

Late response I realize, but see here: https://bitcoin.stackexchange.com/questions/28380/i-want-to-generate-a-bip32-version-number-for-namecoin-and-other-altcoins/56639#56639


text:
Bitcoind JSON/RPC extremely slow under load
I am data mining the blockchain using JSON/RPC on a bitcoind full node with txindex (0.9.1).
I have 64 RPC connections simultaneously going to bitcoind from a remote client. My workload is mostly getrawtransaction and decoderawtransaction. I have bumped rpcthreads to 64.
What I am observing though is that bitcoind is taking a very large amount of time (from 30 seconds to 2-3 minutes) to respond to each call.
I have verified that there are about 66 connections opened on the RPC port, and the bitcoind process has 73 threads, so that seems to confirm that both my load and the rpcthreads setting are correct.
If I query something like "help", I get the same slow response time, so it seems to be related to the RPC server rather than actually accessing the data from disk/memory.
Am I missing a setting to make it scale?

What is the cpu load on the server? How about the memory usage; are you swapping? Bitcoind is not particularly optimized for performance so it's conceivable that it is just that slow.

CPU is ok, but the memory usage is high, I see quite a bit of swapping. I will allocate more RAM to the machine and see if that makes a difference.

When you have a use case that is very different from what everyone else uses a piece of software for, it's not unusual to see pathological performance behavior. You may want to profile the running instance and see if there's any obvious optimizations that help with your particular use case.

Bitcoind can be quite memory hungry and bandwidth hungry. If you're swapping a lot, definitely add more memory.
You may also consider using an external API like:
http://dev.blockcypher.com/#blockchain-api
Bitcoind itself is actually quite hard to scale out.


text:
Salvaging an old, incompatible wallet with bitcoind
I have an old wallet, created with a very old version of bitcoind, which I'm trying to access once again. I'm trying to understand the various issues that might be preventing me from seeing any balance, currently. I put the various questions I encountered in bold, below.
My plan was to access the old wallet using the old build of bitcoind, then run dumpwallet to get the private keys exported, and re-import those keys to a new wallet on a plain, modern build of the software.
Does this sound like a feasible plan? Is there any information that is lost, when going through dumpwallet as I describe? Will it still see every transaction that occurred and be able to do everything I could with the old wallet?
Some relevant tidbits:

The bitcoind binary that created this wallet was compiled with --with-incompatible-bdb. It is bdb5, I believe. If I want to run a more modern binary, I will have to compile it with that flag too, right? There's no way to 'downgrade' from 5 to 4.8 (which is the default, I believe), as I understand it? This is my main reason for trying to go through the dumpwallet approach.

So far, I have run the old code, with the old wallet, but it is showing a balance of "0.000..." and "txcount:0", even after the block chain is fully downloaded, and even after doing -rescan on the wallet. I'm trying to figure out what the problem is, here.

There have been a few transactions on the wallet, over the years. Probably via different builds of bitcoind (I forget, exactly).

There have been a few splits and many upgrades to bitcoin and I have not followed that stuff in detail. Could they explain why I am seeing "0.000..."? Maybe my old client is communicating with a new network and some information is lost, somehow?

Edit: The accepted answer got me on the right track; I was not getting the right wallet loaded.
The error messages from a modern build of bitcoind are much more useful than the old version I was using. Using -wallet=filename.dat was actually creating an empty wallet of that name, not using the one in the current directory. I had to make sure to copy the file to the $HOME/.bitcoin/ directory, first.

@Prayank What info is in the metadata?

You should be able to load the wallet directly into a recent version of Bitcoin Core and it should load just fine. Compatibility has been maintained.

Does this sound like a feasible plan? Is there any information that is lost, when going throuigh dumpwallet as I describe? Will it still see every transaction that occurred and be able to do everything I could with the old wallet?

You will lose all transaction data and any metadata like accounts (now referred to as labels and has a slightly different meaning) and key birth times.

The bitcoind binary that created this wallet was compiled with --with-incompatible-bdb. It is bdb5, I believe. If I want to run a more modern binary, I will have to compile it with that flag too, right? There's no way to 'downgrade' from 5 to 4.8 (which is the default, I believe), as I understand it? This is my main reason for trying to go through the dumpwallet approach.

Actually you don't. The wallet.dat file itself is compatible, it's some other temp files surrounding it that are not. However if you cleanly shutdown bitcoind, then those files will be cleaned up and everything consolidated into the wallet.dat file. It can be opened in a release version of Bitcoin Core. A clean shutdown means that the wallet.dat file will be portable, so if you are concerned that the other incompatible temp files remain, you can just keep the wallet.dat file and everything will be fine.
In any case, you can just try with a copy of the wallet file. If it is incompatible, you will just get an error saying so. Nothing is written if it can't be opened.

So far, I have run the old code, with the old wallet, but it is showing a balance of "0.000..." and "txcount:0", even after the block chain is fully downloaded, and even after doing -rescan on the wallet. I'm trying to figure out what the problem is, here.

It is possible that you are not actually using the wallet that you think you are. For a long time Bitcoin Core would always create a new wallet if one did not exist. This would often result in people thinking they have restored their wallet (because a wallet was loaded) when in fact a new one was generated. This may be what is happening here.
Or maybe the wallet file just doesn't have anything in it.

There have been a few splits and many upgrades to bitcoin and I have not followed that stuff in detail. Could they explain why I am seeing "0.000..."? Maybe my old client is communicating with a new network and some information is lost, somehow?

No. Any transactions that exist before any splits would still be in the wallet. Furthermore, any transactions that are no longer in the blockchain would still appear because they are stored in your wallet. They would just appear as being unconfirmed or conflicted. That nothing appears indicates the wallet file contains nothing.

Thanks for the info. Regarding "not actually using the wallet that you think you are": I am using bitcoind -wallet xxx.dat ... to run the program (it is v0.15.1). Should that properly get it loaded, or is there something else you are referring to? Also: you say a (properly shut-down) bdb5 wallet should be compatible with a recent release version; but I thought the default was bdb4.8? Are you saying a bdb5 wallet be loaded with bdb4.8?

The correct syntax is -wallet=<wallet name> and the wallet needs to be in the data directory. The only way to be absolutely sure that a new wallet isn't being created is to not use a version that makes new wallets when one doesn't exist. bdb5 and bdb4.8 use the same data format. Only the temp files format changed to be incompatible. So you can use the wallet.dat file created with bdb5 in a version built with bdb4.8.

Got it working; thank you again for the help. The old bitcoind was taking -wallet=foo.dat and creating an empty wallet of that name (I had foo.dat in the local directory, rather than copied into ~/.bitcoin/... as I should have). Still using bdb5, but I assume that's not actually necessary, from what you said.

Yeah it show error some time but you can use pywallet.py to retrieve your privatekey easily. If you don't know how use it search on google pywallet.py you need Python2.7 or 3.9


text:
Why are r and s modulo N? (not P)
As Peter Wuille mentions here, the ECDSA signature values (r, s) are modulo N (eg verifying ECDSA signatures, where u1 = z * w % N), whereas the rest of the ECDSA functionality in Bitcoin seems to be modulo P.
Why is this so?

You should probably update your question to accurately state what Pieter Wuille said. His comment does not say that r, and s are modulo P, he specifically says: r and s in the signature however are modulo n, the group order.

I'll take a look now. I must've misspoke or misunderstood what he said

Good question! There are two concepts here. The finite field Fp, and the EC Group defined by secp256k1.
In Fp, elements are just numbers modulo p. Addition, Subtraction, Multiplication, and Division are all defined for this finite field.
In the EC Group, however, each element is a pair of elements in Fp, such as (f1, f2). You can add and subtract these pairs to get different pairs, but the addition and subtraction has little to do with the addition and subtraction of elements of Fp (technically it uses those operations under the hood, but it's not direct addition. That would be pretty boring if (f1, f2) + (g1, g2) just gave you (f1+g1, f2+g2)).
Also note that since these pairs are a mathematical Group, rather than a field, there's no way to multiply two pairs. You may have seen the syntax k*G before, but this is just shorthand for adding G to itself k times, k is an integer rather than another element of the EC Group defined by secp256k1.
Additionally, if you look at the ECDSA algorithm, you will see that here the final elements are (r, s), but just because it is a pair does not mean it is a pair that lives on the secp256k1 curve! This is a pair of integers mod n (the curve order), as defined by the algorithm, not a point on the curve.

but just because it is a pair does not mean it is a pair that lives on the secp256k1 curve! ! indeed! I was going to ask this question now, actually: see I was thinking that r,s was the x,y point on the curve: I actually was great at math but this stuff is so different from the algebra/calculus I was good with.

The premise of your question is wrong.  In fact, Pieter said the opposite:

X and Y coordinates are numbers modulo p, the field size, which is around 2^256 - 2^32 for secp256k1. The value r and s in the signature however are modulo n, the group order, which is around 2^256 - 2^128.

If things still aren't making sense to you, I would recommend reading the Wikipedia ECDSA article and SEC1, and then asking a new, clearer question.  It would be nice if your question included a brief definition of every number you are talking about (like Pieter's comment did) so we can make sure we are all talking about the same things.
The Wikipedia article has a short section explaining the correctness of the algorithm, and you would probably see that the math doesn't work if you try to change the way the signature is generated.
Also, I have written an implementation of ECDSA in Ruby that should be pretty easy to read and modify if you want to try out your ideas.
Alternative answer assuming you switched P and N in your question
However, if I assume that you just accidentally switched P and N in your question, then my answer would be:
N is defined to be the the order of the secp256k1 group.  So it is the number of distinct points in the group, including the infinity point.  When you have a number like r or s that is between 0 and N - 1, it is actually the index of a particular point on the curve.  It's like a private key (which are between 1 and  N - 1), because you can use that number to generate secp256k1 point.  The secp256k1 group is isomorphic to the group of integers modulo N: adding two such integers is equivalent to adding their corresponding secp256k1 points.  The number 0 is equivalent to the infinity point.
So that should explain why it might be useful to have numbers in the algorithm that are between 0 and N - 1.  We use the modulus operator to convert arbitrary integers to that range.
Of course, this doesn't explain why r and s in particular are modulo N, but if you work through the math in the "Correctness of the Algorithm Section" of the Wikipedia ECDSA article you would probably see that the math doesn't work if you change the way the signature is generated.

Thanks mate, yeah, there was definite confusion on my part. I've edited the question title/content to reflect my intention, to wit, reversal p / n


text:
Signing a raw transaction with Python ECDSA (or OpenSSL)
I'm looking for specifics of Step15-17 from Redeeming a raw Tx Step By Step, which is essentially the step where the concatenated raw Tx structure is double sha256 hashed, and then signed with an ECDSA library. I've also referred to other raw transactions guides; I'm looking specifically how to sign a raw hex Tx structure without a GUI/website/etc
I've constructed a testnet Tx using Bitcoincore v0.10 (a full node) and attempted the same with Python and cannot correctly sign the raw Tx structure using Python ecdsa.

TxID: 72b764383b99fb3d112ac8b474a5d7c4242b75dbfee2d4e9cf9a6703d90f805a
vout: 1
To: n1hjyVvYQPQtejJcANd5ZJM5rmxHCCgWL7
Amount: 0.990 BTC

I'll show the Bitcoincore commands first:
importprivkey 93FxXUeMJp93YQAtGeW5cE23gFN4sJbBr1RBmerLFVUDuqQqKL5
mu858WTEPiWWpAJRTMxC4ka6DJqiaCZiSB
createrawtransaction '[{"txid" : "72b764383b99fb3d112ac8b474a5d7c4242b75dbfee2d4e9cf9a6703d90f805a", "vout" : 1}]' '{"n1hjyVvYQPQtejJcANd5ZJM5rmxHCCgWL7" : 0.990}'
signrawtransaction 01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b7720000000000ffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac00000000

Final bitcoincore hex Tx (using signrawtransaction):
 01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b772010000008a47304402204d78d2e6c0f801573e4960fb8e51ad939380d119d25f97d15efdedf815b05f02022066bd2ab0b401e32e7ce67ea45f8224097eeafbef2335d563776e5efe6632732d01410479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1ffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac00000000
Now the Python 2.7.9 code follows (FYI, using iPython 2.0 so there's boilerplate missing in the following code) :
# please excuse the hexlify/unhexlify, I work better in strings than bytes
import __future__
from pybitcointools import sha256
import hashlib, ecdsa
from ecdsa import SigningKey, SECP256k1
addr, pubkey = 'mu858WTEPiWWpAJRTMxC4ka6DJqiaCZiSB', '0479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1'
rawtx = '01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b7720100000000ffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac00000000' # TX structure with 00 as scriptSig, from bitcoincore createrawtransaction
# replacing the '00' scriptSig value
unsigned.append(rawtx[:82])
unsigned.append('19'+'76a914953de657be4b305f606d9a9fbd35b070a682475788ac') # scriptSig = scriptPubKey input
unsigned.append(rawtx[84:])
unsigned.append('01000000')  # appending sighash_all
unsigned = ''.join(unsigned)

unsigned = '01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b772010000001976a914953de657be4b305f606d9a9fbd35b070a682475788acffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac0000000001000000'

# See https://github.com/warner/python-ecdsa/blob/master/README.md
sig1 = sk.sign(sha256(sha256(unsigned)), hashfunc=hashlib.sha256, sigencode=ecdsa.util.sigencode_der) # note this references 2 different sha256 functions
sig2 = [hex(len(sig1 + '\x01'))[2:], hexlify(sig1), hexlify('\x01'), hex(len(unhexlify(pubkey)))[2:], pubkey]
sig2
>>> ['48',  '304502200e98d54ad642488121fa1fd4d055ff8f5b40773a21ecb42b5ef44ed9fd3b103c022100a2a56ffc3f27021a4be5d1d7a3016eff08fe7f550a4a894cca845ceab54dc53b', '01', '41', '0479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1']
sig2 = len(''.join(map(unhexlify, sig2)))
hex(len(''.join(map(unhexlify, sig2))))[2:]
>>> '8b'  # push 139 bytes
sig3
>>> 8b48304502200e98d54ad642488121fa1fd4d055ff8f5b40773a21ecb42b5ef44ed9fd3b103c022100a2a56ffc3f27021a4be5d1d7a3016eff08fe7f550a4a894cca845ceab54dc53b01410479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1
signed = unsigned[:82] + sig3 + unsigned[84:]  # inserting the signature into the 00 the core software uses in place of ScriptSig

Final (invalid) Python Tx:
01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b772010000008b48304502200e98d54ad642488121fa1fd4d055ff8f5b40773a21ecb42b5ef44ed9fd3b103c022100a2a56ffc3f27021a4be5d1d7a3016eff08fe7f550a4a894cca845ceab54dc53b01410479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1ffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac00000000
Sending the Python generated Tx does not work. If I sendrawtransaction <PYTHON HEX> in Bitcoincore it returns an invalid signature error (Specifically, 16: mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element) (code -26)).
(TL;DR) QUESTION: Where am I going wrong in signing the raw transaction structure manually?
NB: I am aware pybitcointools and related libraries can sign Txs, but I am looking for specifics, as even these two very thorough Bitcoin SE resources (LINK1, LINK2) brush past the details. I'd prefer an answer for Python ECDSA or PyCrypto, however OpenSSL I suppose is the next best answer.

I've debugged this for the last two hours or so but haven't been able to find any errors. Sorry, I can't find anything wrong, and every time I try to submit a transaction it has error code -25. I've even verified that the hash being signed is the same one that the daemon signs through print lines in my compiled daemon. You can see my debugging file here, in case it helps you.

I see now that that transaction output has already been spent. Does this mean you successfully found your error? If so, you should post it!

@StephenM347 Yes! I'll add the code. The problem was the code for ECDSA

@StephenM347 See the answer below but the issue seemed to arise from using the public key in signing and a disparity between string/bytes/DER input

OK, I figured out how to sign the raw Tx using Python ecdsa. I'll step through it:
Recall:
createrawtransaction '[{"txid" : "72b764383b99fb3d112ac8b474a5d7c4242b75dbfee2d4e9cf9a6703d90f805a", "vout" : 1}]' '{"n2kx7k6JuA5Wy27fawaeiPX7dq8mbRDPAv" : 0.99}' =
01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b7720100000000ffffffff01c09ee605000000001976a914e900510876cb689f1db6fa982376c301362b740c88ac00000000
And then adding in the scriptPubKey for scriptSig's 00:
unsigned = '01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b772010000001976a914953de657be4b305f606d9a9fbd35b070a682475788acffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac0000000001000000'
Note unsigned has the 01000000 appended because the SIGNHASH is 01 (which will also be appended to the DER signature in a minute)
So, we double SHA256 bytes and return txhash as bytes:
txhash = hashlib.sha256(hashlib.sha256(unsigned.decode('hex')).digest()).digest()
We also need the privkey for mu858WTEPiWWpAJRTMxC4ka6DJqiaCZiSB (in secret exponent form, ie hex):
privkey = 'dc57c6d067376c36bbed632c9d00f03767867f337d5a86b5b0308a60004f08ee'.zfill(64)
privkey = 'dc57c6d067376c36bbed632c9d00f03767867f337d5a86b5b0308a60004f08ee'
Now, we sign using this corrected code:
signingkey = ecdsa.SigningKey.from_string(privkey.decode('hex'), curve=ecdsa.SECP256k1)
SIG = signingkey.sign_digest(txhash, sigencode=ecdsa.util.sigencode_der) +'01'.decode('hex')

This is working code. From here on in, we're simply making the signature:
ScriptSig = <varint of total sig length> <SIG from code, including appended 01 SIGNHASH> <length of pubkey (0x21 or 0x41)> <pubkey>
where pubkey = '0479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1
Giving us a valid signed Tx without using bitcoincore:
01000000015a800fd903679acfe9d4e2fedb752b24c4d7a574b4c82a113dfb993b3864b772010000008a47304402204d78d2e6c0f801573e4960fb8e51ad939380d119d25f97d15efdedf815b05f02022066bd2ab0b401e32e7ce67ea45f8224097eeafbef2335d563776e5efe6632732d01410479b22a5127d176a49d506c86f791031f94a389227ef46a8ddb725a88c944c37e3f753de6ee0b441a0237801f140810e111a1fd8276a2a5d0ee07224a1b551cc1ffffffff01c09ee605000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac00000000

Thank you very much!!! Took a bit of figuring out but your tips helped a lot.

That ecdsa signing code often returns 'Non-canonical signature: High S Value' that are now non-standard. Any ideas of how can this be solved?

@NathanParker SIG is <r><s> concatenated together. We need to check s < N/2 where N is the curve order, 115792089237316195423570985008687907852837564279074904382605163141518161494337. If s>N/2, then s = N-s

@NathanParker to use Python-ECDSA, replace sigencode=ecdsa.util.sigencode_der with sigencode=ecdsa.util.sigencode_der_canonize

I would have never guessed it was so incredibly easy. Thanks!


text:
Why does transaction activity show on the blockchain for my Bitcoin address at my hosted (shared) E-Wallet service?
I have an online wallet at localbitcoins.com (address 12pHFR5yv2KGqck5N8teb5MgoRtzAgLRn2).
I made three transfers to it, for a total of 0.5 BTC + 0.5 BTC + 0.3031 BTC = 1.3031 BTC.
Blockchain.info did show my address receiving coins. However, it is showing my address sending coins to several addresses after receiving them https://blockchain.info/address/12pHFR5yv2KGqck5N8teb5MgoRtzAgLRn2:

Is someone using my online wallet at localbitcoins.com to withdraw money?

Does localbitcoins or wherever you sent the coins from use a mixing (anonymizer) service or shared-send ?  You'd generally see something like that in that scenario.

@NeilNeyman, not sure about their implementation. I sent from MtGox to LocalBitcoins.

You do not have a Bitcoin wallet at LocalBitcoins.  Instead you have only a ledger account with their hosted (shared) Bitcoin E-Wallet.
What this means is that you cannot use the blockchain to track your balance.  You can only use it to determine how many confirmations your transfer (deposit) has received.
The E-Wallet provider simply credits your account when they see a confirmed deposit transaction (e.g., 6 block confirmations) to a Bitcoin address associated with your E-Wallet account.
To know your balance, you will need to login to your E-Wallet account on LocalBitcoins.  That will show you your balance.  The account details will show deposits, withdrawals, purchases and sales.

Probably not. Most online wallets don't hold your bitcoins against the receiving address for your wallet; instead they transfer them to a central wallet and keep a record of your balance.
When you want to spend from your wallet, they make a transaction from their centralised wallet to your desired sending address, and adjust your balance accordingly.
This method of providing an online wallet has the advantage that they can reduce transaction fees (they can spend their oldest bitcoins first, and consolidate appropriately sized inputs for your desired transaction output), but also some disadvantages such as that you don't get to hold the private key for your receiving address (and thus can't retrieve your bitcoins without them).

Hmm, why does blockchain.info sometime show multiple addresses in a single transaction to a single address as in https://blockchain.info/address/1LbAh4zeHSt68zzdoqH6J9EbctQc1Q3aVS showing 4 addresses sending 0.3 coins to an address. What does it mean?

I'm not sure; perhaps this could be asked as a separate question?

@Pacerier Bitcoin transactions pull in funds from one or more sources and pay out to one or more sources.

@DavidSchwartz, If that's the case, then wouldn't the balance not be tallied?

@Pacerier I don't know what balance you're talking about or what you mean by "tallied".

@DavidSchwartz, If I want to send from A to B and money goes to B from A and C.... wouldn't that means C is losing money?

@Pacerier I don't know what A, B, and C are here. Are they people? Addresses? Accounts? Perhaps you're incorrectly assuming a one-to-one relationship between accounts and addresses? Generally, addresses are managed as a pool shared by all accounts.


text:
Why might MultiBit not show a transaction that was sent to me?
So i recently bought a bitcoin from a vendor , and i had it sent to my Address in multibit.
Now the problem is , the money isn't there and i'm not sure what to do.
He told me to get bitcoin (program) and now it's starting to download a chain. Currently it's at 95000.
I'm not sure what to do exactly , as i'm worried i may have lost my funds.
What can i do at this point? Do i wait till the Blockchain is finished or should i import my wallet from Multibit to Bitcoin?
Thanks guys!
-D

PS. If you're worried that the merchant scammed you, you can put your bitcoin address into this website and it will tell you how much your address really holds.

You can ask the vendor for the transaction id of the transaction they sent you. Look it up on http://blockchain.info to check it exists and is sending bitcoin to your receiving address. Look at the date of the transaction. Go into MultiBit, select your wallet and do a 'Tools | Reset blockchain and transactions' and reset from the day before the transaction. Once it has resynced to the network you should see it in MultiBit.

@jim618 that would probably be the accepted answer (to the revised question title) if you were to add it as one.

Good job marking it as a duplicate of "before properly synced" when the asker didn't mention that symptom. Heck, the "duplicate" doesn't even mention MultiBit! Over-zealous duplicate marking is annoying.

Actual answer: because of a bug in MultiBit. You need to "Reset Blockchain and Transactions" for the transaction to appear.

You can ask the vendor for the transaction id of the transaction where they sent the bitcoin to you. Look it up on https://blockchain.info to check it exists and is sending bitcoin to your receiving address correctly. Look at the date of the transaction. Go into MultiBit, select your wallet and choose the menu option 'Tools | Reset blockchain and transactions'. Reset from the day before the transaction. Once it has resynced to the network you should see it in MultiBit.