Closed KhandakerBD closed 4 years ago
Whatever you put in place of INPUT_ADDRESS_PRIVATE_KEY
is not a valid WIF key.
It must be base58check encoded according to the WIF protocol.
this is the error your got >>> Error: Invalid checksum
this is the base58check library which is throwing the error >>> at Object.decode (/var/www/test/yyyBtcLib/node_modules/bs58check/base.js:41:25)
this is the wif library >>> at Object.decode (/var/www/test/yyyBtcLib/node_modules/wif/index.js:43:30)
fromWIF in your code >>> at Object.fromWIF (/var/www/test/yyyBtcLib/node_modules/bitcoinjs-lib/src/ecpair.js:75:23)
The WIF key should look something like this: (Obviously do not use these keys, but just showing you some examples. Valid WIF bitcoin keys start with K L or 5.
# Compressed key WIF (This is good)
L13AeJxBxTgkzyrMNFoV5oX1nz7HAp8f8X6HjzNEvsFyvPq9eFhw
Ky1vMqcf99YF94scEbZRY2vPVjGBTi1885ggy7WTN5nVAua5qxGj
# Uncompressed key WIF (This is old, and won't work with segwit)
5JDtxvcGSQghp98PV18M4QYaeKdyHvhMeQGLUfdacbAQ9bVATyP
The WIF key should look something like this: (Obviously do not use these keys, but just showing you some examples. Valid WIF bitcoin keys start with K L or 5.
# Compressed key WIF (This is good) L13AeJxBxTgkzyrMNFoV5oX1nz7HAp8f8X6HjzNEvsFyvPq9eFhw Ky1vMqcf99YF94scEbZRY2vPVjGBTi1885ggy7WTN5nVAua5qxGj # Uncompressed key WIF (This is old, and won't work with segwit) 5JDtxvcGSQghp98PV18M4QYaeKdyHvhMeQGLUfdacbAQ9bVATyP
Oh, okay.
Can i know when i am trying to create new raw transaction am i in need of to use the full amount of previous transactions output? or i can just use any amount less than previous transactions output to this transactions input?
inputs spend 100% of the referenced output's amount.
You have to create an extra output sending money back to you, this is called "change"
So if you have a 10k satoshi output you wish to spend but only want to send 3k satoshi to a friend and you want to add a 400 satoshi fee to the tx, your tx would look like this:
Inputs | Outputs |
---|---|
10000 satoshi |
3000 satoshi to friend |
(only one input) | 6600 satoshi to self |
@junderw Hello sir,,
i have another question, Can i use the same address as change address? let me explain:
inputs => 32T8ff96iUQov1DGq6kEXRC1iK9QTpasCJ - 10000 satoshi output => 1155HZhXLJxjQg65Vgq3429y5snXVqNLad - 3000 satoshi output => 32T8ff96iUQov1DGq6kEXRC1iK9QTpasCJ - 6600 satoshi
like using the input address as change address!
Yes you can, but it is not recommended for privacy reasons.
Hello i am trying to get RAW TX HEX, here is my code on
run.js
:on console am running:
Getting this error:
I have no knowledge about
js
language, the error must be in my code, Because i can't figure out the error asking here.Thank You.