Bitcoin Forum
May 06, 2024, 05:11:34 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How i can use electrum in node js ?  (Read 64 times)
hellossy (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 1


View Profile
November 11, 2020, 07:28:23 AM
 #1

Hi. I install electrum on my server. How i can connect to electrum from node js script ? I try build website with bitcoin payment;
I have not found examples of using electrum in the node js
Unlike traditional banking where clients have only a few account numbers, with Bitcoin people can create an unlimited number of accounts (addresses). This can be used to easily track payments, and it improves anonymity.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715015494
Hero Member
*
Offline Offline

Posts: 1715015494

View Profile Personal Message (Offline)

Ignore
1715015494
Reply with quote  #2

1715015494
Report to moderator
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
November 11, 2020, 09:08:42 AM
Merited by ABCbits (1)
 #2

This apparently is a "multicurrency" wallet that uses a local version of electrum to work the "btc" functionality: https://github.com/jesobreira/multiwallet

You can see it just uses the Electrum JSONRPC API to communicate with Electrum from within node.js: https://github.com/jesobreira/multiwallet/blob/master/lib/currencies/btc.js#L122
You can read more about the Electrum JSONRPC here: https://electrum.readthedocs.io/en/latest/jsonrpc.html

Note, I believe that the full list of available commands is the same as you get when you use help() in the Electrum console:
Code:
>>> help()
[
    "add_lightning_request",
    "add_peer",
    "add_request",
    "addtransaction",
    "broadcast",
    "changegaplimit",
    "clear_invoices",
    "clear_ln_blacklist",
    "clear_requests",
    "close_channel",
    "close_wallet",
    "commands",
    "convert_xkey",
    "create",
    "createmultisig",
    "createnewaddress",
    "decode_invoice",
    "decrypt",
    "deserialize",
    "dumpgraph",
    "dumpprivkeys",
    "enable_htlc_settle",
    "encrypt",
    "export_channel_backup",
    "freeze",
    "get",
    "get_channel_ctx",
    "get_ssl_domain",
    "get_tx_status",
    "get_watchtower_ctn",
    "getaddressbalance",
    "getaddresshistory",
    "getaddressunspent",
    "getalias",
    "getbalance",
    "getconfig",
    "getfeerate",
    "getinfo",
    "getmasterprivate",
    "getmerkle",
    "getminacceptablegap",
    "getmpk",
    "getprivatekeyforpath",
    "getprivatekeys",
    "getpubkeys",
    "getrequest",
    "getseed",
    "getservers",
    "gettransaction",
    "getunusedaddress",
    "help",
    "import_channel_backup",
    "importprivkey",
    "init_lightning",
    "inject_fees",
    "is_synchronized",
    "ismine",
    "lightning_history",
    "list_channels",
    "list_invoices",
    "list_peers",
    "list_requests",
    "list_wallets",
    "listaddresses",
    "listcontacts",
    "listunspent",
    "lnpay",
    "load_wallet",
    "make_seed",
    "nodeid",
    "normal_swap",
    "notify",
    "onchain_history",
    "open_channel",
    "password",
    "payto",
    "paytomany",
    "remove_lightning",
    "removelocaltx",
    "restore",
    "reverse_swap",
    "rmrequest",
    "searchcontacts",
    "serialize",
    "setconfig",
    "setlabel",
    "signmessage",
    "signrequest",
    "signtransaction",
    "stop",
    "sweep",
    "unfreeze",
    "validateaddress",
    "verifymessage",
    "version"
]

The documentation for each one isn't great... but reading the python code here should help: https://github.com/spesmilo/electrum/blob/master/electrum/commands.py

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
November 11, 2020, 06:33:37 PM
 #3

If you just need middleware that talks to Electrum from node.js, then the JSONRPC API that HCP posted is sufficient.

If you also need a web frontend, you also need to follow the instructions at https://electrum.readthedocs.io/en/latest/merchant.html, which enables the Electrum daemon to generate a webpage people can pay at.

The most important command you need to run online your terminal is:

Code:
electrum -o setconfig payserver_address ecdsa.org:80

Replace ecdsa.org:80 with your domain name and port. This is the site that Electrum will create the payment frontend on. Then you’d use node.js to programmatically pay it using the appropriate JSONRPC command. But to finish the frontend initialization, you need to also run the other commands in the documentation I linked.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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!