Error upon getting transactions received by address using bitcoin-cli - bitcoin

I've got problem with printing transactions received on address.
On my machine I've got full sync node
but still cannot get transactions on address. Command which I use:
bitcoin-cli getreceivedbyaddress ADDRESS
Result:
error code: -4
error message:
Address not found in wallet
Is there anything more that I should do?

getreceivedbyaddress is a wallet RPC query. It queries your own wallet.
Bitcoind does not maintain a full per-address index of the blockchain.
To query any address you should use importaddress RPC call
importaddress "address" ( "label" rescan p2sh ) Adds an address or
script (in hex) that can be watched as if it were in your wallet but
cannot be used to spend. Requires a new wallet backup.
rescan is on by default and rescanning can take some time.

Related

insufficient funds for intrinsic transaction cost on test ropsten server

I'm trying to follow a tutorial to create an NFT: https://ethereum.org/en/developers/tutorials/how-to-write-and-deploy-an-nft/
I took a faucet here: https://faucet.metamask.io/
But when trying to mint the contract I get this error:
λ npx hardhat --network ropsten run scripts/deploy.js Error: insufficient funds for intrinsic transaction cost (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS, version=providers/5.5.3) at Logger.makeError (E:\chat\nft\my-nft\node_modules\#ethersproject\logger\src.ts\index.ts:225:28) at Logger.throwError (E:\chat\nft\my-nft\node_modules\#ethersproject\logger\src.ts\index.ts:237:20) at checkError (E:\chat\nft\my-nft\node_modules\#ethersproject\providers\src.ts\json-rpc-provider.ts:53:16) at E:\chat\nft\my-nft\node_modules\#ethersproject\providers\src.ts\json-rpc-provider.ts:215:24 at processTicksAndRejections (internal/process/task_queues.js:93:5) { reason: 'insufficient funds for intrinsic transaction cost', code: 'INSUFFICIENT_FUNDS', error: ProviderError: insufficient funds for gas * price + value at HttpProvider.request (E:\chat\nft\my-nft\node_modules\hardhat\src\internal\core\providers\http.ts:49:19) at LocalAccountsProvider.request (E:\chat\nft\my-nft\node_modules\hardhat\src\internal\core\providers\accounts.ts:182:36) at processTicksAndRejections (internal/process/task_queues.js:93:5) at EthersProviderWrapper.send (E:\chat\nft\my-nft\node_modules\#nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20), method: 'sendTransaction', transaction: undefined } I have tried to find on the net I do not understand why it does not work when I am on the ropsten test network.
how i can solve this problem?
Thank you
I also had the same problem, and I reached the same point in that tutorial failing with the same exact message.
The problem on my side was the address was indeed without funds.
Go to this address to request funds from the faucet https://fauceth.komputing.org/ and enter your wallet address from metamask. if you have the browser extension you can find your correct address right there, see the following image:
You can also check on Etherscan to validate if the funds are really there in your address.
Hope it helps Rija Cloud !
Make sure you select rospten network in Alchemy.
Make sure when you update your testnet eg: from rinkeby to kovan, you also go ahead and get the new URL to reflect that change in network. If you done the URL will be pointing to the wrong testnet.

How does full node verify transaction if all it has bitcoin address and no public key

If it’s impossible to get public address from bitcoin address. How can a full node performing the transaction verify that the transaction is coming from authorised user.
The core of bitcoin is he language, Bitcoin Script, this is a language not Turing complete because is without loop.
The node bitcoin doesn't need the public key for spending the bitcoin, but a transaction input have an unlocked script (known as ScriptSig) this transaction can unlock a previous output transaction with have a locked script(Know as Script pubkey), for unlocked the node executed in the stack the ScriptSig + ScrptPubKey, if return true the transaction is spendable otherwise no.
an example
if you have two transaction
Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501
Output:
Value: 5000000000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG
How bitcoin execute the script
Complete script
304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10 OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG
if you push the script inside this ide and run it you can see how bitcoin run the script.
In this example the ide returned false because the transaction output cannot be sent with her input
The ScriptPubKey(most of the time) contains the pubKey
The ScriptSing contains the Signature of the private key
This are all informations for work the simple node bitcoin.
Now I have and question for you.
You say
impossible to get public address from bitcoin address.
what does it mean?

bitcoin-cli: how to create a wallet and utxo address

I am a relative newbie in bitcoin and blockchain and hope you can help me with some of the questions.
So I launched a "regtest" network and generated 101 blocks using
bitcoin-cli -regtest generate 101
Now, if I launch 'bitcoin-cli -regtest getaddressesbyaccount ""', I get the public address of my default account:
[
"mwpKJNJ4UZL7yFyj53RSVcwauGAK84UvV2"
]
And of course, I should not have any other accounts as for now.
When I launch 'bitcoin-cli -regtest listunspent':
[
{
"txid": "694030f8638318c8c54054515ec716159edc494b14234885deb48f294b75a2fe",
"vout": 0,
"address": "n1queZpweTHjrMLvwSmcfrrJSQjsrYG3nG",
"scriptPubKey": "21038cadb266ed1ae6c474f5c1b74fc5f6790eacde843a673a16cfc924a100f2a679ac",
"amount": 50.00000000,
"confirmations": 101,
"spendable": true,
"solvable": true,
"safe": true
}
]
First question:
I understand that the only transaction listed by "listunspent" is UTXO,
meaning this is a transaction what I received to my address "n1queZpweTHjrMLvwSmcfrrJSQjsrYG3nG" with 50 BTC as amount.
Where this address comes from? By what bitcoin-cli command I can see/find it in my wallet?
Second question:
How can I create a new wallet with some balances and switch between them ( using bitcoin-cli )?
Basically, I would like to be able to test my app using bitcoin-cli - I need to be able to create wallets, switch between them and send btc between the addresses.
Coinbase coins can't be transferred until 100 blocks after they were created.
(Why did you generate "101" blocks specifically?)
So, the amount in your wallet you see is from the first block you mined. You can verify that by bitcoin-cli -regtest getblock "<hash of first block>" which you had got in return to the generate 101 command you ran earlier (an array of 101 block hashes).
Try the following
generate one more block bitcoin-cli -regtest generate 1
now listunspent and you should see 2 utxos instead of 1.
Depending on what you want to test, maybe simply creating a new address and sending money to it is enough for you?
[Edit]
Shut down core properly.
Rename your wallet.dat file
When you restart, a new wallet(wallet.dat) will be created. You can use them by supplying -wallet arg to bitcoin-qt
For example, if you are on linux:
Create 4 wallets by starting bitcoin core, stopping bitcoin core and then renaming the wallet.dat in your ~/.bitcoin folder (then repeating the process). For example, run this process 4 times to generate :
mywallet.dat
wifeswallet.dat
kidswallet.dat
businesswallet.dat
Then, in linux, in your .bashrc :
alias mywallet="bitcoin-qt -wallet=~/.bitcoin/mywallet.dat"
alias wifeswallet="bitcoin-qt -wallet=~/.bitcoin/wifeswallet.dat"
alias kidswallet="bitcoin-qt -wallet=~/.bitcoin/kidswallet.dat"
alias businesswallet="bitcoin-qt -wallet=~/.bitcoin/businesswallet.dat"

Create Refund on square_connect Ruby sdk gives INTERNAL SERVER ERROR

I am using square_connect ruby gem to refund payments.
body =
#<SquareConnect::CreateRefundRequest
#amount_money=#<SquareConnect::Money #amount=200, #currency="USD">,
#idempotency_key="be70cc12-28dd-4168-96ea-6eb78f299207",
#tender_id="asdkasdkakdakdakda">
All other parameters are just as intended. I have changed Tender key too.
result = api_instance.create_refund(authorization, location_id, transaction_id, body)
This gives me INTERNAL SERVER ERROR.
ETHON: performed EASY effective_url=https://connect.squareup.com/v2/locations/BP6GXQNEANA9B/transactions/b2fd4689-af1b-40a4-b706-aafd592e1111/refund response_code=500 return_code=ok total_time=1.883598
SquareConnect::ApiError: Internal Server Error - {"errors":[{"category":"API_ERROR","code":"INTERNAL_SERVER_ERROR","detail":"An internal error has occurred, and the API was unable to service your request."}]}
Are you sure that your tender_id matches a tender you want to refund? 500 isn't the correct response, but it seems like you are likely not selecting a correct tender to refund.
Also you should look into upgrading your SDK to the latest version.
This is a major bug in the Square Connect API. I was actually trying with a wrong transaction ID, instead of getting something like "Incorrect Transaction ID" I was getting 500 Internal Server Error.
I have been using Stripe, Payflow. Authorize.net, Braintree and Moneris API for almost 2 years now but I have never received a 500 Internal server error for a wrong transaction Id. So Square needs to address it on urgent basis.

See foreign bitcoin transactions

I'm trying to get a transaction info using
bitcoind gettransaction \
9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271
but I'm receiving
error: {"code":-5,"message":"Invalid or non-wallet transaction id"}
How to see a transaction using bitcoin API?
You can view foreign transactions using bitcoind.
Set txindex=1 in your bitcoin.conf file.
restart bitcoind with -reindex (you need to re-build your entire index)
After you've indexed a few blocks you can use something like this:
$ bitcoind getblockcount
122735
$ bitcoind getblockhash 67543
0000000004e213266ccd388df12896412c1a70e647b48004f7d6894b9d6f63b9
$ bitcoind getblock 0000000004e213266ccd388df12896412c1a70e647b48004f7d6894b9d6f63b9
// JSON containing tx "a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa"
$ bitcoind getrawtransaction a93a668d9332e21d51380c7251bbf5ad47295ca9795e0ad6f2fe8d63b76af9aa 1
// json of transaction - note that "1" at the end tells bitcoind to decode into json
See this for more.
getrawtransaction <txid> command gets any transaction even from Bitcoin-qt client
Raw Transactions
The "raw transaction API" was introduced with Bitcoin-Qt/bitcoind version 0.7. It gives developers or very sophisticated end-users low-level access to transaction creation and broadcast.
This will return hexadecimal string of bytes, which is not very useful. But if you type
getrawtransaction <txid> 1
you'll get nicely formatted JSON representation
znort987's blockparser program looks promising. i haven't had a chance to play with it yet so i'm not sure if it has native support for specifying an individual transaction to inspect, but the doco says that if you know the receiving address then you can get all transaction details for that address like so:
./parser transactions the_receiving_address
As the error said, you are trying to see a transaction which is not part of your wallet. Bitcoind only allows you to explore transactions that are related to your wallet.
If you want to explore "foreign" transactions, you should use other tools like http://blockexplorer.com/