Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge armory/dev #124

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
fc3ec7d
Separate many Dlgs from qtdialogs.py
Dec 16, 2021
3c2c23d
import LOG functions in PyBtcWallet.py
goatpig Jan 27, 2022
0afbcc5
Fix missing imports, minor bugs
goatpig Jan 27, 2022
a1868dc
guard around SBD setup from empty strings
goatpig Jan 28, 2022
28bc489
remove obsolete leveldbwin folder
goatpig Jan 28, 2022
ad7589c
fix max button
goatpig Jan 28, 2022
87258e5
add missing definition in CppBridge.py
goatpig Jan 28, 2022
1863ed0
display datadir on DB startup
goatpig Jan 28, 2022
2f9e540
link to system protobuf
goatpig Jan 28, 2022
eedff09
add missing import
goatpig Jan 28, 2022
7192639
Merge remote-tracking branch 'origin/dev' into attic_qtdialogs
goatpig Feb 2, 2022
9fcdbd5
fix DlgDispTxInfo
goatpig Feb 2, 2022
f47bada
fix error verbose in when resolving config paths
goatpig Feb 2, 2022
7b4f153
fix licensing on refactor dlg files
goatpig Feb 2, 2022
cfa9089
implement botched Armory python hmac in cpp
goatpig Feb 16, 2022
d428b99
Refactor BackupCenter into its own file
goatpig Feb 16, 2022
87e9a54
Implement client side addSupportingTx for Signer object
goatpig Mar 13, 2022
9c29992
[WIP] dont handle p2sh preimage image in py unsigned tx ser/deser, us…
goatpig Mar 13, 2022
fd2d310
Fix some whitespace/style infractions
goatpig Mar 13, 2022
2042e5c
const a bunch of getters in BinaryData
goatpig Mar 13, 2022
5da73fc
increase size limits for supernode tables
goatpig Mar 13, 2022
b2fdfdc
Fix locktime ser/deser in Signer
goatpig Mar 13, 2022
799d7ec
USTX serialization type selector
goatpig Mar 30, 2022
a0d706b
fix filename hint in file save dialog
goatpig Mar 30, 2022
b8fc461
Update address type frame when selecting a wallet in Address Book dialog
goatpig Apr 5, 2022
2850e32
Fix missing imports in DlgNewAddress.py
goatpig Apr 5, 2022
6f99c2c
Fix isMine toggle in Wallet Details dialog
goatpig Apr 5, 2022
3498bd8
Deser sequence from legacy txsigcollect
goatpig Apr 5, 2022
a7d4bc7
P2SH-P2PK support for legacy USTX
goatpig May 24, 2022
c12846e
Fix wallet update labels, disable heavy benchmark in unit tests
goatpig May 25, 2022
0f8a813
cleaner coin2str algo
goatpig Jun 1, 2022
5671742
fix right click menu in main ledger
goatpig Jun 15, 2022
04e9b51
fix tx review dialog for unsigned transactions
goatpig Jun 15, 2022
63bd25a
fix coin control utxo listing
goatpig Sep 10, 2022
972949c
More readable block parsing options
goatpig Sep 11, 2022
5882a94
move blockchain database files to their own folder
goatpig Sep 11, 2022
a26b46e
use srcdir in makefile
goatpig Sep 11, 2022
776252f
[ARMORY-8] rework bridge api
goatpig Jan 31, 2023
48c1673
[ARMORY-8] python side
goatpig Apr 14, 2023
dc18b65
[ARMORY-8] fix spending, isolate python address code in armoryengine.…
goatpig May 5, 2023
b291975
[ARMORY-8] fix tests
goatpig May 16, 2023
0076e1c
[ARMORY-29] BIP39 support
goatpig May 19, 2023
1e16f07
[ARMORY-29]
goatpig May 28, 2023
2a94305
[ARMORY-29] BIP39 legacy English Trezor dictionnary support
goatpig May 29, 2023
07be576
[ARMORY-29] update wallet creation diagram
goatpig May 29, 2023
210cf43
Merge pull request #692 from goatpig/armory_29_bip39_support
goatpig May 29, 2023
c53de90
Merge pull request #691 from goatpig/armory_8_rework_bridge_api
goatpig May 29, 2023
40b6f92
merged Armory/dev
sergey-chernikov May 29, 2023
eeb41ad
merged with master
sergey-chernikov May 29, 2023
a8dcce5
file templates for regular wallets
sergey-chernikov May 31, 2023
f895833
ifdef'ed BUILD_PROTOBUF
sergey-chernikov Aug 29, 2024
641063b
superfluous include
sergey-chernikov Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[ARMORY-8] fix tests
goatpig committed May 16, 2023
commit b2919758c2b496c3495e943ba743dda00aeca050
21 changes: 13 additions & 8 deletions cppForSwig/Signer/Signer.cpp
Original file line number Diff line number Diff line change
@@ -447,9 +447,9 @@ BinaryData ScriptSpender::getAvailableInputScript() const
}

