Understanding simple Transactions


I try to understand Transactions.

I have a Source Wallet1 (Address1/PublicKey1 and PrivateKey1) - with 10 Bitcoins (simplified).

Now a friend gives me his Wallet2 (Address2/PublicKey2), and wants to receive 1 Bitcoin.

When I read the documentation (https://bitcore.io/api/lib/transaction) then for a simple Transaction (1-to-1) the code looks like this:

var transaction = new Transaction()
.from(utxos)          // Feed information about what unspent outputs one can use
.to(address, amount)  // Add an output with the given amount of satoshis
.change(address)      // Sets up a change address where the rest of the funds will go
.fee(5430) // Minimum non-dust amount
.sign(privkeySet)     // Signs all the inputs it can

But I have these Questions:

  1. What is the argument utxos int the .from(utxos) function is. Is this the PublicKey1 from my Wallet1?
  2. The argument address for the .to(address) function is the PublicKey2 of my Friends Wallet2?
  3. The argument address for the change(address) function is a new Address3, which belongs to MY Wallet3, which I have to create just before I make the transaction? => This means I need to know the PrivateKey3 of this Wallet3 and this is the Wallet3 which I will get my rest of the 9 Bitcoins? => Is it possible to do the Transaction without this .change(address) function? If I say, I don’t want to transfer the rest of my 9 Bitcoins to the new Address? They should just stay in the original Wallet1?
  4. The .fee(5430) means that I will spend 5430 Satoshi = USD $0.2337424950 for this Transaction?
  5. The privkeySet in the .sign(privkeySet) function is the PrivateKey1 from my original Wallet1 right? After this .sign() function the Transaction will be ‘fired’ and the job is done?

Thank you very much for your support.

(Eray) #2

About fee function, there should be more clear explanation in the API I know. You should try such things with the testnet if you as me so that you can have a concrete understanding of the process.

After sign, it is not done. Docs says you need to use


and you will use the command with the return value of this serialize

bitcoin-cli sendrawtransaction