Bitcoin Forum
March 28, 2024, 09:50:26 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Make a bitcoin transaction with python?  (Read 352 times)
JasonSato (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 4


View Profile
May 01, 2022, 05:01:43 PM
Merited by o_e_l_e_o (4)
 #1

I've tested almost all bitcoin wallets in Windows.
Is it possible to make a transaction with a python script?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1711619426
Hero Member
*
Offline Offline

Posts: 1711619426

View Profile Personal Message (Offline)

Ignore
1711619426
Reply with quote  #2

1711619426
Report to moderator
1711619426
Hero Member
*
Offline Offline

Posts: 1711619426

View Profile Personal Message (Offline)

Ignore
1711619426
Reply with quote  #2

1711619426
Report to moderator
BlackHatCoiner
Legendary
*
Online Online

Activity: 1470
Merit: 7064


Farewell, Leo


View Profile
May 01, 2022, 05:34:44 PM
Merited by Pmalek (1)
 #2

What do the wallets have to do with this? Have you tried python-bitcointx[1] or pybitcointools[2]? I just did a search and these came up. And I know little about python.

[1] https://pypi.org/project/python-bitcointx/
[2] https://bitcoin.stackexchange.com/questions/46735/how-can-i-sign-transaction-hex-with-python-library

If you want my recommendation, use bitcoin.stackexchange.com a lot. It's useful for bitcoin related technical stuff.

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
Husires
Legendary
*
Offline Offline

Activity: 1554
Merit: 1278



View Profile WWW
May 01, 2022, 05:54:53 PM
 #3

Yes, you need to Install bitcoin python library

Code:
pip install bitcoin
then generate your private key using my_key= = random_key()
then your public key using my_pubkey= privtopub(my_private_key)
then your address my_address=pubtoaddr(my_public_key)
then you can send it using tx_hex = make_transaction(
    inputs=[[your_address, your_private_key]],
    to='receiver address',
    amount=BTC,
    miner_fee=0.0001
)

Code:
my_key= = random_key()
my_pubkey= privtopub(my_private_key)
my_address=pubtoaddr(my_public_key)
tx_hex = make_transaction(
    inputs=[[my_address, my_key]],
    to='receiver address',
    amount=BTC,
    miner_fee=0.0001
)





it is better to do it with test net follow this https://dev.to/nownodes/how-to-make-a-bitcoin-transaction-with-python-54k4

.BEST..CHANGE.███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
JasonSato (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 4


View Profile
May 01, 2022, 06:12:22 PM
 #4

Thanks for the tips Grin
Honestly, I don't fully trust those software wallets.
I want to know how to use a python script to make a tx with my private key and address.
BlackHatCoiner
Legendary
*
Online Online

Activity: 1470
Merit: 7064


Farewell, Leo


View Profile
May 01, 2022, 06:21:21 PM
 #5

Honestly, I don't fully trust those software wallets.
Which ones and why? Every wallet from bitcoin.org is open-source; if you want to verify the code, then so be it. If you don't want or can't understand it, then you'll have to take everyone's word for it. It doesn't make sense to not trust reputable open-source software. That's bitcoin in the end.

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
JasonSato (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 4


View Profile
May 01, 2022, 06:49:18 PM
 #6

Which ones and why? Every wallet from bitcoin.org is open-source; if you want to verify the code, then so be it. If you don't want or can't understand it, then you'll have to take everyone's word for it. It doesn't make sense to not trust reputable open-source software. That's bitcoin in the end.
I didn't mean that hot wallets are not reliable at all!
Somehow I want to make my transactions in my own way Wink
garlonicon
Hero Member
*****
Offline Offline

Activity: 789
Merit: 1910


View Profile
May 01, 2022, 07:42:58 PM
 #7

If you know what are you doing, then of course you can. You can write a transaction even in a notepad, use custom scripts, and make your own stuff. It is an incredible world with a lot of treasures and puzzles, also you can do things that are hard or impossible in typical GUI wallets, for example transaction mining, see 000000000fdf0c619cd8e0d512c7e2c0da5a5808e60f12f1e0d01522d2986a51.

Hold your horses before deploying blockchain-related things. You don't want to deploy SHA-1 collision without deploying hardened SHA-1. Once you reveal some code, and make it Open Source, there is no "undo" button. Once you share some idea, there is no way to erase it from reader's memory.
stanner.austin
Member
**
Online Online

Activity: 65
Merit: 53


View Profile
May 02, 2022, 08:15:05 AM
 #8

@JasonSato
Hello
With python example and there web link to empty out old private key.
https://bitcointalk.org/index.php?topic=5392986.msg59753846#msg59753846
JasonSato (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 4


View Profile
May 02, 2022, 10:16:46 AM
 #9

@JasonSato
Hello
With python example and there web link to empty out old private key.
https://bitcointalk.org/index.php?topic=5392986.msg59753846#msg59753846
Hi
Thanks for the tip.
I'm looking for the best script to sign and broadcast a tx with python.
OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 3430
Merit: 6083



View Profile
May 04, 2022, 03:46:48 PM
 #10

Hi
Thanks for the tip.
I'm looking for the best script to sign and broadcast a tx with python.

The code he shared with you should be very helpful. Instead of create_transaction()[1], you can use send()[2] which attempts to broadcast the transaction.  

[1] https://ofek.dev/bit/dev/api.html#bit.PrivateKey.create_transaction
[2] https://ofek.dev/bit/dev/api.html#bit.PrivateKey.send

█▀▀▀











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











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

Activity: 1554
Merit: 6532


bitcoincleanup.com / bitmixlist.org


View Profile WWW
May 05, 2022, 11:02:37 AM
 #11

~
You can write a transaction even in a notepad
~

Not that it's particularly advisable.

A hex editor is probably more suitable than a text editor given that BTC transactions are byte-oriented and not some markup language.

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
n0nce
Hero Member
*****
Offline Offline

Activity: 868
Merit: 5808


not your keys, not your coins!


View Profile WWW
May 07, 2022, 05:17:23 PM
 #12

Thanks for the tips Grin
Honestly, I don't fully trust those software wallets.
I want to know how to use a python script to make a tx with my private key and address.
Oh this is a very bad idea. By typing your seed phrase or private key into a Python script, it could be stolen by an attacker (now or in the future). Your backup software might create a file system backup without you noticing or you might use an HDD from which deleted files can be recovered even a long time in the future, so writing a seed to disk is always highly discouraged (by me).
And your secondary risk will be loss of funds due to an error in your code. The open-source wallets BlackHatCoiner linked for you, have been reviewed, tested and improved over years by hundreds of developers; I don't see why they would be worse than your own custom script.

Especially if you don't write everything by yourself, but trust one of the libraries linked above, you can just as well use a tried-and-tested open-source wallet (that most probably uses the exact same library).

For educational purposes, I get it and would recommend the same things that the others recommended above. But since you specifically mentioned you intend to use this with real mainnet funds, I wanted to type out a little disclaimer.

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
DireWolfM14
Copper Member
Legendary
*
Offline Offline

Activity: 2142
Merit: 4224


Join the world-leading crypto sportsbook NOW!


View Profile WWW
July 12, 2022, 03:58:23 AM
 #13

Honestly, I don't fully trust those software wallets.

By running pip install bitcoin you're installing a software wallet, it's just lighter and runs with python.  That's how bitcoin works, you need software.  Unless you write your own software wallet, you'll have to trust someone else's.

  ▄▄███████▄███████▄▄▄
 █████████████
▀▀▀▀▀▀████▄▄
███████████████
       ▀▀███▄
███████████████
          ▀███
 █████████████
             ███
███████████▀▀               ███
███                         ███
███                         ███
 ███                       ███
  ███▄                   ▄███
   ▀███▄▄             ▄▄███▀
     ▀▀████▄▄▄▄▄▄▄▄▄████▀▀
         ▀▀▀███████▀▀▀
░░░████▄▄▄▄
░▄▄░
▄▄███████▄▀█████▄▄
██▄████▌▐█▌█████▄██
████▀▄▄▄▌███░▄▄▄▀████
██████▄▄▄█▄▄▄██████
█░███████░▐█▌░███████░█
▀▀██▀░██░▐█▌░██░▀██▀▀
▄▄▄░█▀░█░██░▐█▌░██░█░▀█░▄▄▄
██▀░░░░▀██░▐█▌░██▀░░░░▀██
▀██
█████▄███▀▀██▀▀███▄███████▀
▀███████████████████████▀
▀▀▀▀███████████▀▀▀▀
▄▄██████▄▄
▀█▀
█  █▀█▀
  ▄█  ██  █▄  ▄
█ ▄█ █▀█▄▄█▀█ █▄ █
▀▄█ █ ███▄▄▄▄███ █ █▄▀
▀▀ █    ▄▄▄▄    █ ▀▀
   ██████   █
█     ▀▀     █
▀▄▀▄▀▄▀▄▀▄▀▄
▄ ██████▀▀██████ ▄
▄████████ ██ ████████▄
▀▀███████▄▄███████▀▀
▀▀▀████████▀▀▀
█████████████LEADING CRYPTO SPORTSBOOK & CASINO█████████████
MULTI
CURRENCY
1500+
CASINO GAMES
CRYPTO EXCLUSIVE
CLUBHOUSE
FAST & SECURE
PAYMENTS
.
..PLAY NOW!..
NotATether
Legendary
*
Offline Offline

Activity: 1554
Merit: 6532


bitcoincleanup.com / bitmixlist.org


View Profile WWW
July 12, 2022, 04:32:53 AM
Merited by DireWolfM14 (1), BlackHatCoiner (1)
 #14

Unless you write your own software wallet, you'll have to trust someone else's.

This is really a "don't try this at home" kind of thing because there are so many bugs that can possibly creep inside a DIY wallet, that if you got no time to fix them, they could be exploited against other users who happen to trust your wallet.

..JAMBLER.io..Create Your Bitcoin Mixing
Business Now for   F R E E 
▄█████████████████████████████
█████████████████████████
████▀████████████████████
███▀█████▄█▀███▀▀▀██████
██▀█████▄█▄██████████████
██▄▄████▀▄▄▄▀▀▀▀▀▄▄██████
█████▄▄▄██████████▀▄████
█████▀▄█▄██████▀█▄█████
███████▀▄█▀█▄██▀█▄███████
█████████▄█▀▄█▀▄█████████
█████████████████████████
█████████████████████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
      OUR      
PARTNERS

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
▄█████████████████████████████
████████▀▀█████▀▀████████
█████▀█████████████▀█████
████████████████████████
███████████████▄█████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████▀█████████
████████████████████████
█████▄█████████████▄█████
████████▄▄█████▄▄████████
▀█████████████████████████████
█████████████████████████████████████████████████
.
   INVEST   
BITCOIN

.
█████████████████████████████████████████████████
████▄
██
██
██
██
██
██
██
██
██
██
██
████▀
DireWolfM14
Copper Member
Legendary
*
Offline Offline

Activity: 2142
Merit: 4224


Join the world-leading crypto sportsbook NOW!


View Profile WWW
July 12, 2022, 08:52:33 PM
 #15

Unless you write your own software wallet, you'll have to trust someone else's.

This is really a "don't try this at home" kind of thing because there are so many bugs that can possibly creep inside a DIY wallet, that if you got no time to fix them, they could be exploited against other users who happen to trust your wallet.

Whatchu talkin' 'bout?  Really, what can go wrong?




All kidding aside, of course I was being facetious.  I don't recommend you attempt write your own wallet software unless you are a competent programmer working as a member of competent team.  Even the best of us can overlook simple issues that can cause major damage.

  ▄▄███████▄███████▄▄▄
 █████████████
▀▀▀▀▀▀████▄▄
███████████████
       ▀▀███▄
███████████████
          ▀███
 █████████████
             ███
███████████▀▀               ███
███                         ███
███                         ███
 ███                       ███
  ███▄                   ▄███
   ▀███▄▄             ▄▄███▀
     ▀▀████▄▄▄▄▄▄▄▄▄████▀▀
         ▀▀▀███████▀▀▀
░░░████▄▄▄▄
░▄▄░
▄▄███████▄▀█████▄▄
██▄████▌▐█▌█████▄██
████▀▄▄▄▌███░▄▄▄▀████
██████▄▄▄█▄▄▄██████
█░███████░▐█▌░███████░█
▀▀██▀░██░▐█▌░██░▀██▀▀
▄▄▄░█▀░█░██░▐█▌░██░█░▀█░▄▄▄
██▀░░░░▀██░▐█▌░██▀░░░░▀██
▀██
█████▄███▀▀██▀▀███▄███████▀
▀███████████████████████▀
▀▀▀▀███████████▀▀▀▀
▄▄██████▄▄
▀█▀
█  █▀█▀
  ▄█  ██  █▄  ▄
█ ▄█ █▀█▄▄█▀█ █▄ █
▀▄█ █ ███▄▄▄▄███ █ █▄▀
▀▀ █    ▄▄▄▄    █ ▀▀
   ██████   █
█     ▀▀     █
▀▄▀▄▀▄▀▄▀▄▀▄
▄ ██████▀▀██████ ▄
▄████████ ██ ████████▄
▀▀███████▄▄███████▀▀
▀▀▀████████▀▀▀
█████████████LEADING CRYPTO SPORTSBOOK & CASINO█████████████
MULTI
CURRENCY
1500+
CASINO GAMES
CRYPTO EXCLUSIVE
CLUBHOUSE
FAST & SECURE
PAYMENTS
.
..PLAY NOW!..
n0nce
Hero Member
*****
Offline Offline

Activity: 868
Merit: 5808


not your keys, not your coins!


View Profile WWW
July 22, 2022, 08:40:39 PM
 #16

Honestly, I don't fully trust those software wallets.
By running pip install bitcoin you're installing a software wallet, it's just lighter and runs with python.  That's how bitcoin works, you need software.  Unless you write your own software wallet, you'll have to trust someone else's.
I guess for eliminating all trust and only needing to sign transactions, you could write a very small subsection of what I'd call a software wallet all from scratch.

I'd start with a reference of the transaction format: https://en.bitcoin.it/wiki/Transaction
Create it according to spec and then submit it to the mempool of your node using bitcoin-cli sendrawtransaction.

In case you do trust Bitcoin Core, another idea would be to just issue calls to bitcoin-cli from Python (os.popen()).
Or you could use Bitcoin's RPC interface. https://stackoverflow.com/questions/42183776/bitcoin-json-rpc-with-python-requests-module

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
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!