Bitcoin Forum
April 19, 2024, 02:06:33 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: simple transaction bitcoin . Java  (Read 109 times)
Sanka555 (OP)
Member
**
Offline Offline

Activity: 96
Merit: 36


View Profile
January 27, 2022, 08:27:26 AM
Last edit: January 27, 2022, 10:07:11 AM by Sanka555
 #1

java 8

I have 2 addresses. the key from the first and the amount to be sent.
I assume that the amount at the address is sufficient
I need the simplest possible code to send a given amount of Satoshi from one to another in testnet.
 Please tell me how to do it.
Thank you very much in advance  Smiley

example:

Quote
String myAdress= "tbc1qnsfqpgy3z8vnjpn68j7drhekwztrxtr9.....";
String myKey="KzerGrhf................XddJ";
String destination= "tbc1qnsfqpgy3z8vnjpn68j7drhekwztrxtr92.....";
.
.
.

public static void name(String myAdress, String myKey, String destination, long summ, long commission){
...
}

1713535593
Hero Member
*
Offline Offline

Posts: 1713535593

View Profile Personal Message (Offline)

Ignore
1713535593
Reply with quote  #2

1713535593
Report to moderator
1713535593
Hero Member
*
Offline Offline

Posts: 1713535593

View Profile Personal Message (Offline)

Ignore
1713535593
Reply with quote  #2

1713535593
Report to moderator
Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713535593
Hero Member
*
Offline Offline

Posts: 1713535593

View Profile Personal Message (Offline)

Ignore
1713535593
Reply with quote  #2

1713535593
Report to moderator
1713535593
Hero Member
*
Offline Offline

Posts: 1713535593

View Profile Personal Message (Offline)

Ignore
1713535593
Reply with quote  #2

1713535593
Report to moderator
vjudeu
Hero Member
*****
Offline Offline

Activity: 656
Merit: 1509



View Profile
January 27, 2022, 09:43:56 AM
 #2

Quote
I need the simplest possible code to send a given amount of Satoshi from one to another in testnet.
Quote
bc1qnsfqpgy3z8vnjpn68j7drhekwztrxtr92p7893
This address is not for testnet, but for mainnet. In testnet, you would have tb1q address. Also, you have invalid address in "myAdress", because it ends with 5 instead of 3.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
n0nce
Hero Member
*****
Offline Offline

Activity: 882
Merit: 5814


not your keys, not your coins!


View Profile WWW
January 27, 2022, 09:53:27 AM
 #3

public static void(String myAdress, String myKey, String destination, long summ, long commission){
...
}
Pretty sure this function is invalid, since it has no name. Or maybe it's interpreted as having the name 'void', but then you wouldn't have a return type.
It should look like this, where send is a name you can choose.

Code:
public static void send(String myAdress, String myKey, String destination, long summ, long commission){
...
}

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
odolvlobo
Legendary
*
Offline Offline

Activity: 4298
Merit: 3192



View Profile
January 28, 2022, 03:25:52 AM
Merited by ABCbits (2), BlackHatCoiner (2)
 #4

I hate to be the one to break the bad news. Your code is woefully inadequate.

If you are constructing the transaction yourself, then you need more information than just the "sending" address and its private key. Here is some information on constructing a transaction (sorry, its not the best source): https://stackoverflow.com/questions/60255876/signing-a-bitcoin-segwit-transaction

If you are using a wallet through an API, then you will need look into how to use the API.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!