0

I'm trying to create a transaction and send it to the blockchain.

The goal is to get an address from which the money comes and an address to which the money will go, send the transaction to the network, wait for the wallet owner from which the money comes to approve the transaction in his wallet and finally get the transaction address.

I can not understand how to do this without asking the wallet owner from whom the money was sent the private key.

I would appreciate your help, Thanks!

RedGrittyBrick
  • 24,039
  • 3
  • 23
  • 47
Salvador
  • 21
  • 2
  • Are you creating a custodial wallet service? What is the role of what you are creating? – RedGrittyBrick Jul 10 '22 at 15:29
  • No. What I need is simple, a customer enters a web form, enters his wallet address (from which bitcoin came out), address to which he will send the bitcoin, how much bitcoin to send. I want to transmit the transaction to the network, the customer in his wallet (Electrum, Exodus Etc.) will confirm the transaction, it will be executed and finally I will receive the TxHash of the transaction. – Salvador Jul 10 '22 at 15:36
  • 1
    I still don't understand. Why wouldn't the customer do the whole job in Electrum, Exodus etc. Why would they want to involve a 3rd-party web-page? Is this multisig escrow PSBT or something else? – RedGrittyBrick Jul 10 '22 at 16:01
  • They need to do the transaction through me so I get their TxHash automatically. – Salvador Jul 10 '22 at 16:21
  • 2
    Well what you're asking for is fundamentally impossible. You need the user's wallet to produce the signatures in the transaction inputs. Without those, the transaction is incomplete, invalid, and the network won't relay such transactions. – Pieter Wuille Jul 10 '22 at 16:27
  • I want to prepare the transaction for him, send it to the network, he will confirm it in his wallet and finally I will receive the transaction address – Salvador Jul 10 '22 at 16:35
  • I manage to do it on the Etherium network and it works great. In Bitcoin I do not succeed – Salvador Jul 10 '22 at 16:36
  • 2
    The Bitcoin network does not relay transactions that aren't valid. You'll need to communicate with the user out of band, using protocols like PSBT, to construct the transaction. – Pieter Wuille Jul 10 '22 at 16:45
  • look at this: https://developer.bitcoin.org/devguide/payment_processing.html By 'Requesting Payments' it is impossible to do so? – Salvador Jul 11 '22 at 08:07
  • You "Request payment" by, for example, showing the customer a barcode (QR-code) that contains the address you want to be paid and the amount. Alternatively you just show them the address and amount in plain text. As that developer web-page implies, the customer creates the whole transaction themselves without any assistance. They might typically use a wallet app to scan the barcode and press "send". See https://bitcoin.stackexchange.com/q/4987/13866 – RedGrittyBrick Jul 11 '22 at 09:23
  • The question is if there is a way I can do that and get TxHash automatically? – Salvador Jul 11 '22 at 17:13
  • 1
    When your wallet observes any payment to the given address it will be able to calculate the TxHash. – RedGrittyBrick Jul 12 '22 at 09:54

1 Answers1

1

The process described in the question is not the way normal transactions are created and processed in Bitcoin.

You can request payment by, for example, showing the customer a barcode (QR-code) that contains the address you want to be paid and the amount. Alternatively you just show them the address and amount in plain text. As a developer web-page on payment processing implies, the customer creates the whole transaction themselves without any assistance. They might typically use a wallet app to scan the barcode and press "send".

When your wallet observes any payment to the given address, including unconfirmed payments, it will, as part of verification, calculate the TxHash (Transaction-ID, a hash of transaction data).


There is provision for more complex forms of transaction. For example multisignature transactions and partially signed bitcoin transactions (PSBT). There is also Lightning, Liquid etc. However, it isn't clear from the information provided that any of these are relevant to you.


See Bitcoin URL scheme

Murch
  • 71,155
  • 33
  • 180
  • 600
RedGrittyBrick
  • 24,039
  • 3
  • 23
  • 47