common: add Peercoin, regenerate coins

pull/740/head
Pavol Rusnak 4 years ago
parent 5301c03607
commit 3d50bb5ed8
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -0,0 +1,44 @@
{
"coin_name": "Peercoin",
"coin_shortcut": "PPC",
"coin_label": "Peercoin",
"website": "https://peercoin.net",
"github": "https://github.com/peercoin/peercoin",
"maintainer": "backpacker69 <backpacker69@protonmail.com>",
"curve_name": "secp256k1",
"divisibility": 6,
"address_type": 55,
"address_type_p2sh": 117,
"maxfee_kb": 2000000,
"minfee_kb": 10000,
"signed_message_header": "Peercoin Signed Message:\n",
"hash_genesis_block": "0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3",
"xprv_magic": 76066276,
"xpub_magic": 76067358,
"xpub_magic_segwit_p2sh": 77429938,
"xpub_magic_segwit_native": 78792518,
"bech32_prefix": "pc",
"cashaddr_prefix": null,
"slip44": 6,
"segwit": true,
"decred": false,
"fork_id": null,
"force_bip143": false,
"bip115": false,
"default_fee_b": {
"Normal": 10
},
"dust_limit": 10000,
"blocktime_seconds": 600,
"uri_prefix": "peercoin",
"min_address_length": 27,
"max_address_length": 34,
"bitcore": [],
"blockbook": [
"https://blockbook.peercoin.net"
],
"negative_fee": false,
"cooldown": 100,
"consensus_branch_id": null,
"confidential_assets": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

@ -0,0 +1,44 @@
{
"coin_name": "Peercoin Testnet",
"coin_shortcut": "tPPC",
"coin_label": "Peercoin Testnet",
"website": "https://peercoin.net",
"github": "https://github.com/peercoin/peercoin",
"maintainer": "backpacker69 <backpacker69@protonmail.com>",
"curve_name": "secp256k1",
"divisibility": 6,
"address_type": 111,
"address_type_p2sh": 196,
"maxfee_kb": 2000000,
"minfee_kb": 10000,
"signed_message_header": "Peercoin Signed Message:\n",
"hash_genesis_block": "00000001f757bb737f6596503e17cd17b0658ce630cc727c0cca81aec47c9f06",
"xprv_magic": 70615956,
"xpub_magic": 70617039,
"xpub_magic_segwit_p2sh": 71979618,
"xpub_magic_segwit_native": 73342198,
"bech32_prefix": "tpc",
"cashaddr_prefix": null,
"slip44": 1,
"segwit": true,
"decred": false,
"fork_id": null,
"force_bip143": false,
"bip115": false,
"default_fee_b": {
"Normal": 10
},
"dust_limit": 10000,
"blocktime_seconds": 600,
"uri_prefix": "peercoin",
"min_address_length": 27,
"max_address_length": 34,
"bitcore": [],
"blockbook": [
"https://tblockbook.peercoin.net"
],
"negative_fee": false,
"cooldown": 100,
"consensus_branch_id": null,
"confidential_assets": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

File diff suppressed because it is too large Load Diff

@ -26,6 +26,7 @@
"bitcoin:NMC": true,
"bitcoin:PIVX": true,
"bitcoin:POLIS": true,
"bitcoin:PPC": true,
"bitcoin:PTC": true,
"bitcoin:RITO": true,
"bitcoin:RVN": true,
@ -46,6 +47,7 @@
"bitcoin:tDASH": true,
"bitcoin:tLTC": true,
"bitcoin:tPIVX": true,
"bitcoin:tPPC": true,
"bitcoin:tXZC": true,
"eth:AKA": true,
"eth:ATH": true,
@ -127,6 +129,7 @@
"bitcoin:PART": "1.8.3",
"bitcoin:PIVX": "1.8.0",
"bitcoin:POLIS": "1.8.2",
"bitcoin:PPC": "1.8.4",
"bitcoin:PTC": "1.7.1",
"bitcoin:QTUM": "1.8.1",
"bitcoin:REGTEST": "1.8.2",
@ -157,6 +160,7 @@
"bitcoin:tLTC": "1.6.2",
"bitcoin:tPART": "1.8.3",
"bitcoin:tPIVX": "1.8.0",
"bitcoin:tPPC": "1.8.4",
"bitcoin:tQTUM": "1.8.1",
"bitcoin:tSMART": "1.7.1",
"bitcoin:tXZC": "1.6.2",
@ -1596,6 +1600,7 @@
"bitcoin:PART": "2.1.4",
"bitcoin:PIVX": "2.0.11",
"bitcoin:POLIS": "2.1.1",
"bitcoin:PPC": "2.1.9",
"bitcoin:PTC": "2.0.8",
"bitcoin:QTUM": "2.1.1",
"bitcoin:REGTEST": "2.1.1",
@ -1627,6 +1632,7 @@
"bitcoin:tLTC": "2.0.7",
"bitcoin:tPART": "2.1.4",
"bitcoin:tPIVX": "2.0.11",
"bitcoin:tPPC": "2.1.9",
"bitcoin:tQTUM": "2.1.1",
"bitcoin:tSMART": "2.0.8",
"bitcoin:tXZC": "2.0.7",
@ -3043,6 +3049,7 @@
"bitcoin:MONA": true,
"bitcoin:MUE": true,
"bitcoin:NMC": true,
"bitcoin:PPC": true,
"bitcoin:QTUM": true,
"bitcoin:RVN": true,
"bitcoin:TAZ": true,
@ -3055,6 +3062,7 @@
"bitcoin:ZEC": true,
"bitcoin:tGRS": true,
"bitcoin:tLTC": true,
"bitcoin:tPPC": true,
"eth:ETC": true,
"eth:ETH": true
},

@ -100,6 +100,9 @@
"bitcoin:POLIS": {
"PolisPay": "https://polispay.com"
},
"bitcoin:PPC": {
"Magnum": "https://magnumwallet.co"
},
"bitcoin:QTUM": {
"Qtum-Electrum": "https://github.com/qtumproject/qtum-electrum"
},

@ -1283,6 +1283,54 @@ def by_name(name: str) -> CoinInfo:
curve_name='secp256k1',
confidential_assets=None,
)
elif name == "Peercoin":
return CoinInfo(
coin_name=name,
coin_shortcut="PPC",
divisibility=6,
address_type=55,
address_type_p2sh=117,
maxfee_kb=2000000,
signed_message_header="Peercoin Signed Message:\n",
xpub_magic=0x0488b21e,
xpub_magic_segwit_p2sh=0x049d7cb2,
xpub_magic_segwit_native=0x04b24746,
bech32_prefix="pc",
cashaddr_prefix=None,
slip44=6,
segwit=True,
fork_id=None,
force_bip143=False,
bip115=False,
decred=False,
negative_fee=False,
curve_name='secp256k1',
confidential_assets=None,
)
elif name == "Peercoin Testnet":
return CoinInfo(
coin_name=name,
coin_shortcut="tPPC",
divisibility=6,
address_type=111,
address_type_p2sh=196,
maxfee_kb=2000000,
signed_message_header="Peercoin Signed Message:\n",
xpub_magic=0x043587cf,
xpub_magic_segwit_p2sh=0x044a5262,
xpub_magic_segwit_native=0x045f1cf6,
bech32_prefix="tpc",
cashaddr_prefix=None,
slip44=1,
segwit=True,
fork_id=None,
force_bip143=False,
bip115=False,
decred=False,
negative_fee=False,
curve_name='secp256k1',
confidential_assets=None,
)
elif name == "Pesetacoin":
return CoinInfo(
coin_name=name,

@ -72,6 +72,7 @@ static uint32_t lock_time = 0;
static uint32_t expiry = 0;
static bool overwintered = false;
static uint32_t version_group_id = 0;
static uint32_t timestamp = 0;
#if !BITCOIN_ONLY
static uint32_t branch_id = 0;
#endif
@ -487,6 +488,7 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin,
#if !BITCOIN_ONLY
overwintered = msg->has_overwintered && msg->overwintered;
version_group_id = msg->version_group_id;
timestamp = msg->timestamp;
branch_id = msg->branch_id;
// set default values for Zcash if branch_id is unset
if (overwintered && (branch_id == 0)) {
@ -534,7 +536,7 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin,
next_nonsegwit_input = 0xffffffff;
tx_init(&to, inputs_count, outputs_count, version, lock_time, expiry, 0,
coin->curve->hasher_sign, overwintered, version_group_id);
coin->curve->hasher_sign, overwintered, version_group_id, timestamp);
#if !BITCOIN_ONLY
if (coin->decred) {
@ -542,7 +544,8 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin,
to.is_decred = true;
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0,
coin->curve->hasher_sign, overwintered, version_group_id);
coin->curve->hasher_sign, overwintered, version_group_id,
timestamp);
ti.version |= (DECRED_SERIALIZE_NO_WITNESS << 16);
ti.is_decred = true;
}
@ -1210,7 +1213,7 @@ void signing_txack(TransactionType *tx) {
}
tx_init(&tp, tx->inputs_cnt, tx->outputs_cnt, tx->version, tx->lock_time,
tx->expiry, tx->extra_data_len, coin->curve->hasher_sign,
overwintered, version_group_id);
tx->overwintered, tx->version_group_id, tx->timestamp);
#if !BITCOIN_ONLY
if (coin->decred) {
tp.version |= (DECRED_SERIALIZE_NO_WITNESS << 16);
@ -1312,7 +1315,8 @@ void signing_txack(TransactionType *tx) {
PROGRESS_PRECISION);
if (idx2 == 0) {
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0,
coin->curve->hasher_sign, overwintered, version_group_id);
coin->curve->hasher_sign, overwintered, version_group_id,
timestamp);
hasher_Reset(&hasher_check);
}
// check prevouts and script type
@ -1555,13 +1559,15 @@ void signing_txack(TransactionType *tx) {
if (idx1 == 0) {
// witness
tx_init(&to, inputs_count, outputs_count, version, lock_time, expiry, 0,
coin->curve->hasher_sign, overwintered, version_group_id);
coin->curve->hasher_sign, overwintered, version_group_id,
timestamp);
to.is_decred = true;
}
// witness hash
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0,
coin->curve->hasher_sign, overwintered, version_group_id);
coin->curve->hasher_sign, overwintered, version_group_id,
timestamp);
ti.version |= (DECRED_SERIALIZE_WITNESS_SIGNING << 16);
ti.is_decred = true;
if (!compile_input_script_sig(&tx->inputs[0])) {

@ -510,6 +510,10 @@ uint32_t tx_serialize_header(TxStruct *tx, uint8_t *out) {
r += 4;
} else {
memcpy(out, &(tx->version), 4);
if (tx->timestamp) {
memcpy(out + r, &(tx->timestamp), 4);
r += 4;
}
if (tx->is_segwit) {
memcpy(out + r, segwit_header, 2);
r += 2;
@ -527,6 +531,9 @@ uint32_t tx_serialize_header_hash(TxStruct *tx) {
r += 4;
} else {
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->version), 4);
if (tx->timestamp) {
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->timestamp), 4);
}
if (tx->is_segwit) {
hasher_Update(&(tx->hasher), segwit_header, 2);
r += 2;
@ -766,7 +773,7 @@ uint32_t tx_serialize_extra_data_hash(TxStruct *tx, const uint8_t *data,
void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
uint32_t version, uint32_t lock_time, uint32_t expiry,
uint32_t extra_data_len, HasherType hasher_sign, bool overwintered,
uint32_t version_group_id) {
uint32_t version_group_id, uint32_t timestamp) {
tx->inputs_len = inputs_len;
tx->outputs_len = outputs_len;
tx->version = version;
@ -781,6 +788,7 @@ void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
tx->is_decred = false;
tx->overwintered = overwintered;
tx->version_group_id = version_group_id;
tx->timestamp = timestamp;
hasher_Init(&(tx->hasher), hasher_sign);
}

@ -36,6 +36,7 @@ typedef struct {
uint32_t version;
uint32_t version_group_id;
uint32_t timestamp;
uint32_t lock_time;
uint32_t expiry;
bool is_segwit;
@ -92,7 +93,7 @@ uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input,
void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
uint32_t version, uint32_t lock_time, uint32_t expiry,
uint32_t extra_data_len, HasherType hasher_sign, bool overwintered,
uint32_t version_group_id);
uint32_t version_group_id, uint32_t timestamp);
uint32_t tx_serialize_header_hash(TxStruct *tx);
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input);
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxOutputBinType *output);

