Bitcoin transactions are the backbone of the Bitcoin network, facilitating the transfer of value. Understanding their structure is essential for anyone interested in blockchain technology. This article delves into the details of both legacy and witness (SegWit) transaction structures. Basics of Bitcoin Transactions A Bitcoin transaction comprises inputs and outputs. Inputs are sources of funds,
Read more
Tag: Script
Proving Ownership of BTC Multisig Addresses
Posted onProving ownership of a Bitcoin (BTC) address is a crucial aspect in various scenarios. The post Proof of Ownership for BTC Addresses introduced the proof for non-multisig addresses. This guide explores how to prove ownership for different multisig BTC address types, including algorithm specifications and step-by-step methods. What is a Multisig Address? A Bitcoin multisig
Read more
Proof of Ownership for BTC Addresses: A Detailed Guide
Posted onProving ownership of a Bitcoin (BTC) address is a crucial aspect in various scenarios, such as verifying identity in a transaction or demonstrating holdings without revealing private keys. This guide explores how to prove ownership for different BTC address types, including algorithm specifications and step-by-step methods. BTC Address Types P2PKH (Pay-to-Public-Key-Hash) P2SH (Pay-to-Script-Hash) P2WPKH (Pay-to-Witness-Public-Key-Hash)
Read more
Multisig 101
Posted onMultisig, short for “multisignature,” is a cryptographic mechanism that requires multiple signatures to authorize and execute a transaction. What is Multisig Multisig ensures that multiple parties must collaborate and approve a transaction before it can be deemed valid. It provides an additional layer of security requiring multiple parties’ signatures to spend or transfer the crypto
Read more
3 Ways of .odt to .txt File Conversion in Command Line in Linux
Posted onThe Open Document .odt files can contain rich formats for the content. However, some times a plain text file is more handy. We may convert .odt files to plain text files for such needs. In this post, we discuss 3 ways of how to convert .odt files to .text files in command line in Linux.
Read more
How to Count the Number of Words in a File in PHP?
Posted onCounting the number of words in a file is useful in many programs. In this post, we will discuss how to count the number of words in a file in a PHP script. In PHP standard library, we have function str_word_count($str) which returns the number of words from a string $str. On the other hand,
Read more
Add Inline Comments for Multi-line Command in Bash Script
Posted onIn Bash script, it is common that multiple small commands run together connected by pipes (|) and the whole command is quite long. For clarity, we may write the command in multiple lines. How to add comments for these long multi-line commands? In Bash, the content after # in a line is the comment. Using
Read more
How to Match Multiple Lines using Regex in Perl One-liners
Posted onPerl one-liners with perl’s regular expression statement can be a very powerful text processing tools used as commands in a terminal or a script. By default, the input to the perl one-liner with -p or -n options is passed line by line. However, when we want to match multiple lines, it gets us some trouble.
Read more
How to Query Transaction By ID in Hyperledger Fabric 2.0
Posted onQuerying transaction content out from a blockchain network is a common practice used by common scenarios like exploring the blockchain history or verifying the blockchain transaction content from a known ID. In Hyperledger Fabric, the transaction can be queried using a special system chaincode QSCC (Query System Chaincode) which is for ledger and other Fabric-related
Read more
How to Install Hyperledger Fabric 2.0 in Ubuntu 18.04
Posted onHyperledger Fabric is a consortium blockchain system. It’s performance is relatively good and its modular architecture enables it to be usable in many scenarios. Hyperledger Fabric itself has rich documents and samples of test networks. For beginners, deploying a new network for trying and testing still consumes quite some time. In this post, we will
Read more
How to Install Go 1.13.x on Ubuntu 18.04
Posted onIn Ubuntu 18.04 LTS, the default Go lang version is 1.10. For compatibility reason, the Ubuntu LTS will usually keep the major release version numbers for packages. However, many applications, such as Hyperledger Fabric 2.0, require a newer version of Go. In this post, let’s take a look at how to install a system level
Read more
Bash Learning Materials
Posted onBash (GNU Bourne-Again SHell) the default shell for many Linux distributions. It is very common for scripting languages in Linux. Bash is easy and straightforward for writing small tools. However, as most tools, it has its grammars that could easily cause bugs if they are not used correctly. Here I summarize a list of good
Read more
How to Install Wine 32-bit on CentOS 8
Posted onSince version 7, RHEL and CentOS only have 64 bit versions. For some reasons, it’s better to run many Windows applications under 32 bit wine. Like How to Install Wine 32-bit on CentOS 7, this post introduce how to install 32-bit Wine on CentOS 8. Most of the mechanisms are similar yet there are differences.
Read more
How to get the full path and directory of a Python script itself?
Posted onIn a Python script, how to get the full path and directory of the Python script itself? To get the path of the current file (the script itself), you can use __file__. To resolve any symbolic links in the path, you can use os.path.realpath(). Putting them together, you can do os.path.realpath(__file__) to get the full
Read more
How to judge whether its STDERR is redirected to a file in a Bash script on Linux?
Posted onWithin a Bash script, how to judge whether its STDERR is redirected to a file in Bash on Linux? For example, ./script.sh /tmp/log 2>&1 Can script.sh detect that its STDERR is redirected? Knowing the destination file is better. To test whether a script’s STDERR (or STDOUT) is redirected to a file, check by [[ -f
Read more
How to get the full request URL in PHP?
Posted onHow to get the full request URL of the page being processed in PHP? If you are sure the request is a http or https one, and the PHP script is executed according to (e.g. by a load balancer or apache reverse proxy) the REQUEST_URI/HTTP_HOST which are set by the client, the PHP script can
Read more
How to add a prefix string at the beginning of each line in Bash shell script on Linux?
Posted onHow to add a prefix string at the beginning of each line in Bash shell script on Linux? For example, assume we have a file a.txt: line 1 line 2 I want to have, pre line 1 pre line 2 You may use sed, the stream editor for filtering and transforming text: sed -e ‘s/^/pre
Read more
Killing Running Bash Script Process Itself and All Child Processes In Linux
Posted onIn Linux, how to kill a process and all its child processes? For example, a Bash script A starts B, B starts C and C calls rsync. I would like to kill A and all its child processes all together. How to do this? There are possibly many answers to this question. One of the
Read more
How to Debug a Bash script?
Posted onHow to debug a Bash script if it has some bugs? Common techniques like printing varibles out for checking apply for bash too. For bash, I also use 2 bash-specific techniques. Use errexit option Run the script with -e option like bash -e your-script.sh or add set -o errexit to the beginning of the script.
Read more
How to delete or get the number in the tail from a string in shell script?
Posted onHow to delete or get the number in the tail from a string in shell script (bash script)? Okay to call other tools. For example, from “/dev/sda8”, I want to get “/dev/sda” and “8” separately. This can be achieved by using sed as follows. To get the string after deleting the tailing numbers, we can
Read more