////////////////////////////////////////////////////////////////////////////////
BinaryData ScriptSpender::getSerializedInput(bool withSig) const
BinaryData ScriptSpender::getSerializedInput(bool withSig, bool loose) const
{
if (legacyStatus_ == SpenderStatus::Unknown)
if (legacyStatus_ == SpenderStatus::Unknown && !loose)
{
throw SpenderException("unresolved spender");
}
@@ -1520,8 +1520,13 @@ void ScriptSpender::sign(shared_ptr<SignerProxy> proxy)
}
};

signStack(legacyStack_, false);
signStack(witnessStack_, true);
try
{
signStack(legacyStack_, false);
signStack(witnessStack_, true);
}
catch (const exception&)
{}

processStacks();
}
@@ -2726,7 +2731,7 @@ BinaryDataRef Signer::serializeSignedTx(void) const

//txins
for (auto& spender : spenders_)
bw.put_BinaryData(spender->getSerializedInput(true));
bw.put_BinaryData(spender->getSerializedInput(true, false));

//txout count
auto recVector = getRecipientVector();
@@ -2793,7 +2798,7 @@ BinaryDataRef Signer::serializeUnsignedTx(bool loose)

//txins
for (auto& spender : spenders_)
bw.put_BinaryData(spender->getSerializedInput(false));
bw.put_BinaryData(spender->getSerializedInput(false, loose));

