Bitcoin Forum
May 03, 2024, 04:57:04 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Electrum to notify on address status change (CLI)  (Read 159 times)
ayadev (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 6


View Profile
December 19, 2020, 03:52:25 PM
Merited by ABCbits (1)
 #1

Hello,

As a developer, I've been testing Electrum command line interface (as well as JSON RPC) for some days to receive payments through my web apps.

I've been trying to use notify (address, [url]) command to get notified every time a wallet's address status changes.

It works quite well, I receive JSON responses but I don't know how to process the status string, which appears to be encoded. I don't know whether this is a binary or encrypted string actually.

Typical JSON response:

Code:
{"address": "tb1poly23484gvhb9atztrvaydzh0t9hcadncrmba1", "status": "34a4e9286fa705980e42edbc95db515593d46f30164f8d45d4b2387e0541b211"}

I may be missing something obvious but I haven't found specific documentation on this.

I tested this with Electrum 4.0.7 and a read-only Testnet wallet.

Any further information ?

Thanks





1714712224
Hero Member
*
Offline Offline

Posts: 1714712224

View Profile Personal Message (Offline)

Ignore
1714712224
Reply with quote  #2

1714712224
Report to moderator
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
December 19, 2020, 04:20:15 PM
 #2

Check out the documentation:

blockchain.address.subscribe

A request to send to the client notifications when status (i.e., transaction history) of the given address changes. Status is a hash of the transaction history. If there isn’t any transaction for the address yet, the status is null.


You will get notified, but still have to request the history to actually get the new transactions if you want to parse and/or react to them.

The documentation contains all necessary commands to get the information you are looking for. It is worth checking out.

ayadev (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 6


View Profile
December 19, 2020, 04:47:50 PM
 #3

Hey,

I guess I started to read Electrum Protocol section but content was marked as outdated (redirecting to ElectrumX doc) so I may have missed it. Anyways.

Thank you so much for your help !
xmr00
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
January 16, 2021, 03:37:53 AM
 #4

Check out the documentation:

blockchain.address.subscribe

A request to send to the client notifications when status (i.e., transaction history) of the given address changes. Status is a hash of the transaction history. If there isn’t any transaction for the address yet, the status is null.


You will get notified, but still have to request the history to actually get the new transactions if you want to parse and/or react to them.

The documentation contains all necessary commands to get the information you are looking for. It is worth checking out.

How I can check status of transactions from the hash of the transaction history ?
hash of tx history is not tx_hash (I can check tx_hash on blockchain)
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4165


View Profile
January 16, 2021, 04:03:44 AM
 #5

How I can check status of transactions from the hash of the transaction history ?
hash of tx history is not tx_hash (I can check tx_hash on blockchain)
The method got changed to blockchain.scripthash.subscribe. You can't. The hash orders the transactions in specific order together with their confirmations, -1 for unconfirmed and 0 for confirmed. The way this works is for scripts to monitor and compare the hashes between different calls and they will know that there is either a new transaction or an unconfirmed transaction has gotten a confirmation, this allows for a quick and easy way to determine the status of transactions without much hassle. It's a one way function so you can't get the list from the hash alone.

If you want to get the list of transaction and it's information, you should be looking at blockchain.scripthash.get_history.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
xmr00
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
January 16, 2021, 05:11:23 AM
 #6

How I can check status of transactions from the hash of the transaction history ?
hash of tx history is not tx_hash (I can check tx_hash on blockchain)
The method got changed to blockchain.scripthash.subscribe. You can't. The hash orders the transactions in specific order together with their confirmations, -1 for unconfirmed and 0 for confirmed. The way this works is for scripts to monitor and compare the hashes between different calls and they will know that there is either a new transaction or an unconfirmed transaction has gotten a confirmation, this allows for a quick and easy way to determine the status of transactions without much hassle. It's a one way function so you can't get the list from the hash alone.

If you want to get the list of transaction and it's information, you should be looking at blockchain.scripthash.get_history.

what is a typical workflow to get notified and confirm transaction (1 is enough)?

1 electrum daemon -d
2 electrum load_wallet

then JSONRPC calls:

3 electrum getunusedaddress
{"id":"myquery","method":"getunusedaddress","params":[]}
=>>>>
{
    "id": "myquery",
    "jsonrpc": "2.0",
    "result": "tb1qfzvln0uccwvqf9n727l9eyaaklyhpprru5rhyj"
}

display address for payer person

4 set notify to backend
{"jsonrpc":"2.0","id":"curltext","method":"notify", "params": {"address":"tb1qfzvln0uccwvqf9n727l9eyaaklyhpprru5rhyj", "URL":"192.168.0.1/notify"}}

when person pays I get responses at backend:

{
  address: 'tb1qfzvln0uccwvqf9n727l9eyaaklyhpprru5rhyj',
  status: '3a54b412d59fcad712f3d6f8120b65f3bd670b448a2ec7ae238b3ec05ec4d8e4'
}

{
  address: 'tb1qfzvln0uccwvqf9n727l9eyaaklyhpprru5rhyj',
  status: 'd28c3faa2a3632f33d2bae516f2bc6b79f94c0ef58f914aeead9ff29bf4015e3'
}

{
  address: 'tb1qfzvln0uccwvqf9n727l9eyaaklyhpprru5rhyj',
  status: 'a47c8b54068215ff6e5c672e870a81a11d590924fb82ab3d30539715f79c61c9'
}

I understand that these messages to backend reflects changes on address (confirmations)
status is hash of transaction history, ok. You said "status" is useless.

How I can confirm payment? if "status" would be equal to transaction ID - I can check it my "electrum get_tx_status txID"? but..

thanx.


ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4165


View Profile
January 16, 2021, 05:44:51 AM
 #7

I understand that these messages to backend reflects changes on address (confirmations)
status is hash of transaction history, ok. You said "status" is useless.

How I can confirm payment? if "status" would be equal to transaction ID - I can check it my "electrum get_tx_status txID"? but..

thanx.
It isn't. The script hash format is defined here: https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-basics.html#status. You can't reverse the SHA256 hash, you cannot get the inputs of that specific hash. This command merely indicates that there has been some changes to the address, ie getting confirmed or having new transactions. If you want, then you can call getaddresshistory whenever the status changes.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Pages: [1]
  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!