Bitcoin Forum
March 29, 2024, 12:19:05 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Getting unspent outs for arbitrary addresses from BlockExplorer. (Bounty 20BTC)  (Read 8631 times)
dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 03, 2011, 05:25:39 PM
Last edit: November 08, 2011, 09:46:19 AM by dogisland
 #1

Update: I've added a 20 BTC bounty for the creation of an offline HTML page that creates an address transaction using Javascript.

The Bounty has been claimed.

I want to get a sanity check on something I'm currently working on. At the moment StrongCoin uses BitcoinJS and the BitcoinJS exit node to generate transactions for arbitrary addresses.

The standard bitcoin client already knows what addresses it's looking out for so it doesn't need to go back through the blockchian to collect unspent transaction outs. It just maintains a list of unspent outs as the blocks arrive.

However with StrongCoin you can import a key at any time so I need the ability to get the unspent transaction outs form the past so to speak.

Take this block explorer API call for example http://blockexplorer.com/q/mytransactions/1PurtonoEouSwXZXZqddxWgeLTRJynr51A

Is there enough information in the q/mytransactions call to calculate the unspent outs ?

Has anyone use blockexplorer this way to get at that information ?

If blockexplorer does provide enough information in that call then I reckon it wouldn't be too difficult to knock up a web page (html page) that people could use offline.

i.e.

1. The page would take the BlockExplorer JSON from a q/mytransactions query in a text area. (You could copy it over on a USB).
2. A text area for your private key in hex.
3. A submit button that then uses Javascript to create a Bitcoin transaction (in hex). (BitcoinJS has code for this).
4. This transaction could then be carried over to an online machine and broadcasted.

20 BTC to the first person to implement this. The 20 BTC will be paid through with a transaction created with the page.

So the solution would be 1 html page then a number of JS files (i.e. BitcoinJS etc) that the page links to. This must work with no network connection.
Each block is stacked on top of the previous one. Adding another block to the top makes all lower blocks more difficult to remove: there is more "weight" above each block. A transaction in a block 6 blocks deep (6 confirmations) will be very difficult to remove.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5152
Merit: 12580


View Profile
November 03, 2011, 06:05:39 PM
 #2

I designed /q/mytransactions for things like that. It has all the information you need to do that, assuming your client only sends and receives address transactions. That page doesn't show non-address transactions.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 03, 2011, 06:28:50 PM
 #3

I designed /q/mytransactions for things like that. It has all the information you need to do that, assuming your client only sends and receives address transactions. That page doesn't show non-address transactions.

Thanks. In that case I've added a bounty to see if anyone wants to implement this.
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 03, 2011, 06:36:03 PM
Last edit: November 03, 2011, 11:39:01 PM by BTCurious
 #4

I will work on this, it seems perfectly doable as far as I can tell.

Edit: One thing the /q/mytransactions doesn't show, is block generation reward. However, I highly doubt that this is relevant for your purposes. It's something to keep in mind, though, if someone ever uses the code to count wallet balance.

theymos
Administrator
Legendary
*
Offline Offline

Activity: 5152
Merit: 12580


View Profile
November 03, 2011, 07:17:40 PM
 #5

Something to note: if you're capable of storing data, you can minimize the amount of data you download/process by handling ETag headers and using the block-stop parameter to /q/mytransactions.

It would not be too hard for me to add pubkey-TX support to /q/mytransactions. I haven't seen any demand for it, though.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 03, 2011, 07:32:26 PM
 #6

Something to note: if you're capable of storing data, you can minimize the amount of data you download/process by handling ETag headers and using the block-stop parameter to /q/mytransactions.
I think processing all transactions of just one address won't be slow enough for the user to get bothered by it, really. I'll code it without storing data first, since that's easier.

dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 03, 2011, 07:51:44 PM
 #7

It would not be too hard for me to add pubkey-TX support to /q/mytransactions. I haven't seen any demand for it, though.

What is pubkey-TX ?
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5152
Merit: 12580


View Profile
November 03, 2011, 08:20:28 PM
 #8

What is pubkey-TX ?

Transactions can be sent directly to a public key instead of to an address. Some generation transactions do this.

The generations that pools like Eligius produce are actually address transactions, so they will be detected by mytransactions. Nowadays few individuals receive pubkey transactions.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 03, 2011, 11:10:11 PM
 #9

In what format do you usually have your private key?

dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 04, 2011, 09:14:46 AM
 #10

In what format do you usually have your private key?

Base58.
dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 07, 2011, 02:28:05 PM
 #11

Anyone fancy a go at this ?
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 07, 2011, 02:48:23 PM
 #12

Is there still one of those broadcast transaction sites, so I can check if everything's working? Can't seem to find it anymore…

etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
November 07, 2011, 04:17:55 PM
 #13

Is there still one of those broadcast transaction sites, so I can check if everything's working? Can't seem to find it anymore…

It turns out the original site you are thinking of was taken offline, but Nibor is working on one based on this thread.  You could PM him to find out how he's doing on it.

Admittedly, such a site is useful occasionally for folks, but has remarkably low-demand on a regular basis, which is why the original site was taken offline.

Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 08, 2011, 12:23:38 AM
Last edit: November 08, 2011, 12:46:14 AM by BTCurious
 #14

My homemade transaction, and the client's transaction based on that one, were just accepted in the blockchain. Which means it's working Smiley