//txout count
auto recVector = getRecipientVector();
@@ -2856,7 +2861,7 @@ BinaryData Signer::serializeAvailableResolvedData(void) const
{
try
{
bw.put_BinaryData(spender->getSerializedInput(false));
bw.put_BinaryData(spender->getSerializedInput(false, false));
}
catch (const exception&)
{
@@ -4050,7 +4055,7 @@ BinaryData Signer::getTxId_const() const
if (!spender->isSegWit() && !spender->isSigned())
throw runtime_error("cannot get hash for unsigned legacy input");

bw.put_BinaryData(spender->getSerializedInput(false));
bw.put_BinaryData(spender->getSerializedInput(false, false));
}

//outputs
2 changes: 1 addition & 1 deletion cppForSwig/Signer/Signer.h
Original file line number Diff line number Diff line change
@@ -199,7 +199,7 @@ namespace Armory
BinaryDataRef getOutputScript(void) const;
BinaryDataRef getOutputHash(void) const;
unsigned getOutputIndex(void) const;
BinaryData getSerializedInput(bool) const;
BinaryData getSerializedInput(bool, bool) const;
BinaryData getEmptySerializedInput(void) const;
BinaryDataRef getFinalizedWitnessData(void) const;
BinaryData serializeAvailableWitnessData(void) const;
2 changes: 1 addition & 1 deletion cppForSwig/Wallets/Accounts/AccountTypes.cpp
Original file line number Diff line number Diff line change
@@ -320,7 +320,7 @@ AddressAccountId AccountType_ECDH::getAccountID() const
}
else
{
auto&& root_pub = CryptoECDSA().ComputePublicKey(privateKey_);
auto&& root_pub = CryptoECDSA().ComputePublicKey(privateKey_, true);
root_pub.getPtr()[0] ^= (uint8_t)type();

auto&& pub_hash160 = BtcUtils::getHash160(root_pub);
56 changes: 52 additions & 4 deletions cppForSwig/Wallets/Accounts/AddressAccounts.cpp
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ unique_ptr<AddressAccount> AddressAccount::make_new(

unique_ptr<AddressAccount> addressAccountPtr;
const auto& addressAccountId = accType->getAccountID();
addressAccountPtr.reset(new AddressAccount(dbName, accType->getAccountID()));
addressAccountPtr.reset(new AddressAccount(dbName, addressAccountId));

//create root asset
auto createRootAsset =
@@ -286,8 +286,8 @@ unique_ptr<AddressAccount> AddressAccount::make_new(
//create assets
auto cipherData = make_unique<Encryption::CipherData>(
encrypted_root, move(cipher_copy));
auto priv_asset =
make_shared<Asset_PrivateKey>(assetId, move(cipherData));
auto priv_asset = make_shared<Asset_PrivateKey>(
assetId, move(cipherData));
rootAsset = make_shared<AssetEntry_Single>(
assetId, pubkey, priv_asset);
}
@@ -918,13 +918,30 @@ AddressAccountPublicData AddressAccount::exportPublicData() const
rootData = woRoot->serialize();

SecureBinaryData derData;
std::shared_ptr<AssetAccountExtendedData> extended = nullptr;
if (assetData->derScheme_ != nullptr)
{
derData = assetData->derScheme_->serialize();

//check for salts
auto derEcdh = dynamic_pointer_cast<DerivationScheme_ECDH>(
assetData->derScheme_);
if (derEcdh != nullptr)
{
auto saltMap = derEcdh->getSaltMap();
auto salts = std::make_shared<AssetAccountSaltMap>();

for (const auto& saltPair : saltMap)
salts->salts_.emplace(saltPair.second, saltPair.first);
extended = salts;
}
}

AssetAccountPublicData assaPD {
assetData->id_,
rootData, derData,
accPtr->getHighestUsedIndex(), accPtr->getLastComputedIndex() };
assaPD.extendedData = extended;

aapd.accountDataMap_.emplace(assetData->id_, move(assaPD));
}
@@ -946,6 +963,37 @@ void AddressAccount::importPublicData(const AddressAccountPublicData& aapd)
if (accPtr == nullptr)
throw AccountException("[importPublicData] missing asset account");

switch (accPtr->type())
{
case AssetAccountTypeEnum::AssetAccountTypeEnum_ECDH:
{
//ecdh account, inject the existing salts
auto accEcdh = dynamic_cast<AssetAccount_ECDH*>(accPtr.get());
if (accEcdh == nullptr)
throw AccountException("[importPublicData] account isnt ECDH");

auto saltMap = dynamic_pointer_cast<AssetAccountSaltMap>(
assapd.second.extendedData);
if (saltMap == nullptr)
{
throw AccountException("[importPublicData]"
" imported data missing salt map");
}

for (const auto& saltPair : saltMap->salts_)
{
if (accEcdh->addSalt(nullptr, saltPair.second) != saltPair.first)
{
throw AccountException("[importPublicData]"
" injected salt order mismtach");
}
}
}

default:
break;
}

//do not allow rollbacks
if (assapd.second.lastComputedIndex_ > accPtr->getLastComputedIndex())
{
@@ -960,7 +1008,7 @@ void AddressAccount::importPublicData(const AddressAccountPublicData& aapd)
//sync address set
instantiatedAddressTypes_ = aapd.instantiatedAddressTypes_;

//check the assets for addresses do exist
//TODO: check the assets for addresses do exist

}

5 changes: 4 additions & 1 deletion cppForSwig/Wallets/Accounts/AssetAccounts.cpp
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@ shared_ptr<AssetAccountData> AssetAccountData::copy(
return accDataCopy;
}

AssetAccountExtendedData::~AssetAccountExtendedData() {}
AssetAccountSaltMap::~AssetAccountSaltMap() {}

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//// AssetAccount
@@ -801,7 +804,7 @@ AssetKeyType AssetAccount_ECDH::addSalt(
shared_ptr<IO::WalletIfaceTransaction> tx,
const SecureBinaryData& salt)
{
auto derScheme =
auto derScheme =
dynamic_pointer_cast<DerivationScheme_ECDH>(data_->derScheme_);

if (derScheme == nullptr)
14 changes: 14 additions & 0 deletions cppForSwig/Wallets/Accounts/AssetAccounts.h
Original file line number Diff line number Diff line change
@@ -83,6 +83,18 @@ namespace Armory
};

//////////////////////////////////////////////////////////////////////////
struct AssetAccountExtendedData
{
virtual ~AssetAccountExtendedData(void) = 0;
};

struct AssetAccountSaltMap : public AssetAccountExtendedData
{
std::map<Wallets::AssetKeyType, SecureBinaryData> salts_;
~AssetAccountSaltMap(void) override;
};

////
struct AssetAccountPublicData
{
const Wallets::AssetAccountId id_;
@@ -92,6 +104,8 @@ namespace Armory

const Wallets::AssetKeyType lastUsedIndex_;
const Wallets::AssetKeyType lastComputedIndex_;

std::shared_ptr<AssetAccountExtendedData> extendedData;
};

//////////////////////////////////////////////////////////////////////////
22 changes: 15 additions & 7 deletions cppForSwig/Wallets/DerivationScheme.cpp
Original file line number Diff line number Diff line change
@@ -577,9 +577,6 @@ BinaryData DerivationScheme_ECDH::serialize() const
AssetKeyType DerivationScheme_ECDH::addSalt(const SecureBinaryData& salt,
shared_ptr<IO::DBIfaceTransaction> txPtr)
{
if (txPtr == nullptr)
throw DerivationSchemeException("addSalt: null tx");

if (salt.getSize() != 32)
throw DerivationSchemeException("salt is too small");

@@ -595,8 +592,9 @@ AssetKeyType DerivationScheme_ECDH::addSalt(const SecureBinaryData& salt,
if (!insertIter.second)
throw DerivationSchemeException("failed to insert salt");

//update on disk
putSalt(id, salt, txPtr);
//update on disk if we have a db tx
if (txPtr != nullptr)
putSalt(id, salt, txPtr);

//return insert index
return id;
@@ -615,7 +613,11 @@ void DerivationScheme_ECDH::putSalt(AssetKeyType id,
auto dataRef = txPtr->getDataRef(bwKey.getData());
if (!dataRef.empty())
{
if (dataRef != salt)
//read the salt
BinaryRefReader brr(dataRef);
auto size = brr.get_var_int();
auto saltRef = brr.get_BinaryDataRef(size);
if (saltRef != salt)
{
throw DerivationSchemeException(
"trying to write a salt different from the one on disk");
@@ -849,4 +851,10 @@ AssetKeyType DerivationScheme_ECDH::getIdForSalt(
throw DerivationSchemeException("missing salt");

return iter->second;
}
}

////////////////////////////////////////////////////////////////////////////////
const map<SecureBinaryData, AssetKeyType>& DerivationScheme_ECDH::getSaltMap() const
{
return saltMap_;
}
2 changes: 2 additions & 0 deletions cppForSwig/Wallets/DerivationScheme.h
Original file line number Diff line number Diff line change
@@ -275,6 +275,8 @@ namespace Armory
void putAllSalts(std::shared_ptr<Wallets::IO::DBIfaceTransaction>);
void getAllSalts(std::shared_ptr<Wallets::IO::DBIfaceTransaction>);
Wallets::AssetKeyType getIdForSalt(const SecureBinaryData&);
const std::map<SecureBinaryData, Wallets::AssetKeyType>&
getSaltMap(void) const;
};
}; //namespace Assets
}; //namespace Armory
8 changes: 4 additions & 4 deletions cppForSwig/Wallets/Wallets.cpp
Original file line number Diff line number Diff line change
@@ -904,7 +904,7 @@ string AssetWallet::forkWatchingOnly(
if (DBUtils::fileExists(newname, 0))
throw WalletException("WO wallet filename already exists");

//open original wallet db & new
//open original wallet db & new
auto originIface = getIfaceFromFile(filename, true, passLbd);
auto masterID = getMasterID(originIface);

@@ -1854,8 +1854,8 @@ const SecureBinaryData& AssetWallet_Single::getArmory135Chaincode() const
}

////////////////////////////////////////////////////////////////////////////////
void AssetWallet_Single::importPublicData(
const WalletPublicData& wpd, std::shared_ptr<IO::WalletDBInterface> iface)
void AssetWallet_Single::importPublicData(const WalletPublicData& wpd,
std::shared_ptr<IO::WalletDBInterface> iface)
{
//TODO: merging from exported data

@@ -2041,7 +2041,7 @@ void AssetWallet_Single::importPublicData(
"Failed to resolve address account type");
}

//address account main flag
//flag main account
if (accData.ID_ == wpd.mainAccountID_)
accTypePtr->setMain(true);

6 changes: 3 additions & 3 deletions cppForSwig/gtest/SignerTests.cpp
Original file line number Diff line number Diff line change
@@ -3628,7 +3628,7 @@ TEST_F(SignerTest, GetUnsignedTxId)
//locktime deser test
{
signer2.setLockTime(++locktime);
auto unsignedTx = signer2.serializeUnsignedTx();
auto unsignedTx = signer2.serializeUnsignedTx(true);

Tx tx(unsignedTx);
EXPECT_EQ(tx.getLockTime(), locktime);
@@ -3661,7 +3661,7 @@ TEST_F(SignerTest, GetUnsignedTxId)

//locktime deser test
{
auto unsignedTx = signer3.serializeUnsignedTx();
auto unsignedTx = signer3.serializeUnsignedTx(true);

Tx tx(unsignedTx);
EXPECT_EQ(tx.getLockTime(), locktime);
@@ -3679,7 +3679,7 @@ TEST_F(SignerTest, GetUnsignedTxId)
signer4.setFeed(assetFeed2);

{
auto unsignedTx = signer4.serializeUnsignedTx();
auto unsignedTx = signer4.serializeUnsignedTx(true);

Tx tx(unsignedTx);
EXPECT_EQ(tx.getLockTime(), locktime);