Bitcoin Forum
April 24, 2024, 10:17:42 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Electrum / Request address balance from any Electrum server on: January 31, 2023, 08:41:33 PM
Hello
Can we request an Electrum server to tell us balance of an address? As electrum software does this by querying these servers to get balances of addresses so can we do this manually in browser or through some short code? What will be the process?
Can Electrum servers be used to confirm payments for website invoices?
Thanks
2  Bitcoin / Development & Technical Discussion / A custom solution to accept Bitcoin Payments on your website on: January 31, 2023, 02:43:05 PM
Hello all.

Backstory
I am owner of https://selldefi.com (Read more). This website helps people to sell their files for bitcoin. This website script is kinda famous and have multiple clones in market but I have made its payment system by myself. Older system was on Coinpayments which requires heavy KYC so I thought to make my own custom solution. Though it is not a standard way and you can call it DIY method but it works perfectly and it is decentralized.

Accepting Payment
To accept Bitcoin payments you need 3 steps
  • Generate new Bitcoin Address for each customer
  • Check balance of address
  • Update database once address have enough balance and confirmation

Generate new Bitcoin Address for each customer
There are two ways to generate Bitcoin address and both require xpub. For people who do not know XPUB is Master Public Key which can generate as many addresses as you want under same Seed. Mean all addresses can be derived by yourself if you have your seed phrase. Other names of XPUB are ZPUB and YPUB which are for addresses starting with bc and 3 respectively. You can play with seeds, addresses and master pub key here. Master public key is only used to derived addresses and if someone knows your master public key they can know all addresses that belong to you in that wallet. But they cannot spend funds from it.

How to get XPUB/YPUB/ZPUB
You can get your Master public key from Electrum wallet or any other similiar wallet. For Electrum 4.3 you can get it in Menu as Wallet > Information > Master public key. There you can have your xpub, ybup or zpub.

How to genenrate addresses from master key
Wallets automatically generate addresses for us but for website we have to do it ourselves. So there are again two methods to generate addresses from Master public key.
1. Blockchain API V2
2. Bitswap

If you use Blockchain v2 Api it is very helpful and easy. You get API. You provide your xpub and it will automatically generate 1 address for you and when that address will receive balance with 6 confirmations then blockchain.com will call your callback url once. In your callback url you can put code for checking received balance, confirmations and update Database. You may face address limit (20 address gap limitation is met) problem which you can read about it once you face it but its solution is to add below code in end of your api call.
Code:
&gap_limit=1000000
although setting such high limit is not feasible for you to handle as Electrum will take time to generate 1m addresses. Also if you do not know how to generate more addresses in Electrum then you can do this by these commands.

Code:
-----For Older version
wallet.create_new_address(False)
wallet.storage.put('gap_limit',1000)

-----For New version
wallet.change_gap_limit(5000)

Restart Electrum to generate addresses

Bitswap
You can use Bitswap library to custom generate addresses for you
Code:
<?php
function GenerateAddress($nb){
    require_once(
'loader.php');
$xpub 'xpub.........';
$rem '0/';
$path $rem.$nb// Receiving address path

$hd = new HD();
$hd->set_xpub($xpub);
$address $hd->address_from_master_pub($path);

return 
$address;
}
This function will return new address you will pass it number of address you want to generate.
?>
Save addresses in database and check last addresses you have used and generate next address.

Check balance of address
Once you have received bitcoins you can check with any APi to check for balance. That can be blockchain.info api like
Code:
public function CheckBalance($addr) {

    $balance = file_get_contents('https://blockchain.info/q/addressbalance/'.$addr.'?confirmations=2');
    $balance = $balance/100000000;
if($balance > 0 ) {
return $balance;
} else return 0;

}
You can also check address balance and confirmations by subtracting block of payment confirmation from current block height. There are hundreds of free api available to do this you have to be little creative for this.

Update database once address have enough balance and confirmation
Once you have received required balance you can update database and transactions. You can reuse addresses if you manage previous balance of each address and reuse it after a week.

I recommend to not use above 5000 addresses from each master key and change new wallets because Electrum cannot handle more than 5000 addresses with ease. It can handle any number of addresses but for a normal computer it is not friendly.

I hope you will like this and in future many more will take benefits from this. Remind me in your prayers.
3  Bitcoin / Development & Technical Discussion / Guidance for accepting lighting BTC on website on: January 29, 2023, 08:05:10 PM
Hello
I want some guidance to accept L. Bitcoin on my website preferably in PHP.
If it is not available then help me understand how can we generate invoices and how can we confirm if they have been paid.
Thanks
4  Bitcoin / Electrum / Electrum legacy wallet in new version on: January 24, 2023, 09:08:31 PM
Is there a way to create a legacy wallet in current version of Electrum? As far as I have checked I was unable to find a way to create a legacy wallet starting with 1.
5  Economy / Service Announcements / [ANN] SellDefi.com ~ Sell files for Bitcoin on: January 19, 2023, 07:30:46 PM
Dear SellDefi Users,

We regret to inform you that Selldefi Service is closing on 05-02-2024. Despite our efforts, we couldn't garner enough users and profits to sustain the business.

Key Information:

    Clear Payments: All payments are settled. For inquiries, DM.
    Link Deactivation: Product links are disabled.
    Data Deletion: User files and information are permanently deleted.

We appreciate your support and apologize for any inconvenience.

Thank you for being part of SellDefi.

Sincerely,
Selldefi team

(Selldefi was a service to sell digital files for bitcoin anonymously. It was closed after a small run due to lack of users.)
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!