Bitcoin Forum
July 20, 2019, 08:33:25 AM *
News: Latest Bitcoin Core release: 0.18.0 [Torrent] (New!)
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getTxOut by address  (Read 1209 times)
scalaz
Newbie
*
Offline Offline

Activity: 15
Merit: 0


View Profile
March 12, 2016, 01:43:42 PM
 #1

Hello!
I'm trying to get transaction tx out by address with bitcoind. Current address does not contains in the bitcoin wallet.

Current solution

1. getblockhash
2. getblock
3. gettxout "a070c999b594d7b0922adebf00c74c69db5b2c1b6da08a83dad99c11f57c03d1" 0

Quote
{
"bestblock" : "000000000000000000ca1b3c58c26c016a1cf6331675bd4b7e303a2522a6f4ce",
"confirmations" : 231,
"value" : 0.17800000,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 0596a9bc158e13ba4a75c800d317b748bfe3577a OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9140596a9bc158e13ba4a75c800d317b748bfe3577a88ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"1WYsDAYJBiLxLQKeSR8eLfpTumUYmuxgW"
]
},
"version" : 1,
"coinbase" : false
}

4. compare address from JSON with my address.

As you can see this is like brute force. O(n) complexity...

Do you know how to subscribe address for checking incoming tx_outs by address "address does not exist in the bitcoind wallet" 

Any Java libraries for this aims ?
Any free API ?
Any recommendations ?

Thanks!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1563611605
Hero Member
*
Offline Offline

Posts: 1563611605

View Profile Personal Message (Offline)

Ignore
1563611605
Reply with quote  #2

1563611605
Report to moderator
1563611605
Hero Member
*
Offline Offline

Posts: 1563611605

View Profile Personal Message (Offline)

Ignore
1563611605
Reply with quote  #2

1563611605
Report to moderator
1563611605
Hero Member
*
Offline Offline

Posts: 1563611605

View Profile Personal Message (Offline)

Ignore
1563611605
Reply with quote  #2

1563611605
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1820
Merit: 2551


bc1qshxkrpe4arppq89fpzm6c0tpdvx5cfkve2c8kl


View Profile WWW
March 12, 2016, 03:27:35 PM
 #2

You could import the address into the wallet as watching-only with importaddress <address>. Otherwise, Bitcoin Core doesn't do address checking stuff, so you can use online apis from blockchain.info, blocktrail.com, blockcypher.com, and many other places.

danda
Full Member
***
Offline Offline

Activity: 195
Merit: 140


View Profile WWW
March 12, 2016, 08:43:57 PM
 #3

For local lookups of arbitrary addresses you could use btcd instead of bitcoind.

btcd has an address index.  It needs to be enabled in your config with the addrindex flag.  See the searchrawtransactions API.

mybitprices.info - wallet auditing tools
btc_enigma
Hero Member
*****
Offline Offline

Activity: 648
Merit: 502


View Profile
March 14, 2016, 01:29:24 PM
 #4

There is code to enable addrindex in bitcoin https://github.com/bitcoin/bitcoin/pull/6835/commits . Its not merged yet,  but should work. You can try it out

scalaz
Newbie
*
Offline Offline

Activity: 15
Merit: 0


View Profile
March 16, 2016, 05:52:19 PM
 #5

> For local lookups of arbitrary addresses you could use btcd instead of bitcoind.
> btcd has an address index.  It needs to be enabled in your config with the addrindex flag.  See the searchrawtransactions API.

Do you mean https://opensource.conformal.com/wiki/btcd ?
scalaz
Newbie
*
Offline Offline

Activity: 15
Merit: 0


View Profile
March 16, 2016, 06:15:13 PM
 #6

Can I subscribe some address with bitc?
I mean if get incoming transaction for the my address bitd will send notification
or need to ping bitd each 5 seconds for example ?
Can I check bitd like online service ? I mean online API for testing

Thank you for recommendation!
danda
Full Member
***
Offline Offline