File diff suppressed because one or more lines are too long

@ -34,6 +34,10 @@ def is_capricoin(coin):
return coin["coin_name"].lower().startswith("capricoin")
def is_peercoin(coin):
return coin["coin_name"].lower().startswith("peercoin")
def is_dash(coin):
return coin["coin_name"].lower().startswith("dash")
@ -72,7 +76,12 @@ def _json_to_input(coin, vin):
def _json_to_bin_output(coin, vout):
o = messages.TxOutputBinType()
o.amount = int(Decimal(vout["value"]) * 100000000)
if is_peercoin(coin):
DIVISIBILITY = 1000000
else:
DIVISIBILITY = 100000000
o.amount = int(Decimal(vout["value"]) * DIVISIBILITY)
o.script_pubkey = bytes.fromhex(vout["scriptPubKey"]["hex"])
if coin["bip115"] and o.script_pubkey[-1] == 0xB4:
# Verify if coin implements replay protection bip115 and script includes
@ -92,7 +101,7 @@ def json_to_tx(coin, data):
t.version = data["version"]
t.lock_time = data.get("locktime")
if is_capricoin(coin):
if is_capricoin(coin) or is_peercoin(coin):
t.timestamp = data["time"]
if coin["decred"]:

@ -11,6 +11,7 @@ monero
multisig
nem
ontology
peercoin
ripple
sd_card
stellar

