bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.62k stars 2.09k forks source link

How to generate a signature after successful transfer? #1304

Closed prodigaLaugh closed 4 years ago

prodigaLaugh commented 5 years ago

After the transfer is successful, how to generate the signature. Use the generated signature to request the interface to be chained.

junderw commented 5 years ago

I don't understand your question. Please re-phrase it, and maybe paste some code if you're having problems.

What do you mean "generate"? Do you mean "retrieve the signature from inside the successful transaction"?

I don't understand.

Tell us what you want to do and we can help you find out what to do to accomplish that goal.

prodigaLaugh commented 5 years ago

Transfer required parameters:

{
  "address": "string",//coin address
  "value": 12//transfer amount
}

and then data returned in the backend:

"data": [
    [
      {
        "hash": "string",
        "n": 0,
        "value": 10//coin amount
      },
     {
        "hash": "string",
        "n": 0,
        "value": 1//coin amount
      },
     {
        "hash": "string",
        "n": 0,
        "value": 1//coin amount
      },
    ]
  ]

transfer amout = data[0].value+data[1].value+data[2].value;

Then use the private key to encrypt the transaction to generate the signature, and then use the generated signature to request an interface, the data is wound.

I don't know how to process the returned data after the transfer. Then generate signatures, winding.

prodigaLaugh commented 5 years ago

After the transfer is successful, I don’t know how to get it or generate a signature.

junderw commented 5 years ago

Here are some examples to help you learn how to use the TransactionBuilder object.

https://github.com/bitcoinjs/bitcoinjs-lib/blob/a6f2cc2924df170537f0b588254178f5445d7dc8/test/integration/transactions.js#L46-L78

prodigaLaugh commented 5 years ago

Thanks a lot.

sahityakumarsuman commented 4 years ago

I am using a private node with two coinbase wallet

Wallet1.dat Wallet2.dat

with the help of rpc client, I am able to generate blocks and even get the mining reward in my coinbse account (Wallet1.dat) from it

now I have a hot wallet address like hw0 = 'mxxxxxxxxxxxxxxxxxxxxxxfdkajdkjxxxx'

I also have

privKeyWIF = 'afdhjafjkaxxxjjkajkdlxxjkflad' // assumed

I am able to transfer the amount from coinbase account(Wallet1.dat) to my hot wallet (hw0)

and now I want to transfer the amount from hot wallet(hw0) to wallet address like recever_wallet_address = 'mdfdxxxxxxmxxxxxxxxxmxxx'

can you help me to find out how I have to send it to

I have the amount and to address like below

const receiver = { to : 'm__recever_bitcoin_address', amount : 2 }

I have to broadcast this receiver transaction on my private node

how should I have to ... please help me with it

I am using

const Rpc_client = require('bitcoin-core'); to create my client // which had the coinbase address

now I want to use

const bitcoin_lib = require('bitcoinjs-lib');

to send the transaction from hot wallet to another address (recever_wallet_address)

(i am in a running project and not able to find out how I have to perform my action and this is the only place where I am getting a response from you guys)

sahityakumarsuman commented 4 years ago

I have already solved almost all the problems that one will face while sending and receiving any transaction over chain. So if anyone facing same ping me or drop your question will be happy to connect and help you any of you.