Bitcoin Forum
April 19, 2024, 09:19:38 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Get the address sent from  (Read 2362 times)
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
November 07, 2012, 05:07:44 PM
 #21

I already got it 100 times by now, I undestand that it isn't the most reliable method, what code would I use to get this address?

The correct answer to your question is mu (please read G.E.B. to find out exactly what that means - and I hope you enjoy the experience as much as I did as it is IMHO one of the best books ever written).

Smiley

For the lazy:

Quote
2. /moo/ The correct answer to the classic trick question "Have you stopped beating your wife yet?". Assuming that you have no wife or you have never beaten your wife, the answer "yes" is wrong because it implies that you used to beat your wife and then stopped, but "no" is worse because it suggests that you have one and are still beating her. According to various Discordians and Douglas Hofstadter the correct answer is usually "mu", a Japanese word alleged to mean "Your question cannot be answered because it depends on incorrect assumptions".


How do I send back coins like satosh dice?








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


The forum was founded in 2009 by Satoshi and Sirius. It replaced a SourceForge forum.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
November 07, 2012, 05:45:57 PM
 #22

How do I send back coins like satosh dice?

You were already given the answer both in general terms and with the exact RPC call?  I mean kjj gave you exactly the answer you were asking for (even though it is advised not to use it)

https://bitcointalk.org/index.php?topic=122220.msg1322012#msg1322012
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
November 07, 2012, 06:21:13 PM
 #23

How do I send back coins like satosh dice?

You were already given the answer both in general terms and with the exact RPC call?  I mean kjj gave you exactly the answer you were asking for (even though it is advised not to use it)

https://bitcointalk.org/index.php?topic=122220.msg1322012#msg1322012


Bitcoin .NET C# doesn't contain these functions.








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
November 07, 2012, 08:36:47 PM
 #24

How do I send back coins like satosh dice?

You were already given the answer both in general terms and with the exact RPC call?  I mean kjj gave you exactly the answer you were asking for (even though it is advised not to use it)

https://bitcointalk.org/index.php?topic=122220.msg1322012#msg1322012


Bitcoin .NET C# doesn't contain these functions.

Ahh, I think you might need to do some reading on what the RPC API is, and how to use it.  I suggest starting with the link I posted earlier.

Are you wondering how to use the RPC service from .net?

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
November 10, 2012, 01:34:50 PM
 #25

I have an address in bitcoind and I would like to receive the first address that bitcoins were sent from in Bitcoin.net.

For example if I have an address 37muSN5ZrukVTvyVh3mT5Zc5ew9L9CBare with a balance of 9.5 coins, I would like to receive the address those coins were sent from. This is a problem since I will have multiple addresses each with a couple of coins and I want to get the addresses the coins were sent from for each address.

The Raw Transactions API will give you this info.


Filter the results of listunspent for the output address to learn the transaction ids.  Then get each transaction and pull the first input for each.

use:
getrawtransaction
then for the output of that,
decoderawtransaction

 - http://en.bitcoin.it/wiki/Raw_Transactions

[Edit: See the next few posts to tell you why there is no "from" addresses with Bitcoin.   The right way to know what invoice a payment is for (or what customer sent the payment) is to give out a new address for each transaction.]

I list the transactions:
[
  {
    "account": "testacc",
    "address": "18LaYLjk4ktP5PvHZ9X2afBW1uoJxhBZWN",
    "category": "receive",
    "amount": 5E-05,
    "confirmations": 213,
    "blockhash": "00000000000002ab8a627d4d88385a1c8b11b5bcc1de1ebee90a747e15ed87
d4",
    "blockindex": 171,
    "blocktime": 1352434315,
    "txid": "0601b1b121e2b8c7db0ab57620c97f3a8cefefa626a1838718baa8154f9fea84",
    "time": 1352434315,
    "timereceived": 1352550740
  },
  {
    "account": "testacc",
    "address": "18LaYLjk4ktP5PvHZ9X2afBW1uoJxhBZWN",
    "category": "receive",
    "amount": 5E-05,
    "confirmations": 180,
    "blockhash": "000000000000002afc8044a5b98e2634b8058e90e4ee9e22ebd722566c24bf
28",
    "blockindex": 268,
    "blocktime": 1352457915,
    "txid": "b57619177c9cb1031e9e867246751e810593ef1b9520e70de50f09ebb6503b7c",
    "time": 1352457915,
    "timereceived": 1352551000
  }
]
Then I pull a transaction:
{
  "amount": 5E-05,
  "confirmations": 213,
  "blockhash": "00000000000002ab8a627d4d88385a1c8b11b5bcc1de1ebee90a747e15ed87d4
",
  "blockindex": 171,
  "blocktime": 1352434315,
  "txid": "0601b1b121e2b8c7db0ab57620c97f3a8cefefa626a1838718baa8154f9fea84",
  "time": 1352434315,
  "timereceived": 1352550740,
  "details": [
    {
      "account": "testacc",
      "address": "18LaYLjk4ktP5PvHZ9X2afBW1uoJxhBZWN",
      "category": "receive",
      "amount": 5E-05
    }
  ]
}
Still no relevant information about where did it came from?








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


fergalish
Sr. Member
****
Offline Offline

Activity: 440
Merit: 250


View Profile
November 10, 2012, 02:06:16 PM
 #26

You can get the previous addresses.  The transaction structure contains a list of prior transaction outputs which it is redeeming and which, necessarily, have never been spent before.  We get the list of those (txids,vout) pairs and find which address is associated with each output.  What about something like this pseudocode, where tx0 is the transaction which gave coins to your address:

%START PSEUDOCODE
rawtx = getrawtransaction(tx0)
rawtxdec = decoderawtransaction(rawtx)
for (input in rawtxdec['inputs'])    %LOOP OVER ALL INPUTS
   {
   tx_in=input.txid
   vout_number=input.vout
   rawtx_in = getrawtransaction(tx_in)
   rawtxdec_in = decoderawtransaction(rawtx_in)
   printf "Input address: ",rawtxdec_in['outputs'][vout_number]['destination_address']
   }
%ENDPSEUDOCODE

rawtxdec['inputs'] is an array of transaction inputs, each element of which contains the TXID and VOUT of prior outputs it is redeeming.
rawtxdec['outputs'] is an array of transaction outputs.
rawtxdec['outputs'][vout_number] is a single transaction output we are interested in.
rawtxdec['outputs'][vout_number]['destination_address'] is the address of that output.

I understand that the sender of the transaction might not know anything about the sending address (it could be change from a previous tx), and they might be using a web wallet and so not even have that address in their own personal wallet.
fergalish
Sr. Member
****
Offline Offline

Activity: 440
Merit: 250


View Profile
November 10, 2012, 06:15:13 PM
 #27

Ah, you can also get the BTC amount associated with each "sending" address. Substitute the printf command with:

printf "Input address: ",rawtxdec_in['outputs'][vout_number]['destination_address'], "Amount: ", rawtxdec_in['outputs'][vout_number]['amount']

Or something similar. You'll have to read the documentation to find out the precise syntax, structure, and array keys.
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!