Skip to main content
Share Your Experience: Take the 2024 Developer Survey
7 votes
Accepted

How to sign raw transaction given a private key and SHA hash (in java)

This answer does not attempt to sign a transaction, but simply focuses on successfully calling the sign method of the ECKey class, i.e. making your code work. I am not yet familiar with the ...
Sven Williamson's user avatar
7 votes
Accepted

Bruteforce bitcoin address - I know the words + public address but not the order

Doing this requires three things: Permutations of the seed words The address you're trying to locate The derivation path for that address. In this specific case, the address is the one this puzzle ...
Raghav Sood's user avatar
  • 17.1k
4 votes
Accepted

Why the bitcoin address is not valid in any of the testNet faucet

Testnet uses a different address format than the main network. Testnet addresses start with an "m" or "n". The address you are using starts with a "1" and is therefore for the main network. This is ...
cpsola's user avatar
  • 1,548
4 votes
Accepted

How to develop with the Bitcoin cash?

There is a bitcoinj.cash project currently being put together. The code is not ready for use but should be by next week: https://github.com/bitcoinj-cash/bitcoinj
user3169736's user avatar
4 votes
Accepted

Java: Base58-encode String

Your output is correct given the input that you used. However, If you are expecting to get an output address of 39YteymR86cG7V3Kijg8Gm2ST1r4nTeM1b, it looks like your input is incorrect. It's missing ...
Ryan McGeary's user avatar
4 votes

ECDSA signature with r value of 31?

This is valid, and there are even smaller types as well. Be aware that Bitcoin no longer really uses ASN.1 DER, but a even more restrictive subset of it. ASN.1 itself as it turns out is not ...
Claris's user avatar
  • 15.4k
3 votes
Accepted

The BTC shows 10^8 times more than what is received in the account

Apparently the app shows the amount as Satoshi (the smallest unit) instead of BTC. For internal calculations that's ok because it avoids rounding errors, but for input and output you should scale by ...
Hans-Martin Mosner's user avatar
3 votes

Unable to execute getwork logic in java

The getwork RPC call was removed from Bitcoin Core. It was deprecated and then superceded by the getblocktemplate RPC call. It looks like the pool that you are using uses an unspecified protocol. It'...
Ava Chow's user avatar
  • 70.8k
3 votes

How to convert from Ardor time to Unix time?

Ardor time is measured in seconds since the Genesis block, represented as Java int. Currently there is no API which performs conversion to Unix time so you have to code it yourself. If you are ...
lyaffe's user avatar
  • 1,495
3 votes
Accepted

How to verify a signed message by bitcoin core?

The preimage used when signing messages with Bitcoin Core is a combination of the "Magic" phrase: Bitcoin Signed Message:\n and the Message you are signing. However there is one caveat, being you must ...
Septem151's user avatar
  • 667
3 votes
Accepted

Can I always set the first byte to 0x02 with the following implementation?

You're correct that the first byte should be 0x03 if the y-coordinate of the public key is odd. So indeed, the tutorial is not correct. If the y-coordinate is odd, just set this instead: pubBytes[0] = ...
meshcollider's user avatar
  • 11.8k
2 votes
Accepted

How can I create a raw transaction in hex format with Bitcoinj?

Don't build the entire parent transaction, just build the outpoint, which is all that is relevant for encoding a transaction to hex. Specifically use this constructor EDIT: More specifically, cannot ...
Chris Stewart's user avatar
2 votes

Get uncompressed public key from compressed form

You can use bouncycastle ECPoint to do this conversion: static ECParameterSpec SPEC = ECNamedCurveTable.getParameterSpec("secp256k1"); static byte[] compressedToUncompressed(byte[] compKey) { ...
michaelliao's user avatar
2 votes
Accepted

Get uncompressed public key from compressed form

Yes, you can convert a 33-byte compressed public key into a 65-byte uncompressed public key in Java. Here is the code to perform the operation. It is correct, robust, and only requires Java SE ...
Nayuki's user avatar
  • 882
2 votes

Bitcoin ZeroMQ and Scala application

It is not specified what to subscribe. socket.connect("tcp://127.0.0.1:28332") socket.subscribe("hashtx"); # if you need raw data or block data, to add-> socket.subscribe("hashblock"); socket....
hnak's user avatar
  • 21
2 votes

Library for trading on major exchanges

You may also want to take a look at my ccxt library on GitHub: https://github.com/kroitor/ccxt It is a JavaScript / Python / PHP library for cryptocurrency trading and e-commerce with support for ...
Igor Kroitor's user avatar
2 votes

What is the difference between transactioninput.getFromAddress() and transactioninput.getConnectedOutput().getAddressFromP2SH(networkparameter))?

