How to get received/sent transactions from bitcoin core? - bitcoin

I have configured bitcoin core daemon. Using JSON-RPC I want to build web wallet. This why I need list of all incoming/outgoing transactions.
listtransactions returns only incoming transactions.
Questions:
How to get outgoing & incoming transactions?
In listtransactions field address - is it receiver or sender?
If I can't get outgoing transactions using listtransactions, why here is may be three categories like "move", "receive" and "send"?

Problem was in provided account. When I set it to "*" all transactions was received.
Wrong
listtransactions('my_account', 100)
Right
listtransactions('*', 100)

For getting listtransactions of bitcoind server command is
bitcoin-cli listtransactions (This command will return last 10 transactions)
bitcoin-cli listtransactions "*" 100 0 (This command will return last 100 transactions here 0 to 100 transactions)

Related

Error upon getting transactions received by address using bitcoin-cli

I've got problem with printing transactions received on address.
On my machine I've got full sync node
but still cannot get transactions on address. Command which I use:
bitcoin-cli getreceivedbyaddress ADDRESS
Result:
error code: -4
error message:
Address not found in wallet
Is there anything more that I should do?
getreceivedbyaddress is a wallet RPC query. It queries your own wallet.
Bitcoind does not maintain a full per-address index of the blockchain.
To query any address you should use importaddress RPC call
importaddress "address" ( "label" rescan p2sh ) Adds an address or
script (in hex) that can be watched as if it were in your wallet but
cannot be used to spend. Requires a new wallet backup.
rescan is on by default and rescanning can take some time.

Create Refund on square_connect Ruby sdk gives INTERNAL SERVER ERROR

I am using square_connect ruby gem to refund payments.
body =
#<SquareConnect::CreateRefundRequest
#amount_money=#<SquareConnect::Money #amount=200, #currency="USD">,
#idempotency_key="be70cc12-28dd-4168-96ea-6eb78f299207",
#tender_id="asdkasdkakdakdakda">
All other parameters are just as intended. I have changed Tender key too.
result = api_instance.create_refund(authorization, location_id, transaction_id, body)
This gives me INTERNAL SERVER ERROR.
ETHON: performed EASY effective_url=https://connect.squareup.com/v2/locations/BP6GXQNEANA9B/transactions/b2fd4689-af1b-40a4-b706-aafd592e1111/refund response_code=500 return_code=ok total_time=1.883598
SquareConnect::ApiError: Internal Server Error - {"errors":[{"category":"API_ERROR","code":"INTERNAL_SERVER_ERROR","detail":"An internal error has occurred, and the API was unable to service your request."}]}
Are you sure that your tender_id matches a tender you want to refund? 500 isn't the correct response, but it seems like you are likely not selecting a correct tender to refund.
Also you should look into upgrading your SDK to the latest version.
This is a major bug in the Square Connect API. I was actually trying with a wrong transaction ID, instead of getting something like "Incorrect Transaction ID" I was getting 500 Internal Server Error.
I have been using Stripe, Payflow. Authorize.net, Braintree and Moneris API for almost 2 years now but I have never received a 500 Internal server error for a wrong transaction Id. So Square needs to address it on urgent basis.

Multiple conversations on Service Broker

Let say I have two instances of the same app interacting with a backend service in Service Broker. How can each instance know to handle only conversations it initiated and ignore the rest? If I recall correctly, every RECEIVE will remove the message from the queue.
Here's an example:
-- Assume the SquareService return the square of the number sent to it
-- Instance 1
BEGIN DIALOG #Conversation1
FROM SERVICE InitService
TO SERVICE 'SquareService'
ON CONTRACT (MyContract)
WITH ENCRYPTION = OFF;
SEND ON CONVERSATION #Conversation1 MESSAGE TYPE MyMessageType('1');
-- Instance 2
BEGIN DIALOG #Conversation2
...;
SEND ON CONVERSATION #Conversation2 MESSAGE TYPE MyMessageType('2');
Now who should I write the RECEIVE statement so that Instance 1 will correctly get 1 and Instance 2 get 4 back?
You are already using a Conversation Group.
Is this not sufficient for your needs when Receiving the messages?
-> using GET CONVERSATION GROUP and RECEIVE together
you can read more about it here: http://technet.microsoft.com/en-us/library/ms166131%28v=sql.105%29.aspx
and also here Sql Server Service Broker Conversation Groups
I'm assuming you have an InitQueue associated with your InitService. You can use a WHERE clause with RECEIVE to listen for messages on the same conversation:
WAITFOR (RECEIVE #response = CONVERT(xml, message_body)
FROM InitQueue -- InitService setup to use InitQueue?
WHERE conversation_handle = #Conversation1

See foreign bitcoin transactions

I'm trying to get a transaction info using
bitcoind gettransaction \
9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271
but I'm receiving
error: {"code":-5,"message":"Invalid or non-wallet transaction id"}
How to see a transaction using bitcoin API?
You can view foreign transactions using bitcoind.
Set txindex=1 in your bitcoin.conf file.
restart bitcoind with -reindex (you need to re-build your entire index)
After you've indexed a few blocks you can use something like this:
$ bitcoind getblockcount
122735
$ bitcoind getblockhash 67543
0000000004e213266ccd388df12896412c1a70e647b48004f7d6894b9d6f63b9
$ bitcoind getblock 0000000004e213266ccd388df12896412c1a70e647b48004f7d6894b9d6f63b9
// JSON containing tx "a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa"
$ bitcoind getrawtransaction a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa 1
// json of transaction - note that "1" at the end tells bitcoind to decode into json
See this for more.
getrawtransaction <txid> command gets any transaction even from Bitcoin-qt client
Raw Transactions
The "raw transaction API" was introduced with Bitcoin-Qt/bitcoind version 0.7. It gives developers or very sophisticated end-users low-level access to transaction creation and broadcast.
This will return hexadecimal string of bytes, which is not very useful. But if you type
getrawtransaction <txid> 1
you'll get nicely formatted JSON representation
znort987's blockparser program looks promising. i haven't had a chance to play with it yet so i'm not sure if it has native support for specifying an individual transaction to inspect, but the doco says that if you know the receiving address then you can get all transaction details for that address like so:
./parser transactions the_receiving_address
As the error said, you are trying to see a transaction which is not part of your wallet. Bitcoind only allows you to explore transactions that are related to your wallet.
If you want to explore "foreign" transactions, you should use other tools like http://blockexplorer.com/

How to get priority of current job?

In beanstalkd
telnet localhost 11300
USING foo
put 0 100 120 5
hello
INSERTED 1
How can I know what is the priority of this job when I reserve it? And can I release it by making the new priority equals to current priority +100?
Beanstalkd doesn't return the priority with the data - but you could easily add it as metadata in your own message body. for example, with Json as a message wrapper:
{'priority':100,'timestamp':1302642381,'job':'download http://example.com/'}
The next message that will be reserved will be the next available entry from the selected tubes, according to priority and time - subject to any delay that you had requested when you originally sent the message to the queue.
Addition: You can get the priority of a beanstalk job (as well as a number of other pieces of information, such as how many times it has previously been reserved), but it's an additional call - to the stats-job command. Called with the jobId, it returns about a dozen different pieces of information. See the protocol document, and your libraries docs.