Activity: 195
Merit: 140


View Profile WWW
March 17, 2016, 12:40:26 AM
 #7

yes.  aka:  https://github.com/btcsuite/btcd


mybitprices.info - wallet auditing tools
danda
Full Member
***
Offline Offline

Activity: 195
Merit: 140


View Profile WWW
March 17, 2016, 12:45:28 AM
 #8

Here is the btcd help for searchrawtransactions so you can see if it does what you need.  Personally I have found it very useful and speedy.

Code:
$ ./btcctl help searchrawtransactions
searchrawtransactions "address" (verbose=1 skip=0 count=100 vinextra=0 reverse=false ["filteraddr",...])

Returns raw data for transactions involving the passed address.
Returned transactions are pulled from both the database, and transactions currently in the mempool.
Transactions pulled from the mempool will have the 'confirmations' field set to 0.
Usage of this RPC requires the optional --addrindex flag to be activated, otherwise all responses will simply return with an error stating the address index has not yet been built.
Similarly, until the address index has caught up with the current best height, all requests will return an error response in order to avoid serving stale data.

Arguments:
1. address     (string, required)                 The Bitcoin address to search for
2. verbose     (numeric, optional, default=1)     Specifies the transaction is returned as a JSON object instead of hex-encoded string
3. skip        (numeric, optional, default=0)     The number of leading transactions to leave out of the final response
4. count       (numeric, optional, default=100)   The maximum number of transactions to return
5. vinextra    (numeric, optional, default=0)     Specify that extra data from previous output will be returned in vin
6. reverse     (boolean, optional, default=false) Specifies that the transactions should be returned in reverse chronological order
7. filteraddrs (array of string, optional)        Address list.  Only inputs or outputs with matching address will be returned

Result (verbose=0):
"value" (string) Hex-encoded serialized transaction

Result (verbose=1):
[{
 "hex": "value",               (string)          Hex-encoded transaction
 "txid": "value",              (string)          The hash of the transaction
 "version": n,                 (numeric)         The transaction version
 "locktime": n,                (numeric)         The transaction lock time
 "vin": [{                     (array of object) The transaction inputs as JSON objects
  "coinbase": "value",         (string)          The hex-encoded bytes of the signature script (coinbase txns only)
  "txid": "value",             (string)          The hash of the origin transaction (non-coinbase txns only)
  "vout": n,                   (numeric)         The index of the output being redeemed from the origin transaction (non-coinbase txns only)
  "scriptSig": {               (object)          The signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)
   "asm": "value",             (string)          Disassembly of the script
   "hex": "value",             (string)          Hex-encoded bytes of the script
  },
  "prevOut": {                 (object)          Data from the origin transaction output with index vout.
   "addresses": ["value",...], (array of string) previous output addresses
   "value": n.nnn,             (numeric)         previous output value
  },
  "sequence": n,               (numeric)         The script sequence number
 },...],
 "vout": [{                    (array of object) The transaction outputs as JSON objects
  "value": n.nnn,              (numeric)         The amount in BTC
  "n": n,                      (numeric)         The index of this transaction output
  "scriptPubKey": {            (object)          The public key script used to pay coins as a JSON object
   "asm": "value",             (string)          Disassembly of the script
   "hex": "value",             (string)          Hex-encoded bytes of the script
   "reqSigs": n,               (numeric)         The number of required signatures
   "type": "value",            (string)          The type of the script (e.g. 'pubkeyhash')
   "addresses": ["value",...], (array of string) The bitcoin addresses associated with this script
  },
 },...],
 "blockhash": "value",         (string)          Hash of the block the transaction is part of
 "confirmations": n,           (numeric)         Number of confirmations of the block
 "time": n,                    (numeric)         Transaction time in seconds since 1 Jan 1970 GMT
 "blocktime": n,               (numeric)         Block time in seconds since the 1 Jan 1970 GMT
},...]

mybitprices.info - wallet auditing tools
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!