-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename docker-engine to docker-ce. (#982) * upgrade pip before installing requirements * CIP-11: Shorten Transaction Type ID Namespace (#977) * Implements CIP 9 (WIP) (#985) * instead of auto-correcting the quantity to the amount the address holds return invalid: insufficient funds * CIP12 REQUIRE_MEMO: * Fix locked issuance (#999) * Remove rpcthreads=100 (#1002) * Use python-bitcoinlib snapshot for segwit support (#1001) Signed-off-by: Devon Weller <[email protected]>
- Loading branch information
Showing
52 changed files
with
3,663 additions
and
2,105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
import struct | ||
|
||
import bitcoin | ||
|
||
def pack(address): | ||
""" | ||
Converts a base58 bitcoin address into a 21 byte bytes object | ||
""" | ||
|
||
short_address_bytes = bitcoin.base58.decode(address)[:-4] | ||
return short_address_bytes | ||
|
||
# retuns both the message type id and the remainder of the message data | ||
def unpack(short_address_bytes): | ||
""" | ||
Converts a 21 byte prefix and public key hash into a full base58 bitcoin address | ||
""" | ||
|
||
check = bitcoin.core.Hash(short_address_bytes)[0:4] | ||
return bitcoin.base58.encode(short_address_bytes + check) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
import struct | ||
|
||
from counterpartylib.lib import config | ||
from counterpartylib.lib import util | ||
|
||
def pack(message_type_id, block_index=None): | ||
# pack message ID into 1 byte if not zero | ||
if util.enabled('short_tx_type_id', block_index) and message_type_id > 0 and message_type_id < 256: | ||
return struct.pack(config.SHORT_TXTYPE_FORMAT, message_type_id) | ||
|
||
# pack into 4 bytes | ||
return struct.pack(config.TXTYPE_FORMAT, message_type_id) | ||
|
||
# retuns both the message type id and the remainder of the message data | ||
def unpack(packed_data, block_index=None): | ||
message_type_id = None | ||
message_remainder = None | ||
|
||
if len(packed_data) > 1: | ||
# try to read 1 byte first | ||
if util.enabled('short_tx_type_id', block_index): | ||
message_type_id = struct.unpack(config.SHORT_TXTYPE_FORMAT, packed_data[:1])[0] | ||
if message_type_id > 0: | ||
message_remainder = packed_data[1:] | ||
return (message_type_id, message_remainder) | ||
|
||
# First message byte was 0. We will read 4 bytes | ||
if len(packed_data) > 4: | ||
message_type_id = struct.unpack(config.TXTYPE_FORMAT, packed_data[:4])[0] | ||
message_remainder = packed_data[4:] | ||
|
||
return (message_type_id, message_remainder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.