Là Con Gái Phải Xinh
  • Đăng Nhập
No Result
View All Result
  • Trang chủ
  • Mỹ Phẩm
  • Nước hoa
  • Nước hoa hồng
  • Phụ kiện làm đẹp
Là Con Gái Phải Xinh
No Result
View All Result
Home CRYPTOCURRENCY

Bitcoin: (Programming Q) Generating receive addresses from p2wsh multi-sig script?

by Thủy Tiên Anna
13 Tháng Hai, 2025
in CRYPTOCURRENCY
Share on FacebookShare on Twitter

Generating Receiving Addresses from the P2Wash Multi-Sig Script

= Here is an example of how this can be implemented:

import hashlib

import binascii

from embit import bech32


Define constants for the blockchain hash and signature derivation parameters

BLOCKCHAIN_HASH = "your_blockchain_hash_here"

SIGDERivationParameter = 3

def derive_signature(p, r, s):

"""Derivate signature using public key"""

return (hexlify(p).decode() + hashlib.sha256(b"s".encode()).digest().hex()) % 1000000

def p2wpub_script(p, sig, r, s, n):

"""Generate P2Wash multi-sig script"""

return bech32.decode_p2wsh_script(

f"1.{sig}.{r}.{s}.{n}",

[hexlify(p).decode(), hashlib.sha256(b"s".encode()).digest().hex()]

)

def main():


Derived public key, signature and random number

p = derive_signature("your_public_key_here", 0x12, 0x34)

r = derive_signature(p, 1, 2)

s = derive_signature(r, 3, 4)

n = derive_signature(s, 5, 6)


Generate P2Wash multi-sig script

script = p2wpub_script(p, Nothing, r, s, n)


Print generated script

print(script.decode("utf-8"))

if __name__ == "__main__":

main()

Generating receive addresses

Bitcoin: (Programming Q) Generating receive addresses from p2wsh multi-sig script?

————————————

Receive address is a unique identifier that can be used to receive funds from other users. In the context of P2Wash, receiving addresses are usually derived using a similar process.

The p2wpub_script function generates a multi-character P2Wash script, which includes the public key, signature, random number, and non-random parameters (r, s, n). To generate recipient addresses from this script, we need to derive a unique identifier that is not present in the script.

Here is the updated version of the code:

“`python

import hashlib

import binascii

Define constants for the blockchain hash derivation and signature parameters

BLOCKCHAIN_HASH = “your_blockchain_hash_here”

SIGDERivationParameter = 3

def derive_signature(p, r, s):

“””Derivate signature using public key”””

return (hexlify(p).decode() + hashlib.sha256(b”s”.encode()).digest().hex()) % 1000000

def p2wpub_script(p, sig, r, s, n):

“””Generate P2Wash multi-sig script”””

return bech32.decode_p2wsh_script(

f”1.{sig}.{r}.{s}.{n}”,

[hexlify(p).decode(), hashlib.sha256(b”s”.encode()).digest().hex()]

)

def derive_receive_address(script, script_hash):

“””Derivate receive address from P2Wash multi-sig script”””

Extract non-random parameters (r, s, n) and hash

r, s, n = extract_parameters(script)

Derive unique identifier using SHA-256

id = hashlib.sha256(r + s + n.encode()).digest()

return f”2.{id.hex()}{BLOCKCHAIN_HASH}”

def extract_parameters(script):

“””Extract non-random parameters (r, s, n) and hash from script”””

Extract signature, random number and non-random parameters

r, s = extract_signature(script)

id = hashlib.sha256(r + s.encode()).

ETHEREUM DOES CANCELLING CARRY

Thủy Tiên Anna

Thủy Tiên Anna

Liên quan Posts

CRYPTOCURRENCY

The Importance Of Community Engagement In The Success Of Avalanche (AVAX)

4 Tháng Ba, 2025

Strength of Community Involvement: Unlocking the Full Potential of Avalanche (Avax) In The Rapidly Developing World of Cryptocurrencies, A Successful...

CRYPTOCURRENCY

The Impact Of Hyperliquid (HYPE) On Market Dynamics And Trading Strategies

4 Tháng Ba, 2025

The Rise of Hyperliquid (HEPE): Understanding the Impact of Market Dynamics and Trading Strategies We resent there, a new player...

CRYPTOCURRENCY

How Governance Tokens Impact The Value Of Avalanche (AVAX)

4 Tháng Ba, 2025

The Rise of Governance Tokens and their Impact on Avalanche (AVAX) As the world becomes increasingly digital, cryptocurrencies have gained...

CRYPTOCURRENCY

What To Know About Digital Wallets Before You Start Trading

4 Tháng Ba, 2025

negot to Knw to kowal Walletal Walles Bephtal Yu Stating Cryptocurration * The World of Cryptody has Has Exploded in...

CRYPTOCURRENCY

Market Dynamics And Their Influence On Ethereum Classic (ETC)

4 Tháng Ba, 2025

Cryptocurrency Market Dynamics: Understanding Their Impact on Ethereum Classic (ETC) The world of cryptocurrency has been rapidly evolving in recent...

CRYPTOCURRENCY

The Role Of Smart Contracts In Enhancing Security For Stellar (XLM)

4 Tháng Ba, 2025

Here's a topic summary: Smart Contracts and Star (XLM) Smart contracts are self-exhibited contracts with conditions of agreement written directly...

Next Post

How AI Can Transform the Decentralized Application Ecosystem

Kraken, Fork, Mnemonic phrase

Trading Signal, Memecoin, Peer-to-Peer Trading

Trả lời Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Là Con Gái Phải Xinh

Cùng Con Gái Phải Xinh làm đẹp và chia sẽ phương pháp làm đẹp của riêng mình các chị em nhé!

© 2019 Con Gai Phai Xinh

No Result
View All Result
  • Trang chủ
  • Mỹ Phẩm
  • Nước hoa
  • Nước hoa hồng
  • Phụ kiện làm đẹp

© 2019 Con Gai Phai Xinh

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Go to mobile version