1

I am using bitcoin-rpc and every time I create an invoice for the client to pay, I create a new address. The payment is okay, I get the money after a cron.php sees that the transaction has three or more confirmations, but then when I try to send my money back to my big wallet, I see 200—300 usd in fees.

bitcoin-cli sendtoaddress "MY_WALLET" 0.1 "" "" true

I see on blockchain that everything was sent from each and every address that I have created

ADDRESS1 ... 0.05
ADDRESS2 ... 0.08
ADDRESS2 ... 0.028

... and so on

How can I send everything from one big address and pay only 20$ usd fee?

I think I pay per vbyte for what I have read ... but I want to send internally with low or no fees or something. Can I send coins internally to one big wallet?

I mean don't think that big payment gateways that do the same thing and create an address for every invoice but pay such amounts of fees.

Thank you.

2
  • 1
    How many UTXOs are you trying to spend in this transaction? or in different words, How many inputs does it have? Did you specify fee rate for this transaction using fee_rate in sendtoaddress or use estimate_mode and conf_target? Do you have other UTXOs in wallet with more than 0.1 BTC?
    – user103136
    Commented Mar 13, 2021 at 16:04
  • i think it is estimate_mode and as imputs i have 30 40 50 100 ... a lot , explain more about UTXO or a link ...
    – dotifag851
    Commented Mar 13, 2021 at 19:52

3 Answers 3

2

Can i send coins internally to one big wallet?

No.

By internal you mean without communicating with the Bitcoin network and without involving external miners.

All Bitcoin transactions which move money from one set of Bitcoin addresses to another Bitcoin address are external in the sense that they must be recorded on the blockchain and therefore must incur transaction fees.

1
  • ok, i understand, but how to implement a payment systems when i transfer all i got into my big wallet and after that i lose a lot of money? if i use a big payment gateway service, they send with 10 ... 20 usd fee ... how they do it ?
    – dotifag851
    Commented Mar 13, 2021 at 19:54
1

Each on-chain payment you receive creates a new Unspent Transaction Output (UTXO) for your wallet. When you forward the received payments to your other wallet, each of those UTXOs is consumed in an input of your consolidation transaction. This will happen whether you receive payments to different addresses or reuse the same one.

Given that you will need to spend a number of UTXOs corresponding to the count of payments you receive and Bitcoin transactions bid on the amount of blockspace they occupy, you have several options to reduce the total cost:

  1. Blockspace-efficient output types
    If you have been using P2PKH addresses (i.e. "legacy addresses" that start with 1…), you could significantly reduce weight of your inputs by switching to a more modern output type. P2PKH inputs weigh 148 vbytes each, while P2WPKH (native segwit) inputs weigh 68 vbytes, and P2TR inputs even weigh only 57.5 vB.
  2. Low feerate
    Consolidation transactions tend to require a larger amount of blockspace than most transactions. The command that you cite
    bitcoin-cli sendtoaddress "MY_WALLET" 0.1 "" "" true
    does not set a feerate. This means that your transaction will use the default feerate estimate which aims to get a transaction confirmed very quickly. In this case, you are just moving money from your left pocket to your right pocket, so you actually probably do not need the transaction to be confirmed urgently. Instead of using a feerate high enough to get a confirmation in the next half hour, you could use a feerate that is sufficient for the transaction to confirm within the next day or week. This could easily reduce the overall transaction fee by 50–90% depending on, or di the prevalent feerates. You can find a view of the mempool as well as a feerate estimate for example on mempool.space.
  3. Off-chain payments
    In the time since you wrote this question, it has become a lot more viable to receive payments off-chain, e.g. via the Lightning Network. Especially if you are receiving many small payments, you may consider running a Lightning node to receive your payments which would allow you to receive payments without generating a new UTXO with every single payment.
0

I mean don't think that big payment gateways that do the same thing and create an address for every invoice but pay such amounts of fees.

As far as I know typical approach is to have root P2WPKH bitcoin wallet and to generate child wallets for each payments. Benefits of P2WPKH is lower transaction fees. Because the witness data is stored outside the main block, less block space is used, resulting in lower fees.

Then you need to create many-to-one transaction to withdraw, where inputs are the unspent UTXOs related to your child wallets and one output is the destination address. Required fee for your withdraw transaction = raw transaction size * fee rate in sat/vB. You can use public API (for example, https://blockstream.info/api/fee-estimates) to get current fee rate.

1
  • Hi dmitrdv, welcome to Bitcoin Stack Exchange. Thanks for chiming in on this topic. I am writing to point out that it’s a common myth that witness data is not part of the block. While non-segwit output types used the input script to authorize payments, segwit transactions have a new section called "Witness" that holds a witness stack for each input. The witness is part of the transaction, and each transaction is recorded in full in the block that confirms it.
    – Murch
    Commented Sep 10 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.