Shabahat's answer is good, but here's how each method of getting an address works: getFromAddress() takes the last element of the scriptSig, and hashes it to find the P2SH address. If the transaction ...
Nick ODell's user avatar
  • 29.4k
2 votes

What is the difference between transactioninput.getFromAddress() and transactioninput.getConnectedOutput().getAddressFromP2SH(networkparameter))?

After going through bitcoinj API documentation regarding the methods you have asked about, the way you make the second method work, you are supposed to connect the input transaction to get the output ...
Shabahat M. Ayubi's user avatar
2 votes
Accepted

I'm working to add multiwallet support to Bitcoin Wallet App, but now the balance is no longer updating

Remove block for else if in that you have used useTor(), it doesnt need at all
Shubham's user avatar
  • 36
2 votes

How to convert Satoshi to BTC in Java?

The Coin.valueOf(long) static constructor takes Satoshis as an input. You can use one of the toString/toFriendlyString/toPlainString methods to derive a human readable value string.
Andreas's user avatar
  • 539
2 votes

The BTC shows 10^8 times more than what is received in the account

Yes, and in bitcoinj there are actually two classes for formatting Coin values for humans: MonetaryFormat and BtcFormat. I strongly suggest using one of the two. Here's an example: Wallet wallet = &...
Andreas's user avatar
  • 539
2 votes
Accepted

How to generate xPub Key from public key in java

The extended public key, xPub, consists of both a chaincode and the public key itself. These are effectively distinct from each other, you cannot generate the chain code from the public key or vice-...
meshcollider's user avatar
  • 11.8k
2 votes
Accepted

Java: way to convert a 256-bit private key to WIF?

You should convert hex representation of bytes to byte array (not String to byte array). Then make hash. Then convert the byte array back to hex representation of bytes in String. The whole solution ...
Michał Zabielski's user avatar
2 votes
Accepted

JAVA JSON-RPC for Litecoin

Since Litecoin is a fork of bitcoin you can use JavaBitcoindRpcClient to connect with litecoin client and execute API calls. link:https://github.com/Polve/JavaBitcoindRpcClient To connect with ...
Ajit Soman's user avatar
2 votes

How do i parse the zeroMQ messages in java?

Bitcoin Core does not give you strings for the data from ZMQ. It provides the raw bytes of the transactions, blocks, and their hashes. You will need to interpret the received data as byte arrays and ...
Ava Chow's user avatar
  • 70.8k
2 votes
Accepted

How do i parse the zeroMQ messages in java?

Ok so i found the solution. The "hashtx, hashblock" etc messages are sent as raw binary bytes which then need to be converted to hexadecimal. Here is my code. public static void main(String[] args) ...
dudious maximus's user avatar
2 votes
Accepted

how to create Watching Address from available xPub key

For generating addresses from extended public key for watch-only wallet, First of all you need to first create the watch-only wallet by that extended public key. and then you can simply derive the ...
FairyRosie's user avatar
2 votes
Accepted

Handling fees and setting them

I was able to resolve the issue. public static String estFee(String amount, String receiver, WalletAppKit kit, NetworkParameters params){ try { String value2 = String.format("%.8f"...
BTCDude's user avatar
  • 41
2 votes
Accepted

Can't see balance after some time

Sounds like a watching wallet, but you need to save the wallet file as well as you're saving spv file. As per documentation
Zombie's user avatar
  • 548
2 votes

what are the dangers of transfering bitcoins between addresses?

The dangers are minimal. There is no restriction on which addresses can send to which other addresses. Most common issues arise from wallets failing to support different address encodings (many ...
Raghav Sood's user avatar
  • 17.1k

Only top scored, non community-wiki answers of a minimum length are eligible