Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: markthedark on August 17, 2018, 10:05:26 AM



Title: Implementing a bitcoin payment system
Post by: markthedark on August 17, 2018, 10:05:26 AM
Hello,

we are looking into implementing a Bitcoin payment system and are wondering about a few things.

Is there anyway to make sure that a transaction, with which someone will pay us a certain amount, will really be successfully validated and processed before it's actually inside a certain block?
Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real.

Best regards,
Mark


Title: Re: Implementing a bitcoin payment system
Post by: AdolfinWolf on August 17, 2018, 11:18:32 AM

Is there anyway to make sure that a transaction, with which someone will pay us a certain amount, will really be successfully validated and processed before it's actually inside a certain block?
Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real.


No. You really shouldn't try to process a transaction that has 0 confirmations.

An experienced bitcoin user (Or anyone that isn't using a webwallet really) could doublespend the transaction, in which case your system would receive nothing but does "process/credit" the transaction.

Read more about doublespending and how it exactly works here, https://coinsutra.com/bitcoin-double-spending/

~It makes me wonder though, what service are you creating where you can't wait for 1+ confirmations?


Title: Re: Implementing a bitcoin payment system
Post by: Heisenberg_Hunter on August 17, 2018, 11:34:29 AM
Is there anyway to make sure that a transaction, with which someone will pay us a certain amount, will really be successfully validated and processed before it's actually inside a certain block?
No, not really.
Transactions would stay unconfirmed only on rare cases. These may include, very low to null transaction fees. A miner won't include the transaction in block if he doesn't gain anything from spending his power to mine. A required minimum fee transaction may eventually get confirmed sooner. Tx won't get unconfirmed when the coins are spent from unconfirmed transactions or the coins are double spent. These are some of the possible reasons when the tx gets stuck in the mempool. Also a tx will stay in the mempool for 14 days (though I am not really familiar about this). After this time period it gets dropped from mempool, or the tx may get dropped when the mempool gets full.
Although you can check them manually by entering the txid in any block explorer and see to the fees. A recommended fee tx will be included in the block.

Quote
Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real
If you pay a higher fee, it would be confirmed soon. You can't exactly check them manually I guess. Also why don't  you wait for confirmations?


Title: Re: Implementing a bitcoin payment system
Post by: Thirdspace on August 17, 2018, 12:25:17 PM
Is there anyway to make sure that a transaction, with which someone will pay us a certain amount, will really be successfully validated and processed before it's actually inside a certain block?
transaction included in a block means valid confirmed transaction
there is no other measure to guarantee successful transaction than that

Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real.
if it stays queued in a mempool because of low tx feerate and busy network, you could do CPFP
it would increase the chance to get included/confirmed in the next block found  


Title: Re: Implementing a bitcoin payment system
Post by: odolvlobo on August 17, 2018, 04:45:03 PM
Is there anyway to make sure that a transaction, with which someone will pay us a certain amount, will really be successfully validated and processed before it's actually inside a certain block?
Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real.

Check out Lightning Network. It might be a good fit. It allows you to make instant Bitcoin transactions, though it isn't as straightforward as a normal Bitcoin transaction.


Title: Re: Implementing a bitcoin payment system
Post by: seoincorporation on August 19, 2018, 09:22:01 PM
Hello,

we are looking into implementing a Bitcoin payment system and are wondering about a few things.

Is there anyway to make sure that a transaction, with which someone will pay us a certain amount, will really be successfully validated and processed before it's actually inside a certain block?
Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real.

Best regards,
Mark

Hello Mark. The only way to be sure is waiting the transaction get the first confirmation. The problem here is... if you accept a transaction as valid without confirmations, then you can get a double spend, and that way the coins will never arrive to your wallet. There is no way to be sure that the transaction will not have a double spend unless it's confirmed.

Hope this information helps, other way you can google about double spends and the risk they have.


Title: Re: Implementing a bitcoin payment system
Post by: bob123 on August 20, 2018, 09:02:09 AM
You can't make sure that a transaction will for sure confirm. But you can achieve a pretty high probability.

For example, if you have multiple nodes geographically spread and let the customer choose a fee which is high enough you can calculate the probability of a double spending to occur after a given time.
Especially with multiple nodes, since you are able to detect a network split within seconds. The fee will guarantee that the confirmation will follow within the next blocks.

Such a concept is good enough to sell coffee for BTC.
You let them pay and after their coffee is finished you will have a high probability of the transactions going through.

Note that this requires the miner to be honest and NOT to cooperate with the malicious customer.


For stuff being worth a few $ this totally is fine. But i wouldn't use that for larger sums AND also not for online purchases (anonymity makes a difference here).


Title: Re: Implementing a bitcoin payment system
Post by: nc50lc on August 20, 2018, 10:00:57 AM
Quote
Since the txs can hang in the mempool for quite some time, it's not really an option to wait till it's included in a block for real
If you pay a higher fee, it would be confirmed soon. You can't exactly check them manually I guess. Also why don't  you wait for confirmations?
His team might be aiming for instant payment system that doesn't require a 3rd-party API or exchange-like system.

Depending on your business model and preferences, it's quite possible using Bob's interesting and promising concept (https://bitcointalk.org/index.php?topic=4911033.msg44396413#msg44396413).
You must also consider mandatory requirements to the invoice page like transaction fee that was suggested by something like a bot/program that can accurately compute the current recommended tx fee. If the buyer didn't sent the tx with that fee, notify him that he will have to wait for confirmation(s).

Another, if he's in the actual location (in coffee and pizza cases), quite simple, you can safely accept unconfirmed transactions on the counter.
The person's there, so why not?

Note that this requires the miner to be honest and NOT to cooperate with the malicious customer.
Like every million-dollar mining pools will conspire to steal a cup of coffee  ::)


Title: Re: Implementing a bitcoin payment system
Post by: bob123 on August 20, 2018, 10:34:29 AM
Note that this requires the miner to be honest and NOT to cooperate with the malicious customer.
Like every million-dollar mining pools will conspire to steal a cup of coffee  ::)

The reason i have added this is to make clear that its possible to accept 0-conf payments for low-value goods (coffee).
But for higher amounts where once COULD cooperate with mining pools it is not safe to accept them. And OP has to choose the limit until it is worth the risk for him to accept 0-conf payments.

Therefore instead of suggesting to accept 0 conf payments until X$, i gave OP enough information to conclude the maximum amount to accept with the desired risk for himself.