@ -0,0 +1,58 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2019 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import pytest
from trezorlib import btc, messages
from trezorlib.tools import parse_path
from ..tx_cache import tx_cache
TXHASH_41b29a = bytes.fromhex(
"41b29ad615d8eea40a4654a052d18bb10cd08f203c351f4d241f88b031357d3d"
)
@pytest.mark.altcoin
@pytest.mark.peercoin
def test_timestamp_included(client):
# tx: 41b29ad615d8eea40a4654a052d18bb10cd08f203c351f4d241f88b031357d3d
# input 0: 0.1 PPC
inp1 = messages.TxInputType(
address_n=parse_path("m/44'/6'/0'/0/0"), prev_hash=TXHASH_41b29a, prev_index=0
)
out1 = messages.TxOutputType(
address="PXtfyTjzgXSgTwK5AbszdHQSSxyQN3BLM5",
amount=100000 - 10000,
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
details = messages.SignTx(version=1, timestamp=0x5DC5448A)
_, timestamp_tx = btc.sign_tx(
client,
"Peercoin",
[inp1],
[out1],
details=details,
prev_txes=tx_cache("Peercoin", allow_fetch=False),
)
# Accepted by network https://explorer.peercoin.net/api/getrawtransaction?txid=f7e3624c143b6a170cc44f9337d0fa8ea8564a211de9c077c6889d8c78f80909&decrypt=1
accepted_txhex = "010000008a44c55d013d7d3531b0881f244d1f353c208fd00cb18bd152a054460aa4eed815d69ab241000000006a473044022025c0ea702390c702c7ae8b5ea469820bea8d942c8c16439f8f0ba2e91e699efc02200db9b0a48fa2861695fa91df4831a4c7306587e5d2dc85419647f462717bc8f001210274cb0ee652d9457fbb0f3872d43155a6bc16f77bd5749d8826b53db443b1b278ffffffff01905f0100000000001976a914ff9a05654150fdc92b1655f49d7f2a8aaf6a3a2a88ac00000000"
assert timestamp_tx.hex() == accepted_txhex

@ -0,0 +1,45 @@
{
"txid": "41b29ad615d8eea40a4654a052d18bb10cd08f203c351f4d241f88b031357d3d",
"version": 1,
"time": 1573209046,
"locktime": 0,
"vin": [
{
"txid": "67abe6288fdec766e106a46125727eb7c608266950746fc10d1d1c69645f68af",
"vout": 0,
"scriptSig": {
"asm": "3044022052748f479c41b432352772ef7aa4b090e4f8df8d589aaea5cfc3dbef237a3935022012f53265e223c3cce6348306d7085b0538b68a52dbd99b0035a01b5bb2a8e50a[ALL] 038fa1b058febedda1a414ccb39f55ac09dd832e5c2e5af9b14ff49ea9d520b9fe",
"hex": "473044022052748f479c41b432352772ef7aa4b090e4f8df8d589aaea5cfc3dbef237a3935022012f53265e223c3cce6348306d7085b0538b68a52dbd99b0035a01b5bb2a8e50a0121038fa1b058febedda1a414ccb39f55ac09dd832e5c2e5af9b14ff49ea9d520b9fe"
},
"sequence": 4294967295
}
],
"vout": [
{
"value": 0.100000,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 d68a96304b1fb73aadfea0f44c17061f5e353e1b OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914d68a96304b1fb73aadfea0f44c17061f5e353e1b88ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"PU9ZnCJsFwz39F1ndzx4FdN41DWg3mDjYo"
]
}
},
{
"value": 0.695400,
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 60223495a70ca30abcee5b93687d5fa88fa5d4ec OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91460223495a70ca30abcee5b93687d5fa88fa5d4ec88ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"PHMV12FFYucgf3mybnmF8qYJwtV6sx89ji"
]
}
}
]
}
Loading…
Cancel
Save