{"id":27954115,"url":"https://github.com/pdoup/bitcoin-p2sh-2of3","last_synced_at":"2026-05-02T03:09:34.188Z","repository":{"id":129337367,"uuid":"486934127","full_name":"pdoup/bitcoin-p2sh-2of3","owner":"pdoup","description":"Spends all funds sent to a 2-of-3 P2SH address","archived":false,"fork":false,"pushed_at":"2022-10-12T17:05:33.000Z","size":99,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T17:20:41.537Z","etag":null,"topics":["bitcoin","bitcoin-script","p2sh"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pdoup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-29T10:41:50.000Z","updated_at":"2022-10-12T20:06:30.000Z","dependencies_parsed_at":"2023-06-09T06:15:49.270Z","dependency_job_id":null,"html_url":"https://github.com/pdoup/bitcoin-p2sh-2of3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pdoup/bitcoin-p2sh-2of3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdoup%2Fbitcoin-p2sh-2of3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdoup%2Fbitcoin-p2sh-2of3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdoup%2Fbitcoin-p2sh-2of3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdoup%2Fbitcoin-p2sh-2of3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdoup","download_url":"https://codeload.github.com/pdoup/bitcoin-p2sh-2of3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdoup%2Fbitcoin-p2sh-2of3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32521152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","bitcoin-script","p2sh"],"created_at":"2025-05-07T17:20:12.009Z","updated_at":"2026-05-02T03:09:34.182Z","avatar_url":"https://github.com/pdoup.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bitcoin-p2sh-2of3\n\n### **Data \u0026 Web Science MSc Program**\n### *Decentralized Technologies Course - Assignment 1, 2022, Bitcoin*\n\nFor this assignment you will need to implement two scripts using `Python 3` and any\nadditional library of your choice (bitcoin-utils is highly recommended though).\nThe first one will create a `P2SH` Bitcoin address that implements a `MULTISIG` scheme,\nwhere all funds sent to it should be locked until 2 out of 3 potential signers sign a\ntransaction to move the funds elsewhere.\nThe second program will allow spending all funds from this `P2SH` address.\nBoth programs should:\n* use regtest/testnet\n* assume a local Bitcoin regtest/testnet node is running\n\n### The first program should:\n\n- [X] accept 3 public keys for the purpose of creating the `P2SH` address that will implement a `2-of-3 MULTISIG` scheme\n- [X] display the `P2SH` address\n\n---\n\n### The second program should:\n\n- [X] accept 2 private keys (used to sign transactions) and 1 public key (to recreate the\nredeem script as above – the other two public keys may be derived from the\nprovided private keys)\n- [X] accept a `P2SH` address to get the funds from (the one created by the first script)\n- [X] accept a `P2PKH` address to send the funds to\n- [X] check if the `P2SH` address has any `UTXO`s to get funds from\n- [X] calculate the appropriate fees with respect to the size of the transaction\n- [X] send all funds that the `P2SH` address received to the `P2PKH` address provided\n- [X] display the raw unsigned transaction\n- [X] sign the transaction\n- [X] display the raw signed transaction\n- [X] display the transaction id\n- [X] verify that the transaction is valid and will be accepted by the Bitcoin nodes\n- [X] if the transaction is valid, send it to the blockchain\n\n### ***Notes***\n1. there is some repetition between the 2 programs; this is fine[^1].\n2. you may test your scripts by sending some funds to the P2SH address you created\n3. you may query the local Bitcoin testnet/regtest node using the JSON-RPC interface\nyou may query an external API for the currently accepted fees/byte\n4. the P2SH address might have received funds from multiple transactions. Create an\ninitial version of your script where it handles a single known transaction. Expand it\nto using multiple unknown transactions later.\n5. when dealing with multiple inputs, you will need to sign all of them\n6. try implementing a 1-of-3 MULTISIG scheme as a first step\n7. you are expected to manually construct the Bitcoin locking/unlocking script for the\nMULTISIG transactions, using the appropriate OP_codes. If the programming\nlibraries you are using have functionality to automatically create such transactions,\ndo not use them (it will be penalized)\n8. for the sake of simplicity, the 2 required private keys that are needed for signing\nthe transaction in the second program can be provided at the same time and\ntransactions can be signed with both signatures within the same program,\nalthough obviously this would never happen in a real world setting\n9. you will submit a single compressed file (zip or tar.gz) that contains the Python\nsource code. It should include a text file with detailed instructions on how to run\nyour programs\n10. Also include a `requirements.txt` file that will specify any extra Python libraries you\nhave used. You can easily create such a file using the following command in your\nPython virtual environment:\n```$ pip freeze \u003e requirements.txt```\n11. the source code is your main submission and it should contain everything you\nwant to share. It should include detailed comments and everything else you think\nwe should be aware of\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdoup%2Fbitcoin-p2sh-2of3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdoup%2Fbitcoin-p2sh-2of3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdoup%2Fbitcoin-p2sh-2of3/lists"}