(So yes, it took somewhat longer than expected, but everything is in working order now.)

It's available here: http://ge.tt/9XKMag9?c

The library included is bitcoinjs-lib, so you can download that instead of the lib directory in the zip, then there's less code to "trust".

I haven't done any error catching, so if there is any error (incorrect key, not enough funds, etc), then it will show up in the javascript console.

The user interface is probably self-explanatory, but:
Put in the transaction history (eg this) in the big box, and the private key for that address in the box below.
Press "Parse"
It will calculate your address (You can verify this is correct), and your current balance.
You can now fill in the target address, the money you want to send, and the fee you want to include. Any change will be sent back to the original address itself.
Press generate to generate the transaction. It will pop up in the bar below the button.

If there are any questions, let me know.

Enjoy, and goodnight Smiley (Any of the addresses in my sig will do for a payment)

PS: I broadcasted my transaction eventually by hardcoding/hacking it into a python bitcoin client by ThomasV, but since you run strongcoin, you probably have your own broadcast script anyway.

(Screenshot:)

dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 08, 2011, 09:47:14 AM
 #15

This is great. Thanks. 20BTC Payment has been made.
dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
November 08, 2011, 03:11:33 PM
 #16

I've written up the process in a blog entry. comments are available here https://bitcointalk.org/index.php?topic=51252.0
Jaagu
Member
**
Offline Offline

Activity: 62
Merit: 10



View Profile
November 09, 2011, 12:28:53 PM
Last edit: November 09, 2011, 12:40:22 PM by Jaagu
 #17

BTCurious,
I tried your Offline TX generation webpage in 1) IE 6.0 2) OperaTor 3) Google Chrome and 4) FireFox portable.
Parse > Address, Balance worked only in FireFox Undecided

Next I tried in Opera.
It returned errors:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

JavaScript - file://localhost/D:/tmp2/offlineTransaction.html
Inline script compilation
Syntax error while loading: line 209 of linked script at file://localhost/D:/tmp2/offlineTransaction.js :
Expected identifier
      for (var b in tx.in ) {
---------------------^
JavaScript - file://localhost/D:/tmp2/offlineTransaction.html
Event thread: click
Error:
name: ReferenceError
message: Statement on line 1: Undefined variable: parseFormData
Backtrace:
  Line 1 of function script
    parseFormData(this.form)
  ...
stacktrace: n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace'
JavaScript - file://localhost/D:/tmp2/offlineTransaction.html
Event thread: click
Error:
name: ReferenceError
message: Statement on line 1: Undefined variable: parseFormData
Backtrace:
  Line 1 of function script
    parseFormData(this.form)
  ...
stacktrace: n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace'
JavaScript - file://localhost/D:/tmp2/offlineTransaction.html
Event thread: click
Error:
name: ReferenceError
message: Statement on line 1: Undefined variable: parseFormData
Backtrace:
  Line 1 of function script
    parseFormData(this.form)
  ...
stacktrace: n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace'
JavaScript - file://localhost/D:/tmp2/offlineTransaction.html
Event thread: click
Error:
name: ReferenceError
message: Statement on line 1: Undefined variable: parseFormData
Backtrace:
  Line 1 of function script
    parseFormData(this.form)
  ...
stacktrace: n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace'


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I am dumbuser. Maybe you could help?
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 09, 2011, 01:03:11 PM
 #18

BTCurious,
I tried your Offline TX generation webpage in 1) IE 6.0 2) OperaTor 3) Google Chrome and 4) FireFox portable.
Parse > Address, Balance worked only in FireFox Undecided

Next I tried in Opera.
It returned errors:
--snip--
Maybe you could help?

Heya!
For me it worked fine in both chrome and firefox. (I just tried on IE, and it didn't work for that. Is there anyone who wants IE to be specifically supported?)

About the Opera error: I suspect the first error is due to the field in the data called "in". "in" is also a javascript keyword, which might cause problems. For me it didn't, so I went with it.
Here's a file with a workaround which shouldn't have that problem: http://ge.tt/9jstkk9

About it not working in various browsers: It might be that it's erroring on some unique thing in the data you gave it. There should be an error console in firefox (Maybe tools > web developer?), or in chrome ("Wrench tool" > tools > javascript console) that will give you an error. Apart from that, can you tell me what address you're trying to parse? I can see if it works for me.

Jaagu
Member
**
Offline Offline

Activity: 62
Merit: 10



View Profile
November 09, 2011, 01:19:43 PM
Last edit: November 09, 2011, 02:55:00 PM by Jaagu
 #19

Your improvement made it work in Chrome (both Address and Balance are returned), but in Opera only Address is returned.
Compatibility with IE would be also desirable, because then one could make tx-s from any computer in the world, without installing bitcoin client and without using online wallets (after nibor gets he's webpage http://bitsend.rowit.co.uk/ fixed (see: https://bitcointalk.org/index.php?topic=50282.msg611729#msg611729).
BTCurious
Hero Member
*****
Offline Offline

Activity: 714
Merit: 503


^SEM img of Si wafer edge, scanned 2012-3-12.


View Profile
November 09, 2011, 01:31:35 PM
 #20

Can you check if you get any errors in a javascript console? It should be somewhere in the menus… I never really use Opera.

Oh btw, "Apart from that, can you tell me what address you're trying to parse? I can see if it works for me." I meant public address (1somethingsomething) of course, not private key.

Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!